Merge
This commit is contained in:
commit
0091cd268a
@ -882,4 +882,9 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
|
|||||||
public boolean isTrustedInterfaceType() {
|
public boolean isTrustedInterfaceType() {
|
||||||
return TrustedInterface.class.isAssignableFrom(mirror());
|
return TrustedInterface.class.isAssignableFrom(mirror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCloneableWithAllocation() {
|
||||||
|
return (getAccessFlags() & config().jvmAccIsCloneableFast) != 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,4 +267,9 @@ public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType
|
|||||||
public boolean isTrustedInterfaceType() {
|
public boolean isTrustedInterfaceType() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCloneableWithAllocation() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1077,6 +1077,7 @@ public class HotSpotVMConfig {
|
|||||||
@HotSpotVMConstant(name = "JVM_ACC_FIELD_STABLE") @Stable public int jvmAccFieldStable;
|
@HotSpotVMConstant(name = "JVM_ACC_FIELD_STABLE") @Stable public int jvmAccFieldStable;
|
||||||
@HotSpotVMConstant(name = "JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE") @Stable public int jvmAccFieldHasGenericSignature;
|
@HotSpotVMConstant(name = "JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE") @Stable public int jvmAccFieldHasGenericSignature;
|
||||||
@HotSpotVMConstant(name = "JVM_ACC_WRITTEN_FLAGS") @Stable public int jvmAccWrittenFlags;
|
@HotSpotVMConstant(name = "JVM_ACC_WRITTEN_FLAGS") @Stable public int jvmAccWrittenFlags;
|
||||||
|
@HotSpotVMConstant(name = "JVM_ACC_IS_CLONEABLE_FAST") @Stable public int jvmAccIsCloneableFast;
|
||||||
|
|
||||||
// Modifier.SYNTHETIC is not public so we get it via vmStructs.
|
// Modifier.SYNTHETIC is not public so we get it via vmStructs.
|
||||||
@HotSpotVMConstant(name = "JVM_ACC_SYNTHETIC") @Stable public int jvmAccSynthetic;
|
@HotSpotVMConstant(name = "JVM_ACC_SYNTHETIC") @Stable public int jvmAccSynthetic;
|
||||||
|
@ -359,4 +359,12 @@ public interface ResolvedJavaType extends JavaType, ModifiersProvider {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this type is {@link Cloneable} and can be safely cloned by creating a normal
|
||||||
|
* Java allocation and populating it from the fields returned by
|
||||||
|
* {@link #getInstanceFields(boolean)}. Some types may require special handling by the platform
|
||||||
|
* so they would to go through the normal {@link Object#clone} path.
|
||||||
|
*/
|
||||||
|
boolean isCloneableWithAllocation();
|
||||||
}
|
}
|
||||||
|
@ -309,6 +309,7 @@
|
|||||||
declare_constant(JVM_ACC_MONITOR_MATCH) \
|
declare_constant(JVM_ACC_MONITOR_MATCH) \
|
||||||
declare_constant(JVM_ACC_HAS_MONITOR_BYTECODES) \
|
declare_constant(JVM_ACC_HAS_MONITOR_BYTECODES) \
|
||||||
declare_constant(JVM_ACC_HAS_FINALIZER) \
|
declare_constant(JVM_ACC_HAS_FINALIZER) \
|
||||||
|
declare_constant(JVM_ACC_IS_CLONEABLE_FAST) \
|
||||||
declare_constant(JVM_ACC_FIELD_INTERNAL) \
|
declare_constant(JVM_ACC_FIELD_INTERNAL) \
|
||||||
declare_constant(JVM_ACC_FIELD_STABLE) \
|
declare_constant(JVM_ACC_FIELD_STABLE) \
|
||||||
declare_constant(JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE) \
|
declare_constant(JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE) \
|
||||||
|
@ -866,6 +866,31 @@ public class TestResolvedJavaType extends TypeUniverse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class TrivialCloneable implements Cloneable {
|
||||||
|
@Override
|
||||||
|
protected Object clone() {
|
||||||
|
return new TrivialCloneable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isCloneableWithAllocationTest() {
|
||||||
|
ResolvedJavaType cloneable = metaAccess.lookupJavaType(Cloneable.class);
|
||||||
|
for (Class<?> c : classes) {
|
||||||
|
ResolvedJavaType type = metaAccess.lookupJavaType(c);
|
||||||
|
if (type.isCloneableWithAllocation()) {
|
||||||
|
// Only Cloneable types should be allocation cloneable
|
||||||
|
assertTrue(c.toString(), cloneable.isAssignableFrom(type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* We can't know for sure which types should be allocation cloneable on a particular
|
||||||
|
* platform but assume that at least totally trivial objects should be.
|
||||||
|
*/
|
||||||
|
ResolvedJavaType trivialCloneable = metaAccess.lookupJavaType(TrivialCloneable.class);
|
||||||
|
assertTrue(trivialCloneable.toString(), trivialCloneable.isCloneableWithAllocation());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findMethodTest() {
|
public void findMethodTest() {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user