java.lang.IllegalArgumentException: Illegal group reference at java.util.regex.Matcher.appendExpandedReplacement(java.base@9-ea/Matcher.java:1068) at java.util.regex.Matcher.appendReplacement(java.base@9-ea/Matcher.java:998) at java.util.regex.Matcher.replaceAll(java.base@9-ea/Matcher.java:1181) at java.lang.String.replaceAll(java.base@9-ea/String.java:2162)

JDK Bug System | Webbug Group | 7 months ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    FULL PRODUCT VERSION : java version "1.8.0_73" Java(TM) SE Runtime Environment (build 1.8.0_73-b02) Java HotSpot(TM) Client VM (build 25.73-b02, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Windows 10 EXTRA RELEVANT SYSTEM CONFIGURATION : In Matcher.java line 854 is written: // The first number is always a group refNum = (int)nextChar - '0'; if ((refNum < 0)||(refNum > 9)) throw new IllegalArgumentException( "Illegal group reference"); That the first character after $ is always a number is not correct. A DESCRIPTION OF THE PROBLEM : That the first character after $ is always a number is not correct. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : public static void main(String[] args) { final String k = "1234"; System.out.println(k.replaceAll("23", "$&")); } ACTUAL - Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference at java.util.regex.Matcher.appendReplacement(Matcher.java:857) at java.util.regex.Matcher.replaceAll(Matcher.java:955) at java.lang.String.replaceAll(String.java:2210) at overlay.StartupTest.main(StartupTest.java:52) ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference at java.util.regex.Matcher.appendReplacement(Matcher.java:857) at java.util.regex.Matcher.replaceAll(Matcher.java:955) at java.lang.String.replaceAll(String.java:2210) at overlay.StartupTest.main(StartupTest.java:52) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public static void main(String[] args) { final String k = "1234"; System.out.println(k.replaceAll("23", "$&")); } ---------- END SOURCE ----------

    JDK Bug System | 7 months ago | Webbug Group
    java.lang.IllegalArgumentException: Illegal group reference at java.util.regex.Matcher.appendExpandedReplacement(java.base@9-ea/Matcher.java:1068) at java.util.regex.Matcher.appendReplacement(java.base@9-ea/Matcher.java:998) at java.util.regex.Matcher.replaceAll(java.base@9-ea/Matcher.java:1181) at java.lang.String.replaceAll(java.base@9-ea/String.java:2162)

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Illegal group reference at java.util.regex.Matcher.appendExpandedReplacement(java.base@9-ea/Matcher.java:1068) at java.util.regex.Matcher.appendReplacement(java.base@9-ea/Matcher.java:998) at java.util.regex.Matcher.replaceAll(java.base@9-ea/Matcher.java:1181) at java.lang.String.replaceAll(java.base@9-ea/String.java:2162)

      at JI9042279.main()
    2. Unknown
      JI9042279.main
      1. JI9042279.main(JI9042279.java:6)
      1 frame