Skip to content

Instantly share code, notes, and snippets.

@joakime
Last active December 3, 2021 00:57
Show Gist options
  • Save joakime/476ecbd47200025229be8a376147ea71 to your computer and use it in GitHub Desktop.
Save joakime/476ecbd47200025229be8a376147ea71 to your computer and use it in GitHub Desktop.
Example of a small java source to big class file
# The raw file size
$ ls -l
total 4
-rw-rw-r-- 1 joakim joakim 564 Nov 11 16:01 A.java
# The java source contents
$ cat A.java
class A {{
int a;
try {a=0;} finally {
try {a=0;} finally {
try {a=0;} finally {
try {a=0;} finally {
try {a=0;} finally {
try {a=0;} finally {
try {a=0;} finally {
try {a=0;} finally {
try {a=0;} finally {
try {a=0;} finally {
try {a=0;} finally {
try {a=0;} finally {
a=0;
}}}}}}}}}}}}
}
A() { }
A(int a) { }
A(char a) { }
A(double a) { }
A(float a) { }
A(long a) { }
A(short a) { }
A(boolean a) { }
A(String a) { }
A(Integer a) { }
A(Float a) { }
A(Short a) { }
A(Long a) { }
A(Double a) { }
A(Boolean a) { }
A(Character a) { }
}
# Compile it
$ javac A.java
# How big is the resulting class file?
$ ls -l
total 102780
-rw-rw-r-- 1 joakim joakim 105236500 Nov 11 16:21 A.class
-rw-rw-r-- 1 joakim joakim 564 Nov 11 16:01 A.java
# What? thats a 101M class file!
$ ls -lh
total 101M
-rw-rw-r-- 1 joakim joakim 101M Nov 11 16:21 A.class
-rw-rw-r-- 1 joakim joakim 564 Nov 11 16:01 A.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment