Community
Participate
Working Groups
I get the error dialog, that says "AspectJ Internal Compiler Error", with the Details panel as below. The problem occurs when AspectJ Project contains following two Java files. Foo.java: ---- package a; public class Foo { private static void foo(Object a) { } public static void foo(int[] a) { } } Main.java ---- package a; public class Main { public static void main(String[] args) { Object a = null; Foo.foo((int[])a); } } Eclipse Version: 3.2.2 AJDT: Version: 1.4.2.200703020612 AspectJ version: 1.5.4.200701151324 java.lang.ClassCastException at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding.getVisibleBinding(MethodBinding.java:213) at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod(Scope.java:2178) at org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression.checkAlternateBinding(CastExpression.java:238) at org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression.checkNeedForArgumentCasts(CastEx ... thrown: org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression$1 cannot be cast to org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode
I am also getting the same ClassCastException at MethodBinding.java:213. I am running Eclipse 3.3.0 Build I20070625-1500 under Mac OS X 10.4.10 Build 8R218. === How to Reproduce === 1. Download and install the MaintainJ plugin from http://www.maintainj.com/ 2. Check out version R3_3 of the 'org.eclipse.jdt.ui' plugin from 'dev.eclipse.org' (and any other plugins in the JDT UI component that it depends on). 3. Click File > New > Other... 4. In the dialog select MaintainJ > MaintainJ Instrumentation Project and click OK. 5. Click Eclipse Plug-In and click Next. 6. Click 'org.eclipse.jdt.ui' and click Next. 7. Click 'org' and click Finish. 8. Wait while the workspace rebuilds itself. 9. Eventually an 'AspectJ Internal Compiler Error' dialog will appear. The stack trace that is listed in this dialog is: java.lang.ClassCastException at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding.getVisibleBinding(MethodBinding.java:213) at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope.getConstructor(Scope.java:1658) at org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression.checkAlternateBinding(CastExpression.java:234) at org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression.checkNeedForArgumentCasts(C ... internal.jobs.Worker.run(Worker.java:55) Compile error: ClassCastException thrown: org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression$1
The NPE occurs if you have the compiler option switched on to display unnecessary casts. So I could recreate it with the simple code below on the command line with: ajc -warn:+uselessTypeCheck Foo.java Main.java The problem was the code to search for privileged access to a method assumed a particular object was always an ASTNode but in the case of a parameter with a cast like this, it was not an ASTNode. I changed the compiler to allow for this case and that fixes the NPE. have committed test and fix.