Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected class exception #49

Closed
tahiat opened this issue Nov 21, 2023 · 3 comments
Closed

Unexpected class exception #49

tahiat opened this issue Nov 21, 2023 · 3 comments
Assignees

Comments

@tahiat
Copy link
Collaborator

tahiat commented Nov 21, 2023

Reproduction steps: From twofilesimple test input, remove the Baz.java file and modify the Foo.java file as below:

package com.example;
class Foo {
    void bar(Baz b) {
        Baz obj = new Baz("hello");
    }
}

Execute the command: ./gradlew run --args='--outputDirectory "tempDir" --root "src/test/resources/twofilesimple/input/" --targetFile "com/example/Foo.java" --targetMethod "com.example.Foo#bar(Baz)"'

Exception stack trace:

> Task :run FAILED
Exception in thread "main" java.lang.RuntimeException: Unexpected class: Baz
        at org.checkerframework.specimin.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:567)
        at org.checkerframework.specimin.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:68)
        at com.github.javaparser.ast.body.Parameter.accept(Parameter.java:113)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:1129)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:51)
        at com.github.javaparser.ast.NodeList.accept(NodeList.java:277)
        at com.github.javaparser.ast.visitor.ModifierVisitor.modifyList(ModifierVisitor.java:1168)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:673)
        at org.checkerframework.specimin.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:498)
        at org.checkerframework.specimin.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:68)
        at com.github.javaparser.ast.body.MethodDeclaration.accept(MethodDeclaration.java:98)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:1129)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:51)
        at com.github.javaparser.ast.NodeList.accept(NodeList.java:277)
        at com.github.javaparser.ast.visitor.ModifierVisitor.modifyList(ModifierVisitor.java:1168)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:243)
        at org.checkerframework.specimin.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:277)
        at org.checkerframework.specimin.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:68)
        at com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.accept(ClassOrInterfaceDeclaration.java:92)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:1129)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:51)
        at com.github.javaparser.ast.NodeList.accept(NodeList.java:277)
        at com.github.javaparser.ast.visitor.ModifierVisitor.modifyList(ModifierVisitor.java:1168)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:306)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:51)
        at com.github.javaparser.ast.CompilationUnit.accept(CompilationUnit.java:127)
        at org.checkerframework.specimin.SpeciminRunner.performMinimization(SpeciminRunner.java:121)
        at org.checkerframework.specimin.SpeciminRunner.main(SpeciminRunner.java:61)

FAILURE: Build failed with an exception.
@LoiNguyenCS
Copy link
Collaborator

The issue originates from the visit method for MethodDeclaration.

Currently, this method raises an exception when encountering an unresolved type that lacks an import statement. However, if the unresolved type is expected to be in the same directory as the input class file, importing it is unnecessary.

@tahiat If you want to solve this bug, let me know. Otherwise I will be happy to do it.

@LoiNguyenCS
Copy link
Collaborator

Hello, I can fix this problem.

@tahiat
Copy link
Collaborator Author

tahiat commented Nov 29, 2023

Fixed by #57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants