summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/157-void-class/expected.txt2
-rw-r--r--test/157-void-class/info.txt0
-rwxr-xr-xtest/157-void-class/run22
-rw-r--r--test/157-void-class/src/Main.java57
-rwxr-xr-xtest/etc/run-test-jar16
-rwxr-xr-xtest/run-test16
6 files changed, 97 insertions, 16 deletions
diff --git a/test/157-void-class/expected.txt b/test/157-void-class/expected.txt
new file mode 100644
index 0000000000..3f61c0b5b0
--- /dev/null
+++ b/test/157-void-class/expected.txt
@@ -0,0 +1,2 @@
+JNI_OnLoad called
+void.class = void
diff --git a/test/157-void-class/info.txt b/test/157-void-class/info.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/157-void-class/info.txt
diff --git a/test/157-void-class/run b/test/157-void-class/run
new file mode 100755
index 0000000000..59e852c8cd
--- /dev/null
+++ b/test/157-void-class/run
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# Copyright (C) 2017 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.
+
+# Let the test build its own core image with --no-image and use verify-profile,
+# so that the compiler does not try to initialize classes. This leaves the
+# java.lang.Void compile-time verified but uninitialized.
+./default-run "$@" --no-image \
+ --runtime-option -Ximage-compiler-option \
+ --runtime-option --compiler-filter=verify-profile
diff --git a/test/157-void-class/src/Main.java b/test/157-void-class/src/Main.java
new file mode 100644
index 0000000000..322b705f1d
--- /dev/null
+++ b/test/157-void-class/src/Main.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2017 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 libcore.util.EmptyArray;
+
+public class Main {
+ public static void main(String[] args) {
+ try {
+ // Check if we're running dalvik or RI.
+ Class<?> class_loader_class = Class.forName("dalvik.system.PathClassLoader");
+ System.loadLibrary(args[0]);
+ } catch (ClassNotFoundException e) {
+ usingRI = true;
+ // Add expected JNI_OnLoad log line to match expected.txt.
+ System.out.println("JNI_OnLoad called");
+ }
+ try {
+ // Initialize all classes needed for old java.lang.Void.TYPE initialization.
+ Runnable.class.getMethod("run", EmptyArray.CLASS).getReturnType();
+ } catch (Exception e) {
+ throw new Error(e);
+ }
+ // Clear the resolved types of the ojluni dex file to make sure there is no entry
+ // for "V", i.e. void.
+ clearResolvedTypes(Integer.class);
+ // With java.lang.Void being compile-time verified but uninitialized, initialize
+ // it now. Previously, this would indirectly initialize TYPE with the current,
+ // i.e. zero-initialized, value of TYPE. The only thing that could prevent the
+ // series of calls leading to this was a cache hit in Class.getDexCacheType()
+ // which we have prevented by clearing the cache above.
+ Class<?> voidClass = void.class;
+ System.out.println("void.class = " + voidClass);
+ }
+
+ public static void clearResolvedTypes(Class<?> c) {
+ if (!usingRI) {
+ nativeClearResolvedTypes(c);
+ }
+ }
+
+ public static native void nativeClearResolvedTypes(Class<?> c);
+
+ static boolean usingRI = false;
+}
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index f3d4332009..99926aa9a3 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -371,6 +371,22 @@ fi
if [ "$HAVE_IMAGE" = "n" ]; then
+ if [ "${HOST}" = "y" ]; then
+ framework="${ANDROID_HOST_OUT}/framework"
+ bpath_suffix="-hostdex"
+ else
+ framework="${ANDROID_ROOT}/framework"
+ bpath_suffix=""
+ fi
+ # TODO If the target was compiled WITH_DEXPREOPT=true then these tests will
+ # fail since these jar files will be stripped.
+ bpath="${framework}/core-libart${bpath_suffix}.jar"
+ bpath="${bpath}:${framework}/core-oj${bpath_suffix}.jar"
+ bpath="${bpath}:${framework}/conscrypt${bpath_suffix}.jar"
+ bpath="${bpath}:${framework}/okhttp${bpath_suffix}.jar"
+ bpath="${bpath}:${framework}/bouncycastle${bpath_suffix}.jar"
+ # Pass down the bootclasspath
+ FLAGS="${FLAGS} -Xbootclasspath:${bpath}"
# Add 5 minutes to give some time to generate the boot image.
TIME_OUT_VALUE=$((${TIME_OUT_VALUE} + 300))
DALVIKVM_BOOT_OPT="-Ximage:/system/non-existant/core.art"
diff --git a/test/run-test b/test/run-test
index 6134a14696..7d3d813da0 100755
--- a/test/run-test
+++ b/test/run-test
@@ -530,22 +530,6 @@ if [ "$have_image" = "no" ]; then
err_echo "--no-image is only supported on the art runtime"
exit 1
fi
- if [ "$target_mode" = "no" ]; then
- framework="${ANDROID_HOST_OUT}/framework"
- bpath_suffix="-hostdex"
- else
- framework="${android_root}/framework"
- bpath_suffix=""
- fi
- # TODO If the target was compiled WITH_DEXPREOPT=true then these tests will
- # fail since these jar files will be stripped.
- bpath="${framework}/core-libart${bpath_suffix}.jar"
- bpath="${bpath}:${framework}/core-oj${bpath_suffix}.jar"
- bpath="${bpath}:${framework}/conscrypt${bpath_suffix}.jar"
- bpath="${bpath}:${framework}/okhttp${bpath_suffix}.jar"
- bpath="${bpath}:${framework}/bouncycastle${bpath_suffix}.jar"
- # Pass down the bootclasspath
- run_args="${run_args} --runtime-option -Xbootclasspath:${bpath}"
run_args="${run_args} --no-image"
fi