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

abruptly initialized class is not discarded

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2alpha
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Not verified

      Description



      Name: szC45993 Date: 08/13/97



      The Java Virtual Machine, chapter 5 Constant Pool Resolution,
      section 5.1.1 Current Class or Interface Not Loaded by a Class Loader, claims:

      "If none of the preceding errors were detected, constant pool resolution of the class or interface reference must have completed successfully. However, if an error was detected, one of the following must be true.
       - If some exception is thrown in steps 1-4, the class being resolved must have been marked as unusable or must have been discarded.
      ..."

      The test below shows that it is possible to use a class (for example,
      to set its static field) initialization of which has completed abruptly.

      Note that the bug has been fixed in jdk1.2 and is filed against
      jdk1.1.4 just for reference from JCK1.1.4 exclude test list.

      See log and test sources (extracted from JCK test ClassInterf01801) below:

      ----------------------------------------------------------------------------
      > /export/ld14/java/dest/jdk1.1.4/solaris/bin/java -fullversion
      java full version "JDK-sparkler_B"
      > /export/ld14/java/dest/jdk1.1.4/solaris/bin/javac clss.java Intrmdt.java
      > /export/ld14/java/dest/jdk1.1.4/solaris/bin/java Intrmdt
      java.lang.ExceptionInInitializerError
      Bad: (5.1.1:) If some exception is thrown when class is loaded then the class being resolved must have been marked as unusable or must have been discarded.
      novo7% echo $status
      2
      ----------------------------------------------------------------------------

      SOURCES:

      --------------------- Intrmdt.java
      public class Intrmdt{

        public static void main(String argv[]) {
      try{
      new clss();
      }catch (java.lang.ExceptionInInitializerError e) {
      System.out.println(e);
      try{
      clss.i = 2;
      System.out.println("Bad: (5.1.1:) If some exception is thrown when class is loaded then the class being resolved must have been marked as unusable or must have been discarded.");
      }catch (Throwable ee) {
      System.out.println(ee);
      System.out.println("Okay!");
      System.exit(0);
      }
      }
      System.exit(2);

        }
      }
      --------------------- clss.java
      public class clss{
        static int i = 1;
        static int j = 1;

        static {
      i /= (j - 1); // <<<<<<<<<<<<<< ArithmeticException: / by zero
        }

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

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              sliangsunw Sheng Liang (Inactive)
              Reporter:
              zsssunw Zss Zss (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: