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

String.prototype.charCodeAt called with invalid index throws ClassCastException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8u40
    • core-libs
    • None
    • b39
    • generic
    • generic

        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

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

                Created:
                Updated:
                Resolved: