Community
Participate
Working Groups
The ajc compiler it seems is removing the final keyword when it generates the class files. This causes the serial version of the class to be different when compiled using aspectj vs javac. For example the attached class produces different output for javac vs ajc.
Created attachment 4808 [details] the test file
This appears to be a bug report relative to the 1.0.6 compiler. We are no longer maintaining that branch but have moved on the the 1.1 branch. This bug is not present in that branch. You should try out the 1.1rc1 (or in the next few days 1.1rc2) to see if that solves your problems.
*** Bug 37311 has been marked as a duplicate of this bug. ***
I tried the aspect rc1.1 and still found the same problem. I am running ajc compiler on this class: import java.io.Serializable; public class Text implements Serializable { public static final Integer SUCCESS = new Integer(0); public static void main(String[] args) { System.out.println("Hello String!"); } } and the ajc compiler gets rid of the final keyword in the generated class file. And I have tried the lates version. it happens there also.
I still can't reproduce this bug with 1.1rc1 or 1.1rc2. Here's my test program: import java.io.Serializable; import java.lang.reflect.*; public class FinalFields implements Serializable { public static final Integer SUCCESS = new Integer(0); public static void main(String[] args) throws Exception { Class c = FinalFields.class; Field f = c.getDeclaredField("SUCCESS"); int mods = f.getModifiers(); System.out.println("modifers are: " + Modifier.toString(mods)); if (!Modifier.isFinal(mods)) throw new RuntimeException ("modifier should be final"); if (!Modifier.isPublic(mods)) throw new RuntimeException ("modifier should be public"); if (!Modifier.isStatic(mods)) throw new RuntimeException ("modifier should be static"); } } Please look closely at your classpath and other configuration issues to make sure you're seeing this as a bug in 1.1rc2. If so, please include detailed step-by-step instructions for reproducing this bug.
This issue has indeed been fixed in version 1.1. When I did the test earlier I used the ajc.exe and aspectjrt.jar from 1.1 but my ASPECTJ_HOME was still set to version 1.0.6. Somehow that env variable was still being used. Thats why I was seeing the problem.