Bug 32463 - ajc reports error when encountering static declaration of nested classes
Summary: ajc reports error when encountering static declaration of nested classes
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-21 05:59 EST by Per S Hustad CLA
Modified: 2003-03-05 19:18 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Per S Hustad CLA 2003-02-21 05:59:47 EST
Version: AspectJ Compiler 1.1beta4

The ajc compiler issues a spurious error message and exits with a negative 
error code when weaving code containing static declaration of a nested class. 
The compiler seem to write the classfiles correctly but the negative exit 
status causes problems when e.g. using the AjcCompilerAdapter in ant.

To reproduce:
1) Extract the following two files into an empty directory:
// File: A.aj:
aspect A  {

    pointcut withinTest(): within(Test);
    pointcut callToHandleOrder() : (withinTest() &&
                             call(* handleOrder(..)));

    Object around(): callToHandleOrder() {

      return "DUMMY inserted by ASPECT" ;
   }
}
// End of File A.aj

// File : Test.java
public class Test
{
    // Commenting out the static declaration makes everything work OK
    static
    {
        class StaticNestedClass
        {
        }
    }
    
    public static void main(String[] args)
    {
      System.out.println(new Test().handleOrder("test"));
    }

    private String handleOrder(String t)
    {
      return t;
    }

}
// End of Test.java

2) Compile the files 
   ajc -sourceroots . -verbose

Output:
-----
compiling c:/aspectj1.1/doc/examples/bug/./A.aj
compiling c:/aspectj1.1/doc/examples/bug/./Test.java
weaving
might need to weave [UnwovenClassFile(null, Test$1$StaticNestedClass), 
UnwovenClassFile(null, A), UnwovenClassFile(null, Test)](world=true)
wrote class file: c:\aspectj1.1\doc\examples\bug\A.class
can't find type Test$1
wrote class file: c:\aspectj1.1\doc\examples\bug\Test$1$StaticNestedClass.class
wrote class file: c:\aspectj1.1\doc\examples\bug\Test.class

1 error
------
Comment 1 Jim Hugunin CLA 2003-03-05 19:18:35 EST
fixed in current tree, test in bugs/WeaveLocal.java

This bug had been reported before on the mailing list, but by including
a small self-contained test case, this report made the bug easy to reproduce
and hence easy to fix.  Thanks.