History log of /dalvik/dx/src/com/android/dx/command/dexer/Main.java
Revision Date Author Comments
e9262fc38f6fc3645a209fac7c4919e4d9cda576 04-Jan-2017 Colin Cross <ccross@android.com> Allow invokevirtual, invokespecial, invokestatic on interface methods

Allow default and static methods on interfaces if
--min-sdk-version >= 24.

Test: make checkbuild
Change-Id: I6b617a37256bdb95f4c11e58fe2ebf08cf7aa324
16fc52fde7c71ebdd14a03d0434058dbfa48b4ab 26-Jan-2017 Chris Warrington <cmw@google.com> Make Dx argument parser reusable.

Test: will be part of tools/base tests.
Change-Id: Ib21c9ca2a95a5b78d0a229234a4f03a56cdba29c
f809c2f0028b3df79787a5da5d5b35ce85331a32 23-Jan-2017 Chris Warrington <cmw@google.com> Use ConcurrentHashMaps for intern tables.

To reduce lock contention when predexing in process in parallel.

Test: existing.
Change-Id: Ia929bc10f57b1d2d4c62cffff4fc0f09cbf9e445
1c57b94a7dff8b47f8b1e52503834aed1baf2c36 23-Jan-2017 Chris Warrington <cmw@google.com> Dx: use context out/err everywhere.

Test: manual.
Change-Id: I14289dbd2e507372d82dd5cc64b4fac761026a5e
e8bf740e4843a2e7a41bfa6c2f96f8ae4a7147fc 20-Jan-2017 Chris Warrington <cmw@google.com> Javadoc fixes.

Test: Manual.
Change-Id: I306d61e3fe49353b64ebee24413a83062365968d
8f68769869e02895dc6474a5cd0bca20977e5ecd 21-Nov-2016 Chris Warrington <cmw@google.com> Make dx code re-entrant

Remove static state, clear biggest caches after running.

Test: TBD.

Change-Id: Ib41a61687b48bfb46f7e104c41d784cad61f306a
900c3b497902357345a9444a972ac0a3bea1f09c 10-Feb-2016 Liam Miller-Cushon <cushon@google.com> Improve dx error handling

If a class file cannot be parsed, print the error message and context
(including file name), and omit the stack trace unless --debug is
enabled.

Bug: 25075831

(cherry picked from commit bd156605a787bbbb5524b6b25254b37a67e6dd7f)

Change-Id: I1615591e6c389e2c99bbc024da22a59abe62a3a2
bd156605a787bbbb5524b6b25254b37a67e6dd7f 10-Feb-2016 Liam Miller-Cushon <cushon@google.com> Improve dx error handling

If a class file cannot be parsed, print the error message and context
(including file name), and omit the stack trace unless --debug is
enabled.

Bug: 25075831
Change-Id: I0a790a5b329640acb7185dbf94408b21dd17de8c
711bc49d66e3360ba818910b64e66ddd0ccc18ee 17-Oct-2015 Rohit Agrawal <rohitagr@google.com> Add more context to dx if debugging.

Change-Id: Ib1fb4acd2ebac842acd7bd95952317ffa83fb54f
f8ed7d3f0ea87b3fc1aa72859386c82d8d9bdbd4 12-Sep-2015 Esteban de la Canal <estebandlc@google.com> Fixes unnecessary multi-merge steps.

Changes merging from quadratic in the number of classes to linear.
This has a tremendous speed up while merging many dexes at the same time.
A sample test (iosched app) with 29 dexes goes from 6 seconds to 1.

Change-Id: Iff02a0dc44d098b0878e88d18f5f4083804a6495
259c2df556dd80998366fc23debb20cbd2d49be3 12-Sep-2015 Esteban de la Canal <estebandlc@google.com> Fixes unnecessary multi-merge steps.

Changes merging from quadratic in the number of classes to linear.
This has a tremendous speed up while merging many dexes at the same time.
A sample test (iosched app) with 29 dexes goes from 6 seconds to 1.

Change-Id: Iff02a0dc44d098b0878e88d18f5f4083804a6495
74fe74478c9112ab9fb042f1dfb0d9ac2b7ab9e2 11-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Fixes unnecessary multi-merge steps."

Breaks continuous libcore tests.

This reverts commit 964d093874aa3533aaf899429dc3820f0fdef4e6.

Change-Id: Ic22b473094425b4dbf5a15a6e1a4c9f66b1b4001
964d093874aa3533aaf899429dc3820f0fdef4e6 20-Aug-2015 estebandlc <estebandlc@google.com> Fixes unnecessary multi-merge steps.

Changes merging from quadratic in the number of classes to linear.
This has a tremendous speed up while merging many dexes at the same time.
A sample test (iosched app) with 29 dexes goes from 6 seconds to 1.

Change-Id: Ie287bdb32b76ba06f362437b05f928bb7b528493
ab01c96b3c21098dffbba03248f801486c76bdc7 17-Aug-2015 Yohann Roussel <yroussel@google.com> Ensure deterministic multidex partitioning

This is done by sorting inputs before processing them.

Bug: 23305646

Change-Id: Ia55c481f4eb342bc925bc100299324ea470bf9a0
635aecf324d618ef45d82183d148d47e08383601 25-Mar-2015 Peter Jensen <jensenp@google.com> Fix potential dex index overflow in dx

Revert change to dex rotation algorithm made as part of commit:
845d9d0eed0f6556e11ee7f7204fda9c8dd41154

Bug: https://code.google.com/p/android/issues/detail?id=161887
Signed-off-by: Peter Jensen <jensenp@google.com>

