JDK-6214503 : Annotate .class files with the version of javac that produced it
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Rejected
  • OS: generic
  • CPU: generic
  • Submitted: 2005-01-06
  • Updated: 2025-05-05
  • Resolved: 2025-05-05
Related Reports
Relates :  
Description
http://forums.java.net/jive/thread.jspa?threadID=63#8886 suggests that the javac compiler annotate generated .class files with a tag that lets subsequent tools determine which javac compiler produced the .class file.  The particular request is to know if one is mixing compilers, but a lunch table discussion came up with several other reasons why one might want to know which compiler was used: e.g., experimental versions of the compiler, upon discovering bugs in previous versions of the compiler, etc.

The tag doesn't have to be non-spoofable: it's just a hint for sane development scenarios.

Adding the annotation will increase the size of the .class file.  It might be good to have a way to aggregate the annotations when building a .jar file.
###@###.### 2005-1-06 00:36:07 GMT

Comments
EVALUATION javac now has useful version info, obtained from tools.jar ###@###.### 2005-04-18 17:55:37 GMT
18-04-2005

WORK AROUND One relatively easy workaround, which is used by javac itself, is to put your own annotation on class files for which you want this to apply. Create and use an annotation with a classfile retention policy (so it doesn't take up space at run time) and have the value of theannotation be generated from SCCS tags, or similar. E.g. @Version("%W% %E%") class MyClass .... ###@###.### 2005-03-25 21:22:26 GMT
25-03-2005