-
Bug
-
Resolution: Fixed
-
P3
-
repo-valhalla
The specification of JNI AllocObject needs an update to clarify the behavior when used with a value class in argument.
If the clazz argument is a value class, the function throws an java.lang.InstantiationError.
The rational for this behavior is that value class instances have strict fields that must be initialized before the instance can escape, the initialization being performed in the value's constructor, before calling the super-class constructor.
AllocObject allocates an instance without invoking any constructor, leading to two potential issues:
- the instance escapes with uninitialized fields
- the instance's fields cannot be initialized because strict fields can only be modified when the instance is seen as an 'uninitializedThis' type by the verifier (this type is changed when AllocObject returns)
If the clazz argument is a value class, the function throws an java.lang.InstantiationError.
The rational for this behavior is that value class instances have strict fields that must be initialized before the instance can escape, the initialization being performed in the value's constructor, before calling the super-class constructor.
AllocObject allocates an instance without invoking any constructor, leading to two potential issues:
- the instance escapes with uninitialized fields
- the instance's fields cannot be initialized because strict fields can only be modified when the instance is seen as an 'uninitializedThis' type by the verifier (this type is changed when AllocObject returns)