-
Type:
Enhancement
-
Resolution: Unresolved
-
Priority:
P4
-
Affects Version/s: repo-valhalla
-
Component/s: tools
For test case:
import jdk.internal.vm.annotation.NullRestricted;
import jdk.internal.vm.annotation.Strict;
public class NRTest {
static value class Value { int i = 0; }
@Strict
@NullRestricted
Value v = new Value();
public static void main(String[] args) {
var t = new NRTest();
}
}
javac adds the type of field v to the LoadableDescriptors attribute:
LoadableDescriptors:
LNRTest$Value;
The presence of the field's type in the LoadableDescriptors attribute is not an error, but it is useless and in fact triggers more work in the JVM. Types of non-static null-restricted (an by consequence strict) fields are automatically loaded by the JVM without consulting the LoadableDescriptors attribute. The presence of this type in the attribute will trigger another attempt to load the type at class link time, which is a waste of time because the type is already present in the system dictionary at this time.
Note that non-static null-restricted fields are the only ones currently having their type automatically loaded by the JVM, for all other types from static fields and method arguments, the presence in the LoadableDescriptors attribute is required to guarantee layout and calling convention optimizations.
import jdk.internal.vm.annotation.NullRestricted;
import jdk.internal.vm.annotation.Strict;
public class NRTest {
static value class Value { int i = 0; }
@Strict
@NullRestricted
Value v = new Value();
public static void main(String[] args) {
var t = new NRTest();
}
}
javac adds the type of field v to the LoadableDescriptors attribute:
LoadableDescriptors:
LNRTest$Value;
The presence of the field's type in the LoadableDescriptors attribute is not an error, but it is useless and in fact triggers more work in the JVM. Types of non-static null-restricted (an by consequence strict) fields are automatically loaded by the JVM without consulting the LoadableDescriptors attribute. The presence of this type in the attribute will trigger another attempt to load the type at class link time, which is a waste of time because the type is already present in the system dictionary at this time.
Note that non-static null-restricted fields are the only ones currently having their type automatically loaded by the JVM, for all other types from static fields and method arguments, the presence in the LoadableDescriptors attribute is required to guarantee layout and calling convention optimizations.
- relates to
-
JDK-8367931 [lworld] Handling of @Strict by javac needs some fixes
-
- In Progress
-