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

serialver tool should not initialize the classes it loads

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.3.0, 1.4.2
    • core-libs
    • None

      When the serialver tool loads a class (specified on the command line)
      in order to calculate the serialVersionUID for that class, it specifies
      that the class should be initialized:

          /*
           * From the classname find the serialVersionUID string formatted
           * for to be copied to a java class.
           */
          static String serialSyntax(String classname) throws ClassNotFoundException {
      Class cl = Class.forName(classname, true, loader);
      ObjectStreamClass desc = ObjectStreamClass.lookup(cl);
      if (desc != null) {
      return " static final long serialVersionUID = " +
      desc.getSerialVersionUID() + "L;";
      } else {
      return null;
      }
          }

      The second parameter to the Class.forName method is "true" which
      causes the class to be initialized resulting in the static initializers
      for the class being run. To calculate the serialVersionUID for a
      class, it is not necessary for the class to be initialized and in
      some cases, errors will occur because the static initializers attempt
      to load a library, for example.

            mwarressunw Michael Warres (Inactive)
            awollratsunw Ann Wollrath (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: