-
Bug
-
Resolution: Fixed
-
P4
-
repo-valhalla
Since value types are not cloneable, JVM_Clone can enforce the check
rather than doing an assert. javac does not allow Object::clone be called from a value type but it could be called via reflection/method handle or generated bytecode.
// Check if class of obj supports the Cloneable interface.
// All arrays are considered to be cloneable (See JLS 20.1.5).
// All j.l.r.Reference classes are considered non-cloneable.
if (!klass->is_cloneable() ||
(klass->is_instance_klass() &&
InstanceKlass::cast(klass)->reference_type() != REF_NONE)) {
ResourceMark rm(THREAD);
THROW_MSG_0(vmSymbols::java_lang_CloneNotSupportedException(), klass->external_name());
}
assert(!EnableValhalla || !obj->klass()->is_value(), "Clone disallowed on value type");
rather than doing an assert. javac does not allow Object::clone be called from a value type but it could be called via reflection/method handle or generated bytecode.
// Check if class of obj supports the Cloneable interface.
// All arrays are considered to be cloneable (See JLS 20.1.5).
// All j.l.r.Reference classes are considered non-cloneable.
if (!klass->is_cloneable() ||
(klass->is_instance_klass() &&
InstanceKlass::cast(klass)->reference_type() != REF_NONE)) {
ResourceMark rm(THREAD);
THROW_MSG_0(vmSymbols::java_lang_CloneNotSupportedException(), klass->external_name());
}
assert(!EnableValhalla || !obj->klass()->is_value(), "Clone disallowed on value type");