Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replicate javap's version flag #6

Open
ExcaliburZero opened this issue Jan 9, 2021 · 1 comment
Open

Replicate javap's version flag #6

ExcaliburZero opened this issue Jan 9, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@ExcaliburZero
Copy link
Owner

Currently we do not take in any command line arguments and flags other than the class file to parse and report on. We also as of #5 have the capability to have the executable not include the code references in the program output.

It would be nice to try to have some flags similar to those provided by javap to configure the output of the executable. A good flag to start with would be the -verbose flag.

For example:

$ javap classes/Dummy.class 
Compiled from "Dummy.java"
public class Dummy {
  public Dummy();
}
$ javap -v classes/Dummy.class
Classfile /home/chris/Code/jvm-class-file-parser/classes/Dummy.class
  Last modified Jan 4, 2021; size 184 bytes
  MD5 checksum a1fc389a27d8a93ab140f4a1ecaa33b7
  Compiled from "Dummy.java"
public class Dummy
  minor version: 0
  major version: 55
  flags: (0x0021) ACC_PUBLIC, ACC_SUPER
  this_class: #2                          // Dummy
  super_class: #3                         // java/lang/Object
  interfaces: 0, fields: 0, methods: 1, attributes: 1
Constant pool:
   #1 = Methodref          #3.#10         // java/lang/Object."<init>":()V
   #2 = Class              #11            // Dummy
   #3 = Class              #12            // java/lang/Object
   #4 = Utf8               <init>
   #5 = Utf8               ()V
   #6 = Utf8               Code
   #7 = Utf8               LineNumberTable
   #8 = Utf8               SourceFile
   #9 = Utf8               Dummy.java
  #10 = NameAndType        #4:#5          // "<init>":()V
  #11 = Utf8               Dummy
  #12 = Utf8               java/lang/Object
{
  public Dummy();
    descriptor: ()V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 1: 0
}
SourceFile: "Dummy.java"
@ExcaliburZero ExcaliburZero added the enhancement New feature or request label Jan 9, 2021
@ExcaliburZero
Copy link
Owner Author

Relevant code section:

let javap_result = javap(filepath, false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant