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

NullPointerException at jdk.nashorn.internal.runtime.Context.getContext(Context.java:1393)

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b103
    • Introduced In Version:
      9
    • CPU:
      x86_64
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      openjdk version "9.0.1"
      OpenJDK Runtime Environment (build 9.0.1+11)
      OpenJDK 64-Bit Server VM (build 9.0.1+11, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      Running the test case with Java 9 results in a NullPointerException. It runs successfully with Java 8.

      REGRESSION. Last worked in version 8u151

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_151"
      Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Standard output contains:
      Executed
      ACTUAL -
      Standard output contains:
      Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
      at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:385)
      at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:250)
      at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:240)
      at jdk.nashorn.javaadapters.com_example_nashorn_npe_JdkScriptingNashornNPE$CustomMenu.isManagingFocus(Unknown Source)
      at java.desktop/javax.swing.JComponent.<init>(JComponent.java:603)
      at java.desktop/javax.swing.AbstractButton.<init>(AbstractButton.java:74)
      at java.desktop/javax.swing.JMenuItem.<init>(JMenuItem.java:145)
      at java.desktop/javax.swing.JMenuItem.<init>(JMenuItem.java:124)
      at com.example.nashorn.npe.JdkScriptingNashornNPE$CustomMenu.<init>(JdkScriptingNashornNPE.java:20)
      at jdk.nashorn.javaadapters.com_example_nashorn_npe_JdkScriptingNashornNPE$CustomMenu.<init>(Unknown Source)
      at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$2$\^eval\_$cu1$restOf/758348212.:program(<eval>:1)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:652)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:517)
      at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:448)
      at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:405)
      at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:401)
      at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:154)
      at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
      at com.example.nashorn.npe.JdkScriptingNashornNPE.main(JdkScriptingNashornNPE.java:12)
      Caused by: java.lang.NullPointerException
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Context.getContext(Context.java:1393)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Context.getContextTrusted(Context.java:1303)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Context.fromClass(Context.java:1419)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Context.getDynamicLinker(Context.java:1315)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.linker.Bootstrap.bootstrap(Bootstrap.java:223)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.linker.JavaAdapterServices.bootstrap(JavaAdapterServices.java:206)
      at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:324)
      ... 19 more

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com.example.nashorn.npe;

      import javax.script.ScriptEngineManager;
      import javax.swing.JMenuItem;

      public class JdkScriptingNashornNPE {

          private static final String SCRIPT = "var CustomMenu = Java.type('com.example.nashorn.npe.JdkScriptingNashornNPE$CustomMenu');"
                  + "new CustomMenu('') { custom: function() { print('Executed.') } }.custom()";

          public static void main(String[] args) throws Exception {
              new ScriptEngineManager().getEngineByName("ECMAScript").eval(SCRIPT);
          }

          public abstract static class CustomMenu extends JMenuItem {

              private static final long serialVersionUID = 1L;

              public CustomMenu(String label) {
                  super(label);
              }

              public abstract void custom();
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              hannesw Hannes Wallnoefer
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: