Bug 112602 - ClassCastException with generic wildcard
Summary: ClassCastException with generic wildcard
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M4   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-14 04:13 EDT by Chris Burnley CLA
Modified: 2005-10-20 10:31 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 Chris Burnley CLA 2005-10-14 04:13:34 EDT
I'm using AJDT dev build 20051012172335 and am getting the following error :

java.lang.ClassCastException
at org.aspectj.weaver.World.resolveGenericWildcardFor(World.java:369)
at org.aspectj.weaver.World.resolveToReferenceType(World.java:284)
at org.aspectj.weaver.World.resolve(World.java:209)
at org.aspectj.weaver.World.resolve(World.java:131)
at org.aspectj.weaver.World.resolve(World.java:162)
at org.aspectj.weaver.TypeFactory.createParameterizedType(TypeFactory.java:47)
at org.aspectj.weaver.World.resolveToReferenceType(World.java:273)
at org.aspectj.weaver.World.resolve(World.java:209)
at org.aspectj.weaver.World.resolve(World.java:131)
at org.aspectj.weaver.UnresolvedType.resolve(UnresolvedType.java:636)
at org.aspectj.weaver.ResolvedMemberImpl.resolve(ResolvedMemberImpl.java:429)
at
org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.makeResolvedMember(EclipseFactory.java:475)
at
org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.makeResolvedMember(EclipseFactory.java:424)
at
org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder.genBytecodeInfo(AsmHierarchyBuilder.java:525)
at
org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder.visit(AsmHierarchyBuilder.java:400)
at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:185)
at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1183)
at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:339)
at
org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder.internalBuild(AsmHierarchyBuilder.java:142)
at
org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder.buildStructureForCompilationUnit(AsmHierarchyBuilder.java:82)
at
org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.finishedCompilationUnit(EclipseFactory.java:720)
at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterProcessing(AjCompilerAdapter.java:195)
at
org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$4$6b855184(CompilerAdapter.aj:89)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:528)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:329)
at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:759)
at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:249)
at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild(AjBuildManager.java:158)
at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:117)
at
org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191)

ClassCastException thrown: org.aspectj.weaver.MissingResolvedTypeWithKnownSignature


the following is my test classes : 

public interface GenericInterface<O> {

    public O doSomething(Class<? extends O> type);
	
}

the implementation of the above interface : 


import java.util.Collection;

public class Implementation implements GenericInterface<Collection<?>>{

	public Collection<?> doSomething(Class<? extends Collection<?>> type) {
		return null;
	}

}

granted, the Class<? extends O> in the interface is probably unnecessary for
this example, but still this *is* valid Java and the same problem probably
surfaces in similar valid circumstances.
Comment 1 Andrew Clement CLA 2005-10-17 06:44:17 EDT
The problem here is that in the expression 'Class<? extends Collection<?>>' the
upperbound of the wildcard ? is being incorrectly set to a simple type with
signature 'Collection<?>' which of course does not exist - it should be getting
set to a parameterized type with basetype 'Collection' and typeparameter '?'.

I've fixed this in CVS - waiting on build before closing.
Comment 2 Andrew Clement CLA 2005-10-20 10:31:05 EDT
Fix available in AspectJ - will appear in next AJDT.