Reputation: 123
So I have a line of code in my file, that reads
char[] arr = new char[256];
However, when I change this to
int[] arr = new int[256];
the class file shrinks by .01 Kb. Why is this?
Upvotes: 1
Views: 98
Reputation:
Its probably because the compiler generates a symbol that is a few characters shorter. Just like in the .java
file the first line will create a bigger file because it has more characters.
If you open the .class
in vim you will see the following for an int
array.
Êþº¾^@^@^@2^@^O
^@^C^@^L^G^@^M^G^@^N^A^@^F<init>^A^@^C()V^A^@^DCode^A^@^OLineNumberTable^A^@^Dmain^A^@^V([Ljava/lang/String;)V^A^@
SourceFile^A^@!JFileChooserDisableDirectory.java^L^@^D^@^E^A^@^\JFileChooserDisableDirectory^A^@^Pjava/lang/Object^@!^@^B^@^C^@^@^@^@^@^B^@^A^@^D^@^E^@^A^@^F^@^@^@^]^@^A^@^A^@^@^@^E*·^@^A±^@^@^@^A^@^G^@^@^@^F^@^A^@^@^@^A^@ ^@^H^@ ^@^A^@^F^@^@^@"^@^A^@^B^@^@^@^F^P
¼
L±^@^@^@^A^@^G^@^@^@
^@^B^@^@^@^D^@^E^@^E^@^A^@
^@^@^@^B^@^K
Here is the char
array .class
file.
Êþº¾^@^@^@2^@^O
^@^C^@^L^G^@^M^G^@^N^A^@^F<init>^A^@^C()V^A^@^DCode^A^@^OLineNumberTable^A^@^Dmain^A^@^V([Ljava/lang/String;)V^A^@
SourceFile^A^@!JFileChooserDisableDirectory.java^L^@^D^@^E^A^@^\JFileChooserDisableDirectory^A^@^Pjava/lang/Object^@!^@^B^@^C^@^@^@^@^@^B^@^A^@^D^@^E^@^A^@^F^@^@^@^]^@^A^@^A^@^@^@^E*·^@^A±^@^@^@^A^@^G^@^@^@^F^@^A^@^@^@^A^@ ^@^H^@ ^@^A^@^F^@^@^@"^@^A^@^B^@^@^@^F^P
¼^EL±^@^@^@^A^@^G^@^@^@
^@^B^@^@^@^D^@^E^@^E^@^A^@
^@^@^@^B^@^K
Using TextDiff you can see the differences in the code.
Upvotes: 4
Reputation: 77187
Probably just because the symbol for the type is a tad bit shorter.
Upvotes: 1