This Bug occures if the Source file starts with zero width no-break space.
To simplify matters take a look at the attachment.
Processing C:\Users\Username\Java_programm.jar:myPackage.path/SampleClass.java
Error while processing file: C:\Users\Username\Java_programm.jar:myPackage.path/SampleClass.java
net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file C:\Users\Username\Java_programm.jar:myPackage.path/SampleClass.java at line 1, column 1. Encountered: "\ufeff" (65279), after : ""
at net.sourceforge.pmd.lang.java.ast.JavaParserTokenManager.getNextToken(JavaParserTokenManager.java:2263)
at net.sourceforge.pmd.lang.java.ast.JavaParser.<init>(JavaParser.java:10903)
at net.sourceforge.pmd.lang.java.AbstractJavaParser.createJavaParser(AbstractJavaParser.java:42)
at net.sourceforge.pmd.lang.java.Java18Parser.createJavaParser(Java18Parser.java:23)
at net.sourceforge.pmd.lang.java.AbstractJavaParser.parse(AbstractJavaParser.java:56)
at net.sourceforge.pmd.SourceCodeProcessor.parse(SourceCodeProcessor.java:91)
at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:138)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:76)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:43)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:79)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:25)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)</init>
Hm... javac doesn't compile it:
Java source code obviously can't start with a BOM....
PMD could filter out the BOM of the source file and ignore/hide the problem. However, since you can't compile the source file, the auxclasspath feature of PMD won't work and you might have false positives/false negatives for some rules.
Therefore, this issue won't be fixed.
Workaround is, to remove the BOM.
See also:
Last edit: Andreas Dangel 2016-07-11