You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
934 B
45 lines
934 B
4 years ago
|
/*
|
||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*/
|
||
|
import com.facebook.infer.annotation.Nullsafe;
|
||
|
|
||
|
class OtherClass {
|
||
|
|
||
|
OtherClass x = null;
|
||
|
|
||
|
OtherClass canReturnNull() {
|
||
|
return this.x;
|
||
|
}
|
||
|
|
||
|
String buggyMethodBad() {
|
||
|
OtherClass o = new OtherClass();
|
||
|
return o.canReturnNull().toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
* Pulse will not report NPEs on @Nullsafe classes if flag
|
||
|
* --pulse-nullsafe-report-npe is set to false
|
||
|
*/
|
||
|
|
||
|
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||
|
class NullsafeExampleLocal {
|
||
|
void testingNullsafeLocalMode() {
|
||
|
OtherClass o = new OtherClass();
|
||
|
o = o.canReturnNull();
|
||
|
o.getClass();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Nullsafe(Nullsafe.Mode.STRICT)
|
||
|
class NullsafeExampleStrict {
|
||
|
void testingNullsafeStrictMode() {
|
||
|
OtherClass o = new OtherClass();
|
||
|
o = o.canReturnNull();
|
||
|
o.toString();
|
||
|
}
|
||
|
}
|