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

String.prototype.charCodeAt called with invalid index throws ClassCastException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u40
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b39
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        When String.prototype.charCodeAt() is called with an invalid index argument it throws a ClassCastException.

        jjs> "abc".charCodeAt(10)
        java.lang.ClassCastException
        java.lang.ClassCastException
        at jdk.nashorn.internal.objects.NativeString.getValidChar(NativeString.java:575)
        at jdk.nashorn.internal.objects.NativeString.charCodeAt(NativeString.java:623)
        at jdk.nashorn.internal.scripts.Script$Recompilation$3$\^shell\_.:program(<shell>:1)
        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636)
        at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
        at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
        at jdk.nashorn.internal.runtime.Context.eval(Context.java:697)
        at jdk.nashorn.internal.runtime.Context.eval(Context.java:627)
        at jdk.nashorn.tools.Shell.readEvalPrint(Shell.java:450)
        at jdk.nashorn.tools.Shell.run(Shell.java:158)
        at jdk.nashorn.tools.Shell.main(Shell.java:133)
        at jdk.nashorn.tools.Shell.main(Shell.java:112)

        It looks like this is caused by JDK-8025435
        http://hg.openjdk.java.net/jdk9/dev/nashorn/rev/f0b5e3900a10

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                lagergren Marcus Lagergren
                Reporter:
                hannesw Hannes Wallnoefer
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: