Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
art
Commits
bb1c6242
Commit
bb1c6242
authored
11 years ago
by
Brian Carlstrom
Browse files
Options
Download
Email Patches
Plain Diff
Fix backwards check in CheckStaticMethod
Bug: 11243757 Change-Id: I559d1163ce72ab7831bd328c621519acb72975e0
parent
31b9d664
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletion
+38
-1
runtime/check_jni.cc
runtime/check_jni.cc
+1
-1
test/JniTest/JniTest.java
test/JniTest/JniTest.java
+21
-0
test/JniTest/jni_test.cc
test/JniTest/jni_test.cc
+16
-0
No files found.
runtime/check_jni.cc
View file @
bb1c6242
...
@@ -335,7 +335,7 @@ class ScopedCheck {
...
@@ -335,7 +335,7 @@ class ScopedCheck {
return
;
return
;
}
}
mirror
::
Class
*
c
=
soa_
.
Decode
<
mirror
::
Class
*>
(
java_class
);
mirror
::
Class
*
c
=
soa_
.
Decode
<
mirror
::
Class
*>
(
java_class
);
if
(
!
c
->
IsAssignableFrom
(
m
->
GetDeclaringClass
()))
{
if
(
!
m
->
GetDeclaringClass
()
->
IsAssignableFrom
(
c
))
{
JniAbortF
(
function_name_
,
"can't call static %s on class %s"
,
JniAbortF
(
function_name_
,
"can't call static %s on class %s"
,
PrettyMethod
(
m
).
c_str
(),
PrettyClass
(
c
).
c_str
());
PrettyMethod
(
m
).
c_str
(),
PrettyClass
(
c
).
c_str
());
}
}
...
...
This diff is collapsed.
Click to expand it.
test/JniTest/JniTest.java
View file @
bb1c6242
...
@@ -18,7 +18,28 @@ class JniTest {
...
@@ -18,7 +18,28 @@ class JniTest {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
System
.
loadLibrary
(
"arttest"
);
System
.
loadLibrary
(
"arttest"
);
testFindClassOnAttachedNativeThread
();
testFindClassOnAttachedNativeThread
();
testCallStaticVoidMethodOnSubClass
();
}
}
private
static
native
void
testFindClassOnAttachedNativeThread
();
private
static
native
void
testFindClassOnAttachedNativeThread
();
private
static
void
testCallStaticVoidMethodOnSubClass
()
{
testCallStaticVoidMethodOnSubClassNative
();
if
(!
testCallStaticVoidMethodOnSubClass_SuperClass
.
executed
)
{
throw
new
AssertionError
();
}
}
private
static
native
void
testCallStaticVoidMethodOnSubClassNative
();
private
static
class
testCallStaticVoidMethodOnSubClass_SuperClass
{
private
static
boolean
executed
=
false
;
private
static
void
execute
()
{
executed
=
true
;
}
}
private
static
class
testCallStaticVoidMethodOnSubClass_SubClass
extends
testCallStaticVoidMethodOnSubClass_SuperClass
{
}
}
}
This diff is collapsed.
Click to expand it.
test/JniTest/jni_test.cc
View file @
bb1c6242
...
@@ -54,6 +54,7 @@ static void* testFindClassOnAttachedNativeThread(void*) {
...
@@ -54,6 +54,7 @@ static void* testFindClassOnAttachedNativeThread(void*) {
return
NULL
;
return
NULL
;
}
}
// http://b/10994325
extern
"C"
JNIEXPORT
void
JNICALL
Java_JniTest_testFindClassOnAttachedNativeThread
(
JNIEnv
*
,
extern
"C"
JNIEXPORT
void
JNICALL
Java_JniTest_testFindClassOnAttachedNativeThread
(
JNIEnv
*
,
jclass
)
{
jclass
)
{
pthread_t
pthread
;
pthread_t
pthread
;
...
@@ -65,3 +66,18 @@ extern "C" JNIEXPORT void JNICALL Java_JniTest_testFindClassOnAttachedNativeThre
...
@@ -65,3 +66,18 @@ extern "C" JNIEXPORT void JNICALL Java_JniTest_testFindClassOnAttachedNativeThre
int
pthread_join_result
=
pthread_join
(
pthread
,
NULL
);
int
pthread_join_result
=
pthread_join
(
pthread
,
NULL
);
assert
(
pthread_join_result
==
0
);
assert
(
pthread_join_result
==
0
);
}
}
// http://b/11243757
extern
"C"
JNIEXPORT
void
JNICALL
Java_JniTest_testCallStaticVoidMethodOnSubClassNative
(
JNIEnv
*
env
,
jclass
)
{
jclass
super_class
=
env
->
FindClass
(
"JniTest$testCallStaticVoidMethodOnSubClass_SuperClass"
);
assert
(
super_class
!=
NULL
);
jmethodID
execute
=
env
->
GetStaticMethodID
(
super_class
,
"execute"
,
"()V"
);
assert
(
execute
!=
NULL
);
jclass
sub_class
=
env
->
FindClass
(
"JniTest$testCallStaticVoidMethodOnSubClass_SubClass"
);
assert
(
sub_class
!=
NULL
);
env
->
CallStaticVoidMethod
(
sub_class
,
execute
);
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment