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

Pattern trailing unescaped backslash causes internal error

XMLWordPrintable

    • b05
    • generic
    • generic
    • Verified

      A DESCRIPTION OF THE PROBLEM :
      Compiling a Regex Pattern with an unescaped trailing backslash causes an internal error:
      Pattern.compile("\\")

      Exception:
      Exception java.util.regex.PatternSyntaxException: Unexpected internal error near index 1

      ---

      This report is about the fact that an internal error is reported; it is not (like JDK-4783892) about the misunderstanding that backslashes need to be escaped.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Pattern.compile("\\")

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      An exception with a message saying something similar to:
      > Unescaped trailing backslash at index ...
      ACTUAL -
      Exception java.util.regex.PatternSyntaxException: Unexpected internal error near index 1

            igraves Ian Graves
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: