diff options
| author | 2021-10-13 13:02:26 +0100 | |
|---|---|---|
| committer | 2021-10-14 12:16:10 +0000 | |
| commit | ae96c828a4ca0a688203e3b46abfb28a7b79600d (patch) | |
| tree | e1f7595f16083c5dcc58f155c7588a80be3d194c | |
| parent | 8ed59b840fe8140258e3612eff267b76280f1b8b (diff) | |
Fix `--secondary-class-loader-context` for run-tests.
Change the default context to flat PathClassLoader if the
`--secondary` flag is passed and keep the old PCL hierarchy
otherwise. Explicitly pass that flag in tests where this
default is not correct.
Test: testrunner.py --host --optimizing
Test: Make the "ClassLoaderContext classpath size mismatch"
warning FATAL and retest; only 172-app-image-twice
fails and the failure is expected for that test.
Bug: 166088871
Change-Id: Ic50f206741e6d1f98e08b5db2adc2d7b067266a7
| -rwxr-xr-x | test/146-bad-interface/run | 6 | ||||
| -rw-r--r-- | test/146-bad-interface/src-art/Main.java | 6 | ||||
| -rw-r--r-- | test/164-resolution-trampoline-dex-cache/run | 3 | ||||
| -rw-r--r-- | test/727-checker-unresolved-class/run | 3 | ||||
| -rwxr-xr-x | test/929-search/run | 4 | ||||
| -rwxr-xr-x | test/936-search-onload/run | 4 | ||||
| -rwxr-xr-x | test/etc/run-test-jar | 12 |
7 files changed, 26 insertions, 12 deletions
diff --git a/test/146-bad-interface/run b/test/146-bad-interface/run index 937b4fd3e0..2b4bbb0bba 100755 --- a/test/146-bad-interface/run +++ b/test/146-bad-interface/run @@ -14,4 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -exec ${RUN} --secondary "${@}" +# Use the `--secondary-class-loader-context` switch to compile the secondary dex +# file with the right class loader context. Do not use `--secondary` as we're +# loading the *-ex.jar file in a separate class loader. +exec ${RUN} "${@}" \ + --secondary-class-loader-context "PCL[$DEX_LOCATION/$TEST_NAME.jar]" diff --git a/test/146-bad-interface/src-art/Main.java b/test/146-bad-interface/src-art/Main.java index 958ec7c3c4..77a2682170 100644 --- a/test/146-bad-interface/src-art/Main.java +++ b/test/146-bad-interface/src-art/Main.java @@ -23,11 +23,11 @@ import dalvik.system.PathClassLoader; public class Main { static final String DEX_LOCATION = System.getenv("DEX_LOCATION"); static final String DEX_FILES = - DEX_LOCATION + "/146-bad-interface-ex.jar" + ":" + - DEX_LOCATION + "/146-bad-interface.jar"; + DEX_LOCATION + "/146-bad-interface.jar" + ":" + + DEX_LOCATION + "/146-bad-interface-ex.jar"; public static void main(String[] args) { try { - PathClassLoader p = new PathClassLoader(DEX_FILES, Main.class.getClassLoader()); + PathClassLoader p = new PathClassLoader(DEX_FILES, Main.class.getClassLoader().getParent()); Class<?> c = Class.forName("A", true, p); Object o = c.newInstance(); Class<?> runner = Class.forName("InvokeInf", true, p); diff --git a/test/164-resolution-trampoline-dex-cache/run b/test/164-resolution-trampoline-dex-cache/run index 5e77cd56ed..33a6f019dd 100644 --- a/test/164-resolution-trampoline-dex-cache/run +++ b/test/164-resolution-trampoline-dex-cache/run @@ -14,9 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Use the --secondary switch to add secondary dex file to class path. # Make sure we compile the required method using speed-profile compiler filter. # Enable JIT through runtime option to avoid the compiler filter set by --jit. -exec ${RUN} "${@}" --secondary \ +exec ${RUN} "${@}" \ -Xcompiler-option --compiler-filter=speed-profile --profile \ --runtime-option -Xusejit:true diff --git a/test/727-checker-unresolved-class/run b/test/727-checker-unresolved-class/run index d087a8f980..1c9dd1179c 100644 --- a/test/727-checker-unresolved-class/run +++ b/test/727-checker-unresolved-class/run @@ -17,14 +17,11 @@ if [[ "$TEST_RUNTIME" == "jvm" ]]; then exec ${RUN} $@ else - # Compile the secondary dex file with the right class loader hierarchy with - # --secondary-class-loader-context. # Append graphs for checker tests (we run dex2oat twice) with # --dump-cfg-append. # Make some classes unresolved for AOT compilation with # --updatable-bcp-packages-file. exec ${RUN} $@ \ - --secondary-class-loader-context "PCL[];PCL[$DEX_LOCATION/$TEST_NAME.jar]" \ -Xcompiler-option --dump-cfg-append \ -Xcompiler-option --updatable-bcp-packages-file="$DEX_LOCATION/res/updateable.txt" fi diff --git a/test/929-search/run b/test/929-search/run index 67923a7984..fb6b1b812a 100755 --- a/test/929-search/run +++ b/test/929-search/run @@ -16,6 +16,8 @@ # This test checks whether dex files can be injected into parent classloaders. App images preload # classes, which will make the injection moot. Turn off app images to avoid the issue. +# Pass the correct `--secondary-class-loader-context` for the "-ex" jar. ./default-run "$@" --jvmti \ - --no-app-image + --no-app-image \ + --secondary-class-loader-context "PCL[$DEX_LOCATION/$TEST_NAME.jar]" diff --git a/test/936-search-onload/run b/test/936-search-onload/run index 67923a7984..fb6b1b812a 100755 --- a/test/936-search-onload/run +++ b/test/936-search-onload/run @@ -16,6 +16,8 @@ # This test checks whether dex files can be injected into parent classloaders. App images preload # classes, which will make the injection moot. Turn off app images to avoid the issue. +# Pass the correct `--secondary-class-loader-context` for the "-ex" jar. ./default-run "$@" --jvmti \ - --no-app-image + --no-app-image \ + --secondary-class-loader-context "PCL[$DEX_LOCATION/$TEST_NAME.jar]" diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar index b94c475c77..56cb4a8c0c 100755 --- a/test/etc/run-test-jar +++ b/test/etc/run-test-jar @@ -1020,7 +1020,17 @@ function write_dex2oat_cmdlines { # If the name ends in -ex then this is a secondary dex file if [ "${name:${#name}-3}" = "-ex" ]; then # Lazily realize the default value in case DEX_LOCATION/TEST_NAME change - [ -z "$SECONDARY_CLASS_LOADER_CONTEXT" ] && SECONDARY_CLASS_LOADER_CONTEXT="PCL[];PCL[$DEX_LOCATION/$TEST_NAME.jar]" + if [ "x$SECONDARY_CLASS_LOADER_CONTEXT" = "x" ]; then + if [ "x$SECONDARY_DEX" = "x" ]; then + # Tests without `--secondary` load the "-ex" jar in a separate PathClassLoader + # that is a child of the main PathClassLoader. If the class loader is constructed + # in any other way, the test needs to specify the secondary CLC explicitly. + SECONDARY_CLASS_LOADER_CONTEXT="PCL[];PCL[$DEX_LOCATION/$TEST_NAME.jar]" + else + # Tests with `--secondary` load the `-ex` jar a part of the main PathClassLoader. + SECONDARY_CLASS_LOADER_CONTEXT="PCL[$DEX_LOCATION/$TEST_NAME.jar]" + fi + fi class_loader_context="'--class-loader-context=$SECONDARY_CLASS_LOADER_CONTEXT'" $enable_app_image && [ "$SECONDARY_APP_IMAGE" = "y" ] || enable_app_image=false fi |