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

matches method halt with some reg expressions

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      java -version
      java version "1.8.0_65"
      Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
      Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Tested on Window 7 professional

      A DESCRIPTION OF THE PROBLEM :
      See sample code below:
      it works fine with lower case, but after changin the test string to upper case (only the first letter), calling matches method halt somewhere
      ==========================================================
      public class MatchesMethod{

          public boolean bar(String str){
             return str.matches(".*\\d*[A-Z][a-z]*\\d* (\\d*[a-zA-Z]*\\s*\\d*\\s*)*\\d*[A-Z][a-z]*\\d* (\\D*\\d){10,}\\D*");
          }

          public static void main(String[] args){
             MatchesMethod m=new MatchesMethod();
             String str = "hello Javajava 1234567890";
             
             System.out.print("test with string:"+str);
             m.bar(str);
             System.out.println(" is OK.");

             str = "Hello Javajava 1234567890"; //cap the H
             
             System.out.print("test with string:"+str);
             m.bar(str);
             System.out.println(" is OK.");
          }
      }

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

      public class MatchesMethod{

          public boolean bar(String str){
             return str.matches(".*\\d*[A-Z][a-z]*\\d* (\\d*[a-zA-Z]*\\s*\\d*\\s*)*\\d*[A-Z][a-z]*\\d* (\\D*\\d){10,}\\D*");
          }

          public static void main(String[] args){
             MatchesMethod m=new MatchesMethod();
             String str = "hello Javajava 1234567890";
             
             System.out.print("test with string:"+str);
             m.bar(str);
             System.out.println(" is OK.");

             str = "Hello Javajava 1234567890"; //cap the H
             
             System.out.print("test with string:"+str);
             m.bar(str);
             System.out.println(" is OK.");
          }
      }


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      public class MatchesMethod{

          public boolean bar(String str){
             return str.matches(".*\\d*[A-Z][a-z]*\\d* (\\d*[a-zA-Z]*\\s*\\d*\\s*)*\\d*[A-Z][a-z]*\\d* (\\D*\\d){10,}\\D*");
          }

          public static void main(String[] args){
             MatchesMethod m=new MatchesMethod();
             String str = "hello Javajava 1234567890";
             
             System.out.print("test with string:"+str);
             m.bar(str);
             System.out.println(" is OK.");

             str = "Hello Javajava 1234567890"; //cap the H
             
             System.out.print("test with string:"+str);
             m.bar(str);
             System.out.println(" is OK.");
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      no solution

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              igerasim Ivan Gerasimov
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: