Allow late lookup for @CriticalNative methods.
Test: Add and enable tests in 178-app-image-native-method
Test: Add and enable tests in jni_compiler_test
Test: Manually step through the new stub in GDB and check
that backtrace works at various points.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: aosp_taimen-userdebug boots.
Test: run-gtests.sh
Test: testrunner.py --target --optimizing
Bug: 112189621
Change-Id: If094e5062acbb99eefa88f2afb4815f93730cb82
diff --git a/test/178-app-image-native-method/expected.txt b/test/178-app-image-native-method/expected.txt
index 6327f97..30cc336 100644
--- a/test/178-app-image-native-method/expected.txt
+++ b/test/178-app-image-native-method/expected.txt
@@ -1,10 +1,14 @@
JNI_OnLoad called
test
testFast
+testCritical
testMissing
testMissingFast
+testMissingCritical
JNI_OnLoad called
test
testFast
+testCritical
testMissing
testMissingFast
+testMissingCritical
diff --git a/test/178-app-image-native-method/native_methods.cc b/test/178-app-image-native-method/native_methods.cc
index 5c4fb3e..794a78a 100644
--- a/test/178-app-image-native-method/native_methods.cc
+++ b/test/178-app-image-native-method/native_methods.cc
@@ -38,6 +38,10 @@
(i8 == 81) && (l8 == 82) && (f8 == 83.0) && (d8 == 84.0);
}
+extern "C" JNIEXPORT jint JNICALL Java_Test_nativeMethodVoid(JNIEnv*, jclass) {
+ return 42;
+}
+
extern "C" JNIEXPORT jint JNICALL Java_Test_nativeMethod(JNIEnv*, jclass, jint i) {
return i;
}
@@ -64,6 +68,10 @@
return ok ? 42 : -1;
}
+extern "C" JNIEXPORT jint JNICALL Java_TestFast_nativeMethodVoid(JNIEnv*, jclass) {
+ return 42;
+}
+
extern "C" JNIEXPORT jint JNICALL Java_TestFast_nativeMethod(JNIEnv*, jclass, jint i) {
return i;
}
@@ -90,6 +98,10 @@
return ok ? 42 : -1;
}
+extern "C" JNIEXPORT jint JNICALL Java_TestCritical_nativeMethodVoid() {
+ return 42;
+}
+
extern "C" JNIEXPORT jint JNICALL Java_TestCritical_nativeMethod(jint i) {
return i;
}
diff --git a/test/178-app-image-native-method/run b/test/178-app-image-native-method/run
index 3cb4d09..f4b07f0 100644
--- a/test/178-app-image-native-method/run
+++ b/test/178-app-image-native-method/run
@@ -22,4 +22,4 @@
${RUN} ${@} --profile -Xcompiler-option --compiler-filter=verify
return_status2=$?
-(exit ${return_status1}) # && (exit ${return_status2})
+(exit ${return_status1}) && (exit ${return_status2})
diff --git a/test/178-app-image-native-method/src/Main.java b/test/178-app-image-native-method/src/Main.java
index bec7740..07990cb 100644
--- a/test/178-app-image-native-method/src/Main.java
+++ b/test/178-app-image-native-method/src/Main.java
@@ -31,17 +31,17 @@
new TestMissingCritical();
makeVisiblyInitialized(); // Make sure they are visibly initialized.
- // FIXME: @FastNative and @CriticalNative fail a state check in artFindNativeMethod().
test();
testFast();
- // testCritical();
+ testCritical();
testMissing();
testMissingFast();
- // testMissingCritical();
+ testMissingCritical();
}
static void test() {
System.out.println("test");
+ assertEquals(42, Test.nativeMethodVoid());
assertEquals(42, Test.nativeMethod(42));
assertEquals(42, Test.nativeMethodWithManyParameters(
11, 12L, 13.0f, 14.0d,
@@ -56,6 +56,7 @@
static void testFast() {
System.out.println("testFast");
+ assertEquals(42, TestFast.nativeMethodVoid());
assertEquals(42, TestFast.nativeMethod(42));
assertEquals(42, TestFast.nativeMethodWithManyParameters(
11, 12L, 13.0f, 14.0d,
@@ -70,6 +71,7 @@
static void testCritical() {
System.out.println("testCritical");
+ assertEquals(42, TestCritical.nativeMethodVoid());
assertEquals(42, TestCritical.nativeMethod(42));
assertEquals(42, TestCritical.nativeMethodWithManyParameters(
11, 12L, 13.0f, 14.0d,
@@ -86,6 +88,11 @@
System.out.println("testMissing");
try {
+ TestMissing.nativeMethodVoid();
+ throw new Error("UNREACHABLE");
+ } catch (LinkageError expected) {}
+
+ try {
TestMissing.nativeMethod(42);
throw new Error("UNREACHABLE");
} catch (LinkageError expected) {}
@@ -108,6 +115,11 @@
System.out.println("testMissingFast");
try {
+ TestMissingFast.nativeMethodVoid();
+ throw new Error("UNREACHABLE");
+ } catch (LinkageError expected) {}
+
+ try {
TestMissingFast.nativeMethod(42);
throw new Error("UNREACHABLE");
} catch (LinkageError expected) {}
@@ -130,6 +142,11 @@
System.out.println("testMissingCritical");
try {
+ TestMissingCritical.nativeMethodVoid();
+ throw new Error("UNREACHABLE");
+ } catch (LinkageError expected) {}
+
+ try {
TestMissingCritical.nativeMethod(42);
throw new Error("UNREACHABLE");
} catch (LinkageError expected) {}
@@ -158,6 +175,8 @@
}
class Test {
+ public static native int nativeMethodVoid();
+
public static native int nativeMethod(int i);
public static native int nativeMethodWithManyParameters(
@@ -173,6 +192,9 @@
class TestFast {
@FastNative
+ public static native int nativeMethodVoid();
+
+ @FastNative
public static native int nativeMethod(int i);
@FastNative
@@ -189,6 +211,9 @@
class TestCritical {
@CriticalNative
+ public static native int nativeMethodVoid();
+
+ @CriticalNative
public static native int nativeMethod(int i);
@CriticalNative
@@ -204,6 +229,8 @@
}
class TestMissing {
+ public static native int nativeMethodVoid();
+
public static native int nativeMethod(int i);
public static native int nativeMethodWithManyParameters(
@@ -219,6 +246,9 @@
class TestMissingFast {
@FastNative
+ public static native int nativeMethodVoid();
+
+ @FastNative
public static native int nativeMethod(int i);
@FastNative
@@ -235,6 +265,9 @@
class TestMissingCritical {
@CriticalNative
+ public static native int nativeMethodVoid();
+
+ @CriticalNative
public static native int nativeMethod(int i);
@CriticalNative
diff --git a/test/MyClassNatives/MyClassNatives.java b/test/MyClassNatives/MyClassNatives.java
index c601e3e..7935eb3 100644
--- a/test/MyClassNatives/MyClassNatives.java
+++ b/test/MyClassNatives/MyClassNatives.java
@@ -122,6 +122,8 @@
native void withoutImplementation();
// Normal native
native Object withoutImplementationRefReturn();
+ // Normal native
+ native static void staticWithoutImplementation();
// Normal native
native static void stackArgsIntsFirst(int i1, int i2, int i3, int i4, int i5, int i6, int i7,
@@ -256,6 +258,8 @@
native void withoutImplementation_Fast();
@FastNative
native Object withoutImplementationRefReturn_Fast();
+ @FastNative
+ native static void staticWithoutImplementation_Fast();
@FastNative
native static void stackArgsIntsFirst_Fast(int i1, int i2, int i3, int i4, int i5, int i6, int i7,
@@ -301,6 +305,9 @@
static native double fooSDD_Critical(double x, double y);
@CriticalNative
+ native static void staticWithoutImplementation_Critical();
+
+ @CriticalNative
native static void stackArgsIntsFirst_Critical(int i1, int i2, int i3, int i4, int i5, int i6, int i7,
int i8, int i9, int i10, float f1, float f2, float f3, float f4, float f5, float f6,
float f7, float f8, float f9, float f10);