java.lang.IllegalArgumentException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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 ----------
    via by 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) at JI9042279.main(JI9042279.java:6)
    No Bugmate found.