Hi, I'm working on a temporary solution to resolve method usages until we change the AST.
While trying to test it, type resolution failed with an IllegalStateException
on a very simple primary (object.toString()
). Here's the full stack trace of the exception:
java.lang.IllegalStateException: None of the maximally specific methods are abstract.
net.sourceforge.pmd.lang.java.typeresolution.MethodType@16b3fc9e
net.sourceforge.pmd.lang.java.typeresolution.MethodType@e2d56bf
at net.sourceforge.pmd.lang.java.typeresolution.MethodTypeResolution.selectAmongMaximallySpecific(MethodTypeResolution.java:289)
at net.sourceforge.pmd.lang.java.typeresolution.MethodTypeResolution.selectMostSpecificMethod(MethodTypeResolution.java:259)
at net.sourceforge.pmd.lang.java.typeresolution.MethodTypeResolution.getBestMethodReturnType(MethodTypeResolution.java:230)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:452)
at net.sourceforge.pmd.lang.java.ast.ASTName.jjtAccept(ASTName.java:35)
at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:56)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:10)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:314)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:967)
at net.sourceforge.pmd.lang.java.ast.ASTPrimaryPrefix.jjtAccept(ASTPrimaryPrefix.java:42)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:810)
at net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression.jjtAccept(ASTPrimaryExpression.java:21)
at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:56)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:10)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:230)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:670)
at net.sourceforge.pmd.lang.java.ast.ASTExpression.jjtAccept(ASTExpression.java:21)
at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:56)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:10)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:174)
at net.sourceforge.pmd.lang.java.ast.ASTVariableInitializer.jjtAccept(ASTVariableInitializer.java:21)
at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:56)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:10)
...
The code samples that trigger the exception are here. I think it's notable that the first test throws the exception but the second doesn't, the only difference being that in the first case, the source is loaded using a class literal and in the second it's provided as a string. The methods used to parse and visit the source are taken from ClassTypeResolverTest
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4