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

Type for ":e" is wrong

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • None
    • core-libs
    • None

    Description

      The way we generate code, the symbol for ":e" internal exception variable has type ECMAException, when it should have Throwable. Curiously, this passes the verifier and doesn't cause problems, but it's obviously wrong. This program works:

      try {
         new java.io.FileInputStream("no-such-file");
      } catch(e) {
         print(e.class)
         e.printStackTrace()
      }

      But the generated bytecode for the catch block is:

         FRAME FULL [jdk/nashorn/internal/runtime/ScriptFunction java/lang/Object jdk/nashorn/internal/runtime/ScriptObject java/lang/Object] [java/lang/Throwable]
          ASTORE 4
         L5
          ALOAD 4
          DUP
          INSTANCEOF jdk/nashorn/internal/runtime/ECMAException
          IFEQ L6
          CHECKCAST jdk/nashorn/internal/runtime/ECMAException
          GETFIELD jdk/nashorn/internal/runtime/ECMAException.thrown : Ljava/lang/Object;
          ...
          LOCALVARIABLE :e Ljdk/nashorn/internal/runtime/ECMAException; L0 L4 4

      meaning, we can catch any Throwable and then set it into a lvar typed as ECMAException.

      ":e" should obviously be typed as Throwable.

      Attachments

        Activity

          People

            attila Attila Szegedi
            attila Attila Szegedi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: