src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/URLReader.java

Print this page

        

@@ -28,10 +28,11 @@
 import java.io.CharArrayReader;
 import java.io.IOException;
 import java.io.Reader;
 import java.net.URL;
 import java.nio.charset.Charset;
+import java.util.Objects;
 import jdk.nashorn.internal.runtime.Source;
 
 /**
  * A Reader that reads from a URL. Used to make sure that the reader
  * reads content from given URL and can be trusted to do so.

@@ -75,12 +76,11 @@
      * @param url URL for this URLReader
      * @param cs  Charset used to convert bytes to chars
      * @throws NullPointerException if url is null
      */
     public URLReader(final URL url, final Charset cs) {
-        // null check
-        url.getClass();
+        Objects.requireNonNull(url);
         this.url = url;
         this.cs  = cs;
     }
 
     @Override