![javap示例](https://i-blog.csdnimg.cn/blog_migrate/18b6e337790c60501a352fa394778636.png)
在Java中,我们可以使用javap -verbose className
打印出类信息。
Terminal
D:\projects>javap -verbose Test
Classfile /D:/projects/Test.class
Last modified 16 Apr 2019; size 413 bytes
MD5 checksum 8679313dc0728e291898ad34656241cb
Compiled from "Test.java"
public class Test
minor version: 0
major version: 56
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #5 // Test
super_class: #6 // java/lang/Object
interfaces: 0, fields: 0, methods: 2, attributes: 1
//...
查找主要版本并匹配下表:
Java SE 13 = 57 (0x39 hex)
Java SE 12 = 56 (0x38 hex)
Java SE 11 = 55 (0x37 hex)
Java SE 10 = 54 (0x36 hex)
Java SE 9 = 53 (0x35 hex)
Java SE 8 = 52 (0x34 hex)
Java SE 7 = 51 (0x33 hex)
Java SE 6.0 = 50 (0x32 hex)
Java SE 5.0 = 49 (0x31 hex)
JDK 1.4 = 48 (0x30 hex)
JDK 1.3 = 47 (0x2F hex)
JDK 1.2 = 46 (0x2E hex)
JDK 1.1 = 45 (0x2D hex)
资料来源: 维基百科
对于major version: 56
,此Java类是使用Java SE 12
编译的
参考文献
翻译自: https://mkyong.com/java/how-to-check-which-jdk-version-compiled-the-class/