diff --git a/src/avian/classpath-common.h b/src/avian/classpath-common.h index 951d16b97d..1137f9d2c9 100644 --- a/src/avian/classpath-common.h +++ b/src/avian/classpath-common.h @@ -260,11 +260,14 @@ clone(Thread* t, object o) memcpy(clone, o, size); // clear any object header flags: setObjectClass(t, o, objectClass(t, o)); - } else { + } else if (instanceOf(t, type(t, Machine::CloneableType), o)) { clone = make(t, class_); memcpy(reinterpret_cast(clone) + 1, reinterpret_cast(o) + 1, size - BytesPerWord); + } else { + throwNew(t, Machine::CloneNotSupportedExceptionType, "%s", + &byteArrayBody(t, className(t, objectClass(t, o)), 0)); } return clone; diff --git a/src/types.def b/src/types.def index faf1d1341c..c7731f648d 100644 --- a/src/types.def +++ b/src/types.def @@ -226,6 +226,8 @@ (type negativeArraySizeException java/lang/NegativeArraySizeException) +(type cloneNotSupportedException java/lang/CloneNotSupportedException) + (type reflectiveOperationException java/lang/ReflectiveOperationException) (type classCastException java/lang/ClassCastException) diff --git a/vm.pro b/vm.pro index 8d1ab22177..19bc238967 100644 --- a/vm.pro +++ b/vm.pro @@ -54,6 +54,7 @@ -keep public class java.lang.ArrayIndexOutOfBoundsException -keep public class java.lang.ArrayStoreException -keep public class java.lang.NegativeArraySizeException +-keep public class java.lang.CloneNotSupportedException -keep public class java.lang.ClassCastException -keep public class java.lang.ClassNotFoundException -keep public class java.lang.NullPointerException