我试图找出我的类文件的 jdk 供应商,但没能找到。
任何人都可以帮助我找出是否可以找到编译的 java 文件的 jdk 供应商。如果是,那么如何?
请参阅http://en.wikipedia.org/wiki/Java_class_file。类文件头中没有该信息的位置,仅适用于 Cafe Babe 和类格式版本。
Java 类文件结构有 10 个基本部分:
Magic Number: 0xCAFEBABE
Version of Class File Format: the minor and major versions of the class file
Constant Pool: Pool of constants for the class
Access Flags: for example whether the class is abstract, static, etc.
This Class: The name of the current class
Super Class: The name of the super class
Interfaces: Any interfaces in the class
Fields: Any fields in the class
Methods: Any methods in the class
Attributes: Any attributes of the class (for example the name of the sourcefile, etc.)
在 java 类文件结构中的任何地方都没有提到 jdk 供应商。您可以阅读Inside the Java Virtual Machine
第 6 章The Java Class File
,我相信您将无法找到有关 JDK Vendor 的任何信息。
不,这在现实中是不可能的。
attributes
理论上,Java 编译器可以在表中包含一个非标准属性来保存编译器供应商名称。(JVM 特别允许使用非标准属性,并且要求 JVM 忽略任何它不理解的属性。)但是,我知道没有编译器可以做到这一点。