(cherry picked from commit d024c06726c7e119ee76395611aa7cfe3b0a8b7e)

Change-Id: Iede742620854cef3542bf98b77e66aa8a305195e
bd3b381a74023a63b3713749e4be02429467f789 13-Nov-2014 Peter Jensen <jensenp@google.com> Support --num-threads with --multi-dex (take 2)

With fix for regression introduced in original commit.

The current dx implementation supports options --multi-dex, for applications
not fitting within the dex format limitations; and --num-threads=N, triggers
concurrent processing of multiple input files. However, the implementation
has the following limitations:

The --num-threads option is disabled when used together with --multi-dex.
The --num-threads option implements concurrency at the level of classpath
entries, and does nothing when the classes to be translated are specified
with a single classpath element (e.g. single jar output from Proguard).
The existing --num-threads implementation may produce indeterministic output.
The heuristic used by the --multi-dex option to determine when to rotate the
dex output file is overly conservative.

The primary objective of this change is:
Concurrent translation of classes, independently of input specification format.
Support --num-threads=N in both mono- and multi-dex mode.
Deterministic class output order.
Near optimal use of dex file format capacity.

This is accomplished by reorganizing the dx workflow in a pipeline of
concurrent phases.

read-class | parse-class | translate-class | add-to-dex | convert-dex-to-byte[];
output-dex-files-or-jar

To manage dex file rotation (i.e. --multi-dex support), the parse-class and
add-to-dex phases are synchronized to prevent forwarding classes to the
translate-class phase if it could potentially result in breaking the dex
format limitations. The heuristic currently used to estimate the number of
indices needed for a class is improved, to minimize the amount of serialization
imposed by this feedback mechanism, and to improve the use of dex file capacity.

The translate-class and convert-dex-to-byte[] phases are further parallelized
with configurable (--num-threads=N option) thread pools. This allow translating
classes concurrently, while also performing output conversion in parallel.
Separate collector threads are used to collect results from the thread pools
in deterministic order.

Testing was performed on an Ubuntu system, with 6 cores and 12 hardware threads.
The taskset command was used to experimentally establish that running with more
than 8 hardware threads does not provide any additional benefit.

Experiments shows that the argument to --num-threads should not exceed the
lesser of the number of available hardware threads, and 5. Setting it to a
higher value results in no additional benefit.

The gain is generally larger for larger applications, and not significant for
small applications with less than a few thousands classes. Experiments with
generated classes shows that for large applications gains as high as 50% may
be possible.

For an existing real-life application with more than 11k classes, and requiring
2 dex files, a speed-up of 37% was achieved (--num-threads=5, 8 hardware
threads, 4g Java heap). A speedup of 31% was observed for another application
with ~7 classes.

For small applications, use of --num-threads=N>1 doesn’t provide significant
benefit. Running with --num-threads=1, the modified dx is slightly faster,
but no significant gain is observed unless the application requires multiple
dex files.

The one case where a significant regression may be observed is when using
--num-threads=N>1, with a single hardware thread. This is an inappropriate
configuration, even with the current implementation. However, because of
the limitations of the current implementation, such configurations may exist.
For instance, a configuration using both --multi-dex and --num-threads=5 will
currently generate a warning about using the two options together. With the
new implementation, the options can legitimately be used together, and could
result in an ~20% regression running on a single hardware thread.
Note: the current dx implementation, without --num-threads option, is already
approximately 50% slower with 1 hardware thread, compared to running with 2
or more. With 2 hardware threads the implementations are practically at par
(a little better, or a little worse, depending on the application).

Testing:
Tested with 6 existing applications ranging in size from 1K - 12K classes.
Updated and tested with relevant existing unit tests (one test changed to
account for better dex rotation heuristic).
Added unit test to test deterministic output.
Added unit performance test. By default run script merely validates that
--multi-dex and --num-threads can be used together (fast). However, the test
is configurable to perform performance test, over sets of generated classes.

Signed-off-by: Peter Jensen <jensenp@google.com>

(cherry picked from commit 845d9d0eed0f6556e11ee7f7204fda9c8dd41154)

(cherry picked from commit dd140a22d90495045024334a91770acaad8e065e)

Change-Id: I33a8ea0451efc0af7eb1d72e80cb926d6583d569
dff33a1061ef7ac40fc7035bfbcd7e2512a3ca30 17-Dec-2014 Benoit Lamarche <benoitlamarche@google.com> Do not keep the DexFile field in Main between runs

Bug: 18486731

(cherry picked from commit bb404aa9c531c2e1d27b4f7c6d2b03c2b50fb871)

Change-Id: I048f6064cc49c78df21a1c42316761502a0a5366
e345a3565597b76ee5bf6bfbf2c84ce9271be079 31-Oct-2014 Csaba Kozák <kozakcsabi@gmail.com> Command line option for disabling warnings

This commit adds a new command line option to dx:
--no-warning.
If the caller appends this to the arguments, dx won't print
warnings to System.err. This can be useful if the user
dexes external jars with old class format, so dx would
print lot of warning about those.

Bug: https://code.google.com/p/android/issues/detail?id=78285

Signed-off-by: Csaba Kozák <kozakcsabi@gmail.com>

(cherry picked from commit ef1de423e70704c478ee77956f44b0a040d8bede)

Change-Id: I6d09c684b5eb97aa28e0b12e3ef44b46293c7dec
d024c06726c7e119ee76395611aa7cfe3b0a8b7e 25-Mar-2015 Peter Jensen <jensenp@google.com> Fix potential dex index overflow in dx

Revert change to dex rotation algorithm made as part of commit:
845d9d0eed0f6556e11ee7f7204fda9c8dd41154

Bug: https://code.google.com/p/android/issues/detail?id=161887
Change-Id: I255aa52b74c921a78e77671ae6187157fef011e1
Signed-off-by: Peter Jensen <jensenp@google.com>
dd140a22d90495045024334a91770acaad8e065e 13-Nov-2014 Peter Jensen <jensenp@google.com> Support --num-threads with --multi-dex (take 2)

With fix for regression introduced in original commit.

The current dx implementation supports options --multi-dex, for applications
not fitting within the dex format limitations; and --num-threads=N, triggers
concurrent processing of multiple input files. However, the implementation
has the following limitations:

The --num-threads option is disabled when used together with --multi-dex.
The --num-threads option implements concurrency at the level of classpath
entries, and does nothing when the classes to be translated are specified
with a single classpath element (e.g. single jar output from Proguard).
The existing --num-threads implementation may produce indeterministic output.
The heuristic used by the --multi-dex option to determine when to rotate the
dex output file is overly conservative.

The primary objective of this change is:
Concurrent translation of classes, independently of input specification format.
Support --num-threads=N in both mono- and multi-dex mode.
Deterministic class output order.
Near optimal use of dex file format capacity.

This is accomplished by reorganizing the dx workflow in a pipeline of
concurrent phases.

read-class | parse-class | translate-class | add-to-dex | convert-dex-to-byte[];
output-dex-files-or-jar

To manage dex file rotation (i.e. --multi-dex support), the parse-class and
add-to-dex phases are synchronized to prevent forwarding classes to the
translate-class phase if it could potentially result in breaking the dex
format limitations. The heuristic currently used to estimate the number of
indices needed for a class is improved, to minimize the amount of serialization
imposed by this feedback mechanism, and to improve the use of dex file capacity.

The translate-class and convert-dex-to-byte[] phases are further parallelized
with configurable (--num-threads=N option) thread pools. This allow translating
classes concurrently, while also performing output conversion in parallel.
Separate collector threads are used to collect results from the thread pools
in deterministic order.

Testing was performed on an Ubuntu system, with 6 cores and 12 hardware threads.
The taskset command was used to experimentally establish that running with more
than 8 hardware threads does not provide any additional benefit.

Experiments shows that the argument to --num-threads should not exceed the
lesser of the number of available hardware threads, and 5. Setting it to a
higher value results in no additional benefit.

The gain is generally larger for larger applications, and not significant for
small applications with less than a few thousands classes. Experiments with
generated classes shows that for large applications gains as high as 50% may
be possible.

For an existing real-life application with more than 11k classes, and requiring
2 dex files, a speed-up of 37% was achieved (--num-threads=5, 8 hardware
threads, 4g Java heap). A speedup of 31% was observed for another application
with ~7 classes.

For small applications, use of --num-threads=N>1 doesn’t provide significant
benefit. Running with --num-threads=1, the modified dx is slightly faster,
but no significant gain is observed unless the application requires multiple
dex files.

The one case where a significant regression may be observed is when using
--num-threads=N>1, with a single hardware thread. This is an inappropriate
configuration, even with the current implementation. However, because of
the limitations of the current implementation, such configurations may exist.
For instance, a configuration using both --multi-dex and --num-threads=5 will
currently generate a warning about using the two options together. With the
new implementation, the options can legitimately be used together, and could
result in an ~20% regression running on a single hardware thread.
Note: the current dx implementation, without --num-threads option, is already
approximately 50% slower with 1 hardware thread, compared to running with 2
or more. With 2 hardware threads the implementations are practically at par
(a little better, or a little worse, depending on the application).

Testing:
Tested with 6 existing applications ranging in size from 1K - 12K classes.
Updated and tested with relevant existing unit tests (one test changed to
account for better dex rotation heuristic).
Added unit test to test deterministic output.
Added unit performance test. By default run script merely validates that
--multi-dex and --num-threads can be used together (fast). However, the test
is configurable to perform performance test, over sets of generated classes.

Signed-off-by: Peter Jensen <jensenp@google.com>

(cherry picked from commit 845d9d0eed0f6556e11ee7f7204fda9c8dd41154)

Change-Id: I721effa31c3b1a8b427d3a18ec554a19c5e9765b
c8b036e3fb5e88eb501e953a8a8838b547f2dab4 09-Feb-2015 Benoit Lamarche <benoitlamarche@google.com> Revert "Support --num-threads with --multi-dex"

This reverts commit 845d9d0eed0f6556e11ee7f7204fda9c8dd41154.

Bug: 19313927
Change-Id: Ia6582a3914cc33762aef74da1f5a6a153c8c0ab2
845d9d0eed0f6556e11ee7f7204fda9c8dd41154 13-Nov-2014 Peter Jensen <jensenp@google.com> Support --num-threads with --multi-dex

The current dx implementation supports options --multi-dex, for applications
not fitting within the dex format limitations; and --num-threads=N, triggers
concurrent processing of multiple input files. However, the implementation
has the following limitations:

The --num-threads option is disabled when used together with --multi-dex.
The --num-threads option implements concurrency at the level of classpath
entries, and does nothing when the classes to be translated are specified
with a single classpath element (e.g. single jar output from Proguard).
The existing --num-threads implementation may produce indeterministic output.
The heuristic used by the --multi-dex option to determine when to rotate the
dex output file is overly conservative.

The primary objective of this change is:
Concurrent translation of classes, independently of input specification format.
Support --num-threads=N in both mono- and multi-dex mode.
Deterministic class output order.
Near optimal use of dex file format capacity.

