Affects PMD Version:
PMD version 6.44.0
Description:
java.nio.charset.UnmappableCharacterException when rule LawOfDemeter
violated and SARIF format output written to file.
The message in the exception (This should be unreachable) suggests this is a fault.
I've only seen this with LawOfDemeter
(the other few rules I've tried don't have a problem)
The problem only seems to occur when using -r and SARIF format.
There is no problem if output is sent to stdout (i.e. not using the -r flag)
There is no problem Using a format different to SARIF.
Exception Stacktrace:
CLI_prompt> /opt/pmd/pmd-bin-6.44.0/bin/run.sh pmd --no-cache -f sarif -R unmappable.xml -r pmd-report.sarif --debug -d tmp
Mar 30, 2022 7:30:04 AM net.sourceforge.pmd.util.log.internal.SimpleMessageReporter logImpl
FINER: Adding file /home/ewan/workspace/KalahStandardStarter/tmp/B.java (lang: java 18)
Mar 30, 2022 7:30:04 AM net.sourceforge.pmd.RuleSetFactory parseRuleSetNode
WARNING: RuleSet description is missing. Future versions of PMD will require it.
Mar 30, 2022 7:30:04 AM net.sourceforge.pmd.RuleSetLoader printRulesInDebug
FINE: Rules loaded from unmappable.xml:
Mar 30, 2022 7:30:04 AM net.sourceforge.pmd.RuleSetLoader printRulesInDebug
FINE: - LawOfDemeter (Java)
Mar 30, 2022 7:30:04 AM net.sourceforge.pmd.util.log.internal.SimpleMessageReporter logImpl
FINER: Using Java version 'java 18'
Mar 30, 2022 7:30:04 AM net.sourceforge.pmd.processor.PmdRunnable call
FINE: Processing /home/ewan/workspace/KalahStandardStarter/tmp/B.java
Mar 30, 2022 7:30:04 AM net.sourceforge.pmd.util.log.internal.SimpleMessageReporter logImpl
SEVERE: Exception during processing: java.nio.charset.UnmappableCharacterException: Input length = 1
Exception in thread "main" java.lang.AssertionError: This should be unreachable: exhaustive
at net.sourceforge.pmd.internal.util.AssertionUtil.shouldNotReachHere(AssertionUtil.java:54)
at net.sourceforge.pmd.util.log.MessageReporter$Level.toJutilLevel(MessageReporter.java:85)
at net.sourceforge.pmd.util.log.internal.SimpleMessageReporter.isLoggableImpl(SimpleMessageReporter.java:29)
at net.sourceforge.pmd.util.log.internal.MessageReporterBase.isLoggable(MessageReporterBase.java:36)
at net.sourceforge.pmd.util.log.internal.MessageReporterBase.logEx(MessageReporterBase.java:53)
at net.sourceforge.pmd.util.log.internal.SimpleMessageReporter.logEx(SimpleMessageReporter.java:18)
at net.sourceforge.pmd.util.log.internal.MessageReporterBase.errorEx(MessageReporterBase.java:112)
at net.sourceforge.pmd.util.log.internal.SimpleMessageReporter.errorEx(SimpleMessageReporter.java:18)
at net.sourceforge.pmd.util.log.internal.MessageReporterBase.errorEx(MessageReporterBase.java:107)
at net.sourceforge.pmd.PMD.doPMD(PMD.java:258)
at net.sourceforge.pmd.PMD.runPmd(PMD.java:503)
at net.sourceforge.pmd.PMD.runPmd(PMD.java:470)
at net.sourceforge.pmd.PMD.main(PMD.java:416)
Code Sample demonstrating the issue:
class B {
public void m() {
a.b.c();
}
}
Steps to reproduce:
Please provide detailed steps for how we can reproduce the bug.
tmp
unmappable.xml
containing<?xml version="1.0"?>
<ruleset name="MyRules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<rule ref="category/java/design.xml/LawOfDemeter"/>
</ruleset>
CLI_prompt> /opt/pmd/pmd-bin-6.44.0/bin/run.sh pmd --no-cache -f sarif -R unmappable.xml -r pmd-report.sarif --debug -d tmp
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
CLI
Other
CLI_prompt> java -version
java version "11.0.13" 2021-10-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.13+10-LTS-370)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.13+10-LTS-370, mixed mode)
CLI_prompt> uname -a
Linux machinename 5.13.0-30-generic #33-Ubuntu SMP Fri Feb 4 17:03:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
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