Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.9.3
-
Component/s: Infrastructure: Build, Runtime: Class Library
-
Labels:None
-
Number of attachments :
Description
Some annotations that could give us performance advantages need to be placed on library code. Rather than add the library code to our code base then annotate it, it seems more desirable to have an annotation phase that transforms .class files to annotated .class files.
For example, java.lang.String.value, a package protected character array, will never vary during runtime. If it work marked as immutable then any loads from it could be simplified away. So "Morrissey".charAt(0) could be simplified to 'M' at compile time.
There are various tools for .class to .class transformations. The most famous being BCEL [1], which doesn't have annotation support but can be made to [2]. Performing annotations using a Java tool also gives the possibility to use that tool as a java agent to annotated code dynamically.
An alternate approach is to perform annotations in the class loader.
[1] http://jakarta.apache.org/bcel/news.html
[2] http://www.onjava.com/pub/a/onjava/2004/06/30/insidebox1.html?page=last
When compiled enumerations create arrays that can be marked as Immutable.