The Java class file is a file with a simple format, and this is documented in Section 4.1 of the Java Virtual Machine Specification.

The class file format is as follows:

  • Signature - 4 bytes
  • Minor Version - 2 bytes
  • Major Version - 2 bytes
  • Constant Pool Count - 2 bytes
  • Constant Pool entries
  • Access Flag - 2 bytes
  • This Class - 2 bytes
  • Super Class - 2 bytes
  • Interfaces Count - 2 bytes
  • Interface entries
  • Fields count - 2 bytes
  • Field Info
  • Method count - 2 bytes
  • Method Info
  • Attribute count - 2 bytes
  • Attributes

To peer into the class file, read the JVM specification and create classes to handle the various expected structures in the class file.

To translate descriptors to Java, for each character in the descriptor, translate as follows:

        'B': -> 'byte';
        'C': -> 'char';
        'D': -> 'double';
        'F': -> 'float';
        'I':  -> 'int';
        'J': -> 'long';
        'L': -> read everything after L until ; and that constitutes a Java class name. Replace / with .
        'S': -> 'short';
        'Z': -> 'boolean';
        '[': -> push onto the stack
        'V':-> 'void';

When there are no more characters, pop off the stack and translate '[' to '[]'.

Here's what the current decompiler looks like:

The constant pool is a list of names. In the Interfaces, Fields, Methods and Attributes section, an index exists, such that it acts as an index into the constant pool. The index can be used to read the name of any interface, field, method, variable, etc.

In the Method Info section of the class file, there is a list of Methods. In each Method, there is an optional array of attributes. In one of the attributes, there is a Code table. In the Code table's attributes section, there is a LocalVariableTable attribute, which lists all the variables declared by that specific method. The first variable refers to "this".  So, to obtain the name of the parameters for each method, just read the LocalVariableTable attribute and pick up the names from there.