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

Class::getResource and getResourceAsStream are unspecified when name is empty string

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp
      java version "1.8.0_151"
      Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      Accordingly to Javadoc (https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getResource-java.lang.String-) Class.getResource method returns "A URL object or null if no resource with this name is found". However, a different result is returned when executing the following program.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the program
      2. Run it using Oracle HotSpot java

      ACTUAL -
      file:.../target/classes/

      ---------- BEGIN SOURCE ----------
      public enum A {
          X, Y
      }

      public class B {
          public static void main(String[] args) {
              System.out.println(A[].class.getResource(""));
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            bchristi Brent Christian
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: