java:javap
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
java:javap [2023/04/12 15:04] – odefta | java:javap [2023/07/04 19:36] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 45: | Line 45: | ||
} | } | ||
</ | </ | ||
- | + | <note tip>We want to check if all the generic types are erased after the compilation.</ | |
- | We want to check if all the generic types are erased after the compilation.\\ | + | |
<note important> | <note important> | ||
It is located in the JAVA_HOME\bin folder. | It is located in the JAVA_HOME\bin folder. | ||
Line 55: | Line 54: | ||
C: | C: | ||
</ | </ | ||
+ | |||
+ | <note tip>-c parameter is used to display the disassembled code.</ | ||
Result: | Result: | ||
< | < | ||
public ro.medjava.generics.Erasure(); | public ro.medjava.generics.Erasure(); | ||
- | | + | |
0: aload_0 | 0: aload_0 | ||
- | 1: invokespecial #1 // Method java/ | + | 1: invokespecial #1 // Method java/ |
4: return | 4: return | ||
Line 74: | Line 75: | ||
public static void main(java.lang.String[]); | public static void main(java.lang.String[]); | ||
Code: | Code: | ||
- | 0: new # | + | 0: new # |
3: dup | 3: dup | ||
4: iconst_1 | 4: iconst_1 | ||
- | 5: anewarray | + | 5: anewarray |
8: dup | 8: dup | ||
9: iconst_0 | 9: iconst_0 | ||
- | 10: ldc # | + | 10: ldc # |
12: aastore | 12: aastore | ||
- | 13: invokestatic | + | 13: invokestatic |
- | 16: invokespecial #6 // Method java/ | + | 16: invokespecial #6 |
- | 19: invokestatic | + | 19: invokestatic |
22: return | 22: return | ||
</ | </ | ||
+ | |||
+ | 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.\\ | ||
+ | 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." | ||
+ | |||
+ | {{: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Next, right click on your class and select "Show Decompile Code" option. | ||
+ | Result: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
java/javap.1681301086.txt.gz · Last modified: 2023/07/04 19:36 (external edit)