can be final: should not trigger static fields with initializer in a constructor (IDEA-69011)

This commit is contained in:
anna
2011-08-22 17:56:01 +02:00
parent 49fb929e81
commit c763ca289f
4 changed files with 31 additions and 2 deletions
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Foo.java</file>
<line>2</line>
<description>final</description>
</problem>
</problems>
@@ -0,0 +1,13 @@
public final class Foo {
private static Object f1 = new Object(); // Can be final but unused
private static Object object; // can't be final
Foo() {
object = new Object();
}
public static void main(String[] args) {
System.out.println(Foo.f1);
System.out.println(Foo.object);
}
}