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

specimin faces MethodAmbiguityException when running on issue jdk-8269121 #77

Open
tahiat opened this issue Dec 12, 2023 · 4 comments
Open

Comments

@tahiat
Copy link
Collaborator

tahiat commented Dec 12, 2023

Command:
./gradlew run --args='--outputDirectory "../ISSUES/jdk-8269121/output/" --root "../ISSUES/jdk-8269121/input/TypeInferenceBugOfMethodReferences/src/main/java/" --targetFile "net/mirwaldt/bug/Main.java" --targetFile "net/mirwaldt/bug/Interpreter.java" --targetFile "net/mirwaldt/bug/MyFact.java" --targetFile "net/mirwaldt/bug/DummyInterpreter.java" --targetMethod "net.mirwaldt.bug.Main#main(String[])"'

Exception:

> Configure project :
No explicit dependency on the Checker Framework found, using default version 3.39.0

> Task :run FAILED
Exception in thread "main" com.github.javaparser.resolution.MethodAmbiguityException: Ambiguous method call: cannot find a most applicable method: JavaParserMethodDeclaration{wrappedNode=<Var1Type extends Variable, Var2Type extends Variable> Object query(TwoVariablesQuery<Var1Type, Var2Type> query);, typeSolver=com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver@6c40365c}, JavaParserMethodDeclaration{wrappedNode=<VarType extends Variable> Object query(OneVariableQuery<VarType> query);, typeSolver=com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver@6c40365c}
        at com.github.javaparser.symbolsolver.resolution.MethodResolutionLogic.findMostApplicable(MethodResolutionLogic.java:599)
        at com.github.javaparser.symbolsolver.resolution.MethodResolutionLogic.findMostApplicable(MethodResolutionLogic.java:503)
        at com.github.javaparser.symbolsolver.javaparsermodel.contexts.JavaParserTypeDeclarationAdapter.solveMethod(JavaParserTypeDeclarationAdapter.java:233)
        at com.github.javaparser.symbolsolver.javaparsermodel.contexts.ClassOrInterfaceDeclarationContext.solveMethod(ClassOrInterfaceDeclarationContext.java:111)
        at com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserInterfaceDeclaration.solveMethod(JavaParserInterfaceDeclaration.java:296)
        at com.github.javaparser.symbolsolver.resolution.MethodResolutionLogic.solveMethodInType(MethodResolutionLogic.java:820)
        at com.github.javaparser.symbolsolver.javaparsermodel.contexts.MethodCallExprContext.solveMethod(MethodCallExprContext.java:177)
        at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.solve(JavaParserFacade.java:324)
        at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.solve(JavaParserFacade.java:186)
        at com.github.javaparser.symbolsolver.JavaSymbolSolver.resolveDeclaration(JavaSymbolSolver.java:161)
        at com.github.javaparser.ast.expr.MethodCallExpr.resolve(MethodCallExpr.java:315)
        at org.checkerframework.specimin.TargetMethodFinderVisitor.visit(TargetMethodFinderVisitor.java:266)
        at org.checkerframework.specimin.TargetMethodFinderVisitor.visit(TargetMethodFinderVisitor.java:40)
        at com.github.javaparser.ast.expr.MethodCallExpr.accept(MethodCallExpr.java:116)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:477)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:51)
        at com.github.javaparser.ast.stmt.ExpressionStmt.accept(ExpressionStmt.java:71)
        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:169)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:51)
        at com.github.javaparser.ast.stmt.BlockStmt.accept(BlockStmt.java:70)
        at com.github.javaparser.ast.visitor.ModifierVisitor.lambda$visit$60(ModifierVisitor.java:670)
        at java.base/java.util.Optional.map(Optional.java:260)
        at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:670)
        at org.checkerframework.specimin.TargetMethodFinderVisitor.visit(TargetMethodFinderVisitor.java:218)
        at org.checkerframework.specimin.TargetMethodFinderVisitor.visit(TargetMethodFinderVisitor.java:40)
        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.TargetMethodFinderVisitor.visit(TargetMethodFinderVisitor.java:154)
        at org.checkerframework.specimin.TargetMethodFinderVisitor.visit(TargetMethodFinderVisitor.java:40)
        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:153)
        at org.checkerframework.specimin.SpeciminRunner.main(SpeciminRunner.java:64)

FAILURE: Build failed with an exception.

Project [drive link](https://drive.google.com/file/d/1YC8RofTmDXWGmWOB9Y1zKWtTH72GNck3/view?usp=sharing) or [github](https://github.com/mmirwaldt/TypeInferenceBugOfMethodReferences/)

@LoiNguyenCS
Copy link
Collaborator

LoiNguyenCS commented Dec 24, 2023

Hi, I could not reproduce the bug. Here is the exception message I got with the your command:

    Exception in thread "main" com.github.javaparser.ParseProblemException: (line 3,col 1) Record Declarations are not supported.

    at com.github.javaparser.StaticJavaParser.handleResult(StaticJavaParser.java:270)
    at com.github.javaparser.StaticJavaParser.parse(StaticJavaParser.java:167)
    at org.checkerframework.specimin.SpeciminRunner.parseJavaFile(SpeciminRunner.java:303)
    at org.checkerframework.specimin.SpeciminRunner.performMinimization(SpeciminRunner.java:105)
    at org.checkerframework.specimin.SpeciminRunner.main(SpeciminRunner.java:64)

@jonathan-m-phillips
Copy link
Collaborator

Hi, I could not reproduce the bug. Here is the exception message I got with the your command:

    Exception in thread "main" com.github.javaparser.ParseProblemException: (line 3,col 1) Record Declarations are not supported.

    at com.github.javaparser.StaticJavaParser.handleResult(StaticJavaParser.java:270)
    at com.github.javaparser.StaticJavaParser.parse(StaticJavaParser.java:167)
    at org.checkerframework.specimin.SpeciminRunner.parseJavaFile(SpeciminRunner.java:303)
    at org.checkerframework.specimin.SpeciminRunner.performMinimization(SpeciminRunner.java:105)
    at org.checkerframework.specimin.SpeciminRunner.main(SpeciminRunner.java:64)

Unrelated to this issue, I received the same exception earlier when running ASHE against itself.

Is this due to

  1. Specimin depending on a version of Java Parser that does not support Records?
  2. Java Parser in general doesn’t support Java Records?
  3. Something else?

Please let me know if you find the answer. Thanks!

@LoiNguyenCS
Copy link
Collaborator

Hi,

I could not find any online information regarding this behavior of JavaParser. When I tried a newer version of JavaParser, Specimin could not be compiled.

Maybe @tahiat could help since he did not seem to experience this behavior of JavaParser.

@kelloggm
Copy link
Collaborator

kelloggm commented Jan 3, 2024

Java Parser in general doesn’t support Java Records?

@jonathan-m-phillips is correct: JavaParser does not support records: javaparser/javaparser#3556

I don't think there's much that we can do about this, unfortunately. If we can do so easily, it would be great to catch the exception and throw one of our own that tells the user:

  1. that we don't support records
  2. which file Specimin encountered that does contain a record
  3. gives a brief instruction on what to do ("exclude that file from Specimin's input" would be fine)

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

4 participants