Re-enable tests 934 & 935
There were two issues causing problems with these tests.
1) The loading of classes could occur prior to the transformer being
enabled. This was fixed by putting the classes under test into a
different ClassLoader and disabling app-images.
2) DexToDex compilation was devirtualizing some calls meaning that
reordering the methods was causing incorrect dispatch.
This reverts commit 50cc0cceb5ca0abd4fff2cb3467ea74e7590cb10.
This reverts commit e9f36b7cb42348ef5c4eb3c88bd3cfdd56390a3e.
This reverts commit 1e7e96e4a66f668255a1683b837863228489faf9.
Test: ART_TEST_INTERPRETER=true \
ART_TEST_JIT=true \
mma -j40 test-art-host
Test: ART_TEST_INTERPRETER_ACCESS_CHECKS=true \
ART_TEST_RUN_TEST_NO_DEX2OAT=true \
ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT=true \
ART_TEST_RUN_TEST_NO_RELOCATE=true \
mma -j40 test-art-host-run-test-934-load-transform \
test-art-host-run-test-935-non-retransformable
Change-Id: Ia600ba37d45a5f9489b03c7f4d143849c887b8a7
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 3203048..74d2287 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -529,9 +529,15 @@
// We store the verification information in the class status in the oat file, which the linker
// can validate (checksums) and use to skip load-time verification. It is thus safe to
// optimize when a class has been fully verified before.
+ optimizer::DexToDexCompilationLevel max_level = optimizer::DexToDexCompilationLevel::kOptimize;
+ if (driver.GetCompilerOptions().GetDebuggable()) {
+ // We are debuggable so definitions of classes might be changed. We don't want to do any
+ // optimizations that could break that.
+ max_level = optimizer::DexToDexCompilationLevel::kRequired;
+ }
if (klass->IsVerified()) {
// Class is verified so we can enable DEX-to-DEX compilation for performance.
- return optimizer::DexToDexCompilationLevel::kOptimize;
+ return max_level;
} else if (klass->IsCompileTimeVerified()) {
// Class verification has soft-failed. Anyway, ensure at least correctness.
DCHECK_EQ(klass->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime);
diff --git a/test/934-load-transform/run b/test/934-load-transform/run
index c6e62ae..adb1a1c 100755
--- a/test/934-load-transform/run
+++ b/test/934-load-transform/run
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-./default-run "$@" --jvmti
+./default-run "$@" --jvmti --no-app-image
diff --git a/test/934-load-transform/src-ex/TestMain.java b/test/934-load-transform/src-ex/TestMain.java
new file mode 100644
index 0000000..33be9cd
--- /dev/null
+++ b/test/934-load-transform/src-ex/TestMain.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class TestMain {
+ public static void runTest() {
+ new Transform().sayHi();
+ }
+}
diff --git a/test/934-load-transform/src/Transform.java b/test/934-load-transform/src-ex/Transform.java
similarity index 100%
rename from test/934-load-transform/src/Transform.java
rename to test/934-load-transform/src-ex/Transform.java
diff --git a/test/934-load-transform/src/Main.java b/test/934-load-transform/src/Main.java
index 0b7f2689..3bd913b 100644
--- a/test/934-load-transform/src/Main.java
+++ b/test/934-load-transform/src/Main.java
@@ -14,8 +14,11 @@
* limitations under the License.
*/
+import java.lang.reflect.*;
import java.util.Base64;
-public class Main {
+
+class Main {
+ public static String TEST_NAME = "934-load-transform";
/**
* base64 encoded class/dex file for
@@ -48,14 +51,36 @@
"AOAAAAAGAAAAAQAAAAABAAABIAAAAgAAACABAAABEAAAAQAAAFwBAAACIAAADgAAAGIBAAADIAAA" +
"AgAAABMCAAAAIAAAAQAAAB4CAAAAEAAAAQAAACwCAAA=");
- public static void main(String[] args) {
- doTest();
+ public static ClassLoader getClassLoaderFor(String location) throws Exception {
+ try {
+ Class<?> class_loader_class = Class.forName("dalvik.system.PathClassLoader");
+ Constructor<?> ctor = class_loader_class.getConstructor(String.class, ClassLoader.class);
+ /* on Dalvik, this is a DexFile; otherwise, it's null */
+ return (ClassLoader)ctor.newInstance(location + "/" + TEST_NAME + "-ex.jar",
+ Main.class.getClassLoader());
+ } catch (ClassNotFoundException e) {
+ // Running on RI. Use URLClassLoader.
+ return new java.net.URLClassLoader(
+ new java.net.URL[] { new java.net.URL("file://" + location + "/classes-ex/") });
+ }
}
- public static void doTest() {
+ public static void main(String[] args) {
addCommonTransformationResult("Transform", CLASS_BYTES, DEX_BYTES);
enableCommonRetransformation(true);
- new Transform().sayHi();
+ try {
+ /* this is the "alternate" DEX/Jar file */
+ ClassLoader new_loader = getClassLoaderFor(System.getenv("DEX_LOCATION"));
+ Class<?> klass = (Class<?>)new_loader.loadClass("TestMain");
+ if (klass == null) {
+ throw new AssertionError("loadClass failed");
+ }
+ Method run_test = klass.getMethod("runTest");
+ run_test.invoke(null);
+ } catch (Exception e) {
+ System.out.println(e.toString());
+ e.printStackTrace();
+ }
}
// Transforms the class
diff --git a/test/935-non-retransformable/run b/test/935-non-retransformable/run
index c6e62ae..adb1a1c 100755
--- a/test/935-non-retransformable/run
+++ b/test/935-non-retransformable/run
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-./default-run "$@" --jvmti
+./default-run "$@" --jvmti --no-app-image
diff --git a/test/935-non-retransformable/src-ex/TestMain.java b/test/935-non-retransformable/src-ex/TestMain.java
new file mode 100644
index 0000000..aebcdee
--- /dev/null
+++ b/test/935-non-retransformable/src-ex/TestMain.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.reflect.Method;
+
+public class TestMain {
+ public static void runTest() {
+ Transform t = new Transform();
+ try {
+ // Call functions with reflection. Since the sayGoodbye function does not exist in the
+ // LTransform; when we compile this for the first time we need to use reflection.
+ Method hi = Transform.class.getMethod("sayHi");
+ Method bye = Transform.class.getMethod("sayGoodbye");
+ hi.invoke(t);
+ t.sayHi();
+ bye.invoke(t);
+ } catch (Exception e) {
+ System.out.println("Unexpected error occured! " + e.toString());
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/test/935-non-retransformable/src/Transform.java b/test/935-non-retransformable/src-ex/Transform.java
similarity index 100%
rename from test/935-non-retransformable/src/Transform.java
rename to test/935-non-retransformable/src-ex/Transform.java
diff --git a/test/935-non-retransformable/src/Main.java b/test/935-non-retransformable/src/Main.java
index d9cc329..0d103ab 100644
--- a/test/935-non-retransformable/src/Main.java
+++ b/test/935-non-retransformable/src/Main.java
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-import java.lang.reflect.Method;
+import java.lang.reflect.*;
import java.util.Base64;
-public class Main {
+class Main {
+ public static String TEST_NAME = "935-non-retransformable";
/**
* base64 encoded class/dex file for
@@ -57,37 +58,46 @@
"EAAAAQAAAJABAAACIAAAEAAAAJYBAAADIAAAAwAAAFoCAAAAIAAAAQAAAGsCAAAAEAAAAQAAAIAC" +
"AAA=");
- public static void main(String[] args) {
- doTest();
+
+ public static ClassLoader getClassLoaderFor(String location) throws Exception {
+ try {
+ Class<?> class_loader_class = Class.forName("dalvik.system.PathClassLoader");
+ Constructor<?> ctor = class_loader_class.getConstructor(String.class, ClassLoader.class);
+ /* on Dalvik, this is a DexFile; otherwise, it's null */
+ return (ClassLoader)ctor.newInstance(location + "/" + TEST_NAME + "-ex.jar",
+ Main.class.getClassLoader());
+ } catch (ClassNotFoundException e) {
+ // Running on RI. Use URLClassLoader.
+ return new java.net.URLClassLoader(
+ new java.net.URL[] { new java.net.URL("file://" + location + "/classes-ex/") });
+ }
}
- public static void doTest() {
+ public static void main(String[] args) {
addCommonTransformationResult("Transform", CLASS_BYTES, DEX_BYTES);
enableCommonRetransformation(true);
- // Actually load the class.
- Transform t = new Transform();
try {
- // Call functions with reflection. Since the sayGoodbye function does not exist in the
- // LTransform; when we compile this for the first time we need to use reflection.
- Method hi = Transform.class.getMethod("sayHi");
- Method bye = Transform.class.getMethod("sayGoodbye");
- hi.invoke(t);
- t.sayHi();
- bye.invoke(t);
+ /* this is the "alternate" DEX/Jar file */
+ ClassLoader new_loader = getClassLoaderFor(System.getenv("DEX_LOCATION"));
+ Class<?> klass = (Class<?>)new_loader.loadClass("TestMain");
+ if (klass == null) {
+ throw new AssertionError("loadClass failed");
+ }
+ Method run_test = klass.getMethod("runTest");
+ run_test.invoke(null);
+
// Make sure we don't get called for transformation again.
addCommonTransformationResult("Transform", new byte[0], new byte[0]);
- doCommonClassRetransformation(Transform.class);
- hi.invoke(t);
- t.sayHi();
- bye.invoke(t);
+ doCommonClassRetransformation(new_loader.loadClass("Transform"));
+ run_test.invoke(null);
} catch (Exception e) {
- System.out.println("Unexpected error occured! " + e.toString());
+ System.out.println(e.toString());
e.printStackTrace();
}
}
// Transforms the class
- private static native void doCommonClassRetransformation(Class<?>... klasses);
+ private static native void doCommonClassRetransformation(Class<?>... classes);
private static native void enableCommonRetransformation(boolean enable);
private static native void addCommonTransformationResult(String target_name,
byte[] class_bytes,
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index afd1998..cb798f0 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -341,14 +341,11 @@
# Note 117-nopatchoat is not broken per-se it just doesn't work (and isn't meant to) without
# --prebuild --relocate
-# 934 & 935 are broken due to dex2dex issues and app-images
TEST_ART_BROKEN_NO_RELOCATE_TESTS := \
117-nopatchoat \
118-noimage-dex2oat \
119-noimage-patchoat \
- 554-jit-profile-file \
- 934-load-transform \
- 935-non-retransformable \
+ 554-jit-profile-file
ifneq (,$(filter no-relocate,$(RELOCATE_TYPES)))
ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
@@ -360,12 +357,9 @@
# Temporarily disable some broken tests when forcing access checks in interpreter b/22414682
# 629 requires compilation.
-# 934 & 935 are broken due to dex2dex issues and app-images
TEST_ART_BROKEN_INTERPRETER_ACCESS_CHECK_TESTS := \
137-cfi \
- 629-vdex-speed \
- 934-load-transform \
- 935-non-retransformable \
+ 629-vdex-speed
ifneq (,$(filter interp-ac,$(COMPILER_TYPES)))
ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
@@ -431,7 +425,6 @@
# 147-stripped-dex-fallback is disabled because it requires --prebuild.
# 554-jit-profile-file is disabled because it needs a primary oat file to know what it should save.
# 629-vdex-speed requires compiled code.
-# 934 & 935 are broken due to dex2dex issues and app-images
TEST_ART_BROKEN_FALLBACK_RUN_TESTS := \
116-nodex2oat \
117-nopatchoat \
@@ -441,9 +434,7 @@
138-duplicate-classes-check2 \
147-stripped-dex-fallback \
554-jit-profile-file \
- 629-vdex-speed \
- 934-load-transform \
- 935-non-retransformable \
+ 629-vdex-speed
# This test fails without an image.
# 018, 961, 964 often time out. b/34369284
@@ -521,13 +512,10 @@
# Known broken tests for the interpreter.
# CFI unwinding expects managed frames.
# 629 requires compilation.
-# 934 and 935 are broken due to the PreDefine hook not yet inserting them into the classpath. This should be fixed shortly
TEST_ART_BROKEN_INTERPRETER_RUN_TESTS := \
137-cfi \
554-jit-profile-file \
- 629-vdex-speed \
- 934-load-transform \
- 935-non-retransformable \
+ 629-vdex-speed
ifneq (,$(filter interpreter,$(COMPILER_TYPES)))
ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
@@ -550,7 +538,6 @@
# resolved but until then just disable them. Test 916 already checks this
# feature for JIT use cases in a way that is resilient to the jit frames.
# 912: b/34655682
-# 934 and 935 are broken due to the PreDefine hook not yet inserting them into the classpath. This should be fixed shortly
TEST_ART_BROKEN_JIT_RUN_TESTS := \
137-cfi \
629-vdex-speed \
@@ -563,8 +550,6 @@
917-fields-transformation \
919-obsolete-fields \
926-multi-obsolescence \
- 934-load-transform \
- 935-non-retransformable \
ifneq (,$(filter jit,$(COMPILER_TYPES)))
ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \