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

NPE in PlatformUtil.getRTDir() if PlaformUtil.class cannot be located

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • javafx
    • None

      In RoboVM we strip out .class files from jar files since the .class files aren't needed at runtime (RoboVM compiles classes AOT and doesn't support loading .class files at runtime). getRTDir() locates the jar file containing PlatformUtil.class but on RoboVM classUrlString will be null resulting in NPE later on. Here's a patch which fixes this and returns null if PlatformUtil.class cannot be located:

      diff -r 49cea84b56be javafx-common/src/com/sun/javafx/PlatformUtil.java
      --- a/javafx-common/src/com/sun/javafx/PlatformUtil.java Thu May 02 21:21:03 2013 -0700
      +++ b/javafx-common/src/com/sun/javafx/PlatformUtil.java Mon May 13 11:14:44 2013 +0200
      @@ -236,7 +236,11 @@
               try {
                   String theClassFile = "PlatformUtil.class";
                   Class theClass = PlatformUtil.class;
      - String classUrlString = theClass.getResource(theClassFile).toString();
      + URL classUrl = theClass.getResource(theClassFile);
      + if (classUrl == null) {
      + return null;
      + }
      + String classUrlString = classUrl.toString();
                   if (!classUrlString.startsWith("jar:file:")
                           || classUrlString.indexOf('!') == -1) {
                       return null;

            snorthov Steve Northover (Inactive)
            duke J. Duke
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: