-
Bug
-
Resolution: Duplicate
-
P4
-
repo-valhalla
Assigning null to a NullRestricted field correctly results in an NullPointerException.
However, the message is misleading. For example,
`java.lang.NullPointerException: Cannot assign field "empty" because "this" is null`
The confusing part is the reference to "this" when it should be referring to the local variable.
The message is from JEP 358: Helpful NullPointerExceptions
public value class Value {
@NullRestricted
EmptyValue empty;
Value(EmptyValue empty) {
this.empty = empty;
}
}
Invoke as
`new Value(null)`
However, the message is misleading. For example,
`java.lang.NullPointerException: Cannot assign field "empty" because "this" is null`
The confusing part is the reference to "this" when it should be referring to the local variable.
The message is from JEP 358: Helpful NullPointerExceptions
public value class Value {
@NullRestricted
EmptyValue empty;
Value(EmptyValue empty) {
this.empty = empty;
}
}
Invoke as
`new Value(null)`
- duplicates
-
JDK-8341120 [lworld] NPE message can be wrong for null restricted fields
-
- Open
-