mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-20 20:45:15 +07:00
22 lines
528 B
Java
22 lines
528 B
Java
class Test {
|
|
static class MyResource implements AutoCloseable {
|
|
@Override public void close() { }
|
|
}
|
|
|
|
interface MyResourceProvider {
|
|
MyResource getResource();
|
|
}
|
|
|
|
void m1() throws Exception {
|
|
MyResourceProvider provider = null;
|
|
try (MyResource r = provider.<warning descr="Method invocation 'getResource' may produce 'java.lang.NullPointerException'">getResource</warning>()) {
|
|
System.out.println(r);
|
|
}
|
|
}
|
|
|
|
void m2() {
|
|
try (MyResource r = null) {
|
|
System.out.println(r);
|
|
}
|
|
}
|
|
} |