< prev index next > src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java
Print this page
public final Constructor<?> newConstructorForExternalization(Class<?> cl) {
if (!Externalizable.class.isAssignableFrom(cl)) {
return null;
}
+ if (cl.isValue()) {
+ throw new UnsupportedOperationException("newConstructorForExternalization does not support value classes");
+ }
try {
Constructor<?> cons = cl.getConstructor();
cons.setAccessible(true);
return cons;
} catch (NoSuchMethodException ex) {
{
if (constructorToCall.getDeclaringClass() == cl) {
constructorToCall.setAccessible(true);
return constructorToCall;
}
+ if (cl.isValue()) {
+ throw new UnsupportedOperationException("newConstructorForSerialization does not support value classes");
+ }
return generateConstructor(cl, constructorToCall);
}
/**
* Given a class, determines whether its superclass has
*
* @param cl the class for which a constructor is to be found
* @return the generated constructor, or null if none is available
*/
public final Constructor<?> newConstructorForSerialization(Class<?> cl) {
+ if (cl.isValue()) {
+ throw new UnsupportedOperationException("newConstructorForSerialization does not support value classes: " + cl);
+ }
+
Class<?> initCl = cl;
while (Serializable.class.isAssignableFrom(initCl)) {
Class<?> prev = initCl;
if ((initCl = initCl.getSuperclass()) == null ||
(!disableSerialConstructorChecks() && !superHasAccessibleConstructor(prev))) {
< prev index next >