Skip to content

Instantly share code, notes, and snippets.

@alblue

alblue/X.java

Created Oct 4, 2015
Embed
What would you like to do?
Simple testcase to determine if inner classes or lambdas take up more space
package foo;
public class X {
public static final Runnable y = new Y();
public static final Runnable z = new Z();
static class Y implements Runnable {
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("Hello world");
}
}
static class Z implements Runnable {
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("Hello again");
}
}
}
package foo;
public class Z {
public static final Runnable y = () -> System.out.println("Hello world");
public static final Runnable z = () -> System.out.println("Hello again");
}
@alblue

This comment has been minimized.

Copy link
Owner Author

@alblue alblue commented Oct 4, 2015

File sizes for the above:

Inner classes:

  • 459 X$Y.class
  • 459 X$Z.class
  • 404 X.class

Lambdas:

  • 1130 Z.class

Compiled with 1.8.0_60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.