pmd: #1002 False +: FinalFieldCouldBeStatic on inner class

This commit is contained in:
Andreas Dangel 2013-03-13 20:02:22 +01:00
parent adcbdc204f
commit 3b14b3f5cb
3 changed files with 29 additions and 1 deletions

View File

@ -1,5 +1,6 @@
????? ??, 2013 - 5.0.3:
Fixed bug 1002: False +: FinalFieldCouldBeStatic on inner class
Fixed bug 1064: Exception running PrematureDeclaration
Fixed bug 1068: CPD fails on broken symbolic links
Fixed bug 1073: Hard coded violation messages CommentSize

View File

@ -292,7 +292,7 @@ in each object at runtime.
[@Final='true' and @Static='false']
[not (../../../../ClassOrInterfaceDeclaration[@Interface='true'])]
/VariableDeclarator/VariableInitializer/Expression
/PrimaryExpression/PrimaryPrefix/Literal
/PrimaryExpression[not(PrimarySuffix)]/PrimaryPrefix/Literal
]]>
</value>
</property>

View File

@ -66,4 +66,31 @@ public interface Foo {
}
]]></code>
</test-code>
<test-code>
<description>bug #1002 False +: FinalFieldCouldBeStatic on inner class</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
package net.sourceforge.pmd;
public class FinalFieldCouldBeStaticTest {
public void foo() {
final Test t = new Test() {
// the rule was triggered for "foo" - which could be indeed a final static String constant
private final byte[] b = "foo".getBytes();
@Override
public byte[] bar() {
return b;
}
};
t.bar();
}
}
interface Test {
byte[] bar();
}
]]></code>
</test-code>
</test-data>