This is accomplished by reorganizing the dx workflow in a pipeline of
concurrent phases.

read-class | parse-class | translate-class | add-to-dex | convert-dex-to-byte[];
output-dex-files-or-jar

To manage dex file rotation (i.e. --multi-dex support), the parse-class and
add-to-dex phases are synchronized to prevent forwarding classes to the
translate-class phase if it could potentially result in breaking the dex
format limitations. The heuristic currently used to estimate the number of
indices needed for a class is improved, to minimize the amount of serialization
imposed by this feedback mechanism, and to improve the use of dex file capacity.

The translate-class and convert-dex-to-byte[] phases are further parallelized
with configurable (--num-threads=N option) thread pools. This allow translating
classes concurrently, while also performing output conversion in parallel.
Separate collector threads are used to collect results from the thread pools
in deterministic order.

Testing was performed on an Ubuntu system, with 6 cores and 12 hardware threads.
The taskset command was used to experimentally establish that running with more
than 8 hardware threads does not provide any additional benefit.

Experiments shows that the argument to --num-threads should not exceed the
lesser of the number of available hardware threads, and 5. Setting it to a
higher value results in no additional benefit.

The gain is generally larger for larger applications, and not significant for
small applications with less than a few thousands classes. Experiments with
generated classes shows that for large applications gains as high as 50% may
be possible.

For an existing real-life application with more than 11k classes, and requiring
2 dex files, a speed-up of 37% was achieved (--num-threads=5, 8 hardware
threads, 4g Java heap). A speedup of 31% was observed for another application
with ~7 classes.

For small applications, use of --num-threads=N>1 doesn’t provide significant
benefit. Running with --num-threads=1, the modified dx is slightly faster,
but no significant gain is observed unless the application requires multiple
dex files.

The one case where a significant regression may be observed is when using
--num-threads=N>1, with a single hardware thread. This is an inappropriate
configuration, even with the current implementation. However, because of
the limitations of the current implementation, such configurations may exist.
For instance, a configuration using both --multi-dex and --num-threads=5 will
currently generate a warning about using the two options together. With the
new implementation, the options can legitimately be used together, and could
result in an ~20% regression running on a single hardware thread.
Note: the current dx implementation, without --num-threads option, is already
approximately 50% slower with 1 hardware thread, compared to running with 2
or more. With 2 hardware threads the implementations are practically at par
(a little better, or a little worse, depending on the application).

Testing:
Tested with 6 existing applications ranging in size from 1K - 12K classes.
Updated and tested with relevant existing unit tests (one test changed to
account for better dex rotation heuristic).
Added unit test to test deterministic output.
Added unit performance test. By default run script merely validates that
--multi-dex and --num-threads can be used together (fast). However, the test
is configurable to perform performance test, over sets of generated classes.

Change-Id: Ic2d11c422396e97171c2e6ceae9477113e261b8e
Signed-off-by: Peter Jensen <jensenp@google.com>
bb404aa9c531c2e1d27b4f7c6d2b03c2b50fb871 17-Dec-2014 Benoit Lamarche <benoitlamarche@google.com> Do not keep the DexFile field in Main between runs

Bug: 18486731
Change-Id: I76dbdd709182c4663f2bbf42179f55d0184e97c2
2f99a0c9da7a067938dc2598c5dfebb5a2002b05 14-Nov-2014 Xavier Ducrohet <xav@google.com> Keep --input-list order.

Merging dex files starting with smaller ones can have
a big impact on performance as it potentially reduces
the number of compact events during the merge.

Gradle will now send the list sorted in ascending order
of file size, and dex should keep this order when parsing
the input list file.

Change-Id: Iff3ae4d30106fe70dca0764b33addfecceb84d09
9747950064e4711c15baf0986102320a2512097a 14-Nov-2014 Xavier Ducrohet <xav@google.com> Keep --input-list order.

Merging dex files starting with smaller ones can have
a big impact on performance as it potentially reduces
the number of compact events during the merge.

Gradle will now send the list sorted in ascending order
of file size, and dex should keep this order when parsing
the input list file.

Change-Id: Iff3ae4d30106fe70dca0764b33addfecceb84d09
ef1de423e70704c478ee77956f44b0a040d8bede 31-Oct-2014 Csaba Kozák <kozakcsabi@gmail.com> Command line option for disabling warnings

This commit adds a new command line option to dx:
--no-warning.
If the caller appends this to the arguments, dx won't print
warnings to System.err. This can be useful if the user
dexes external jars with old class format, so dx would
print lot of warning about those.

Bug: https://code.google.com/p/android/issues/detail?id=78285

Change-Id: Ic2da274ec72e096bcf871c1f4512c54ddc228721
Signed-off-by: Csaba Kozák <kozakcsabi@gmail.com>
8a5d5ccc26c97d555024c36f54140f07a4b40b8c 08-Aug-2014 John Fazekas <jfazekas@fd-software.com> Fixes command line too long error on Windows

On Windows machines the command line can only accept
commands that are 8192 characters or less. This can
cause a problem when a project has many dependencies
and many libraries are being passed to dex at once.

This fixes it by adding a new option to dex called
--input-list that can read inputs from a file.
This way we only have to pass a single file name
instead of a ton of jar files. This keeps the command
short so Windows will not complain about it.

Bug: 17438982

Signed-off-by: John Fazekas <jfazekas@fd-software.com>

(cherry picked from commit 914f2263ca57b21dc4ef1fb218e345a16a5a5db5)

