< prev index next >

src/java.base/share/classes/java/io/ObjectStreamClass.java

Print this page
@@ -28,10 +28,11 @@
  import java.lang.invoke.MethodHandle;
  import java.lang.invoke.MethodHandles;
  import java.lang.invoke.MethodType;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Field;
+ import java.lang.reflect.InaccessibleObjectException;
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.RecordComponent;
  import java.lang.reflect.UndeclaredThrowableException;
  import java.lang.reflect.Member;
  import java.lang.reflect.Method;

@@ -59,10 +60,11 @@
  import jdk.internal.reflect.CallerSensitive;
  import jdk.internal.reflect.Reflection;
  import jdk.internal.reflect.ReflectionFactory;
  import jdk.internal.access.SharedSecrets;
  import jdk.internal.access.JavaSecurityAccess;
+ import jdk.internal.value.PrimitiveClass;
  import sun.reflect.misc.ReflectUtil;
  import static java.io.ObjectStreamField.*;
  
  /**
   * Serialization's descriptor for classes.  It contains the name and

@@ -441,10 +443,12 @@
          }
  
          if (deserializeEx == null) {
              if (isEnum) {
                  deserializeEx = new ExceptionInfo(name, "enum type");
+             } else if (cl.isValue() && writeReplaceMethod == null) {
+                 deserializeEx = new ExceptionInfo(name, "value class");
              } else if (cons == null && !isRecord) {
                  deserializeEx = new ExceptionInfo(name, "no valid constructor");
              }
          }
          if (isRecord && canonicalCtr == null) {

@@ -1428,11 +1432,11 @@
          try {
              Constructor<?> cons = cl.getDeclaredConstructor((Class<?>[]) null);
              cons.setAccessible(true);
              return ((cons.getModifiers() & Modifier.PUBLIC) != 0) ?
                  cons : null;
-         } catch (NoSuchMethodException ex) {
+         } catch (NoSuchMethodException | InaccessibleObjectException ex) {
              return null;
          }
      }
  
      /**
< prev index next >