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

Wrong bytecode generation for if/else

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P2
    • Resolution: Fixed
    • 8
    • 8
    • core-libs
    • None
    • b96
    • Verified

    Description

      Run the following piece of code with nashorn, you will get the exception.

      function doIt() {
        if (something) {
          coucou = coucou.obj;
        } else {
          var coucou = "coucou";
        }
      }


      Exception in thread "main" java.lang.VerifyError: Bad local variable type
      Exception Details:
        Location:
          jdk/nashorn/internal/scripts/Script$index.parseChar(Ljdk/nashorn/internal/runtime/ScriptFunction;Ljava/lang/Object;)Ljava/lang/Object; @17: aload
        Reason:
          Type top (current frame, locals[4]) is not assignable to reference type
        Current Frame:
          bci: @17
          flags: { }
          locals: { 'jdk/nashorn/internal/runtime/ScriptFunction', 'java/lang/Object', 'jdk/nashorn/internal/runtime/ScriptObject' }
          stack: { }
        Bytecode:
          0000000: 2ab6 0018 4d2c ba00 3400 00b8 003a 9900
          0000010: 0f19 04ba 003d 0000 3a04 a700 0712 3f3a
          0000020: 04b2 0043 b0
        Stackmap Table:
          append_frame(@29,Object[#76])
          append_frame(@33,Top,Object[#78])

      at java.lang.Class.getDeclaredFields0(Native Method)
      at java.lang.Class.privateGetDeclaredFields(Class.java:2367)
      at java.lang.Class.getDeclaredField(Class.java:1902)
      at jdk.nashorn.internal.codegen.Compiler$2.run(Compiler.java:417)
      at jdk.nashorn.internal.codegen.Compiler$2.run(Compiler.java:413)
      at java.security.AccessController.doPrivileged(Native Method)
      at jdk.nashorn.internal.codegen.Compiler.install(Compiler.java:413)
      at jdk.nashorn.internal.codegen.Compiler.install(Compiler.java:447)
      at jdk.nashorn.internal.runtime.Context.compile(Context.java:799)
      at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:755)
      at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:342)
      at jdk.nashorn.tools.Shell.runScripts(Shell.java:308)
      at jdk.nashorn.tools.Shell.run(Shell.java:178)
      at jdk.nashorn.tools.Shell.main(Shell.java:142)
      at jdk.nashorn.tools.Shell.main(Shell.java:121)
      dhcp-uk-twvpn-2-vpnpool-10-175-51-227:jade jfdenise$ java jdk.nashorn.tools.Shell ./node_modules/character-parser/index.js

      Attachments

        Activity

          People

            lagergren Marcus Lagergren
            jfdenise Jean-Francois Denise (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: