mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 15:41:26 +07:00
dfa: assume fields used before initialization are null (IDEA-110297)
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
class Foo {
|
||||
String field;
|
||||
String field2 = field.<warning descr="Method invocation 'substring' may produce 'java.lang.NullPointerException'">substring</warning>(1);
|
||||
int field3 = field2.length();
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(field.hashCode());
|
||||
}
|
||||
};
|
||||
|
||||
Foo() {
|
||||
field = "x";
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
class Foo {
|
||||
String field;
|
||||
String field2;
|
||||
int hash = field.hashCode();
|
||||
int hash = field.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>();
|
||||
|
||||
Foo(String f2) {
|
||||
field2 = f2;
|
||||
|
||||
@@ -421,6 +421,8 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
|
||||
public void testDivisionByZero() { doTestReportConstantReferences(); }
|
||||
|
||||
public void testFieldUsedBeforeInitialization() { doTest(); }
|
||||
|
||||
public void testImplicitlyInitializedField() {
|
||||
PlatformTestUtil.registerExtension(ImplicitUsageProvider.EP_NAME, new ImplicitUsageProvider() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user