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

PMD Plugin runtime exception error as net.sourceforge.pmd.PMDException: Error while parsing #167

Open
nagadheerajb opened this issue Nov 23, 2022 · 3 comments

Comments

@nagadheerajb
Copy link

nagadheerajb commented Nov 23, 2022

Eclipse IDE for Enterprise Java Developers Version: 2022-06 (4.24.0) Build id: 20220609-1112
pmd-eclipse-plugin version: 4.40.0.v20221029-0812-r

The following line in Java code causing ERROR n.s.p.e.runtime.cmd.BaseVisitor - Runtime exception visiting and net.sourceforge.pmd.lang.java.ast.ParseException

${CLASS:emxContextUtil}.mqlNotice(context, returnMessage);

In my java code i had used ${ at many places due to this I am getting run time exception

pmd-eclipse.log:

`2022/11/18 16:03:05.339 [Worker-33: ReviewCode] ERROR n.s.p.e.runtime.cmd.BaseVisitor - Runtime exception visiting VCSUtil_mxJPO.java
java.lang.RuntimeException: There were processing errors!
C:\Users\nbiddala\Documents\naga\Softwares\NOV_Workspace\TESTPMDSOURCEFILES\src\main\java\VCSUtil_mxJPO.java: PMDException: Error while parsing C:\Users\nbiddala\Documents\naga\Softwares\NOV_Workspace\TESTPMDSOURCEFILES\src\main\java\VCSUtil_mxJPO.java net.sourceforge.pmd.PMDException: Error while parsing C:\Users\nbiddala\Documents\naga\Softwares\NOV_Workspace\TESTPMDSOURCEFILES\src\main\java\VCSUtil_mxJPO.java
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:124)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:100)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:62)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:89)
at net.sourceforge.pmd.processor.MonoThreadProcessor.runAnalysis(MonoThreadProcessor.java:32)
at net.sourceforge.pmd.processor.AbstractPMDProcessor.processFiles(AbstractPMDProcessor.java:143)
at net.sourceforge.pmd.PmdAnalysis.performAnalysisImpl(PmdAnalysis.java:252)
at net.sourceforge.pmd.PmdAnalysis.performAnalysisAndCollectReport(PmdAnalysis.java:237)
at net.sourceforge.pmd.eclipse.runtime.cmd.BaseVisitor.reviewResource(BaseVisitor.java:316)
at net.sourceforge.pmd.eclipse.runtime.cmd.ResourceVisitor.visit(ResourceVisitor.java:32)
at org.eclipse.core.internal.resources.Resource.lambda$1(Resource.java:117)
at org.eclipse.core.internal.resources.Resource.lambda$0(Resource.java:85)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:85)
at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:135)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:55)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:117)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:105)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.processResource(ReviewCodeCmd.java:546)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.processResources(ReviewCodeCmd.java:496)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.execute(ReviewCodeCmd.java:194)
at net.sourceforge.pmd.eclipse.runtime.cmd.JobCommandProcessor$1.run(JobCommandProcessor.java:60)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: net.sourceforge.pmd.lang.java.ast.ParseException: Encountered " "{" "{ "" at line 11848, column 8.
Was expecting one of:
";" ...
"=" ...
"++" ...
"--" ...
"+=" ...
"-=" ...
"*=" ...
"/=" ...
"&=" ...
"|=" ...
"^=" ...
"%=" ...
"<<=" ...
">>=" ...
">>>=" ...

at net.sourceforge.pmd.lang.java.ast.JavaParser.generateParseException(JavaParser.java:13870)
at net.sourceforge.pmd.lang.java.ast.JavaParser.jj_consume_token(JavaParser.java:13754)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Statement(JavaParser.java:5604)
at net.sourceforge.pmd.lang.java.ast.JavaParser.BlockStatement(JavaParser.java:5801)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Block(JavaParser.java:5718)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Statement(JavaParser.java:5595)
at net.sourceforge.pmd.lang.java.ast.JavaParser.IfStatement(JavaParser.java:6452)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Statement(JavaParser.java:5611)
at net.sourceforge.pmd.lang.java.ast.JavaParser.BlockStatement(JavaParser.java:5801)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Block(JavaParser.java:5718)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Statement(JavaParser.java:5595)
at net.sourceforge.pmd.lang.java.ast.JavaParser.IfStatement(JavaParser.java:6452)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Statement(JavaParser.java:5611)
at net.sourceforge.pmd.lang.java.ast.JavaParser.BlockStatement(JavaParser.java:5801)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Block(JavaParser.java:5718)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Statement(JavaParser.java:5595)
at net.sourceforge.pmd.lang.java.ast.JavaParser.IfStatement(JavaParser.java:6452)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Statement(JavaParser.java:5611)
at net.sourceforge.pmd.lang.java.ast.JavaParser.BlockStatement(JavaParser.java:5801)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Block(JavaParser.java:5718)
at net.sourceforge.pmd.lang.java.ast.JavaParser.TryStatement(JavaParser.java:6895)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Statement(JavaParser.java:5638)
at net.sourceforge.pmd.lang.java.ast.JavaParser.BlockStatement(JavaParser.java:5801)
at net.sourceforge.pmd.lang.java.ast.JavaParser.Block(JavaParser.java:5718)
at net.sourceforge.pmd.lang.java.ast.JavaParser.MethodDeclaration(JavaParser.java:2148)
at net.sourceforge.pmd.lang.java.ast.JavaParser.ClassOrInterfaceBodyDeclaration(JavaParser.java:1829)
at net.sourceforge.pmd.lang.java.ast.JavaParser.ClassOrInterfaceBody(JavaParser.java:1782)
at net.sourceforge.pmd.lang.java.ast.JavaParser.ClassOrInterfaceDeclaration(JavaParser.java:923)
at net.sourceforge.pmd.lang.java.ast.JavaParser.TypeDeclaration(JavaParser.java:825)
at net.sourceforge.pmd.lang.java.ast.JavaParser.CompilationUnit(JavaParser.java:545)
at net.sourceforge.pmd.lang.java.AbstractJavaParser.parse(AbstractJavaParser.java:62)
at net.sourceforge.pmd.lang.AbstractParser.doParse(AbstractParser.java:45)
at net.sourceforge.pmd.SourceCodeProcessor.parse(SourceCodeProcessor.java:136)
at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:200)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:118)
... 22 more


at net.sourceforge.pmd.eclipse.runtime.cmd.BaseVisitor.reviewResource(BaseVisitor.java:339)
at net.sourceforge.pmd.eclipse.runtime.cmd.ResourceVisitor.visit(ResourceVisitor.java:32)
at org.eclipse.core.internal.resources.Resource.lambda$1(Resource.java:117)
at org.eclipse.core.internal.resources.Resource.lambda$0(Resource.java:85)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:85)
at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:135)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:55)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:117)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:105)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.processResource(ReviewCodeCmd.java:546)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.processResources(ReviewCodeCmd.java:496)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.execute(ReviewCodeCmd.java:194)
at net.sourceforge.pmd.eclipse.runtime.cmd.JobCommandProcessor$1.run(JobCommandProcessor.java:60)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)`

@adangel how to resolve this "${" run time exception?

@adangel
Copy link
Member

adangel commented Nov 25, 2022

This ${CLASS:emxContextUtil} doesn't look like a valid identifier for a variable in Java.
It looks more like a placeholder, that is replaced before the java compiler sees your code...

Do you use any plugin in eclipse, that replaces these placeholder on the fly? Otherwise you should also see compile errors in eclipse...

PMD can only analyze files, that the java compiler can parse.

How does a complete java file in your case look like? Where is ${CLASS:emxContextUtil} defined?

@nagadheerajb
Copy link
Author

Hello @adangel

I will add dependency jar files which replaces the placeholder on the fly, so there won't be any compilation errors.

The ${CLASS:emxContextUtil} is the java file (emxContextUtil_mxJPO.java) and it is calling the method mqlNotice and java file is placed on the same folder along with other source files
public static void mqlNotice(Context context, String notice) throws Exception
{
MqlUtil.mqlCommand(context, "notice $1", notice);
}

Reagards,
Naga Dheeraj

@adangel
Copy link
Member

adangel commented Dec 1, 2022

Sorry, I don't understand. What dependency jar exactly?

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

No branches or pull requests

2 participants