Change-Id: I6edd1e7c1d1fddc8d6bf4c4963295d4f4e64032e
914f2263ca57b21dc4ef1fb218e345a16a5a5db5 08-Aug-2014 John Fazekas <jfazekas@fd-software.com> Fixes command line too long error on Windows

On Windows machines the command line can only accept
commands that are 8192 characters or less. This can
cause a problem when a project has many dependencies
and many libraries are being passed to dex at once.

This fixes it by adding a new option to dex called
--input-list that can read inputs from a file.
This way we only have to pass a single file name
instead of a ton of jar files. This keeps the command
short so Windows will not complain about it.

Change-Id: Ia62ed125c66b24ac81799d3bbac460ae07495b25
Signed-off-by: John Fazekas <jfazekas@fd-software.com>
084b7f109aa96a86a267074f5464732b8062bd5a 21-Jul-2014 Yohann Roussel <yroussel@google.com> Do not generate empty dex in multidex.

This was possible when the first class considered for adding in a dex was too
big to be sure it will fit. Now DX will try to add the class in the current dex
and crash if the class causes one index to overflow.

(cherry picked from commit f15dafe674d2270cafaf4fb7993963ec474d3761)

Change-Id: I323f8111c2be6bace908d0539ff324c4bd033c05
f15dafe674d2270cafaf4fb7993963ec474d3761 21-Jul-2014 Yohann Roussel <yroussel@google.com> Do not generate empty dex in multidex.

This was possible when the first class considered for adding in a dex was too
big to be sure it will fit. Now DX will try to add the class in the current dex
and crash if the class causes one index to overflow.

Change-Id: Ia1f8f733ee49e24bbb42db335ac9080312c1907a
4ec4dc5c35060cb2346770c84a6e705a45a45804 13-May-2014 Yohann Roussel <yroussel@google.com> Make a better detection of index limit in multidex.

- Intern annotation content sooner.
- Count declared methods separatly because it seems possible to have them
generate more method ids than they account in the constant pool if their
name and descriptor are the same as those of called methods.
- Take into account some possible ids that can be added during dex creation.
- Drop evaluation of type ids numbers because it was wrong, it's not simple
to do better and it's nearly impossible to have type ids overflow before
method ids.
Detection is still rough, only a max value is evaluated not the real value.

Bug 14633887

(cherry picked from commit 466d7d94b8b173a323fc5616837940219a216f9d)

Change-Id: Ib5e7b4a13a69ed76b3bbc19f7d138129fcc569c8
9cda6d302721b6943b32d150830917b17bb7deda 28-Feb-2014 Benoit Lamarche <benoitlamarche@google.com> Fix detection of main dex overflow in multidex

Bug: 13239620

(cherry picked from commit c00fafdb91760a4cdfbe9e5323b5165ab4c01b76)

Change-Id: I1bdeee3b0279bed38e230ed3598c06227fc27477
466d7d94b8b173a323fc5616837940219a216f9d 13-May-2014 Yohann Roussel <yroussel@google.com> Make a better detection of index limit in multidex.

- Intern annotation content sooner.
- Count declared methods separatly because it seems possible to have them
generate more method ids than they account in the constant pool if their
name and descriptor are the same as those of called methods.
- Take into account some possible ids that can be added during dex creation.
- Drop evaluation of type ids numbers because it was wrong, it's not simple
to do better and it's nearly impossible to have type ids overflow before
method ids.
Detection is still rough, only a max value is evaluated not the real value.

Bug 14633887

Change-Id: I2e3180662cb4b1c58bbc743b69270ffaa64f3106
cecacd3a4b5ab7a45340f3843522a42a0a4cf287 18-Apr-2014 Benoit Lamarche <benoitlamarche@google.com> Return the correct error code in multi-thread mode

Bug: 14062905

In "--num-threads" mode, dx did not return a result code different
than zero in case of a Throwable.
This CL aims to have the same behaviour in multi-threaded mode as in
normal mode.
There are 2 cases:
- When there is an Exception, it is supposed to be handled by
ClassPathOpener.Consumer.onException(). The number of errors is then
incremented, which is used in "com.android.dx.command.dexer.Main" to
return the error code. With "--num-threads" it couldn't be handled by
onException(). So I've modified the ParallelProcessor to use the
ClassPathOpener, so that the Exception is handled inside the thread.
- When there is an Error it is handled using the Futures of
ParallelProcessors through ExecutorService.

Change-Id: Idc9d8d8bc737587ca518f8f9166e5e511ec22908
c00fafdb91760a4cdfbe9e5323b5165ab4c01b76 28-Feb-2014 Benoit Lamarche <benoitlamarche@google.com> Fix detection of main dex overflow in multidex

Bug: 13239620

Change-Id: Ie897070cbbe0605f38fd6db7b6a50c91f2d1364b
3530d30f6adfd8b8607d6a0bf7988833945f5cf4 17-Jan-2014 Jean-Marie Henaff <jmhenaff@google.com> Remove code related to extended-opcode.

- This support was removed one year ago.

(cherry-pick from commit 18b65cbb3ec6634618bd3240a692507432e634b5)

Change-Id: I1154e518dc8a15220f2fcb163056570030492bb0
0820aa265488e7104ad43dc0584c01f0bfb01c7a 16-Jan-2014 Jean-Marie Henaff <jmhenaff@google.com> Fix dx test 034.

- Test 034 requires that a dex file is dumped in a human readable form
even if the dex file does not contain ClassDef.
Consequently, the command line behavior is modified to satisfy this requirement.

(cherry-pick from commit 64f4aad1e6ef58b29f860b59512ca1a676ac6eb8)

Change-Id: Id64b563745db2b22ec98fba9be25413192c07719
43ee5e97c443949aa68c529e249ed6e1e5057de5 22-Oct-2013 Benoit Lamarche <benoitlamarche@google.com> Deactivate multi-thread in multi-dex mode

It should already have been the case, but it wasn't and it crashed.

Change-Id: Icb461d6e43ef2d113f59038d8c2327f3cfaff86c
(cherry picked from commit cf069ca52f2af9f70fcbeac99443f00401d43b4a)
cf069ca52f2af9f70fcbeac99443f00401d43b4a 22-Oct-2013 Benoit Lamarche <benoitlamarche@google.com> Deactivate multi-thread in multi-dex mode

It should already have been the case, but it wasn't and it crashed.

Change-Id: Icb461d6e43ef2d113f59038d8c2327f3cfaff86c
418c84770acea60b3b13aa37ac21563dba4c8854 22-Aug-2013 Yohann Roussel <yroussel@google.com> Make a more verbose too many id error message.

This restores the old message, replacing "ids" by "references" and
advertising for multidex otpions.

Updates dalvik/tests/089-many-methods accordingly.

(cherry picked from commit d352de04f03b848e0246119344ea13e7233018f0)

Change-Id: I5934bc9fb7812b66c0e38935946cacdf1c35a402
3abdb48fdefcc3136a8d7f9c168a305d9be9690e 21-Aug-2013 Yohann Roussel <yroussel@google.com> Fix 2 filtering problems in multi dex + main list.

- Classes in archives were added in all dexes.
- Adding resources could be done twice in non "strictNameCheck" mode
(when using BestEffortMainDexListFilter) if there was 2 secondary
dex.

(cherry picked from commit ad27e19691c6723a801b127f8802f5cdf4f44359)

Change-Id: I5cbc1b273518e868fdd3d642d50488ddcbec2af6
4c656e4ec2f5c5036dc67fb4034c1e7ff7abf343 31-Jul-2013 Benoit Lamarche <benoitlamarche@google.com> Introduce --multi-dex option in dx.

Add --multi-dex options to dx command line to allow the generation of
several dex files when method index limit is about to be reached.
Also add
--main-dex-list allowing to force some classes in the main dex.
--minimal-main-dex to keep in main edx only classes specified by
main-dex-list.
--set-max-idx-number to set an arbitrary idx limit for the
splitting.

(cherry picked from commit c7daf656da3a4854296b6a8bb702e3ee418450e5)

Change-Id: I2b42272be91484a75783eb94cd30581159948975
d352de04f03b848e0246119344ea13e7233018f0 22-Aug-2013 Yohann Roussel <yroussel@google.com> Make a more verbose too many id error message.

This restores the old message, replacing "ids" by "references" and
advertising for multidex otpions.

Updates dalvik/tests/089-many-methods accordingly.

Change-Id: Ibc4ad1c4606dba59b515b793d729e4e982709699
ad27e19691c6723a801b127f8802f5cdf4f44359 21-Aug-2013 Yohann Roussel <yroussel@google.com> Fix 2 filtering problems in multi dex + main list.

- Classes in archives were added in all dexes.
- Adding resources could be done twice in non "strictNameCheck" mode
(when using BestEffortMainDexListFilter) if there was 2 secondary
dex.

Change-Id: Id7ecca9965a3adefc93f09d95235befbd2b1fe00
c7daf656da3a4854296b6a8bb702e3ee418450e5 31-Jul-2013 Benoit Lamarche <benoitlamarche@google.com> Introduce --multi-dex option in dx.

Add --multi-dex options to dx command line to allow the generation of
several dex files when method index limit is about to be reached.
Also add
--main-dex-list allowing to force some classes in the main dex.
--minimal-main-dex to keep in main edx only classes specified by
main-dex-list.
--set-max-idx-number to set an arbitrary idx limit for the
splitting.

Change-Id: I57d0860b6156e53355e08151b64c1320b7984004
0b44e47c51b5c735283cc99b0c08cac82dba8a00 26-Apr-2013 delphinemartin <delphinemartin@google.com> Report problems as errors in dx (with exit codes)

(cherry picked from commit 593a7233e13d6eeb8ae5d894e29c6a27cbc7b7f0)

Change-Id: I6421f95ceb97a596a19781e46cb4767bfb21cdbd
fe107fb6e3f308ac5174ebdc5a794ee880c741d9 17-Sep-2011 Jesse Wilson <jessewilson@google.com> Mechanical refactoring of dx into two parts.

This splits off a new package, com.android.dex that contains
code for parsing and modelling dex files. This code is usable
both at build time (for compilation and analysis) and at runtime
(for introspection).

The original package, com.android.dx is the tool that compiles
.class files into .dex files. That package also includes utilities
for merging and querying dex files, all visible to the dx command
line application.

In a follow up change I'll move the new com.android.dex package
into the libcore/ project, and configure build rules so that it's
included in both dx.jar and core.jar. The core.jar will then be
able to use it for annotation processing.

Change-Id: I3c58cf87e728e4dda1925a0992c1ee7b8130e81a
(cherry picked from commit bab4abb07335d162ecdb8091fc395cf84803a580)

Conflicts:
dx/junit-tests/com/android/dx/util/BitIntSetTest.java
dx/junit-tests/com/android/dx/util/BitsTest.java
dx/junit-tests/com/android/dx/util/IntListTest.java
dx/junit-tests/com/android/dx/util/ListIntSetTest.java
dx/src/com/android/dex/Dex.java
dx/src/com/android/dex/TableOfContents.java
dx/src/com/android/dx/annotations/AnnotationAccess.java
dx/src/com/android/dx/command/Main.java
dx/src/com/android/dx/dex/code/OutputFinisher.java
dx/src/com/android/dx/dex/code/form/Form32s.java
dx/src/com/android/dx/dex/code/form/Form33x.java
dx/src/com/android/dx/dex/code/form/Form41c.java
dx/src/com/android/dx/dex/code/form/Form52c.java
dx/src/com/android/dx/gen/DexGenerator.java
dx/src/com/android/dx/merge/DexMerger.java
f870f2dce9300c8dec620613371f08e5c234245b 16-Oct-2012 jeffhao <jeffhao@google.com> Add dx option to always generate const-string/jumbo.do not merge.

This allows large dex files with many strings to be merged properly.

(cherry picked from commit 266f45ff7da18022faf5f77df76c69f8cdad313f)

Change-Id: I5fe4c55d84a91101a4f89f590117aa6dc0bfc0f2
9db54b1e21b8e994658890328e57caa822e444a7 16-Oct-2012 jeffhao <jeffhao@google.com> Add dx option to always generate const-string/jumbo. do not merge.

This allows large dex files with many strings to be merged properly.

(cherry picked from commit 266f45ff7da18022faf5f77df76c69f8cdad313f)

Change-Id: I0277b1a0a81b3a77092a9e9f8f648ff190e29723
69dd411c7ef47e3ea3f6ff8be9a4d903f545f0d5 16-Oct-2012 jeffhao <jeffhao@google.com> Add dx option to always generate const-string/jumbo. do not merge.

This allows large dex files with many strings to be merged properly.

(cherry picked from commit 266f45ff7da18022faf5f77df76c69f8cdad313f)

Change-Id: I5e85346610c4c5280ecdd9e97c63eaef4420642e
266f45ff7da18022faf5f77df76c69f8cdad313f 16-Oct-2012 jeffhao <jeffhao@google.com> Add dx option to always generate const-string/jumbo.

This allows large dex files with many strings to be merged properly.

Change-Id: I2c32b03ddb42735d16bc6155c1a1096159fb15ed
45ffaef820370a176097e2987a27e9169d1f8869 12-Jun-2012 Xavier Ducrohet <xav@android.com> Make dex merging stateless. do not merge.

This is required to run dx in Eclipse which doesn't unload the dx
library after each run.

(cherry-pick of 7aa5ce7e990dc3766eba97cd0932b62e4de21503.)

(cherry picked from commit 5e90165d5918f18aec0964bc475f4064e9143599)

Change-Id: Id5818f516539d13423b7cef4b2b1af30a9686b45
5e90165d5918f18aec0964bc475f4064e9143599 12-Jun-2012 Xavier Ducrohet <xav@android.com> Make dex merging stateless.

This is required to run dx in Eclipse which doesn't unload the dx
library after each run.

(cherry-pick of 7aa5ce7e990dc3766eba97cd0932b62e4de21503.)

Change-Id: I7a69a3015d448ddd5558c307cd01346156cbc739
7aa5ce7e990dc3766eba97cd0932b62e4de21503 12-Jun-2012 Xavier Ducrohet <xav@android.com> Make dex merging stateless.

This is required to run dx in Eclipse which doesn't unload the dx
library after each run.

Change-Id: I84df49d424ea465f70613eb602d1a4890804296a
36db01eeaa04e3af3401c5bd6a399d3fb7b040e3 23-Aug-2011 jeffhao <jeffhao@google.com> Removed parsing and output for unused --target-api switch in dx.

This is cherry-picked from dalvik-dev.

Change-Id: I74627e4c261e086e8c2c7cf38591cd3e9f5707e6
1e4c4bebc1feb4b68155e9c2e7e6f2c056ef8e3b 12-Jul-2011 Raphael Moll <ralf@android.com> Dex for Windows: Support paths with spaces.

1- Change the format of the command line parsed by dx.jar.
Parameters with values are usually specified with one
single argument e.g.
--output=/some/path with spaces
That breaks for a variety of reasons on windows, so the first
step is to allow a new 2-parameter form:
--output "/some/path with spaces"

2- The next step is fixing the way the dx.bat wrapper
extracts the -J parameters to be able to cope with
arguments that contain spaces.

SDK bugs: 4567, 18388

Change-Id: Ia837e7307998c0bf41ae39abb36abebfc27da104
a7ab2182266fb9ea1e4e8d1347fc6d6da35760d4 16-Jun-2011 Elliott Hughes <enh@google.com> Fix unbundled apps on pre-ICS devices.

Change-Id: I4aa58b5395423ec2f05be3dcb1783d0e35eabb2c
7baeded82e40352ebfb43b716e0b1dd752e72e7e 15-Jun-2011 jeffhao <jeffhao@google.com> Dx defaults to emitting dexfiles without jumbo opcodes.

There's compatibility issues with going back and forth between versions,
and it's best to have dx default to a stable point and allow
optimizations to be controlled by switches. For jumbo opcodes to be
enabled, dx can be given the switch "--target-api=14".

Change-Id: I824092c795638ca329325b14c435bc41c1ab56d5
9fdbd91288a237eb58e18e4de9c729c3c268c318 25-May-2011 Dan Bornstein <danfuzz@android.com> Update dex file magic number.

Even though the dex format was technically resilient with respect to
the addition of new opcodes, consensus is that the errors one sees
when trying to use a new dex file on an old build were sufficiently
inscrutable that it was worth the effort to update the version number
embedded in the dex format magic.

This change updates dx to produce the new version number when extended
opcodes are enabled (which is the default, but may be overridden by
targeting an older API level).

This also updates the vm to recognize and accept both the new current
version number as well as the immediately previous one. Note: It won't
reject an old-version file if it happens to use the new opcodes; that
would just be a gratuitous and pointless failure.

Bug: 4364986
Change-Id: If8febbb0b91c1719df4247bf69c511251362d91f
333201833d506a3accdeac6ceb7caba8d4b95797 13-Apr-2011 Jesse Wilson <jessewilson@google.com> Combine CstUtf8 and CstString.

The only benefit we were seeing is that one wrapped its toHuman
in quotes, the other didn't.

It was far too easy to use the wrong one. We had code defending
against that in NameValuePair and CstArray.

Change-Id: Ib2e6a1596b97decced37952d46e1831b7bcd0d5d
afe002d1474d7c2ef2ac80de32f21f1949af2a41 07-Apr-2011 Dan Bornstein <danfuzz@android.com> Update the interpretation of --target-api.

Change-Id: I4ab158384d09470d84097d944ae1ddadeb2ad045
09dc1b7301e8b03fc6772b022d21afe9cb077d89 22-Mar-2011 Dan Bornstein <danfuzz@android.com> Make sure both options objects get created.

Previously, the new DexOptions object would only get created when
calling dx as a command directly, but not when it was used as a
library (via a call to Main.run()).

Change-Id: Ie4f37ff9140539a4f2c7af50228ac6eaf6bebe05
09d308b04b7c4fd3ed83a8f8f4c07be67a25478c 17-Mar-2011 Jesse Wilson <jessewilson@google.com> Add support for pre-dexed libraries to dx.

http://b/4090053

Change-Id: Ifb8b9230939cb2a72a767128f79cbfbd042e95a6
3dfda9ad1964510e4a7948a240b30cd710e86341 17-Mar-2011 Dan Bornstein <danfuzz@android.com> Add --target-api=N option to dx.

This change adds the option and plumbs it into where it
needs to go, but doesn't add any code to take action on it.
That will come in a follow-up.

Bug: 4094709
Change-Id: I9c796e176e125b0bcee18af56d9e6da802dfa081
d2b3f499be6f5b1d4076b1244be3d1501d178315 08-Mar-2011 Jesse Wilson <jessewilson@google.com> Permit dx to build resource-only dex files.

Previously it would build a .jar file containing a classes.dex
that itself contained no classes.

Change-Id: I9c36a5dcdd17d2821be15f87656d72ef0048c113
dc520adfdcf0f0e9190cdb90605c42a7cc8fa98f 07-Feb-2011 Dan Bornstein <danfuzz@android.com> Fix dex processing when no output file is specified.

This case is mainly exercised in test code.

Change-Id: Ifbcbec3f001cae925090796ce8ed69f6a986384c
d0900d13fb7bb1706aff5205af7e2d6517335bee 21-Jan-2011 jeffhao <jeffhao@google.com> Made handling of sim exceptions nicer.

Change-Id: I089512c046d90ea37da4a33433edc4ec308a628d
dc86cd9edc8b80953c8b698a83cdaebf6825d798 18-Jan-2011 Jesse Wilson <jessewilson@google.com> Add an undocumented --incremental option to dx.

Change-Id: I48879b2f724e9b92c99c669803f9c8de01487327
9028bfd131e42a58255699d1471c914d58893c61 13-Dec-2010 jeffhao <jeffhao@google.com> Adding javax.sip to the dx blacklist.

Change-Id: I5be068821862ccf073cb758e60b686f46a3c97c1
590f78fc4b6e3268149c5eacb7c8b7dd33497f44 22-Oct-2010 jeffhao <jeffhao@google.com> Added multi-threaded support to processing of class files in dx.

Change-Id: Ideb54c414073a9651b21ce0697e6444fa80f146d
85dc40d2a0cb19792bf3ee6f6c57fed08eb91ea4 27-Sep-2010 Dan Bornstein <danfuzz@android.com> Take another tilt at the "--core-library" messaging windmill.

This time, I added a note about what appears to be the most common
inadvertent triggering, and I point people at JarJar as a possible
solution when the core class inclusion was intentional.

Change-Id: I2d576df0b8944882838cbb6e2b050d59434a238b
de75089fb7216d19e9c22cce4dc62a49513477d3 09-Jun-2010 Carl Shapiro <cshapiro@google.com> Remove trailing whitespace.

Change-Id: I95534bb2b88eaf48f2329282041118cd034c812b
72e93344b4d1ffc71e9c832ec23de0657e5b04a5 13-Nov-2009 Jean-Baptiste Queru <jbq@google.com> eclair snapshot
55423dcd081e30c4fc27b997f127db7b00f1b981 15-May-2009 Dan Bornstein <danfuzz@android.com> Fix a bunch of little problems noticed by FindBugs, and cleaned up some
spacing issues that I happened to notice along the way.
de1ab3724b284ab053322db7ff723f54d7826c96 31-Mar-2009 Dan Bornstein <> AI 143732: Tweaks, in response to public critique.

Automated import of CL 143732
291fe153ba3b64dfb0472f1f53cee59c53f5da04 30-Mar-2009 Dan Bornstein <> AI 143492: Another crank of the --core-library wheel.

Automated import of CL 143492
99409883d9c4c0ffb49b070ce307bb33a9dfe9f1 19-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import //branches/master/...@140412
f6c387128427e121477c1b32ad35cdcaa5101ba3 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
f72d5de56a522ac3be03873bdde26f23a5eeeb3c 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
2ad60cfc28e14ee8f0bb038720836a4696c478ad 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution