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

initialization exception is not wrapped by ExceptionInInitializerError

    XMLWordPrintable

    Details

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

      Description



      Name: szC45993 Date: 03/12/97



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

      "4. Next, the class is initialized. Details of the initialization procedure are given in $2.16.5 and in The Java Language Specification.
      ...
      If an initializer completes abruptly by throwing some exception E, and if the class of E is not Error or one of its subclasses, then a new instance of the class ExceptionInInitializerError, with E as the argument, is created and used in place of E."

      Meanwhile, undermentioned test gives the following result (jdk_1.0.2):

      java.lang.ArithmeticException: / by zero
      at javasoft.sqe.tests.vm.constantpool.ClassInterf017.ClassInterf01701.clss.<clinit>(clss.java:18)
      at
      at javasoft.sqe.tests.vm.constantpool.ClassInterf017.ClassInterf01701.ClassInterf01701.run(ClassInterf01701.jasm)
      at javasoft.sqe.tests.vm.constantpool.ClassInterf017.ClassInterf01701.ClassInterf01701.main(ClassInterf01701.jasm)

      --------------------- ClassInterf01701.jasm
      package javasoft/sqe/tests/vm/constantpool/ClassInterf017/ClassInterf01701;

      public class ClassInterf01701 {
      // Compiled from ClassInterf01701.java
      // Compiler version 3.45;


      public static Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I"
      stack 3 locals 4
      {
      try t15, t23, t49, t57;
      ldc String "javasoft.sqe.tests.vm.constantpool.ClassInterf017.ClassInterf01701.Intrmdt";
      invokestatic Method java/lang/Class.forName:"(Ljava/lang/String;)Ljava/lang/Class;";
      invokevirtual Method java/lang/Class.newInstance:"()Ljava/lang/Object;";
      checkcast class Inter;
      astore_2;
      endtry t15, t23, t49, t57;
      goto L65;
      catch t15 java/lang/ExceptionInInitializerError;
      astore_3;
      aload_1;
      aload_3;
      invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/Object;)V";
      iconst_0;
      ireturn;
      catch t23 java/lang/ClassNotFoundException;
      astore_3;
      aload_1;
      new class java/lang/StringBuffer;
      dup;
      invokespecial Method java/lang/StringBuffer.<init>:"()V";
      ldc String "CLASS NOT FOUND: ";
      invokevirtual Method java/lang/StringBuffer.append:"(Ljava/lang/String;)Ljava/lang/StringBuffer;";
      aload_3;
      invokevirtual Method java/lang/StringBuffer.append:"(Ljava/lang/Object;)Ljava/lang/StringBuffer;";
      invokevirtual Method java/lang/StringBuffer.toString:"()Ljava/lang/String;";
      invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
      iconst_2;
      ireturn;
      catch t49 java/lang/IllegalAccessException;
      astore_3;
      aload_1;
      aload_3;
      invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/Object;)V";
      iconst_2;
      ireturn;
      catch t57 java/lang/InstantiationException;
      astore_3;
      aload_1;
      aload_3;
      invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/Object;)V";
      iconst_2;
      ireturn;
      try t73;
      L65: aload_2;
      aload_1;
      invokeinterface InterfaceMethod Inter.intrmdtprc:"(Ljava/io/PrintStream;)I", 2;
      ireturn;
      endtry t73;
      catch t73 java/lang/ExceptionInInitializerError;
      pop;
      iconst_0;
      ireturn;
      }

      public static Method main:"([Ljava/lang/String;)V"
      stack 2 locals 1
      {
      aload_0;
      getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
      invokestatic Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I";
      bipush 95;
      iadd;
      invokestatic Method java/lang/System.exit:"(I)V";
      return;
      }

      public Method <init>:"()V"
      stack 1 locals 1
      {
      aload_0;
      invokespecial Method java/lang/Object.<init>:"()V";
      return;
      }

      } // end Class ClassInterf01701
      --------------------- Inter.java
      //File: @(#)Inter.java 1.1 97/02/18
      //Copyright 02/18/97 Sun Microsystems, Inc. All Rights Reserved

      package javasoft.sqe.tests.vm.constantpool.ClassInterf017.ClassInterf01701;

      import java.io.PrintStream;

      interface Inter {
          int intrmdtprc(PrintStream out);
      }

      --------------------- Intrmdt.jasm
      package javasoft/sqe/tests/vm/constantpool/ClassInterf017/ClassInterf01701;

      public class Intrmdt
      implements Inter
      {
      // Compiled from Intrmdt.java
      // Compiler version 3.45;

      static Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf017/ClassInterf01701/clss;";

      public Method intrmdtprc:"(Ljava/io/PrintStream;)I"
      stack 2 locals 2
      {
      try t8;
      getstatic Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf017/ClassInterf01701/clss;";
      aload_1;
      invokevirtual Method clss.prc:"(Ljava/io/PrintStream;)I";
      ireturn;
      endtry t8;
      catch t8 java/lang/ExceptionInInitializerError;
      //but is rised !?
      pop;
      iconst_0;
      ireturn;
      }

      public Method <init>:"()V"
      stack 1 locals 1
      {
      aload_0;
      invokespecial Method java/lang/Object.<init>:"()V";
      return;
      }

      static Method <clinit>:"()V"
      stack 2 locals 0
      {
      new class clss;
      dup;
      invokespecial Method clss.<init>:"()V";
      putstatic Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf017/ClassInterf01701/clss;";
      return;
      }

      } // end Class Intrmdt
      --------------------- clss.java
      //File: @(#)clss.java 1.1 97/02/18
      //Copyright 02/18/97 Sun Microsystems, Inc. All Rights Reserved

      package javasoft.sqe.tests.vm.constantpool.ClassInterf017.ClassInterf01701;

      import java.io.PrintStream;
      import java.io.*;
      import java.lang.*;

      public class clss{
      static File f = new File("unexisting");
      static int i1 = 1;
      static int i2 = 2;
      static int i3 = 3;
      static int i;

      static {
       i = i3 / ((1 + i3) - (i1 + i2) - 1); // devided by zero !!!
      }

        public int prc(PrintStream out) {

      return 2;
        }
      }
      ---------------------

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

        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: