summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Lamarche <benoitlamarche@google.com>2015-03-27 17:11:58 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-03-27 17:11:58 +0000
commit0c94f1468db45d1e791fa3a9d2558fd578b94b30 (patch)
treec825d21400bcca31d52e62c6a9f1d68de6a6ce50
parentfd607f81b759862ca0913cfe873c8b2b87c8b67f (diff)
parent931b89b5d6e2c0243bc03547df1c9a0e18f1f6f8 (diff)
downloadandroid_dalvik-0c94f1468db45d1e791fa3a9d2558fd578b94b30.tar.gz
android_dalvik-0c94f1468db45d1e791fa3a9d2558fd578b94b30.tar.bz2
android_dalvik-0c94f1468db45d1e791fa3a9d2558fd578b94b30.zip
am 931b89b5: Merge "Fix potential dex index overflow in dx"
* commit '931b89b5d6e2c0243bc03547df1c9a0e18f1f6f8': Fix potential dex index overflow in dx
-rw-r--r--dx/src/com/android/dx/command/dexer/Main.java12
-rw-r--r--dx/tests/128-multidex-option-overflow/expected.txt1
2 files changed, 7 insertions, 6 deletions
diff --git a/dx/src/com/android/dx/command/dexer/Main.java b/dx/src/com/android/dx/command/dexer/Main.java
index 36b9e2059..b9c6ec952 100644
--- a/dx/src/com/android/dx/command/dexer/Main.java
+++ b/dx/src/com/android/dx/command/dexer/Main.java
@@ -1731,15 +1731,15 @@ public class Main {
// Calculate max number of indices this class will add to the
// dex file.
- // The constant pool contains at least one entry per method
- // (name and signature), at least one entry per field (name
- // and type), and at least per method/field reference (typed
- // method ref).
+ // The possibility of overloading means that we can't easily
+ // know how many constant are needed for declared methods and
+ // fields. We therefore make the simplifying assumption that
+ // all constants are external method or field references.
int constantPoolSize = cf.getConstantPool().size();
- maxMethodIdsInClass = constantPoolSize - cf.getFields().size()
+ maxMethodIdsInClass = constantPoolSize + cf.getMethods().size()
+ MAX_METHOD_ADDED_DURING_DEX_CREATION;
- maxFieldIdsInClass = constantPoolSize - cf.getMethods().size()
+ maxFieldIdsInClass = constantPoolSize + cf.getFields().size()
+ MAX_FIELD_ADDED_DURING_DEX_CREATION;
synchronized(dexRotationLock) {
diff --git a/dx/tests/128-multidex-option-overflow/expected.txt b/dx/tests/128-multidex-option-overflow/expected.txt
index ac448a63d..3d7a649b8 100644
--- a/dx/tests/128-multidex-option-overflow/expected.txt
+++ b/dx/tests/128-multidex-option-overflow/expected.txt
@@ -1,2 +1,3 @@
classes2.dex
+classes3.dex
classes.dex