Skip to main content

Java Annotations, .class file size and performance

3 replies [Last post]
vishworks
Offline
Joined: 2008-03-03
Points: 0

I had a basic question on Java Annotations (primarily related to performance and .class file memory foot print)-

How can I configure annotations to be available/unavailable in the final .class file?
From a memory foot-print perspective, a .class file with annotations is obviously larger than a .class file without annotations; but is there a very simple/standard way of enabling/disabling annotations when I create a production ready deployment (e.g. what is a best way to disable JUnit annotations on all classes with embedded annotations based JUnit test cases such as @Test, @Before etc.?)

Thanks in advance.
Vishy

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
peter__lawrey
Offline
Joined: 2005-11-01
Points: 0

How many KB are you looking to save?
How much difference would a KB make i.e. how much of your time is it worth?

singaram123
Offline
Joined: 2009-05-12
Points: 0

In javac, annotation processing is enabled by default. We can use the -proc option to disable the annotation processing or run the annotation processing without compiling.

vishworks
Offline
Joined: 2008-03-03
Points: 0

Thanks Singaram; but unfortunately the proc:none|only is available as a compiler option only with JDK 6. I'm looking for any viable options available in JDK 1.5