← Back to team overview

sikuli-driver team mailing list archive

[Bug 1840077] [NEW] Crash on OpenJ9 JVM on Windows

 

Public bug reported:

SikuliX crashes on Windows when running under OpenJ9 JVM (formerly IBM J9).
The crash happens when the JVM loads the Finder class.

This is a simple test program to reproduce the crash:

public class SikuliBug {
 public static void main(String[] args) {
  new org.sikuli.script.Pattern("blah");
 }
}

Exception in thread "main" java.lang.ExceptionInInitializerError
        at java.lang.J9VMInternals.ensureError(J9VMInternals.java:148)
        at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:137)
        at org.sikuli.script.Pattern.<init>(Pattern.java:123)
        at SikuliBug.main(SikuliBug.java:3)
Caused by: java.lang.IllegalArgumentException: Last character in replacement string can't be \, character to be escaped is required.
        at java.lang.String.checkLastChar(String.java:62)
        at java.lang.String.replaceAll(String.java:3530)
        at org.sikuli.script.support.RunTime.addToWindowsSystemPath(RunTime.java:1722)
        at org.sikuli.script.support.RunTime.libsExport(RunTime.java:1661)
        at org.sikuli.script.support.RunTime.libsLoad(RunTime.java:1486)
        at org.sikuli.script.support.RunTime.loadLibrary(RunTime.java:1690)
        at org.sikuli.script.Finder$Finder2.<clinit>(Finder.java:571)
        ... 2 more

The problem happens on this line in addToWindowsSystemPath():

 String libsPath = (fLibsFolder.getAbsolutePath()).replaceAll("/",
"\\");

Proposed fix:

Use replace() instead of replaceAll()

 String libsPath = (fLibsFolder.getAbsolutePath()).replace("/", "\\");

This is more appropriate anyway, since you just want to replace all
occurences of a fixed string or a character.

By the way, try to run this line with the JVM of your choice (you might
be surprised):

"C:/bang/bang".replaceAll("/", "\\")

I get this with Oracle JVM:

Exception in thread "main" java.lang.IllegalArgumentException: character to be escaped is missing
        at java.util.regex.Matcher.appendReplacement(Matcher.java:809)
        at java.util.regex.Matcher.replaceAll(Matcher.java:955)
        at java.lang.String.replaceAll(String.java:2223)
        at J9StringReplaceAllBug.main(SikuliBug.java:4)

** Affects: sikuli
     Importance: Undecided
         Status: New

** Description changed:

  SikuliX crashes on Windows when running under OpenJ9 JVM (formerly IBM J9).
- The crash happens when the JVM loads the Finder class. 
+ The crash happens when the JVM loads the Finder class.
  
  This is a simple test program to reproduce the crash:
  
  public class SikuliBug {
- 	public static void main(String[] args) {
- 		new org.sikuli.script.Pattern("blah");
- 	}
+  public static void main(String[] args) {
+   new org.sikuli.script.Pattern("blah");
+  }
  }
  
  Exception in thread "main" java.lang.ExceptionInInitializerError
-         at java.lang.J9VMInternals.ensureError(J9VMInternals.java:148)
-         at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:137)
-         at org.sikuli.script.Pattern.<init>(Pattern.java:123)
-         at SikuliBug.main(SikuliBug.java:3)
+         at java.lang.J9VMInternals.ensureError(J9VMInternals.java:148)
+         at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:137)
+         at org.sikuli.script.Pattern.<init>(Pattern.java:123)
+         at SikuliBug.main(SikuliBug.java:3)
  Caused by: java.lang.IllegalArgumentException: Last character in replacement string can't be \, character to be escaped is required.
-         at java.lang.String.checkLastChar(String.java:62)
-         at java.lang.String.replaceAll(String.java:3530)
-         at org.sikuli.script.support.RunTime.addToWindowsSystemPath(RunTime.java:1722)
-         at org.sikuli.script.support.RunTime.libsExport(RunTime.java:1661)
-         at org.sikuli.script.support.RunTime.libsLoad(RunTime.java:1486)
-         at org.sikuli.script.support.RunTime.loadLibrary(RunTime.java:1690)
-         at org.sikuli.script.Finder$Finder2.<clinit>(Finder.java:571)
-         ... 2 more
- 
+         at java.lang.String.checkLastChar(String.java:62)
+         at java.lang.String.replaceAll(String.java:3530)
+         at org.sikuli.script.support.RunTime.addToWindowsSystemPath(RunTime.java:1722)
+         at org.sikuli.script.support.RunTime.libsExport(RunTime.java:1661)
+         at org.sikuli.script.support.RunTime.libsLoad(RunTime.java:1486)
+         at org.sikuli.script.support.RunTime.loadLibrary(RunTime.java:1690)
+         at org.sikuli.script.Finder$Finder2.<clinit>(Finder.java:571)
+         ... 2 more
  
  The problem happens on this line in addToWindowsSystemPath():
  
