Questions tagged [javap]

javap - The Java Class File Disassembler

javap - The Java Class File Disassembler:

The javap command disassembles one or more class files. Its output depends on the options used. If no options are used, javap prints out the package, protected, and public fields and methods of the classes passed to it. javap prints its output to stdout.

124 questions
2
votes
1 answer

Stack=4 in Java bytecode. How does the Java Compiler compute the 4 value? (depth of the the stack)

Java Code: public class SimpleRecursion { public int factorial(int n) { if (n == 0) { return 1; } return n * factorial(n - 1); } } Gives the following bytecode for the factorial method (I executed javap…
Youness
  • 57
  • 8
2
votes
1 answer

Why bytecode sequence number are not continuous

static void heapVar(); Code: 0: iconst_3 1: newarray int 3: dup 4: iconst_0 5: bipush 100 7: iastore 8: dup 9: iconst_1 10: sipush 200 13: iastore 14: dup 15: iconst_2 16: sipush 300 …
cox
  • 466
  • 4
  • 8
2
votes
3 answers

java command on DOS

with javap java.lang.Object we are able to see the methods signature under it, where as with javap javax.servlet.ServletConfig we are not able to see it. Could any one please suggest any command for checking the method signatures for…
dfsdf
  • 21
  • 1
2
votes
3 answers

Java class has 2 methods with the same function signature but different return types

AFAIK it's not possible to have a method with the same call signature. However: $ javap -public java.time.LocalTime | grep "minus" | grep "Temporal" | grep -v "long" public java.time.LocalTime minus(java.time.temporal.TemporalAmount); …
2
votes
0 answers

Can I stabilize the output order of functions written by the compiler to bytecode .class files?

If I execute javap on my main application class across compiles (no source change), sometimes the order of functions differs. This is especially true if the build was executed in different environments. Consider this output from two builds. Build…
Chris Betti
  • 2,721
  • 2
  • 27
  • 36
2
votes
1 answer

Why the call to the parent constructor is not the first call in the compiler generated constructor for Inner class?

Consider the following Test class to demonstrate the inner class behavior in Java. The main code is in the run method. Rest is just plumbing code. public class Test { private static Test instance = null; private Test() { …
Geek
  • 26,489
  • 43
  • 149
  • 227
2
votes
1 answer

Unable to use scala's repl :javap to look at trait companion object

I am using the :javap command in the scala repl and was trying to look at the traits companion object, but I couldn't seem to find out how. Here is what I do from command line. $ cat > Foo.scala <
ekaqu
  • 2,038
  • 3
  • 24
  • 38
2
votes
2 answers

Does javac also inline?

I was playing around with javap and some very simple code and that raised a - hopefully simple - question. here is the code first: public class Main { public static void main(String[] args) throws Exception { System.out.println(m1()); …
daschl
  • 1,124
  • 6
  • 11
2
votes
4 answers

Displaying generic type parameters from compiled class files

Is there a tool similar to javap that could display methods and fields with their original (non-erased) types? I know that the type information is erased when source code is compiled. However, the compiler must know somehow, because it is able to…
Petr
  • 62,528
  • 13
  • 153
  • 317
2
votes
2 answers

What javap -c does to a classfile?

Actually, the question is a bit broader. I know that javac compiles java file into a bytecode, a class file. So, class file should contain jvm instructions and all that. On the other hand, the only way to see those instructions is to decompile class…
dhblah
  • 9,751
  • 12
  • 56
  • 92
1
vote
0 answers

How to syntax highlight a hex dump of JVM classfile?

I'm studying binary file structure of JVM classfile. My current toolbox consists of $ xxd and $ javap -v . Sample outputs of these two tools are as follows: $ xxd com/example/mycode/MyTest.class 00000000: cafe babe 0000 003d…
1
vote
2 answers

java internal method signature doesn't match constructor parameters (javap)

I have the following class containing local inner class: class Outer { private boolean beep; private int foo; public Outer(boolean beep) { this.beep = beep; } public void start(boolean beep) { class LocalInner…
joker
  • 3,416
  • 2
  • 34
  • 37
1
vote
1 answer

How to load a class from module(.jmod) file at runtime?

I want to load classes from a module (.jmod) file at runtime into the application memory. I know that we can easily load classes from a (.jar) file using :-) ClassLoader loader = URLClassLoader.newInstance(new URL[]{ jarFile.toURL() …
Omega UI
  • 11
  • 3
1
vote
0 answers

Implementing an interface in Java - Why does javap output two methods with the same signature but different return type?

Given this Java code: interface I { Object getId(); } class A implements I { public Long getId() { return null; } } javac I.java A.java It compiles successfully. When disassembled the class files produces the following output: javap…
1
vote
1 answer

duplicate method in javap result

There is a method in BaseController, e.g. public abstract class BaseManagementController { @PostMapping @ResponseStatus(HttpStatus.CREATED) protected void add(@Valid @RequestBody F form, HttpServletRequest…
zhuguowei
  • 8,401
  • 16
  • 70
  • 106
1 2 3
8 9