Repository navigation
Closed
Description
Affects PMD Version: 7.26.0
Description:
IllegalArgumentException while processing java file below
Exception Stacktrace:
$ pmd check -d ComboBox2Test.java -R final.xml --verbose
[DEBUG] Log level is at TRACE
[DEBUG] Created new FileCollector with LanguageVersionDiscoverer(LanguageRegistry(apex, ecmascript, html, java, jsp, kotlin, modelica, plsql, pom, scala, swift, velocity, visualforce, wsdl, xml, xsl))
[DEBUG] Adding regular file ComboBox2Test.java.
[TRACE] Adding file /home/err/work/bugs/pmd/IntegerStringLong/ComboBox2Test.java (lang: java 26)
[DEBUG] Rules loaded from final.xml:
[DEBUG] - AvoidFinalParameters (Java)
[DEBUG] Runtime classpath:
/junk/BACK_REF/pmd/current/conf:/junk/BACK_REF/pmd/current/lib/rhino-1.7.15.1.jar:/junk/BACK_REF/pmd/current/lib/pmd-css-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/directory-watcher-0.18.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-go-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/progressbar-0.9.5.jar:/junk/BACK_REF/pmd/current/lib/kotlin-stdlib-2.2.10.jar:/junk/BACK_REF/pmd/current/lib/gson-extras-1.3.0.jar:/junk/BACK_REF/pmd/current/lib/antlr4-runtime-4.13.2.jar:/junk/BACK_REF/pmd/current/lib/pmd-python-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-jsp-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/common_2.13-4.17.0.jar:/junk/BACK_REF/pmd/current/lib/checker-compat-qual-2.5.3.jar:/junk/BACK_REF/pmd/current/lib/pmd-rust-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/better-files_2.13-3.9.2.jar:/junk/BACK_REF/pmd/current/lib/trees_2.13-4.17.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-matlab-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/common2_2.13-4.17.0.jar:/junk/BACK_REF/pmd/current/lib/upickle-core_2.13-1.2.0.jar:/junk/BACK_REF/pmd/current/lib/scalajs-stubs_2.13-1.0.0.jar:/junk/BACK_REF/pmd/current/lib/jline-3.21.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-kotlin-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/kotlin-stdlib-jdk8-2.2.10.jar:/junk/BACK_REF/pmd/current/lib/pmd-cs-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/upickle_2.13-1.2.0.jar:/junk/BACK_REF/pmd/current/lib/ujson_2.13-1.2.0.jar:/junk/BACK_REF/pmd/current/lib/upickle-implicits_2.13-1.2.0.jar:/junk/BACK_REF/pmd/current/lib/mainargs_2.13-0.5.4.jar:/junk/BACK_REF/pmd/current/lib/summit-ast-2.4.0.jar:/junk/BACK_REF/pmd/current/lib/scala-parallel-collections_2.13-1.0.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-java-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/jspecify-1.0.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-visualforce-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-groovy-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-javascript-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/scala-json-rpc_2.13-1.1.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-swift-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-objectivec-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-ruby-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-lua-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-ant-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pcollections-4.0.2.jar:/junk/BACK_REF/pmd/current/lib/io_2.13-4.17.0.jar:/junk/BACK_REF/pmd/current/lib/jsoup-1.22.2.jar:/junk/BACK_REF/pmd/current/lib/scala-collection-compat_2.13-2.8.1.jar:/junk/BACK_REF/pmd/current/lib/vf-parser-2.0.0-beta.1.jar:/junk/BACK_REF/pmd/current/lib/checker-qual-4.2.0.jar:/junk/BACK_REF/pmd/current/lib/kotlin-stdlib-jdk7-2.2.10.jar:/junk/BACK_REF/pmd/current/lib/jna-5.12.1.jar:/junk/BACK_REF/pmd/current/lib/nice-xml-messages-3.1.jar:/junk/BACK_REF/pmd/current/lib/scala-json-rpc-upickle-json-serializer_2.13-1.1.0.jar:/junk/BACK_REF/pmd/current/lib/asm-9.10.1.jar:/junk/BACK_REF/pmd/current/lib/error_prone_annotations-2.48.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-plsql-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/xmlresolver-5.3.3.jar:/junk/BACK_REF/pmd/current/lib/apex-ls_2.13-6.0.2.jar:/junk/BACK_REF/pmd/current/lib/scala-library-2.13.18.jar:/junk/BACK_REF/pmd/current/lib/pmd-gherkin-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-tsql-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/groovy-5.0.6.jar:/junk/BACK_REF/pmd/current/lib/pmd-modelica-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/flogger-system-backend-0.8.jar:/junk/BACK_REF/pmd/current/lib/pmd-dart-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/xmlresolver-5.3.3-data.jar:/junk/BACK_REF/pmd/current/lib/outline-parser_2.13-1.3.0.jar:/junk/BACK_REF/pmd/current/lib/commons-lang3-3.20.0.jar:/junk/BACK_REF/pmd/current/lib/parsers_2.13-4.17.0.jar:/junk/BACK_REF/pmd/current/lib/gson-2.14.0.jar:/junk/BACK_REF/pmd/current/lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/junk/BACK_REF/pmd/current/lib/standard-types-65.0.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-cli-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-xml-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/sourcecode_2.13-0.4.4.jar:/junk/BACK_REF/pmd/current/lib/failureaccess-1.0.3.jar:/junk/BACK_REF/pmd/current/lib/trees2_2.13-4.17.0.jar:/junk/BACK_REF/pmd/current/lib/jsr305-3.0.2.jar:/junk/BACK_REF/pmd/current/lib/jsr250-api-1.0.jar:/junk/BACK_REF/pmd/current/lib/slf4j-simple-1.7.36.jar:/junk/BACK_REF/pmd/current/lib/pmd-scala_2.13-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/picocli-4.7.7.jar:/junk/BACK_REF/pmd/current/lib/guava-33.6.0-jre.jar:/junk/BACK_REF/pmd/current/lib/pmd-coco-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-apex-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-velocity-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-cpp-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/upack_2.13-1.2.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-core-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/scala-reflect-2.13.18.jar:/junk/BACK_REF/pmd/current/lib/pmd-php-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-fortran-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/geny_2.13-0.6.2.jar:/junk/BACK_REF/pmd/current/lib/Saxon-HE-12.9.jar:/junk/BACK_REF/pmd/current/lib/sobject-types-65.0.0.jar:/junk/BACK_REF/pmd/current/lib/slf4j-api-1.7.36.jar:/junk/BACK_REF/pmd/current/lib/apex-types_2.13-1.3.0.jar:/junk/BACK_REF/pmd/current/lib/apex-parser-5.0.0.jar:/junk/BACK_REF/pmd/current/lib/scala-xml_2.13-1.3.0.jar:/junk/BACK_REF/pmd/current/lib/jul-to-slf4j-1.7.36.jar:/junk/BACK_REF/pmd/current/lib/pmd-perl-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/directory-watcher-better-files_2.13-0.18.0.jar:/junk/BACK_REF/pmd/current/lib/j2objc-annotations-3.1.jar:/junk/BACK_REF/pmd/current/lib/pmd-html-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/pmd-julia-7.26.0.jar:/junk/BACK_REF/pmd/current/lib/flogger-0.8.jar:/junk/BACK_REF/pmd/current/lib/pmd-designer-7.19.3.jar
[DEBUG] Aux classpath: jdk.internal.loader.ClassLoaders$AppClassLoader@5f6b6180
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r <file> to output the report to a file instead.
[TRACE] Using Java version ''java 26''
[WARN] This analysis could be faster, please consider using Incremental Analysis: https://docs.pmd-code.org/pmd-doc-7.26.0/pmd_userdocs_incremental_analysis.html
[DEBUG] Using analysis classloader: jdk.internal.loader.ClassLoaders$AppClassLoader@5f6b6180
[DEBUG] Using 16 threads for analysis
[TRACE] Processing file (lang: java+version:26): /home/err/work/bugs/pmd/IntegerStringLong/ComboBox2Test.java
[TRACE] PmdThread 1 waiting on : ParseLock{name=ClassStub:java/lang/String,status=NOT_PARSED}
[TRACE] PmdThread 1 locked : ParseLock{name=ClassStub:java/lang/String,status=NOT_PARSED}
[TRACE] PmdThread 1 released : ParseLock{name=ClassStub:java/lang/String,status=FULL}
[TRACE] PmdThread 1 waiting on : ParseLock{name=ClassStub:java/lang/Object,status=NOT_PARSED}
[TRACE] PmdThread 1 locked : ParseLock{name=ClassStub:java/lang/Object,status=NOT_PARSED}
[TRACE] PmdThread 1 released : ParseLock{name=ClassStub:java/lang/Object,status=FULL}
[TRACE] PmdThread 1 waiting on : ParseLock{name=LazyClassSignature:java/lang/Object[null],status=NOT_PARSED}
[TRACE] PmdThread 1 locked : ParseLock{name=LazyClassSignature:java/lang/Object[null],status=NOT_PARSED}
[TRACE] PmdThread 1 released : ParseLock{name=LazyClassSignature:java/lang/Object[null],status=FULL}
[TRACE] PmdThread 1 waiting on : ParseLock{name=ClassStub:java/lang/Integer,status=NOT_PARSED}
[TRACE] PmdThread 1 locked : ParseLock{name=ClassStub:java/lang/Integer,status=NOT_PARSED}
[TRACE] PmdThread 1 released : ParseLock{name=ClassStub:java/lang/Integer,status=FULL}
[DEBUG] at ComboBox2Test.java:2:46: Cannot resolve symbol ComboBox1
[TRACE] PmdThread 1 waiting on : ParseLock{name=ClassStub:java/lang/Long,status=NOT_PARSED}
[TRACE] PmdThread 1 locked : ParseLock{name=ClassStub:java/lang/Long,status=NOT_PARSED}
[TRACE] PmdThread 1 released : ParseLock{name=ClassStub:java/lang/Long,status=FULL}
[DEBUG] at ComboBox2Test.java:11:50: Cannot resolve symbol ComboBox2
[DEBUG] at ComboBox2Test.java:6:38: Cannot resolve symbol Item1
[DEBUG] at ComboBox2Test.java:4:17: Cannot resolve symbol Builder
[DEBUG] at ComboBox2Test.java:15:38: Cannot resolve symbol Item2
[DEBUG] at ComboBox2Test.java:13:17: Cannot resolve symbol Builder
[DEBUG] at ComboBox2Test.java:13:17: Malformed generic type: expected 2 type arguments, got 3
[TRACE] Of 41 distinct queries to the classloader, 13 queries failed, 4 classes were found and parsed successfully, 0 were found but failed parsing (!), 24 were found but never parsed.
ComboBox2Test.java - IllegalArgumentException: Mismatched list sizes [T0, T1] to [java.lang.Integer, java.lang.String, java.lang.Long]
[INFO] An error occurred while executing PMD.
Run in verbose mode to see a stack-trace.
If you think this is a bug in PMD, please report this issue at https://github.com/pmd/pmd/issues/new/choose
If you do so, please include a stack-trace, the code sample
causing the issue, and details about your run configuration.
Code Sample demonstrating the issue:
ComboBox2Test.java
public class ComboBox2Test {
public class ComboBoxIntStringItem extends ComboBox1<Integer, String> {
public ComboBoxIntStringItem() {
super(new Builder<Integer, String>() {});
}
public static class Item extends Item1<Integer, String> {
public Item(Integer key, String displayValue) { super(key, displayValue); }
}
}
public class ComboBoxIntStringLongItem extends ComboBox2<Integer, String, Long> {
public ComboBoxIntStringLongItem() {
super(new Builder<Integer, String, Long>() {});
}
public static class Item extends Item2<Integer, String, Long> {
public Item(Integer key, String displayValue, Long displayValue2) {
super(key, displayValue);
}
}
}
}Ruleset
final.xml
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Custom Final Ruleset"
xmlns="http://sourceforge.net"
xmlns:xsi="http://w3.org"
xsi:schemaLocation="http://sourceforge.net https://sourceforge.net">
<description>Custom ruleset to detect final parameters in PMD 7.</description>
<rule name="AvoidFinalParameters"
language="java"
message="Method parameters should not be declared final."
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<description>
Detects method and constructor parameters that use the final keyword.
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//FormalParameter[@Final = true()]
]]>
</value>
</property>
</properties>
</rule>
</ruleset>
Steps to reproduce:
Please provide detailed steps for how we can reproduce the bug.
- Copy above to local files ComboBox2Test.java and final.xml in <test> directory
- execute
pmd check -d ComboBox2Test.java -R final.xmlin <test> directory - observe exception
Running PMD through: CLI
Activity
errael commentedon Aug 5, 2026
Forgot to mention. Problem is probably that
new Builderis interpreted to refer to a global class, rather than a nested class. And the test file can be simplified to[java] Fix pmd#6926: tolerate mismatched unresolved generic arity
adangel commentedon Aug 14, 2026
Another case of execeuting PMD without providing the auxclasspath -> https://docs.pmd-code.org/latest/pmd_languages_java.html#providing-the-auxiliary-classpath
Does the problem disappear, if you provide the auxclasspath, which should contain "ComboBox1" and "ComboBox2" and "Builder" and "Item1" and "Item2"?
[-][java] pmd check: IllegalArgumentException: Mismatched list sizes [T0, T1] to [java.lang.Integer, java.lang.String, java.lang.Long][/-][+][java] IllegalArgumentException: Mismatched list sizes [T0, T1] to [java.lang.Integer, java.lang.String, java.lang.Long][/+][-][java] IllegalArgumentException: Mismatched list sizes [T0, T1] to [java.lang.Integer, java.lang.String, java.lang.Long][/-][+][java] IllegalArgumentException (Mismatched list sizes) with inconsistent unresolved generic arity[/+]adangel commentedon Aug 14, 2026
So, there are actually two different Builder classes, correct? ComboBoxIntStringItem has a nested generic Builder class with 2 generic parameters, and ComboBoxIntStringLongItem has a different nested Builder class, with 3 generic parameters.
If they are nested, why are they missing in your example? If they are not nested, but somewhere else, they would need to be imported. But as both classes have the same name, then one must be qualified...
Can you provide a code sample with the
Builderclasses? I assume, you have at least two different top-level classes and not one single class as in the test case (ComboBox2Test doesn't really exist).errael commentedon Aug 14, 2026
Yes, there are two different Builder classes.
ComboBox1andComboBox2each has a nested Builder class; so ComboBoxIntStringItem and ComboBoxIntStringLongItem, which extendComboBox[12]have access to them, noimport Builderneeded.class ComboBox2Testdoes exist and is a JUnit5 test, with the same package as the top level classesComboBox1andComboBox2so noimport ComboBox[12]needed.ComboBox[12]are in a different physical directory, but the same package.I will read about the auxclasspath stuff; but I wanted to clarify the structure first. Maybe JUnit5 is contributing to the problem.
errael commentedon Aug 14, 2026
As expected, using
--aux-classpath=/.../project/target/xxx.jar, fixes the crash encountered when runningpmd checkon the project's JUnit5 tests.[java] Fix pmd#6926: tolerate mismatched unresolved generic arity
[java] Fix pmd#6926: tolerate mismatched unresolved generic arity
[java] Fix pmd#6926: tolerate mismatched unresolved generic arity
[java] Fix pmd#6926: tolerate mismatched unresolved generic arity
[java] Fix pmd#6926: tolerate mismatched unresolved generic arity
[java] Fix pmd#6926: skip file on unresolved generic arity mismatch
[java] Fix #6926: skip file on unresolved generic arity mismatch (#6935)