PMD not recognizing 'super' keyword in Java #4744
-
I am testing a rule against Java classes and it seems to work but I continue getting this error at some points: I have pinpointed where it is in the code, which is here: Its error when hovered over is: Type mismatch: cannot convert from Iterable to Iterable I do not know PMD well enough to solve this issue, but I believe that any time it detects the 'super' keyword, it calls this function which in turn throws an error. I have tested it against many Java classes both with the 'super' keyword and without and it only throws this error on classes that contain the 'super' keyword. Any suggestions on how I can fix this locally and allow for the detection of the 'super' keyword while parsing? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Interesting… you are not setting the Can you share a snippet of code that triggers this? |
Beta Was this translation helpful? Give feedback.
-
The "Unresolved Compilation Error" is problematic. This means, that building PMD continued despite the fact, that there were build problems. I know this from Eclipse, that it can partially compile classes even though they have syntax errors... How did you build PMD? Which JDK do you use? Does this problem also happen with the official builds from https://sourceforge.net/projects/pmd/files/pmd/7.0.0-SNAPSHOT/? (If yes, it is a general problem) For reference, we you Adoptium Temurin 11 when compiling PMD (https://adoptium.net/de/temurin/releases/?version=11). And we compile it under Linux. Whatever compiler you use, it is not able to infer the correct type of "ctor" in the lambda... I know, that the eclipse compiler has problems and I'm not sure e.g. if PMD can still be developed using Eclipse. I see, that you use VS Code. Maybe there is some option to configure, which JDK to use? |
Beta Was this translation helpful? Give feedback.
Yes - The extension Language Support for Java(TM) by Red Hat uses the Eclipse Language Server and Eclise JDT under the hood.
The problem seems to happen, if VS Code compiles the project at the same time the maven build is compiling - then it can be that in the produced jar file, the bad compilation result from Eclipse JDT is added. As @oowekyala suggested, exit vscode, and run maven without vscode, then it should work (This seems to be the only reliable way).
By the way, with your command line, you are not skipping tests and javadoc. The property need to be "maven.test.skip" and "maven.javadoc.skip":
Instead…