Bug 37304

Summary: public static fields being ignored
Product: [Tools] AspectJ Reporter: kuchhal
Component: CompilerAssignee: Jim Hugunin <jim-aj>
Status: CLOSED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: rajeshh_98
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
the test file none

Description kuchhal CLA 2003-05-06 18:22:48 EDT
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.
Comment 1 kuchhal CLA 2003-05-06 18:23:32 EDT
Created attachment 4808 [details]
the test file
Comment 2 Jim Hugunin CLA 2003-05-06 18:32:27 EDT
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.
Comment 3 Jim Hugunin CLA 2003-05-07 00:48:48 EDT
*** Bug 37311 has been marked as a duplicate of this bug. ***
Comment 4 kuchhal CLA 2003-05-07 12:28:59 EDT
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.
Comment 5 Jim Hugunin CLA 2003-05-19 16:44:43 EDT
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.
Comment 6 kuchhal CLA 2003-05-21 17:23:37 EDT
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.