< prev index next >

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

Print this page
@@ -1181,10 +1181,12 @@
              }
  
              // remaining cases
              if (obj instanceof String) {
                  writeString((String) obj, unshared);
+             } else if (cl.isPrimitiveClass()) {
+                 throw new NotSerializableException(cl.getName());
              } else if (cl.isArray()) {
                  writeArray(obj, desc, unshared);
              } else if (obj instanceof Enum) {
                  writeEnum((Enum<?>) obj, desc, unshared);
              } else if (obj instanceof Serializable) {
< prev index next >