You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the following program (based on #40, but in a form suitable for a specimin test case):
import java.util.List;
import java.util.ArrayList;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.ImportDeclaration;
public class Issue40 {
List<String> importStatement;
void setclassAndPackageMap() {
}
public void setImportStatement(NodeList<ImportDeclaration> listOfImports) {
List<String> currentImportList = new ArrayList<>();
for (ImportDeclaration importStatement : listOfImports) {
String importAsString = importStatement.getNameAsString();
currentImportList.add(importAsString);
}
this.importStatement = currentImportList;
this.setclassAndPackageMap();
}
}
When I add this to Specimin's test suite (see the issue40 branch), it crashes with the following stacktrace:
java.lang.RuntimeException: Unfound parent for this class: Issue40
at org.checkerframework.specimin.UnsolvedSymbolVisitor.getParentClass(UnsolvedSymbolVisitor.java:1342)
at org.checkerframework.specimin.UnsolvedSymbolVisitor.updateSyntheticClassForSuperCall(UnsolvedSymbolVisitor.java:846)
at org.checkerframework.specimin.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:441)
at org.checkerframework.specimin.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:68)
at com.github.javaparser.ast.expr.NameExpr.accept(NameExpr.java:79)
at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:519)
at com.github.javaparser.ast.visitor.ModifierVisitor.visit(ModifierVisitor.java:51)
at com.github.javaparser.ast.stmt.ForEachStmt.accept(ForEachStmt.java:86)
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 org.checkerframework.specimin.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:406)
at org.checkerframework.specimin.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:68)
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.UnsolvedSymbolVisitor.visit(UnsolvedSymbolVisitor.java:506)
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:287)
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)
at org.checkerframework.specimin.SpeciminTestExecutor.runTest(SpeciminTestExecutor.java:80)
at org.checkerframework.specimin.SpeciminTestExecutor.runTestWithoutJarPaths(SpeciminTestExecutor.java:140)
at org.checkerframework.specimin.Issue40.runTest(Issue40.java:9)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:60)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
This stacktrace indicates that there is no parent class for Issue40. This diagnostic is surprising - there isn't a parent class, of course, but there are no fields that could be attributed to the superclass used. After a lot of investigation, I determined that the issue is the use of listOfImports on line 15 (that is, in the for loop). This parameter isn't found in the map of local variables, leading Specimin to conclude that it is a field.
I tried adding logic so that parameters are considered locals in two ways. Both attempts failed, for different reasons:
I tried adding logic to add parameters to the local variable map in visit(Parameter, Void). This appeared to have no effect - I got the same crash
I tried adding logic to add parameters to the local variable map at the end of visit(MethodDeclaration, Void), as the new scope is created. Somehow, this leads to a seemingly-infinite loop, as variables are added and then found by visit(NameExpression, Void) over and over. I suspect that I did something wrong here, but I don't know the code here well enough to be sure.
@LoiNguyenCS can you look into this? I don't think we can fix #40 until we resolve whatever this issue is.
The text was updated successfully, but these errors were encountered:
Thank you for this minimized test case, Professor. Through some printing statements, I've found out that the bug actually happens at this line:
for (ImportDeclaration importStatement : listOfImports)
importStatement is unsolved, and somehow Specimin mistakes it to be a super field, which means that there is an issue with the way I update the symbol table. I will try fixing it and let you know.
Consider the following program (based on #40, but in a form suitable for a specimin test case):
When I add this to Specimin's test suite (see the
issue40
branch), it crashes with the following stacktrace:This stacktrace indicates that there is no parent class for
Issue40
. This diagnostic is surprising - there isn't a parent class, of course, but there are no fields that could be attributed to the superclass used. After a lot of investigation, I determined that the issue is the use oflistOfImports
on line 15 (that is, in the for loop). This parameter isn't found in the map of local variables, leading Specimin to conclude that it is a field.I tried adding logic so that parameters are considered locals in two ways. Both attempts failed, for different reasons:
visit(Parameter, Void)
. This appeared to have no effect - I got the same crashvisit(MethodDeclaration, Void)
, as the new scope is created. Somehow, this leads to a seemingly-infinite loop, as variables are added and then found byvisit(NameExpression, Void)
over and over. I suspect that I did something wrong here, but I don't know the code here well enough to be sure.@LoiNguyenCS can you look into this? I don't think we can fix #40 until we resolve whatever this issue is.
The text was updated successfully, but these errors were encountered: