Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4402151

java.io.ObjectStreamClass.lookup() throws NPE on interface class

    XMLWordPrintable

    Details

      Description



      Name: ooR10001 Date: 01/05/2001


      java.io.ObjectStreamClass.lookup(Class) method throws NullPointerException when
      the atempt to lookup ObjectStreamClass for serializable interface is made.
      It is the compatibility problem because in previous jdk version
      NPE is not thrown in this case. It needs to be fixed.

      This is a sample to reproduce this bug:
      -----------------------------------------
      interface sample extends java.io.Serializable {
      }

      public class test {

        public static void main(String[] args) {
            Class c = sample.class;
            if (c == null) {
                System.out.println("null parameter passed");
            }
            java.io.ObjectStreamClass streamClass =
                    java.io.ObjectStreamClass.lookup(c);
            System.out.println("OKAY");
        }

      }
      -------------------------------------------

      Output:
      %java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b46)
      Java HotSpot(TM) Client VM (build 1.4beta-B45, mixed mode)
      %java test
      Exception in thread "main" java.lang.NullPointerException
              at java.lang.Class.isAssignableFrom(Native Method)
              at sun.misc.ClassReflector.getSerializableConstructor(ClassReflector.java:1181)
              at sun.misc.ClassReflector.getInvocables(ClassReflector.java:1143)
              at sun.misc.ClassReflector.access$900(ClassReflector.java:27)
              at sun.misc.ClassReflector$2.run(ClassReflector.java:1058)
              at java.security.AccessController.doPrivileged(Native Method)
              at sun.misc.ClassReflector.createClassReflector(ClassReflector.java:1055)
              at sun.misc.ClassReflector.getClassReflector(ClassReflector.java:1043)
              at sun.misc.ClassReflector.access$100(ClassReflector.java:27)
              at sun.misc.ClassReflector$Factory.getClassReflector(ClassReflector.java:87)
              at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:237)
              at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:226)
              at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:103)
              at test.main(test.java:11)
      --------------------------------------------
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mwarressunw Michael Warres (Inactive)
              Reporter:
              oovsunw Oov Oov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: