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

[java] JavaCharStream throws an Error on invalid escape #2472

Closed
oowekyala opened this issue May 7, 2020 · 0 comments · Fixed by #2474
Closed

[java] JavaCharStream throws an Error on invalid escape #2472

oowekyala opened this issue May 7, 2020 · 0 comments · Fixed by #2474
Labels
a:bug PMD crashes or fails to analyse a file.
Milestone

Comments

@oowekyala
Copy link
Member

Affects PMD Version: 6.23.0

Description: Javacc throws an Error on invalid escapes, which isn't caught, so it crashes the whole program. It also doesn't mention the filename.

Exception Stacktrace:

Exception in thread "main" java.lang.Error: Invalid escape character at line 1 column 2.
	at net.sourceforge.pmd.lang.ast.JavaCharStream.readChar(JavaCharStream.java:331)
	at net.sourceforge.pmd.lang.ast.JavaCharStream.BeginToken(JavaCharStream.java:193)
	at net.sourceforge.pmd.lang.java.ast.JavaParserTokenManager.getNextToken(JavaParserTokenManager.java:2271)
	at net.sourceforge.pmd.lang.java.ast.JavaParser.<init>(JavaParser.java:12555)
	at net.sourceforge.pmd.lang.java.AbstractJavaParser.createJavaParser(AbstractJavaParser.java:46)
	at net.sourceforge.pmd.lang.java.JavaLanguageParser.createJavaParser(JavaLanguageParser.java:41)
	at net.sourceforge.pmd.lang.java.AbstractJavaParser.parse(AbstractJavaParser.java:62)
	at net.sourceforge.pmd.SourceCodeProcessor.parse(SourceCodeProcessor.java:121)
	at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:185)
	at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:107)
	at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:89)
	at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:51)
	at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:78)
	at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:24)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

Code Sample demonstrating the issue:

\u00k0 // not a valid unicode escape because k is not a valid hex digit 

Steps to reproduce:

  1. analyse a file with an invalid escape like above

Running PMD through: any

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant