Affects PMD Version:
PMD 7.20.0 (fa478ec, 2025-12-30T14:37:52Z)
Description:
Parsing code fails while it is valid Java.
Exception Stacktrace:
[WARN] This analysis could be faster, please consider using Incremental Analysis: https://docs.pmd-code.org/pmd-doc-7.20.0/pmd_userdocs_incremental_analysis.html
../tools/build/Lambda.java - ParseException: Parse exception in file '../tools/build/Lambda.java' at line 6, column 27: Encountered <IDENTIFIER: "a">.
Was expecting one of:
"instanceof" ...
")" ...
"," ...
"=" ...
"<" ...
"?" ...
"==" ...
"<=" ...
">=" ...
"!=" ...
"||" ...
"&&" ...
"++" ...
"--" ...
"+" ...
"-" ...
"*" ...
"/" ...
"&" ...
"|" ...
"^" ...
"%" ...
"+=" ...
"-=" ...
"*=" ...
"/=" ...
"&=" ...
"|=" ...
"^=" ...
"%=" ...
"<<=" ...
">>=" ...
">>>=" ...
">" ...
[INFO] An error occurred while executing PMD.
Code Sample demonstrating the issue:
public class Lambda {
public static void main( String[] args ) {
foo(switch ( args[0] ) {
default:
yield (Lambda a, Lambda b) -> "hello";
});
}
private static void foo(java.util.function.BiFunction<Lambda, Lambda, String> f) {}
}
Rules
<?xml version="1.0"?>
<ruleset name="Custom Rules"
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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>
Dead code
</description>
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
<properties>
<property name="ignoredAnnotations" value="jakarta.annotation.PostConstruct,jakarta.annotation.PreDestroy" />
</properties>
</rule>
</ruleset>
Steps to reproduce:
Run pmd check -f text -R deadcode.xml -d testdir. Running on Java 25.
Having a single parameter in the lambda does not trigger the parse error.
Affects PMD Version:
PMD 7.20.0 (fa478ec, 2025-12-30T14:37:52Z)
Description:
Parsing code fails while it is valid Java.
Exception Stacktrace:
Code Sample demonstrating the issue:
Rules
Steps to reproduce:
Run
pmd check -f text -R deadcode.xml -d testdir. Running on Java 25.Having a single parameter in the lambda does not trigger the parse error.