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.
59 lines
830 B
59 lines
830 B
10 years ago
|
/*
|
||
6 years ago
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
9 years ago
|
*
|
||
7 years ago
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
9 years ago
|
*/
|
||
10 years ago
|
|
||
5 years ago
|
package codetoanalyze.java.nullsafe_default;
|
||
10 years ago
|
|
||
|
import javax.annotation.Nullable;
|
||
|
|
||
|
public class NullFieldAccess {
|
||
|
class C {
|
||
|
int n;
|
||
|
}
|
||
|
|
||
|
interface I {
|
||
6 years ago
|
@Nullable C c = null;
|
||
10 years ago
|
}
|
||
|
|
||
6 years ago
|
@Nullable C x;
|
||
10 years ago
|
C y;
|
||
6 years ago
|
static final @Nullable C z = null;
|
||
10 years ago
|
|
||
|
NullFieldAccess() {
|
||
|
y = new C();
|
||
|
}
|
||
|
|
||
|
int useX() {
|
||
|
C c = x;
|
||
|
return c.n;
|
||
|
}
|
||
|
|
||
|
int useY() {
|
||
|
C c = y;
|
||
|
return c.n;
|
||
|
}
|
||
|
|
||
|
int useZ() {
|
||
|
C c = z;
|
||
|
return c.n;
|
||
|
}
|
||
|
|
||
|
int useInterface(I i) {
|
||
|
C c = i.c;
|
||
|
return c.n;
|
||
|
}
|
||
|
|
||
|
@Nullable Object[] objects;
|
||
|
|
||
|
int arrayLength() {
|
||
|
return objects.length;
|
||
|
}
|
||
|
|
||
|
Object arrayAccess() {
|
||
|
return objects[0];
|
||
|
}
|
||
|
}
|