JDK-6852371 : different behavior to get static inf. of internal class between jdk5 and 6
  • Type: Bug
  • Component: tools
  • Sub-Component: apt
  • Affected Version: 5.0u18
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2009-06-18
  • Updated: 2010-08-26
  • Resolved: 2010-08-26
Related Reports
Relates :  
Description
When a customer uses apt command in jdk5 and sets a java source file which includes internal class to the argument, annotationProcessor returns the information of "static" of the internal class.

Example)
public class TempImpl2 {

    @CosmiService
    public static class TempImpl2Internal {
        public int addNumbers(int number1) {
            return number1++;
        }
    }
}

In the above program, annotation processor returns the informtion of TempImpl2Internal class.

On the other hand, when the user compiles the same .java source program and sets the compiled class file name with -XclaassesAsDecls option, annotation processor does not return the information.

This problem occurs in jdk5ux, but not in jdk6ux.

TEST PROGRAM:
"apt-test-env.zip" is attached. There are 2 directories, test1_java and test2_class under apt_test dir. test1_java is the environment which specifies java source file to apt command. test2_class is the environment which specifies compiled class file name to apt command.

REPRODUCTION:
The following shows how to reproduce in Windows.
The target files which should be editted are "*.bat" files.
If in Solaris or linux, please edit "*.csh" files.

1. test1_java
(1) set jdk5 path name to the environment variable JDK_PATH 
(2) execute make_ap.bat
    This will compile CosmiService.java and ListClassApf.java
(3) execute go_apt.bat
    This will execute apt command for TempImple2.java and print the information of TempImple2 class.

2. test2_class
(1) set jdk5 path name to the environment variable JDK_PATH 
(2) execute make_ap.bat
    This will compile CosmiService.java and ListClassApf.java
(3) execute compile.bat
    This will compile TempImple2.java
(4) execute go_apt_class.bat
    This will execute apt command for TempImple2$TempImpl2Internal.class and print the information of TempImple2$TempImple2Internal class.

RESULT :
test1_java environment outputs the information to "result.txt" file as follwos.

com.example.impl.TempImpl2
##### Modifier.PUBLIC  YES #####
##### Modifier.FINAL  NO #####
##### Modifier.ABSTRACT  NO #####
##### Modifier.STATIC  NO #####
com.example.impl.TempImpl2.TempImpl2Internal
##### Modifier.PUBLIC  YES #####
##### Modifier.FINAL  NO #####
##### Modifier.ABSTRACT  NO #####
##### Modifier.STATIC  YES #####    <=== This shows the "static" inf. of TempImpl2Internal

As to test2_class, the following will be output.

com.example.impl.TempImpl2.TempImpl2Internal
##### Modifier.PUBLIC  YES #####
##### Modifier.FINAL  NO #####
##### Modifier.ABSTRACT  NO #####
##### Modifier.STATIC  NO #####  <=== This shows the "static" inf. of TempImpl2Internal can not be gotten.

NOTE:
 JDK6u13 can get the TempImpl2.TempImpl2Internal information both in test1_java and test2_class.

Comments
EVALUATION Annotation processing should transition from the JDK 5-era apt to the standardized JSR 269 annotation processing supported in javac as of JDK 6. Closing this apt-specific problem as will-not-fix.
26-08-2010