Bug 88153 - Internal compiler error after setting Java compiler property "Unnecessary cast or 'instanceof' operation" to warning
Summary: Internal compiler error after setting Java compiler property "Unnecessary cas...
Status: RESOLVED WORKSFORME
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M1   Edit
Hardware: PC Windows 2000
: P3 major (vote)
Target Milestone: 1.5.0 M3   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-16 05:27 EST by Philippe Sidler CLA
Modified: 2005-08-24 12:25 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Sidler CLA 2005-03-16 05:27:03 EST
My project compiles successfully when the Java compiler property "Unnecessary
cast or 'instanceof' operation" is set to ignore.


After setting this property to warning, Eclipse displays an "AspectJ Error"
message box with the message:

ClassCastException thrown:
org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression$1
Reason:
ClassCastException thrown:
org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression$1


Then in the Problems view, I can see the following error:

Internal compiler error
java.lang.ClassCastException:
org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression$1
	at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding.getVisibleBinding(MethodBinding.java:141)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope.getConstructor(Scope.java:1101)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression.checkAlternateBinding(CastExpression.java:399)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression.checkNeedForArgumentCasts(CastExpression.java:317)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType(AllocationExpression.java:274)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:189)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:385)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:137)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:363)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:933)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:982)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:273)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:544)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:365)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:682)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:168)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:102)
	at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:122)
	at
org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:165)


I removed code from the class where the internal compiler error occurred while I
still got the error.
The remaining code looked like:

public class MyClass
{
    private GenericPosition position;
    private Object object;

    private void myMethod()
    {
        InstalledObject io = new InstalledObject((SpecificPosition) position,
object);
    }
}

Where:
 - SpecificPosition is a class that implements the interface GenericPosition.
 - The constructor of InstalledObject takes a SpecificPosition as the first
parameter.

I tried to reproduce this issue in a new small project (my project contains more
than 800 classes) without success.
Comment 1 Matt Chapman CLA 2005-03-23 08:36:37 EST
Passing over to compiler
Comment 2 Andrew Clement CLA 2005-05-12 06:45:49 EDT
I modified our test system to force -warn:uselessTypeCheck on - it ran all 1700
tests without showing a problem.  Now I *am* running on a more recent JDT
compiler than the one used when this bug was reported - it could have been fixed
since this report was filed.  Is it possible to retry this on a more recent AJDT
dev build (since that will include the new compiler) ?
Comment 3 Adrian Colyer CLA 2005-08-24 12:25:16 EDT
we haven't been able to reproduce this with the latest builds, and we haven't
seen it in the wild since May, so closing out this report. Please reopen if you
see this behaviour again in the future with the latest builds.