JavaScript performance degraded after moving to Java 8

Solution Verified - Updated -

Issue

  • We moved to java 8 and see notably slower performance. Thread dumps show large amounts of processing time in nashorn, for example:
   java.lang.Thread.State: RUNNABLE
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getDeclaredField(Class.java:2068)
    at jdk.nashorn.internal.runtime.Context$ContextCodeInstaller$1.run(Context.java:213)
    at jdk.nashorn.internal.runtime.Context$ContextCodeInstaller$1.run(Context.java:208)
    at java.security.AccessController.doPrivileged(Native Method)
    at jdk.nashorn.internal.runtime.Context$ContextCodeInstaller.initialize(Context.java:208)
    at jdk.nashorn.internal.codegen.CompilationPhase$14.transform(CompilationPhase.java:568)
    at jdk.nashorn.internal.codegen.CompilationPhase.apply(CompilationPhase.java:716)
    at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:620)
    at jdk.nashorn.internal.runtime.Context.compile(Context.java:1316)
    - locked <0x00000007511175c0> (a jdk.nashorn.internal.runtime.Context)
    at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:1248)
    at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:629)
    at jdk.nashorn.api.scripting.NashornScriptEngine.compileImpl(NashornScriptEngine.java:532)
    at jdk.nashorn.api.scripting.NashornScriptEngine.compileImpl(NashornScriptEngine.java:521)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)
    at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)

Environment

  • Java 8
    • Nashorn Java Script Engine
  • JBoss Enterprise Application Platform (EAP)
    • 6.x
    • 7.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.