Reorganizing CP Entries
Since the order of CP ( Constant Pool ) entries is irrelevant to the program execution, it may be reorganized to optimize efficiency.
Instruction accessing a CP entry by index
Some instructions access CP entries by index, and the size of the index is added to the size of the instruction.
For example, ldc is the instruction to put constants of CP entries onto stack. And it has a 1 byte index to access that entry. If a 2 byte index is necessary, the instruction ldc_w will be used.
If CP entries accessed by ldc_w are moved to within a 1 byte index, ldc_w can be replaced by ldc and the instruction size is now smaller.
Optimize ZIP compression
JAR compression employs the technique called "LZ77".
LZ77 locates identical strings within a text segment, and replaces these strings with their position and length. Ideally, all identical text entries would be found, but since this would take too long, upper limits are set and text is segmented.
By sorting CP entries, you can expect that frequently used strings may be gathered closely and hence ZIP compression will be maximized.