Class NashornBridgeTest

java.lang.Object
scripting.NashornBridgeTest

public class NashornBridgeTest extends Object
Phase-2 Track-A smoke test for the standalone Nashorn bridge (org.openjdk.nashorn:nashorn-core:15.7), the drop-in replacement for the built-in jdk.scripting.nashorn module that disappears on JDK 17+. The engine is instantiated via new NashornScriptEngineFactory() directly — NOT via getEngineByName("nashorn") — because on JDK 11 both the built-in module and the jar register the name "nashorn" through ServiceLoader, making the name lookup ambiguous. This mirrors exactly how AbstractScriptManager and PortalScriptManager now obtain their engines. Asserts the 6 idioms the production scripts rely on (proven on JDK 25): (a) engine is both Invocable and Compilable, (b) eval a function + invokeFunction returns the expected value, (c) load('nashorn:mozilla_compat.js') + importPackage(java.util) builds an ArrayList, (d) importClass / Packages.java.lang.Integer.parseInt -> 42, (e) Compilable.compile a SAM impl + Invocable.getInterface + call, (f) bounded concurrency: 8 threads x 200 invokeFunction on one shared engine, asserting zero exceptions (no IllegalStateException from Nashorn globals). Part of the phase-0 safety net: wired into ./gradlew build (a failure blocks the build). Runtime is a few seconds. No DB / wz / network / Timer is touched.
  • Constructor Details

    • NashornBridgeTest

      public NashornBridgeTest()
  • Method Details

    • engineIsInvocableAndCompilable

      public void engineIsInvocableAndCompilable()
    • evalFunctionThenInvoke

      public void evalFunctionThenInvoke() throws Exception
      Throws:
      Exception
    • mozillaCompatImportPackageBuildsArrayList

      public void mozillaCompatImportPackageBuildsArrayList() throws Exception
      Throws:
      Exception
    • importClassAndPackagesParseInt

      public void importClassAndPackagesParseInt() throws Exception
      Throws:
      Exception
    • compileAndGetInterfaceSam

      public void compileAndGetInterfaceSam() throws Exception
      Throws:
      Exception
    • concurrentInvokeOnSharedEngine

      public void concurrentInvokeOnSharedEngine() throws Exception
      Throws:
      Exception