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

Eagerly lookup browser JS object class in BrowserJSObjectLinker

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • core-libs
    • b99
    • generic
    • generic

      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.

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

              Created:
              Updated:
              Resolved: