< prev index next >

src/java.base/share/classes/java/lang/ClassNotFoundException.java

Print this page

        

@@ -57,10 +57,11 @@
  */
 public class ClassNotFoundException extends ReflectiveOperationException {
     /**
      * use serialVersionUID from JDK 1.1.X for interoperability
      */
+     @java.io.Serial
      private static final long serialVersionUID = 9176873029745254542L;
 
     /**
      * Constructs a <code>ClassNotFoundException</code> with no detail message.
      */

@@ -109,10 +110,11 @@
     /**
      * Serializable fields for ClassNotFoundException.
      *
      * @serialField ex Throwable
      */
+    @java.io.Serial
     private static final ObjectStreamField[] serialPersistentFields = {
         new ObjectStreamField("ex", Throwable.class)
     };
 
     /*

@@ -122,10 +124,11 @@
      *
      * The getException and getCause method returns the private "ex" field
      * in the older implementation and ClassNotFoundException::cause
      * was set to null.
      */
+    @java.io.Serial
     private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
         ObjectInputStream.GetField fields = s.readFields();
         Throwable exception = (Throwable) fields.get("ex", null);
         if (exception != null) {
             setCause(exception);

@@ -134,10 +137,11 @@
 
     /*
      * To maintain compatibility with older implementation, write a serial
      * "ex" field with the cause as the value.
      */
+    @java.io.Serial
     private void writeObject(ObjectOutputStream out) throws IOException {
         ObjectOutputStream.PutField fields = out.putFields();
         fields.put("ex", super.getCause());
         out.writeFields();
     }
< prev index next >