mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
51 lines
1.0 KiB
Java
51 lines
1.0 KiB
Java
import org.jetbrains.annotations.*;
|
|
|
|
class Test {
|
|
enum MyEnum {A, B, C}
|
|
|
|
void test(MyEnum x) {
|
|
String s = null;
|
|
if (x == MyEnum.A) {
|
|
s = "A";
|
|
}
|
|
else if (x == MyEnum.B) {
|
|
s = "B";
|
|
}
|
|
else if (x == MyEnum.C) {
|
|
s = "C";
|
|
}
|
|
System.out.println(s.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>()); // reachable if x is null
|
|
}
|
|
|
|
void test1(@NotNull MyEnum x) {
|
|
String s = null;
|
|
if (x == MyEnum.A) {
|
|
s = "A";
|
|
}
|
|
else if (x == MyEnum.B) {
|
|
s = "B";
|
|
}
|
|
else if (x == MyEnum.C) {
|
|
s = "C";
|
|
}
|
|
System.out.println(s.trim()); // ephemerably reachable
|
|
}
|
|
|
|
void test2(@NotNull MyEnum x) {
|
|
String s = null;
|
|
if (x == MyEnum.A) {
|
|
s = "A";
|
|
}
|
|
else if (x == MyEnum.B) {
|
|
s = "B";
|
|
}
|
|
else if (x == MyEnum.C) {
|
|
s = "C";
|
|
}
|
|
if (s == null) {
|
|
System.out.println("Incompatible class change!");
|
|
return;
|
|
}
|
|
System.out.println(s.trim());
|
|
}
|
|
} |