Embracing the Messiness in Search of Epic Solutions

Comparing Disassembled Java Class From JVM Languages



All JVM languages come with some degrees of syntactic sugar to make the code easier to read and write.

To satisfy my curiosity, I decided to run javap command to disassemble the bytecode inside the class file generated from several JVM languages. The chosen languages are Java, Groovy, Scala, JRuby and Rhino. I left out Clojure because the syntax does not compute for me after having my heavy lunch.


Source Code

public class JavaPerson {
    private String name;
    private int age;

    public JavaPerson(String name, int age) {
        this.name = name;
        this.age = age;

    public String getName() {
        return name;

    public int getAge() {
        return age;

Disassembled Java Class

public class com.choonchernlim.epicapp.JavaPerson {
  public com.choonchernlim.epicapp.JavaPerson(java.lang.String, int);
  public java.lang.String getName();
  public int getAge();


Source Code

class GroovyPerson {
    String name
    int age

Disassembled Java Class

public class com.choonchernlim.epicapp.GroovyPerson implements groovy.lang.GroovyObject {
  public static transient boolean __$stMC;
  public static long __timeStamp;
  public static long __timeStamp__239_neverHappen1395328777863;
  public com.choonchernlim.epicapp.GroovyPerson();
  public java.lang.Object this$dist$invoke$1(java.lang.String, java.lang.Object);
  public void this$dist$set$1(java.lang.String, java.lang.Object);
  public java.lang.Object this$dist$get$1(java.lang.String);
  protected groovy.lang.MetaClass $getStaticMetaClass();
  public groovy.lang.MetaClass getMetaClass();
  public void setMetaClass(groovy.lang.MetaClass);
  public java.lang.Object invokeMethod(java.lang.String, java.lang.Object);
  public java.lang.Object getProperty(java.lang.String);
  public void setProperty(java.lang.String, java.lang.Object);
  public static void __$swapInit();
  static {};
  public java.lang.String getName();
  public void setName(java.lang.String);
  public int getAge();
  public void setAge(int);
  public void super$1$wait();
  public java.lang.String super$1$toString();
  public void super$1$wait(long);
  public void super$1$wait(long, int);
  public void super$1$notify();
  public void super$1$notifyAll();
  public java.lang.Class super$1$getClass();
  public java.lang.Object super$1$clone();
  public boolean super$1$equals(java.lang.Object);
  public int super$1$hashCode();
  public void super$1$finalize();
  static java.lang.Class class$(java.lang.String);


Source Code

class ScalaPerson(val name: String, val age: Int) {

Disassembled Java Class

public class ScalaPerson {
  public java.lang.String name();
  public int age();
  public ScalaPerson(java.lang.String, int);


Source Code

require 'java'

class JRubyPerson
  java_signature 'JRubyPerson(String, int)'
  def initialize (name, age)
    @name= name
    @age = age

  java_signature 'String getName()'
  def name;

  java_signature 'int getAge()'
  def age;

Disassembled Java Class

public class JRubyPerson extends org.jruby.RubyObject {
  public static org.jruby.runtime.builtin.IRubyObject __allocate__(org.jruby.Ruby, org.jruby.RubyClass);
  public JRubyPerson(java.lang.String, int);
  public java.lang.String getName();
  public int getAge();
  static {};


Source Code

function RhinoPerson( name, age ) {
    this.name = name;
    this.age = age;

    this.getName = function () {
        return this.name;

    this.getAge = function () {
        return this.age;

Disassembled Java Class

public class RhinoPerson extends org.mozilla.javascript.NativeFunction implements org.mozilla.javascript.Script {
  public RhinoPerson(org.mozilla.javascript.Scriptable, org.mozilla.javascript.Context, int);
  public RhinoPerson();
  public static void main(java.lang.String[]);
  public final java.lang.Object exec(org.mozilla.javascript.Context, org.mozilla.javascript.Scriptable);
  public final java.lang.Object call(org.mozilla.javascript.Context, org.mozilla.javascript.Scriptable, org.mozilla.javascript.Scriptable, java.lang.Object[]);
  public int getLanguageVersion();
  public java.lang.String getFunctionName();
  public int getParamCount();
  public int getParamAndVarCount();
  public java.lang.String getParamOrVarName(int);
  public java.lang.String getEncodedSource();
  public boolean getParamOrVarConst(int);



Leave a Reply