User Tools

Site Tools


java:javap

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
java:javap [2023/04/12 15:15] odeftajava:javap [2023/07/04 19:36] (current) – external edit 127.0.0.1
Line 45: Line 45:
 } }
 </code> </code>
- +<note tip>We want to check if all the generic types are erased after the compilation.</note>
-We want to check if all the generic types are erased after the compilation.\\ +
 <note important>Be sure that the javap tool is added to the PATH environment variable before using it. <note important>Be sure that the javap tool is added to the PATH environment variable before using it.
 It is located in the JAVA_HOME\bin folder. It is located in the JAVA_HOME\bin folder.
Line 55: Line 54:
 C:\JavaProject\src\main\java> javap -cp ../../../target/classes -c ro.medjava.generics.Erasure C:\JavaProject\src\main\java> javap -cp ../../../target/classes -c ro.medjava.generics.Erasure
 </code> </code>
 +
 +<note tip>-c parameter is used to display the disassembled code.</note>
  
 Result: Result:
Line 87: Line 88:
       22: return       22: return
 </code> </code>
- 
-<note tip>-c parameter is used to display the disassembled code.</note> 
  
 As we can see in the parameter list of doStuff1 and doStuff2 methods, the generic types survived after compilation.\\  As we can see in the parameter list of doStuff1 and doStuff2 methods, the generic types survived after compilation.\\ 
 Some consistency checking information still remains in the binary.\\  Some consistency checking information still remains in the binary.\\ 
 But in the main method, the array list passed to the doStuff2 method does not contain any generic type after compilation. But in the main method, the array list passed to the doStuff2 method does not contain any generic type after compilation.
 +
 +===== Use javap in Intellij IDEA =====
 +
 +Install the plugin "Class Decompile." (File / Settings / Plugins)
 +
 +{{:java:pasted:20230412-152124.png}}
 +
 +{{:java:pasted:20230412-152141.png}}
 +
 +Next, right click on your class and select "Show Decompile Code" option.
 +Result:
 +
 +{{:java:javap_erasure.png?nolink&1536×648}}
 +
 +
 +
 +
 +
 +
java/javap.1681301749.txt.gz · Last modified: 2023/07/04 19:36 (external edit)