-         String libsPath =
- (fLibsFolder.getAbsolutePath()).replaceAll("/", "\\");
- 
+  String libsPath = (fLibsFolder.getAbsolutePath()).replaceAll("/",
+ "\\");
  
  Proposed fix:
  
  Use replace() instead of replaceAll()
  
-         String libsPath = (fLibsFolder.getAbsolutePath()).replace("/",
- "\\");
+  String libsPath = (fLibsFolder.getAbsolutePath()).replace("/", "\\");
  
  This is more appropriate anyway, since you just want to replace all
  occurences of a fixed string or a character.
  
- 
- By the way, try to run this line with the JVM of your choice (you might be surprised):
+ By the way, try to run this line with the JVM of your choice (you might
+ be surprised):
  
  "C:/bang/bang".replaceAll("/", "\\")
  
- You will probably get
+ I get this with Oracle JVM:
  
  Exception in thread "main" java.lang.IllegalArgumentException: character to be escaped is missing
-         at java.util.regex.Matcher.appendReplacement(Matcher.java:809)
-         at java.util.regex.Matcher.replaceAll(Matcher.java:955)
-         at java.lang.String.replaceAll(String.java:2223)
-         at J9StringReplaceAllBug.main(SikuliBug.java:4)
+         at java.util.regex.Matcher.appendReplacement(Matcher.java:809)
+         at java.util.regex.Matcher.replaceAll(Matcher.java:955)
+         at java.lang.String.replaceAll(String.java:2223)
+         at J9StringReplaceAllBug.main(SikuliBug.java:4)

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1840077

Title:
  Crash on OpenJ9 JVM on Windows

Status in Sikuli:
  New

Bug description:
  SikuliX crashes on Windows when running under OpenJ9 JVM (formerly IBM J9).
  The crash happens when the JVM loads the Finder class.

  This is a simple test program to reproduce the crash:

  public class SikuliBug {
   public static void main(String[] args) {
    new org.sikuli.script.Pattern("blah");
   }
  }

  Exception in thread "main" java.lang.ExceptionInInitializerError
          at java.lang.J9VMInternals.ensureError(J9VMInternals.java:148)
          at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:137)
          at org.sikuli.script.Pattern.<init>(Pattern.java:123)
          at SikuliBug.main(SikuliBug.java:3)
  Caused by: java.lang.IllegalArgumentException: Last character in replacement string can't be \, character to be escaped is required.
          at java.lang.String.checkLastChar(String.java:62)
          at java.lang.String.replaceAll(String.java:3530)
          at org.sikuli.script.support.RunTime.addToWindowsSystemPath(RunTime.java:1722)
          at org.sikuli.script.support.RunTime.libsExport(RunTime.java:1661)
          at org.sikuli.script.support.RunTime.libsLoad(RunTime.java:1486)
          at org.sikuli.script.support.RunTime.loadLibrary(RunTime.java:1690)
          at org.sikuli.script.Finder$Finder2.<clinit>(Finder.java:571)
          ... 2 more

  The problem happens on this line in addToWindowsSystemPath():

   String libsPath = (fLibsFolder.getAbsolutePath()).replaceAll("/",
  "\\");

  Proposed fix:

  Use replace() instead of replaceAll()

   String libsPath = (fLibsFolder.getAbsolutePath()).replace("/", "\\");

  This is more appropriate anyway, since you just want to replace all
  occurences of a fixed string or a character.

  By the way, try to run this line with the JVM of your choice (you
  might be surprised):

  "C:/bang/bang".replaceAll("/", "\\")

  I get this with Oracle JVM:

  Exception in thread "main" java.lang.IllegalArgumentException: character to be escaped is missing
          at java.util.regex.Matcher.appendReplacement(Matcher.java:809)
          at java.util.regex.Matcher.replaceAll(Matcher.java:955)
          at java.lang.String.replaceAll(String.java:2223)
          at J9StringReplaceAllBug.main(SikuliBug.java:4)

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1840077/+subscriptions


Follow ups