Merge pull request #3742 from dykov:hotfix/3701

[java] Fix #3701 - fix MissingStaticMethodInNonInstantiatableClass for
method local classes #3742

* pr-3742:
  [doc] Update release notes (#3701, #3742)
  #3701 - fix MissingStaticMethodInNonInstantiatableClass for method
local classes
This commit is contained in:
Andreas Dangel
2022-01-17 19:05:59 +01:00
3 changed files with 33 additions and 1 deletions

View File

@ -2547,7 +2547,7 @@ See the property `annotations`.
<property name="xpath">
<value>
<![CDATA[
//ClassOrInterfaceDeclaration[@Nested= false()]
//ClassOrInterfaceDeclaration[@Nested= false() and @Local= false()]
[
(
(: at least one constructor :)

View File

@ -346,6 +346,36 @@ public abstract class MyADT {
return onInt.apply(integer);
}
}
}
]]></code>
</test-code>
<test-code>
<description>#3701 - false positive with method inner class</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Scratch {
public static void main(String[] args) {
Scratch scratch = new Scratch();
scratch.callMethod();
}
void callMethod() {
class InnerClass {
private InnerClass() {
}
void display() {
System.out.println("Works OK!");
}
}
InnerClass innerClass = new InnerClass();
innerClass.display();
}
}
]]></code>
</test-code>