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

Eagerly lookup browser JS object class in BrowserJSObjectLinker

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b99
    • CPU:
      generic
    • OS:
      generic

      Description

      BrowserJSObjectLinker is lazily looking up netscape.javascript.JSObject, but unfortunately this means it's going through the superclass-traversing loop in canLinkType (which involves a potentially security-checking getClassLoader()) on every link request that reaches it. Adding a

      System.err.println("Checking " + clazz.getName())

      into the loop and running jjs prints:

      $ ./jjs
      Checking jdk.nashorn.internal.runtime.ScriptFunction
      Checking jdk.nashorn.internal.runtime.ScriptObject
      Checking java.lang.Object
      jjs> print("x")
      Checking jdk.nashorn.internal.objects.Global
      Checking jdk.nashorn.internal.runtime.Scope
      Checking jdk.nashorn.internal.runtime.ScriptObject
      Checking java.lang.Object
      x

      and so on. It seems it's easier to just eagerly look up the class once.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: