summaryrefslogtreecommitdiff
path: root/test/176-app-image-string/src/Main.java
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2019-06-10 11:10:38 +0100
committer Vladimir Marko <vmarko@google.com> 2019-06-12 08:44:25 +0000
commit8e05f09ca712c33bf2090cf03a3a8db858a23314 (patch)
treec78491d8a9ef33f4073d0053dfbd6417bbaa13a9 /test/176-app-image-string/src/Main.java
parent23df24822ee70fe255e6c02fb130112e28fdf63a (diff)
Do not force-intern Strings in images.
Interning all image Strings breaks the reference equality semantics. See android.net.Uri.NOT_CACHED for an example where it goes against the intent of the Java code. Instead, only put interned strings (weakly and strongly) to the image intern tables. Since image interns are referenced as long as the image is memory, we can promote weak interns to strong interns. Doing this before the image layout helps ImageWriter::CalculateNewObjectOffsets() which would not have previously found weak interns. Added a regression test that relies on better initialization of app image classes, so it shall be "active" only after an improvement in that area. (This can be checked by commenting out the NoClinitInDependency() check in CompilerDriver's InitializeClassVisitor::TryInitializeClass().) Bug: 134746125 Test: 176-app-image-string 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 Change-Id: I51fa1edf953c9060c41f39812f3ba27f12b02801
Diffstat (limited to 'test/176-app-image-string/src/Main.java')
-rw-r--r--test/176-app-image-string/src/Main.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/176-app-image-string/src/Main.java b/test/176-app-image-string/src/Main.java
new file mode 100644
index 0000000000..f842c10605
--- /dev/null
+++ b/test/176-app-image-string/src/Main.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2019 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 Main {
+ public static final String internedString = "test-string";
+ public static final String nonInternedCopy = new String("test-string");
+
+ public static void main(String args[]) throws Exception {
+ if (internedString == nonInternedCopy) {
+ throw new AssertionError();
+ }
+ System.out.println("pass");
+ }
+}