DFA: exception names shortened in messages ('java.lang.' package prefix is removed)

This commit is contained in:
Tagir Valeev
2018-08-20 13:24:45 +07:00
parent 4ce3758d4a
commit 7e9d7a664e
83 changed files with 177 additions and 177 deletions
@@ -3,6 +3,6 @@
<problem>
<file>Test.java</file>
<line>5</line>
<description>Array access &lt;code&gt;path[0]&lt;/code&gt; will produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;</description>
<description>Array access &lt;code&gt;path[0]&lt;/code&gt; will produce &lt;code&gt;NullPointerException&lt;/code&gt;</description>
</problem>
</problems>
@@ -3,6 +3,6 @@
<problem>
<file>Test.java</file>
<line>4</line>
<description>Dereference of 'path' may produce java.lang.NullPointerException</description>
<description>Dereference of 'path' may produce NullPointerException</description>
</problem>
</problems>
@@ -3,6 +3,6 @@
<problem>
<file>Npe.java</file>
<line>6</line>
<description>Method invocation &lt;code&gt;bar&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;</description>
<description>Method invocation &lt;code&gt;bar&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;</description>
</problem>
</problems>
@@ -3,7 +3,7 @@
<problem>
<file>Finally.java</file>
<line>9</line>
<description>Method invocation 'hashCode' may produce java.lang.NullPointerException</description>
<description>Method invocation 'hashCode' may produce NullPointerException</description>
</problem>
</problems>
@@ -3,7 +3,7 @@
<problem>
<file>NullTest.java</file>
<line>6</line>
<description>Dereference of 't' will produce java.lang.NullPointerException</description>
<description>Dereference of 't' will produce NullPointerException</description>
</problem>
</problems>
@@ -3,6 +3,6 @@
<problem>
<file>Test.java</file>
<line>72</line>
<description>Method invocation &lt;code&gt;length&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;</description>
<description>Method invocation &lt;code&gt;length&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;</description>
</problem>
</problems>
@@ -108,7 +108,7 @@ class AdvancedArrayAccess {
void testMethodQualifier() {
if(getData()[0] == null) {
System.out.println(getData()[0].<warning descr="Method invocation 'trim' will produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(getData()[0].<warning descr="Method invocation 'trim' will produce 'NullPointerException'">trim</warning>());
}
}
@@ -4,12 +4,12 @@ import org.jetbrains.annotations.NotNull;
class ArrayStoreProblems {
void test(String[] args, Integer[] args2) {
Object[] arr = args;
arr[0] <warning descr="Storing element of type 'int' to array of 'java.lang.String' elements may produce 'java.lang.ArrayStoreException'">=</warning> 123;
arr[0] <warning descr="Storing element of type 'int' to array of 'java.lang.String' elements may produce 'ArrayStoreException'">=</warning> 123;
arr = args2;
arr[1] = 124;
arr[2] <warning descr="Storing element of type 'java.lang.String' to array of 'java.lang.Integer' elements may produce 'java.lang.ArrayStoreException'">=</warning> "foo";
arr[2] <warning descr="Storing element of type 'java.lang.String' to array of 'java.lang.Integer' elements may produce 'ArrayStoreException'">=</warning> "foo";
arr = args;
arr[3] = "bar";
arr[4] <warning descr="Storing element of type 'int' to array of 'java.lang.String' elements may produce 'java.lang.ArrayStoreException'">=</warning> 125;
arr[4] <warning descr="Storing element of type 'int' to array of 'java.lang.String' elements may produce 'ArrayStoreException'">=</warning> 125;
}
}
@@ -11,7 +11,7 @@ public class AssertAll {
String s4 = readNullable();
Assertions.assertAll(
() -> Assertions.assertNotNull(<warning descr="Argument 's1' might be null but passed to non-annotated parameter">s1</warning>),
() -> Assertions.assertTrue(s1.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>().isEmpty()),
() -> Assertions.assertTrue(s1.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>().isEmpty()),
<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>
);
Assertions.assertNotNull(<warning descr="Argument 's2' might be null but passed to non-annotated parameter">s2</warning>);
@@ -20,8 +20,8 @@ public class AssertAll {
() -> Assertions.assertTrue(s1.trim().isEmpty()),
() -> Assertions.assertTrue(s1.trim().isEmpty()),
() -> Assertions.assertTrue(s2.trim().isEmpty()),
() -> Assertions.assertTrue(s3.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>().isEmpty()),
() -> Assertions.assertTrue(s4.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>().isEmpty())
() -> Assertions.assertTrue(s3.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>().isEmpty()),
() -> Assertions.assertTrue(s4.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>().isEmpty())
);
Assertions.assertAll(
() -> Assertions.assertTrue(<warning descr="Result of 's1.trim().isEmpty()' is always 'true'">s1.trim().isEmpty()</warning>),
@@ -56,6 +56,6 @@ class Contracts {
private void testNotArraySize() {
String[] things = retrieveThings();
assertThat(things, not(is(arrayWithSize(2))));
assertThat(<warning descr="Array access 'things[0]' may produce 'java.lang.NullPointerException'">things[0]</warning>, is(equalTo("...")));
assertThat(<warning descr="Array access 'things[0]' may produce 'NullPointerException'">things[0]</warning>, is(equalTo("...")));
}
}
@@ -21,6 +21,6 @@ public class AssumeNotNull {
}
public void testNoAssumeSomeStringStartsWithAbc() {
Assert.assertTrue(someString.<warning descr="Method invocation 'startsWith' may produce 'java.lang.NullPointerException'">startsWith</warning>("abc"));
Assert.assertTrue(someString.<warning descr="Method invocation 'startsWith' may produce 'NullPointerException'">startsWith</warning>("abc"));
}
}
@@ -2,7 +2,7 @@ import org.jetbrains.annotations.Nullable;
class DDD {
int test(boolean t) {
if (t && <warning descr="Dereference of 'fff()' may produce 'java.lang.NullPointerException'">fff()</warning>.length == 1) {
if (t && <warning descr="Dereference of 'fff()' may produce 'NullPointerException'">fff()</warning>.length == 1) {
return 0;
}
return 1;
@@ -32,7 +32,7 @@ class Test {
void testTwoObj(boolean b, Object o1, Object o2) {
if((b && o1 instanceof String) || o2 instanceof String) {
String x = (<warning descr="Casting '(b ? o1 : o2)' to 'String' may produce 'java.lang.ClassCastException'">String</warning>)(b ? o1 : o2);
String x = (<warning descr="Casting '(b ? o1 : o2)' to 'String' may produce 'ClassCastException'">String</warning>)(b ? o1 : o2);
}
}
@@ -10,17 +10,17 @@ class BrokenAlignment {
}
data = new Data(null, <warning descr="Passing 'null' argument to non-annotated parameter">null</warning>);
System.out.println(data.getText().<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.getText().<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
if (data.getInner() != null) {
System.out.println(data.getInner().hashCode());
System.out.println(data.getInner().getText().<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.getInner().getText().<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
if (data.getInner() != null) {
System.out.println(data.getInner().hashCode());
}
data = new Data(null, <warning descr="Passing 'null' argument to non-annotated parameter">null</warning>);
System.out.println(data.getInner().<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.getInner().<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -36,7 +36,7 @@ class BrokenAlignment {
System.out.println(data.getInnerOverridden().hashCode());
}
if (data.something() != null) {
System.out.println(data.something().<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.something().<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -7,17 +7,17 @@ class BrokenAlignment {
}
data = new Data(null, <warning descr="Passing 'null' argument to non-annotated parameter">null</warning>);
System.out.println(data.text.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.text.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
if (data.inner != null) {
System.out.println(data.inner.hashCode());
System.out.println(data.inner.text.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.inner.text.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
if (<warning descr="Condition 'data.inner != null' is always 'true'">data.inner != null</warning>) {
System.out.println(data.inner.hashCode());
}
data = new Data(null, <warning descr="Passing 'null' argument to non-annotated parameter">null</warning>);
System.out.println(data.inner.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.inner.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -8,7 +8,7 @@ class Bar3 {
public void foo(@Nullable Object element) {
final String elementType = element != null ? element.toString() : null;
if (elementType == nullableString()) {
System.out.println(element.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(element.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -8,7 +8,7 @@ class Bar3 {
public void foo(@Nullable Object element) {
final String elementType = element != null ? element.toString() : null;
if (elementType == someString()) {
System.out.println(element.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(element.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -40,7 +40,7 @@ class Bar3 {
System.out.println(first.hashCode());
}
if (first == null) {
System.out.println(first.<warning descr="Method invocation 'hashCode' will produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(first.<warning descr="Method invocation 'hashCode' will produce 'NullPointerException'">hashCode</warning>());
}
}
}
@@ -24,7 +24,7 @@ class InitializerTest {
}
}
static final String XYZ = ABC.<warning descr="Method invocation 'toLowerCase' may produce 'java.lang.NullPointerException'">toLowerCase</warning>();
static final String XYZ = ABC.<warning descr="Method invocation 'toLowerCase' may produce 'NullPointerException'">toLowerCase</warning>();
static {
new InitializerTest(); // INITIALIZED is not initialized yet here
@@ -9,9 +9,9 @@ abstract class Bar<T> {
Bar<@NotNull String> bNotNull,
String str) {
final int length = bNullable.getNN(str).length();
final int length1 = bNullable.getNullable(str).<warning descr="Method invocation 'length' may produce 'java.lang.NullPointerException'">length</warning>();
final int length1 = bNullable.getNullable(str).<warning descr="Method invocation 'length' may produce 'NullPointerException'">length</warning>();
final int length2 = bNotNull.getNN(str).length();
final int length3 = bNotNull.getNullable(str).<warning descr="Method invocation 'length' may produce 'java.lang.NullPointerException'">length</warning>();
final int length3 = bNotNull.getNullable(str).<warning descr="Method invocation 'length' may produce 'NullPointerException'">length</warning>();
}
}
@@ -8,7 +8,7 @@ class Doo {
void foo(@Nullable String s) {
if (isMaybeNotNull(s)) {
System.out.println(s.<warning descr="Method invocation 'length' may produce 'java.lang.NullPointerException'">length</warning>());
System.out.println(s.<warning descr="Method invocation 'length' may produce 'NullPointerException'">length</warning>());
}
}
@@ -8,7 +8,7 @@ class TestCase {
String s = normalizeSpace(unknown()).trim();
String s3 = normalizeSpaceInverted(unknown()).trim();
String s4 = normalizeSpace(null).<warning descr="Method invocation 'trim' will produce 'java.lang.NullPointerException'">trim</warning>();
String s4 = normalizeSpace(null).<warning descr="Method invocation 'trim' will produce 'NullPointerException'">trim</warning>();
}
public static native String unknown();
@@ -4,7 +4,7 @@ import org.jetbrains.annotations.*;
class ContractReturnValues {
void testRequireNonNull() {
System.out.println(Objects.requireNonNull(nullable()).trim());
System.out.println(nullable().<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(nullable().<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>());
}
void test(StringBuilder sb) {
@@ -116,7 +116,7 @@ class ContractReturnValues {
System.out.println("Is Empty");
} else {
// In this case system can produce NullPointerException, because Objects.toString(String str) calls methods String.valueOf()
System.out.println(text.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(text.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>());
}
}
}
@@ -18,7 +18,7 @@ class Test2 {
static void test(Project project) {
Version version = getVersion(getInstance(project).getProjectSdk());
System.out.println(version.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(version.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -71,7 +71,7 @@ class CovariantReturn {
void testCast(Super s) {
if(s instanceof Sub) {
Integer i = (<warning descr="Casting 's.get()' to 'Integer' may produce 'java.lang.ClassCastException'">Integer</warning>)s.get();
Integer i = (<warning descr="Casting 's.get()' to 'Integer' may produce 'ClassCastException'">Integer</warning>)s.get();
System.out.println(i);
}
}
@@ -4,7 +4,7 @@ class X {
new Runnable() {
public void run() { }
};
Intf a = (<warning descr="Casting 'result' to 'Intf' may produce 'java.lang.ClassCastException'">Intf</warning>)result;
Intf a = (<warning descr="Casting 'result' to 'Intf' may produce 'ClassCastException'">Intf</warning>)result;
}
public static void main2(Object result) {
@@ -18,7 +18,7 @@ class Test {
} else if ("Queues".equals(parentName)) {
System.out.println(parentNode.toString());
}
System.out.println(parentNode.<warning descr="Method invocation 'toString' may produce 'java.lang.NullPointerException'">toString</warning>());
System.out.println(parentNode.<warning descr="Method invocation 'toString' may produce 'NullPointerException'">toString</warning>());
}
public static int foo(String a, String b) {
@@ -29,7 +29,7 @@ class Main {
}
@NotNull
private Object test7(@NotNull Object defVal, @Nullable final Object val) {
if (val.<warning descr="Method invocation 'equals' may produce 'java.lang.NullPointerException'">equals</warning>(defVal)) {
if (val.<warning descr="Method invocation 'equals' may produce 'NullPointerException'">equals</warning>(defVal)) {
return defVal;
}
return defVal;
@@ -9,7 +9,7 @@ class Zoo2 {
new Runnable() {
int hc = foo.hashCode();
int hc2 = bar.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>();
int hc2 = bar.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>();
public void run() {
}
@@ -1,6 +1,6 @@
class Foo {
String field;
String field2 = field.<warning descr="Method invocation 'substring' will produce 'java.lang.NullPointerException'">substring</warning>(1);
String field2 = field.<warning descr="Method invocation 'substring' will produce 'NullPointerException'">substring</warning>(1);
int field3 = field2.length();
Runnable r = new Runnable() {
public void run() {
@@ -40,7 +40,7 @@ class FieldInitLoop {
static String bar() {
// bar() is invoked from ABC initializer before XYZ initializer
return XYZ.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>();
return XYZ.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>();
}
}
@@ -74,7 +74,7 @@ class FieldInitNoLoop {
class NonFinalNotInitialized {
String x;
String y = x.<warning descr="Method invocation 'trim' will produce 'java.lang.NullPointerException'">trim</warning>();
String y = x.<warning descr="Method invocation 'trim' will produce 'NullPointerException'">trim</warning>();
}
class NonFinalInitialized {
@@ -87,7 +87,7 @@ class NonFinalInitialized {
class NonFinalAssignedInside {
String x;
String y = x.<warning descr="Method invocation 'trim' will produce 'java.lang.NullPointerException'">trim</warning>()+(x = " foo ").trim();
String y = x.<warning descr="Method invocation 'trim' will produce 'NullPointerException'">trim</warning>()+(x = " foo ").trim();
String z = x.trim();
}
@@ -23,7 +23,7 @@ class Test {
private static final Object CONST = getNull();
public static void test() {
System.out.println(CONST.<warning descr="Method invocation 'toString' may produce 'java.lang.NullPointerException'">toString</warning>());
System.out.println(CONST.<warning descr="Method invocation 'toString' may produce 'NullPointerException'">toString</warning>());
}
}
@@ -95,7 +95,7 @@ class Test6 extends BadSuper {
}
public Integer someLength() {
return something.<warning descr="Method invocation 'length' may produce 'java.lang.NullPointerException'">length</warning>();
return something.<warning descr="Method invocation 'length' may produce 'NullPointerException'">length</warning>();
}
protected void overrideableMethod() {
@@ -107,7 +107,7 @@ class Test7 extends BadSuper {
private final String something = new String("something");
protected void overrideableMethod() {
something.<warning descr="Method invocation 'length' may produce 'java.lang.NullPointerException'">length</warning>();
something.<warning descr="Method invocation 'length' may produce 'NullPointerException'">length</warning>();
}
}
@@ -124,6 +124,6 @@ class Test8 {
void other() {
System.out.println(s.hashCode());
System.out.println(s2.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(s2.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -21,7 +21,7 @@ class Doo {
int foo() {
if (<warning descr="Condition 'myB != null' is always 'true'">myB != null</warning> &&
myA.<warning descr="Method invocation 'equals' may produce 'java.lang.NullPointerException'">equals</warning>(myB)) {
myA.<warning descr="Method invocation 'equals' may produce 'NullPointerException'">equals</warning>(myB)) {
return 2;
}
@@ -24,7 +24,7 @@ class Doo {
if (getMethod() == null && !pureSomething()) {
return;
} else {
System.out.println(getMethod().<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(getMethod().<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -5,7 +5,7 @@ class Goo {
void test() {
Object category = permission.getCategory();
System.out.println(category.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(category.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -2,7 +2,7 @@ import foo.*;
class IgnoreNullabilityOnPrimitiveCast {
private static int map(@Nullable int[] mapping, int idx) {
return <warning descr="Array access 'mapping[idx]' may produce 'java.lang.NullPointerException'">mapping[idx]</warning>;
return <warning descr="Array access 'mapping[idx]' may produce 'NullPointerException'">mapping[idx]</warning>;
}
static final int TEST;
@@ -1,7 +1,7 @@
class Foo {
String field;
String field2;
int hash = field.<warning descr="Method invocation 'hashCode' will produce 'java.lang.NullPointerException'">hashCode</warning>();
int hash = field.<warning descr="Method invocation 'hashCode' will produce 'NullPointerException'">hashCode</warning>();
Foo(String f2) {
field2 = f2;
@@ -23,7 +23,7 @@ class Foo {
Instrumented() {
System.out.println(s1.length()
+s2.<warning descr="Method invocation 'length' will produce 'java.lang.NullPointerException'">length</warning>());
+s2.<warning descr="Method invocation 'length' will produce 'NullPointerException'">length</warning>());
}
}
@@ -32,8 +32,8 @@ class Foo {
String s2 = null;
NotInstrumented() {
System.out.println(s1.<warning descr="Method invocation 'length' will produce 'java.lang.NullPointerException'">length</warning>()
+s2.<warning descr="Method invocation 'length' will produce 'java.lang.NullPointerException'">length</warning>());
System.out.println(s1.<warning descr="Method invocation 'length' will produce 'NullPointerException'">length</warning>()
+s2.<warning descr="Method invocation 'length' will produce 'NullPointerException'">length</warning>());
}
}
}
@@ -4,7 +4,7 @@ class Foo {
void test2(final @Nullable Object @NotNull[]@NotNull[] values) {
for (final Object[] line : values) {
for (final Object item : line) {
System.out.println(item.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(item.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
}
@@ -6,6 +6,6 @@ class InnerClassTest {
public static void main(String[] args) {
InnerClassTest test = Math.random() > 0.5 ? new InnerClassTest() : null;
System.out.println(test.new <warning descr="Inner class construction may produce 'java.lang.NullPointerException'">Inner</warning>());
System.out.println(test.new <warning descr="Inner class construction may produce 'NullPointerException'">Inner</warning>());
}
}
@@ -15,7 +15,7 @@ class Test {
}
class Local {
void s(@Nullable String s) {
final int i = s.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>();
final int i = s.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>();
}
}
}
@@ -14,7 +14,7 @@ class X {
}
void foo3(String d1, String d2) {
if(d1 == null | d1.<warning descr="Method invocation 'compareTo' may produce 'java.lang.NullPointerException'">compareTo</warning>(d2) > 0)
if(d1 == null | d1.<warning descr="Method invocation 'compareTo' may produce 'NullPointerException'">compareTo</warning>(d2) > 0)
System.out.println("impossible");
}
}
@@ -198,8 +198,8 @@ public class LongRangeBasics {
System.out.println(s2.trim());
}
if(code == 0) {
System.out.println(s1.<warning descr="Method invocation 'trim' will produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(s2.<warning descr="Method invocation 'trim' will produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(s1.<warning descr="Method invocation 'trim' will produce 'NullPointerException'">trim</warning>());
System.out.println(s2.<warning descr="Method invocation 'trim' will produce 'NullPointerException'">trim</warning>());
}
}
@@ -10,17 +10,17 @@ class MapUpdateInlining {
}
void testValue(Map<String, @NotNull String> map) {
System.out.println(map.computeIfAbsent("foo", k -> null).<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(map.computeIfAbsent("foo", k -> null).<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>());
System.out.println(map.computeIfAbsent("foo", k -> "bar").trim());
}
void testNullable(Map<String, @Nullable String> map) {
System.out.println(map.computeIfAbsent("foo", k -> null).<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(map.computeIfAbsent("foo", k -> null).<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>());
System.out.println(map.computeIfAbsent("foo", k -> "bar").trim());
}
void testPresent(Map<String, @Nullable String> map, String key) {
System.out.println(map.computeIfPresent(key, (k, v) -> v+"xyz").<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(map.computeIfPresent(key, (k, v) -> v+"xyz").<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>());
String res1 = map.computeIfPresent("foo", (k, v) -> <warning descr="Condition 'v == null' is always 'false'">v == null</warning> ? "oops" : k);
String res = map.computeIfPresent(key, (k, v) -> k.isEmpty() ? "foo" : "bar");
if(<warning descr="Condition 'res != null && res.equals(\"x\")' is always 'false'">res != null && <warning descr="Condition 'res.equals(\"x\")' is always 'false' when reached">res.equals("x")</warning></warning>) {
@@ -6,7 +6,7 @@ class MergedInitializerAndConstructor {
private Collection<Object> collection2 = null;
public Test1() {
collection2.<warning descr="Method invocation 'add' will produce 'java.lang.NullPointerException'">add</warning>("");
collection2.<warning descr="Method invocation 'add' will produce 'NullPointerException'">add</warning>("");
}
}
@@ -18,7 +18,7 @@ class MergedInitializerAndConstructor {
}
{
collection2.<warning descr="Method invocation 'add' will produce 'java.lang.NullPointerException'">add</warning>(""); //<- warning here
collection2.<warning descr="Method invocation 'add' will produce 'NullPointerException'">add</warning>(""); //<- warning here
}
}
@@ -27,7 +27,7 @@ class MergedInitializerAndConstructor {
public Test3(String s) {
super();
collection2.<warning descr="Method invocation 'add' will produce 'java.lang.NullPointerException'">add</warning>(s);
collection2.<warning descr="Method invocation 'add' will produce 'NullPointerException'">add</warning>(s);
}
}
@@ -12,7 +12,7 @@ class MethodRef {
}
public static void useGuavaListsTransform_method_ref(List<@foo.Nullable String> list) {
System.out.println(transform(list, s -> s.<warning descr="Method invocation 'length' may produce 'java.lang.NullPointerException'">length</warning>()));
System.out.println(transform(list, <warning descr="Method reference invocation 'String::length' may produce 'java.lang.NullPointerException'">String::length</warning>));
System.out.println(transform(list, s -> s.<warning descr="Method invocation 'length' may produce 'NullPointerException'">length</warning>()));
System.out.println(transform(list, <warning descr="Method reference invocation 'String::length' may produce 'NullPointerException'">String::length</warning>));
}
}
@@ -15,7 +15,7 @@ public class MethodReferenceConstantValue {
}
public void test(Optional<String> opt) {
X x = <warning descr="Method reference invocation 'MethodReferenceConstantValue::strangeMethod' may produce 'java.lang.NullPointerException'"><warning descr="Method reference result is always 'false'">MethodReferenceConstantValue::strangeMethod</warning></warning>;
X x = <warning descr="Method reference invocation 'MethodReferenceConstantValue::strangeMethod' may produce 'NullPointerException'"><warning descr="Method reference result is always 'false'">MethodReferenceConstantValue::strangeMethod</warning></warning>;
Boolean aBoolean = opt.map(<warning descr="Method reference result is always 'false'">this::strangeMethod</warning>)
.map(<warning descr="Method reference result is always 'true'">Objects::nonNull</warning>)
.map(<warning descr="Method reference result is always 'false'">Objects::isNull</warning>)
@@ -3,7 +3,7 @@ import org.jetbrains.annotations.Nullable;
class BrokenAlignment {
{
Runnable t = <warning descr="Dereference of 'getString()' may produce 'java.lang.NullPointerException'">getString()</warning>::length;
Runnable t = <warning descr="Dereference of 'getString()' may produce 'NullPointerException'">getString()</warning>::length;
Runnable t2 = BrokenAlignment::getStringStatic;
}
@@ -37,10 +37,10 @@ public class MutabilityInferred {
}
void test() {
getListNullOrImmutable(0).<warning descr="Immutable object is modified"><warning descr="Method invocation 'add' may produce 'java.lang.NullPointerException'">add</warning></warning>("a");
getListNullOrImmutable(0).<warning descr="Immutable object is modified"><warning descr="Method invocation 'add' may produce 'NullPointerException'">add</warning></warning>("a");
getListImmutable(0).<warning descr="Immutable object is modified">add</warning>("b");
getListImmutableOrMutable(0).add("c");
getListVar(false).<warning descr="Method invocation 'add' may produce 'java.lang.NullPointerException'">add</warning>("d");
getListVar(false).<warning descr="Method invocation 'add' may produce 'NullPointerException'">add</warning>("d");
getMap().<warning descr="Immutable object is modified">put</warning>("baz", "qux");
getEntry().<warning descr="Immutable object is modified">setValue</warning>("qux");
}
@@ -20,7 +20,7 @@ class Foo {
if (data != null) {
return;
}
System.out.println(data.<warning descr="Method invocation 'hashCode' will produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.<warning descr="Method invocation 'hashCode' will produce 'NullPointerException'">hashCode</warning>());
System.out.println(data.hashCode());
}
@@ -20,17 +20,17 @@ class Foo {
if (data != null) {
return;
}
System.out.println(data.<warning descr="Method invocation 'hashCode' will produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.<warning descr="Method invocation 'hashCode' will produce 'NullPointerException'">hashCode</warning>());
System.out.println(data.hashCode());
}
void warnWhenNotCheckedOnce(Foo f) {
System.out.println(f.data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(f.data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
System.out.println(f.data.hashCode());
}
void warnWhenNotCheckedThisOnce() {
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
System.out.println(data.hashCode());
}
@@ -5,7 +5,7 @@ class Foo {
void checkNotNullAndUse(Foo f) {
if (f.data != null) {
System.out.println(f.data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(f.data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -13,23 +13,23 @@ class Foo {
if (f.data == null) {
return;
}
System.out.println(f.data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(f.data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
void warnWhenWrongCheck() {
if (data != null) {
return;
}
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
void warnWhenNotChecked(Foo f) {
System.out.println(f.data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(f.data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
void warnWhenNotCheckedThis() {
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
void dontWarnWhenDoubleChecked(Foo f) {
@@ -39,7 +39,7 @@ class Foo {
if (f.data == null) {
return;
}
System.out.println(f.data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(f.data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
void dontWarnWhenDoubleChecked_This_Synchronized() {
@@ -51,18 +51,18 @@ class Foo {
return;
}
}
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
void dontWarnWhenDoubleChecked_This_WithMethodCall() {
if (data == null) {
return;
}
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
if (data == null) {
return;
}
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(data.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -2,11 +2,11 @@ class DataFlowBug {
public int add2(Object left, Object right) {
if (left != null && !(left instanceof String)) {
return ((<warning descr="Casting 'left' to 'String' may produce 'java.lang.ClassCastException'">String</warning>) left).length();
return ((<warning descr="Casting 'left' to 'String' may produce 'ClassCastException'">String</warning>) left).length();
}
if (!(right instanceof String)) {
return ((<warning descr="Casting 'right' to 'String' may produce 'java.lang.ClassCastException'">String</warning>) right).length();
return ((<warning descr="Casting 'right' to 'String' may produce 'ClassCastException'">String</warning>) right).length();
}
return 2;
@@ -6,7 +6,7 @@ abstract class Node {
Node getRoot() {
Node node = this;
while(node.<warning descr="Method invocation 'getName' may produce 'java.lang.NullPointerException'">getName</warning>() == null) {
while(node.<warning descr="Method invocation 'getName' may produce 'NullPointerException'">getName</warning>() == null) {
node = node.getParent();
}
return node;
@@ -26,7 +26,7 @@ class GetUnknownTest {
if (isApplicable) {
// Dubious warning: message.getHeader() is not annotated, but assigned to nullable field; should we consider the result as nullable?
System.out.println(field.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(field.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -10,7 +10,7 @@ class NullabilityBasics {
if (isEmpty(x) && Math.random() > 0.5) {
return;
}
System.out.println(x.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(x.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>());
}
@Nullable String getNullable() {
@@ -26,6 +26,6 @@ class NullabilityBasics {
if (x == null) {
System.out.println("x is null!");
}
System.out.println(x.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(x.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>());
}
}
@@ -18,6 +18,6 @@ class DDD {
}
int test() {
return new DDD().field.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>();
return new DDD().field.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>();
}
}
@@ -6,19 +6,19 @@ import java.util.List;
class Foo {
void foo1(List<Integer> list) {
for (@Nullable Integer i : list) {
System.out.println(i.<warning descr="Method invocation 'intValue' may produce 'java.lang.NullPointerException'">intValue</warning>());
System.out.println(i.<warning descr="Method invocation 'intValue' may produce 'NullPointerException'">intValue</warning>());
}
}
void foo2(List<@Nullable Integer> list) {
for (@Nullable Integer i : list) {
System.out.println(i.<warning descr="Method invocation 'intValue' may produce 'java.lang.NullPointerException'">intValue</warning>());
System.out.println(i.<warning descr="Method invocation 'intValue' may produce 'NullPointerException'">intValue</warning>());
}
}
void foo3() {
List<@Nullable String> list = new ArrayList<>();
list.add(null);
for (String s : list) {
System.out.println(s.<warning descr="Method invocation 'length' may produce 'java.lang.NullPointerException'">length</warning>());
System.out.println(s.<warning descr="Method invocation 'length' may produce 'NullPointerException'">length</warning>());
}
}
@@ -56,7 +56,7 @@ public class OptionalInlining {
void testDeref(Optional<String> opt) {
if (opt == null) {
System.out.println(opt.<warning descr="Method invocation 'orElse' will produce 'java.lang.NullPointerException'">orElse</warning>("qq"));
System.out.println(opt.<warning descr="Method invocation 'orElse' will produce 'NullPointerException'">orElse</warning>("qq"));
}
}
@@ -124,7 +124,7 @@ public class OptionalInlining {
// n instanceof Integer -> n is not null -> xyz was not null -> safe to dereference
System.out.println(xyz.trim());
}
xyz.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>();
xyz.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>();
//opt.map(x -> x.isEmpty() ? "foo" : "bar").filter(x -> x.isEmpty()).ifPresent(x -> System.out.println(x));
}
@@ -150,7 +150,7 @@ public class OptionalInlining {
// n instanceof Integer -> n is not null -> xyz was not null -> safe to dereference
System.out.println(xyz.trim());
}
xyz.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>();
xyz.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>();
}
void testFlatMap(Optional<String> opt) {
@@ -227,7 +227,7 @@ public class OptionalInlining {
.map(h -> h.s)
.isPresent()</warning>;
opt.filter(h -> h.s == null).map(h -> h.s.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>()).ifPresent(System.out::println);
opt.filter(h -> h.s == null).map(h -> h.s.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>()).ifPresent(System.out::println);
}
private List<Integer> tryGetFromCache(List<String> keys, Map<String, Optional<Integer>> cache) {
@@ -29,13 +29,13 @@ class Test {
// IDEA-188536
public void test(Long value1, Long value2, Long value3) {
// value1 is assumed to be nullable as passed to ofNullable
long l1 = <warning descr="Unboxing of 'Optional.ofNullable(value1).orElse(null)' may produce 'java.lang.NullPointerException'">Optional.ofNullable(value1).orElse(null)</warning>;
long l1 = <warning descr="Unboxing of 'Optional.ofNullable(value1).orElse(null)' may produce 'NullPointerException'">Optional.ofNullable(value1).orElse(null)</warning>;
// value2 is assumed to be notnull as just dereferenced
long l2 = value2;
// value3 is assumed to be nullable as passed to ofNullable
long l3 = Optional.ofNullable(value3).orElse(-1L);
long l3a = <warning descr="Unboxing of 'value3' may produce 'java.lang.NullPointerException'">value3</warning>;
long l3a = <warning descr="Unboxing of 'value3' may produce 'NullPointerException'">value3</warning>;
}
}
@@ -4,15 +4,15 @@ class Test {
Object o;
void field() {
o.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>();
o.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>();
}
void parameter(Object o) {
o.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>();
o.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>();
}
void callUnknownMethod() {
unknownObject().<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>();
unknownObject().<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>();
}
void callNotNullMethod() {
@@ -26,7 +26,7 @@ class Impl1 extends SomeSuper {
@Override
public void run() {
if (Impl1.this.o2 != null) {
System.out.println(Impl2.this.o2.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(Impl2.this.o2.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
};
@@ -11,11 +11,11 @@ class ThisAsVariable {
void checkPoll(Queue<String> queue) {
if(!queue.isEmpty()) {
System.out.println(queue.poll().length() + queue.poll().<warning descr="Method invocation 'length' may produce 'java.lang.NullPointerException'">length</warning>());
System.out.println(queue.poll().length() + queue.poll().<warning descr="Method invocation 'length' may produce 'NullPointerException'">length</warning>());
}
}
void notCheck(Queue<String> queue) {
System.out.println(queue.peek().<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(queue.peek().<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>());
}
}
@@ -10,7 +10,7 @@ class Test {
void test() {
doSmth(RES);
doSmth(<weak_warning descr="Value 'xyz' is always 'null'">xyz</weak_warning>);
System.out.println(process(<weak_warning descr="Value 'xyz' is always 'null'">xyz</weak_warning>).<warning descr="Method invocation 'hashCode' will produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(process(<weak_warning descr="Value 'xyz' is always 'null'">xyz</weak_warning>).<warning descr="Method invocation 'hashCode' will produce 'NullPointerException'">hashCode</warning>());
Integer x = TEST;
System.out.println(TEST);
System.out.println(x);
@@ -20,7 +20,7 @@ class Test {
public void testDontReplaceQualifierWithNull(Object bar) {
if (bar == null) {
bar.<warning descr="Method invocation 'hashCode' will produce 'java.lang.NullPointerException'">hashCode</warning>();
bar.<warning descr="Method invocation 'hashCode' will produce 'NullPointerException'">hashCode</warning>();
}
}
@@ -39,7 +39,7 @@ class TestNewObjects {
if(ConstantHolder.X.str != null && ConstantHolder.X.str.isEmpty()) {
System.out.println("ok");
}
if(ConstantHolder.X.str != null && ConstantHolder.Y.str.<warning descr="Method invocation 'isEmpty' may produce 'java.lang.NullPointerException'">isEmpty</warning>()) {
if(ConstantHolder.X.str != null && ConstantHolder.Y.str.<warning descr="Method invocation 'isEmpty' may produce 'NullPointerException'">isEmpty</warning>()) {
System.out.println("possible NPE");
}
}
@@ -69,7 +69,7 @@ class TestNewObjects {
System.out.println(ConstantHolder.ARRAY[0].hashCode());
}
if(ConstantHolder.ARRAY2[0] != null) {
System.out.println(ConstantHolder.ARRAY[0].<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(ConstantHolder.ARRAY[0].<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
}
@@ -22,17 +22,17 @@ public class StreamComparatorInlining {
list.stream().map(this::process).max(Comparator.nullsFirst(Comparator.naturalOrder()));
list.stream().map(this::process).max(Comparator.nullsFirst(Comparator.comparing(String::length)));
list.stream().map(this::process).min(Comparator.nullsLast(Comparator.comparing(String::length)));
list.stream().map(this::process).min(Comparator.comparing(<warning descr="Method reference invocation 'String::length' may produce 'java.lang.NullPointerException'">String::length</warning>));
list.stream().map(this::process).min(Comparator.comparing(<warning descr="Method reference invocation 'String::length' may produce 'java.lang.NullPointerException'">String::length</warning>).reversed());
list.stream().map(this::process).min(Comparator.comparing(<warning descr="Method reference invocation 'String::length' may produce 'NullPointerException'">String::length</warning>));
list.stream().map(this::process).min(Comparator.comparing(<warning descr="Method reference invocation 'String::length' may produce 'NullPointerException'">String::length</warning>).reversed());
}
void testSorted(List<String> list) {
list.stream().sorted(Comparator.comparing(<warning descr="Function may return null, but it's not allowed here">this::process</warning>, Comparator.reverseOrder())).collect(Collectors.toList());
list.stream().sorted(Comparator.comparing(<warning descr="Function may return null, but it's not allowed here">this::process</warning>)).collect(Collectors.toList());
list.stream().sorted(Comparator.comparing(this::process, Comparator.nullsFirst(Comparator.naturalOrder()))).collect(Collectors.toList());
list.stream().map(this::process).sorted(Comparator.comparing(<warning descr="Method reference invocation 'String::length' may produce 'java.lang.NullPointerException'">String::length</warning>)).collect(Collectors.toList());
list.stream().map(this::process).sorted(Comparator.comparing(<warning descr="Method reference invocation 'String::length' may produce 'NullPointerException'">String::length</warning>)).collect(Collectors.toList());
list.stream().map(<warning descr="Function may return null, but it's not allowed here">this::process</warning>).sorted().collect(Collectors.toList());
list.stream().map(this::process).sorted(<warning descr="Method reference invocation 'String::compareToIgnoreCase' may produce 'java.lang.NullPointerException'">String::compareToIgnoreCase</warning>).collect(Collectors.toList());
list.stream().map(this::process).sorted(<warning descr="Method reference invocation 'String::compareToIgnoreCase' may produce 'NullPointerException'">String::compareToIgnoreCase</warning>).collect(Collectors.toList());
list.stream().map(<warning descr="Function may return null, but it's not allowed here">this::process</warning>).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList());
}
@@ -12,11 +12,11 @@ public class StreamInlining {
list.stream().flatMap(<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>).forEach(System.out::println);
list.stream().filter(x -> x != null).forEach(<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>);
List<String> l = null;
l.<warning descr="Method invocation 'stream' will produce 'java.lang.NullPointerException'">stream</warning>().count();
l.<warning descr="Method invocation 'stream' will produce 'NullPointerException'">stream</warning>().count();
int[] arr = null;
Arrays.stream(<warning descr="Argument 'arr' might be null">arr</warning>).count();
Stream<String> stream = null;
stream.<warning descr="Method invocation 'filter' will produce 'java.lang.NullPointerException'">filter</warning>(x -> x != null).forEach(System.out::println);
stream.<warning descr="Method invocation 'filter' will produce 'NullPointerException'">filter</warning>(x -> x != null).forEach(System.out::println);
}
void testMethodRef(List<String> list, int[] data) {
@@ -26,7 +26,7 @@ public class StreamInlining {
if(<warning descr="Condition 'Arrays.stream(data).mapToObj(int[]::new).anyMatch(x -> x == null)' is always 'false'">Arrays.stream(data).mapToObj(int[]::new).anyMatch(x -> <warning descr="Condition 'x == null' is always 'false'">x == null</warning>)</warning>) {
System.out.println("never");
}
list.stream().filter(Objects::isNull).map(<warning descr="Method reference invocation 'String::trim' may produce 'java.lang.NullPointerException'">String::trim</warning>).forEach(System.out::println);
list.stream().filter(Objects::isNull).map(<warning descr="Method reference invocation 'String::trim' may produce 'NullPointerException'">String::trim</warning>).forEach(System.out::println);
if(<warning descr="Condition 'list.stream().filter(Objects::nonNull).anyMatch(x -> x == null)' is always 'false'">list.stream().filter(Objects::nonNull).anyMatch(x -> <warning descr="Condition 'x == null' is always 'false'">x == null</warning>)</warning>) {
System.out.println("never");
}
@@ -42,7 +42,7 @@ public class StreamInlining {
}
int hash(List<Holder> holders) {
return holders.stream().filter(h -> h.obj == null).mapToInt(h -> h.obj.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>()).sum();
return holders.stream().filter(h -> h.obj == null).mapToInt(h -> h.obj.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>()).sum();
}
void test2(int[] array) {
@@ -61,7 +61,7 @@ public class StreamInlining {
void testIsInstanceIncomplete(List<?> objects) {
IntStream is = objects.stream()
.filter(String.class::isInstance)
.mapToInt(x -> (<warning descr="Casting 'x' to 'Integer' may produce 'java.lang.ClassCastException'">Integer</warning>)x);
.mapToInt(x -> (<warning descr="Casting 'x' to 'Integer' may produce 'ClassCastException'">Integer</warning>)x);
objects.stream()
.filter(String.class::isInstance)
@@ -126,7 +126,7 @@ public class StreamInlining {
boolean flatMap(List<String> list, List<List<String>> ll) {
System.out.println(ll.stream().flatMap(l -> l.stream()).count());
return <warning descr="Result of 'list.stream().map(s -> s.isEmpty() ? null : s) .flatMap(s -> Stream.of(s, s.trim()) ...' is always 'false'">list.stream().map(s -> s.isEmpty() ? null : s)
.flatMap(s -> Stream.of(s, s.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>())
.flatMap(s -> Stream.of(s, s.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>())
.filter(r -> <warning descr="Condition 'r != null' is always 'true'">r != null</warning>))
.anyMatch(x -> <warning descr="Condition 'x == null' is always 'false'">x == null</warning>)</warning>;
}
@@ -31,7 +31,7 @@ class InspectionTest {
void testTernary(@Nullable String foo, X x) {
switch (foo == null ? X.A : x) {
case A:
System.out.println(foo.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(foo.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>());
break;
case B:
System.out.println(foo.trim());
@@ -3,7 +3,7 @@ import org.jetbrains.annotations.Nullable;
class BrokenAlignment {
void test(@Nullable String n) {
switch (<warning descr="Dereference of 'n' may produce 'java.lang.NullPointerException'">n</warning>) {
switch (<warning descr="Dereference of 'n' may produce 'NullPointerException'">n</warning>) {
}
}
@@ -9,11 +9,11 @@ class DataFlowBug {
public Object add(Object left, Object right) {
if (left != null && right != null && (left instanceof Date || right instanceof Date)) {
if (isNumberable(left)) {
return ((<warning descr="Casting 'right' to 'Date' may produce 'java.lang.ClassCastException'">Date</warning>) right).getTime();
return ((<warning descr="Casting 'right' to 'Date' may produce 'ClassCastException'">Date</warning>) right).getTime();
}
if (isNumberable(right)) {
return ((<warning descr="Casting 'left' to 'Date' may produce 'java.lang.ClassCastException'">Date</warning>) left).getTime();
return ((<warning descr="Casting 'left' to 'Date' may produce 'ClassCastException'">Date</warning>) left).getTime();
}
}
return new Object();
@@ -3,7 +3,7 @@ import org.jetbrains.annotations.Nullable;
class BrokenAlignment {
void test(@Nullable Object n) {
synchronized (<warning descr="Dereference of 'n' may produce 'java.lang.NullPointerException'">n</warning>) {
synchronized (<warning descr="Dereference of 'n' may produce 'NullPointerException'">n</warning>) {
}
}
@@ -93,7 +93,7 @@ class ThisAsVariable {
} else {
Runnable r = new Runnable() {
public void run() {
System.out.println(s.<warning descr="Method invocation 'trim' will produce 'java.lang.NullPointerException'">trim</warning>());
System.out.println(s.<warning descr="Method invocation 'trim' will produce 'NullPointerException'">trim</warning>());
}
};
r.run();
@@ -2,7 +2,7 @@ class DataFlowBug {
public void add2() {
try {
throw <warning descr="Dereference of 'null' will produce 'java.lang.NullPointerException'">null</warning>;
throw <warning descr="Dereference of 'null' will produce 'NullPointerException'">null</warning>;
} catch (Throwable e) {
if (e instanceof NullPointerException) {
return;
@@ -2,13 +2,13 @@ class DataFlowBug {
void foo() {
RuntimeException o = System.nanoTime() % 2 == 0 ? null : new RuntimeException();
throw <warning descr="Dereference of 'o' may produce 'java.lang.NullPointerException'">o</warning>;
throw <warning descr="Dereference of 'o' may produce 'NullPointerException'">o</warning>;
}
void foo2() {
try {
RuntimeException o = System.nanoTime() % 2 == 0 ? null : new RuntimeException();
throw <warning descr="Dereference of 'o' may produce 'java.lang.NullPointerException'">o</warning>;
throw <warning descr="Dereference of 'o' may produce 'NullPointerException'">o</warning>;
}
catch (RuntimeException exception) {
@@ -9,7 +9,7 @@ class Test {
void m1() throws Exception {
MyResourceProvider provider = null;
try (MyResource r = provider.<warning descr="Method invocation 'getResource' will produce 'java.lang.NullPointerException'">getResource</warning>()) {
try (MyResource r = provider.<warning descr="Method invocation 'getResource' will produce 'NullPointerException'">getResource</warning>()) {
System.out.println(r);
}
}
@@ -6,6 +6,6 @@ interface UnknownInterface {
class ImplWithNotNull implements UnknownInterface {
public void foo(@bar.NullableNick String s) {
System.out.println(s.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(s.<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -8,9 +8,9 @@ class Test {
}
void n(@org.jetbrains.annotations.Nullable Integer i) {
Unbx f = () -> <warning descr="Unboxing of 'i' may produce 'java.lang.NullPointerException'">i</warning>;
Unbx f = () -> <warning descr="Unboxing of 'i' may produce 'NullPointerException'">i</warning>;
Unbx f1 = () -> {
return <warning descr="Unboxing of 'i' may produce 'java.lang.NullPointerException'">i</warning>;
return <warning descr="Unboxing of 'i' may produce 'NullPointerException'">i</warning>;
};
}
@@ -7,7 +7,7 @@ class X {
Integer get();
}
I is = <warning descr="Use of 'X::m' would need unboxing which may produce 'java.lang.NullPointerException'">X::m</warning>;
I is = <warning descr="Use of 'X::m' would need unboxing which may produce 'NullPointerException'">X::m</warning>;
J j = X::m;
@org.jetbrains.annotations.Nullable
@@ -7,7 +7,7 @@ class Test {
private void method() {
if (timeStamp == null) {
timeStamp.<warning descr="Method invocation 'set' will produce 'java.lang.NullPointerException'">set</warning>(Calendar.getInstance().getTimeInMillis()); // not reported
timeStamp.<warning descr="Method invocation 'set' will produce 'NullPointerException'">set</warning>(Calendar.getInstance().getTimeInMillis()); // not reported
}
}
}
@@ -9,6 +9,6 @@ class Doo {
public void main(String[] args) {
Object method = getMethod();
System.out.println(getMethod().<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
System.out.println(getMethod().<warning descr="Method invocation 'hashCode' may produce 'NullPointerException'">hashCode</warning>());
}
}
@@ -8,7 +8,7 @@ class Some {
while (parent != null) {
parent = parent.getParentFile();
}
System.out.println(parent.<warning descr="Method invocation 'getName' will produce 'java.lang.NullPointerException'">getName</warning>());
System.out.println(parent.<warning descr="Method invocation 'getName' will produce 'NullPointerException'">getName</warning>());
}
System.out.println(file.getName());
}
@@ -1,6 +1,6 @@
class VoidIsAlwaysNull {
// IDEA-195506
void foo(Void p) {
System.out.println(p.<warning descr="Method invocation 'toString' will produce 'java.lang.NullPointerException'">toString</warning>());
System.out.println(p.<warning descr="Method invocation 'toString' will produce 'NullPointerException'">toString</warning>());
}
}
@@ -4,7 +4,7 @@ class Test {
public void foo() {
if (x != null) {
System.out.println(x.<warning descr="Method invocation 'substring' may produce 'java.lang.NullPointerException'">subs<caret>tring</warning>(1));
System.out.println(x.<warning descr="Method invocation 'substring' may produce 'NullPointerException'">subs<caret>tring</warning>(1));
}
}
}
@@ -13,7 +13,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -31,7 +31,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -49,7 +49,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -67,7 +67,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -85,7 +85,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -103,7 +103,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -121,7 +121,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -139,7 +139,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -157,7 +157,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -175,7 +175,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -193,7 +193,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -211,7 +211,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -229,7 +229,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -247,7 +247,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -265,7 +265,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -283,7 +283,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -301,7 +301,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -319,7 +319,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -337,7 +337,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -355,7 +355,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
@@ -373,7 +373,7 @@
</class>
</method>
<problem_class>Constant conditions &amp; exceptions</problem_class>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;.</description>
<description>Unboxing of &lt;code&gt;i&lt;/code&gt; may produce &lt;code&gt;NullPointerException&lt;/code&gt;.</description>
</problem>
<problem>
@@ -55,17 +55,17 @@ inspection.data.flow.use.computeifpresent.quickfix=Replace 'compute' with 'compu
configure.annotations.option=Configure annotations
#messages from dataflow inspection
dataflow.message.npe.method.invocation=Method invocation <code>#ref</code> #loc may produce <code>java.lang.NullPointerException</code>
dataflow.message.npe.method.invocation.sure=Method invocation <code>#ref</code> #loc will produce <code>java.lang.NullPointerException</code>
dataflow.message.npe.inner.class.construction=Inner class construction may produce <code>java.lang.NullPointerException</code>
dataflow.message.npe.inner.class.construction.sure=Inner class construction will produce <code>java.lang.NullPointerException</code>
dataflow.message.npe.methodref.invocation=Method reference invocation <code>#ref</code> #loc may produce <code>java.lang.NullPointerException</code>
dataflow.message.npe.array.access=Array access <code>#ref</code> #loc may produce <code>java.lang.NullPointerException</code>
dataflow.message.npe.array.access.sure=Array access <code>#ref</code> #loc will produce <code>java.lang.NullPointerException</code>
dataflow.message.npe.field.access.sure=Dereference of <code>#ref</code> #loc will produce <code>java.lang.NullPointerException</code>
dataflow.message.npe.field.access=Dereference of <code>#ref</code> #loc may produce <code>java.lang.NullPointerException</code>
dataflow.message.cce=Casting <code>{0}</code> to <code>#ref</code> #loc may produce <code>java.lang.ClassCastException</code>
dataflow.message.arraystore=Storing element of type <code>{0}</code> to array of <code>{1}</code> elements may produce <code>java.lang.ArrayStoreException</code>
dataflow.message.npe.method.invocation=Method invocation <code>#ref</code> #loc may produce <code>NullPointerException</code>
dataflow.message.npe.method.invocation.sure=Method invocation <code>#ref</code> #loc will produce <code>NullPointerException</code>
dataflow.message.npe.inner.class.construction=Inner class construction may produce <code>NullPointerException</code>
dataflow.message.npe.inner.class.construction.sure=Inner class construction will produce <code>NullPointerException</code>
dataflow.message.npe.methodref.invocation=Method reference invocation <code>#ref</code> #loc may produce <code>NullPointerException</code>
dataflow.message.npe.array.access=Array access <code>#ref</code> #loc may produce <code>NullPointerException</code>
dataflow.message.npe.array.access.sure=Array access <code>#ref</code> #loc will produce <code>NullPointerException</code>
dataflow.message.npe.field.access.sure=Dereference of <code>#ref</code> #loc will produce <code>NullPointerException</code>
dataflow.message.npe.field.access=Dereference of <code>#ref</code> #loc may produce <code>NullPointerException</code>
dataflow.message.cce=Casting <code>{0}</code> to <code>#ref</code> #loc may produce <code>ClassCastException</code>
dataflow.message.arraystore=Storing element of type <code>{0}</code> to array of <code>{1}</code> elements may produce <code>ArrayStoreException</code>
dataflow.message.redundant.instanceof=Condition <code>#ref</code> #loc is redundant and can be replaced with a null check
dataflow.message.contract.fail=The call to '#ref' always fails, according to its method contracts
dataflow.message.contract.fail.index=The call to '#ref' always fails as index is out of bounds
@@ -87,8 +87,8 @@ dataflow.message.return.nullable.from.notnull=Expression <code>#ref</code> might
dataflow.message.return.null.from.notnullable=<code>null</code> is returned by the method which is not declared as @{0}
dataflow.message.return.nullable.from.notnullable=Expression <code>#ref</code> might evaluate to null but is returned by the method which is not declared as @{0}
dataflow.message.return.nullable.from.notnull.function=Function may return null, but it's not allowed here
dataflow.message.unboxing=Unboxing of <code>#ref</code> #loc may produce <code>java.lang.NullPointerException</code>
dataflow.message.unboxing.method.reference=Use of <code>#ref</code> #loc would need unboxing which may produce <code>java.lang.NullPointerException</code>
dataflow.message.unboxing=Unboxing of <code>#ref</code> #loc may produce <code>NullPointerException</code>
dataflow.message.unboxing.method.reference=Use of <code>#ref</code> #loc would need unboxing which may produce <code>NullPointerException</code>
dataflow.too.complex=Method <code>#ref</code> is too complex to analyze by data flow algorithm
dataflow.too.complex.class=Class initializer is too complex to analyze by data flow algorithm
dataflow.method.fails.with.null.argument=Method will throw an exception when parameter is null