summaryrefslogtreecommitdiffstats
path: root/test/138-duplicate-classes-check2/build
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-04-23 22:23:47 -0700
committerAndreas Gampe <agampe@google.com>2015-04-24 11:17:20 -0700
commitb9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188 (patch)
tree86154f70ec4a971540363673236bf6b3ff81593c /test/138-duplicate-classes-check2/build
parent9d4d13f38398e880e610323242fe73d609bac40d (diff)
downloadart-b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188.zip
art-b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188.tar.gz
art-b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188.tar.bz2
ART: Check for duplicate classes when loading oat files
Oat files are usually produced standalone, and the compilers take advantage of any information they get. It is thus possible that when compile-time and runtime class-path are not the same, classes are resolved differently and optimized code is incorrect. This is a very conservative check, scanning the complete class tables of dex files. In case any duplicate class is found, the new oat file will be rejected and the original dex files will be used in interpreted mode. A possible refinement to this is actual tracking of the compile-time class-path instead. That is however significantly complicated by the DexFile API and the non-standard uses it allows. An alternative for both optimized code and correct resolution is native multidex. Apps should switch to multidex and benefit from the optimization as well as the shift of all compile time to install time. Split APKs are currently compiled separately, but it is a goal to change that install flow to simulated multidex. Change-Id: Ib9e0db5091e060e3bb2c0e5e6c007430becbfc21
Diffstat (limited to 'test/138-duplicate-classes-check2/build')
-rwxr-xr-xtest/138-duplicate-classes-check2/build32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/138-duplicate-classes-check2/build b/test/138-duplicate-classes-check2/build
new file mode 100755
index 0000000..abcbbb8
--- /dev/null
+++ b/test/138-duplicate-classes-check2/build
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Copyright (C) 2015 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.
+
+# Stop if something fails.
+set -e
+
+mkdir classes
+${JAVAC} -d classes `find src -name '*.java'`
+
+mkdir classes-ex
+${JAVAC} -d classes-ex `find src-ex -name '*.java'`
+rm classes-ex/A.class
+
+if [ ${NEED_DEX} = "true" ]; then
+ ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes
+ zip $TEST_NAME.jar classes.dex
+ ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes.dex --dump-width=1000 classes-ex
+ zip ${TEST_NAME}-ex.jar classes.dex
+fi