Project: AspectJ
Bug 32463 ajc reports error when encountering static declaration of nested classes
Reported: 2003-02-21 05:59:47 | Status: resolved fixed

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 ------

Files changed in fix:
tests/bugs/WeaveLocal.java weaver/src/org/aspectj/weaver/NameMangler.java weaver/src/org/aspectj/weaver/ResolvedTypeX.java weaver/src/org/aspectj/weaver/TypeX.java weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java