Skip to content

bug: Qualified generic classes with incomplete classpath crash spoon #4077

Description

@I-Al-Istannen

Description

Explicitly qualified references for types Spoon doesn't know crashes it. If the reference uses an import, all is fine though.

Crashing example

import foo.A;
import foo.B;

class Test {
    public static void main(String args[]) {
        java.util.AbstractMap.SimpleEntry<A, B> entry = new java.util.AbstractMap.SimpleEntry<>(A.a, B.b);
    }
}

Working example

import foo.A;
import foo.B;
import java.util.AbstractMap.SimpleEntry;

class Test {
    public static void main(String args[]) {
        SimpleEntry<A, B> entry = new SimpleEntry<>(A.a, B.b);
    }
}

Stacktrace

==== Building spoon model ====
Starting phase COMPILE
Phase COMPILE done! Discovered Classes: 1
Starting phase COMMENT
Phase COMMENT done! Discovered Classes: 1
Starting phase MODEL
Exception in thread "main" spoon.SpoonException: Unexpected QualifiedNameReference tokens java.util.AbstractMap.SimpleEntry<> for typeRef: java.util.AbstractMap.SimpleEntry
	at spoon.support.compiler.jdt.JDTTreeBuilderHelper.handleImplicit(JDTTreeBuilderHelper.java:557)
	at spoon.support.compiler.jdt.JDTTreeBuilderHelper.handleImplicit(JDTTreeBuilderHelper.java:488)
	at spoon.support.compiler.jdt.ReferenceBuilder.getTypeReference(ReferenceBuilder.java:518)
	at spoon.support.compiler.jdt.ReferenceBuilder.getExecutableReference(ReferenceBuilder.java:451)
	at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:874)
	at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.traverse(AllocationExpression.java:716)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.traverse(LocalDeclaration.java:484)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:411)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1708)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:827)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:788)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.traverseUnitDeclaration(JDTBasedSpoonCompiler.java:480)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.lambda$buildModel$0(JDTBasedSpoonCompiler.java:437)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.forEachCompilationUnit(JDTBasedSpoonCompiler.java:464)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildModel(JDTBasedSpoonCompiler.java:435)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnitsAndModel(JDTBasedSpoonCompiler.java:372)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildSources(JDTBasedSpoonCompiler.java:335)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:116)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:99)
	at spoon.Launcher.buildModel(Launcher.java:772)
	at de.ialistannen.javadocapi.indexing.Indexer.main(Indexer.java:62)

Process finished with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions