< prev index next >

src/java.base/share/classes/java/net/URL.java

Print this page

        

@@ -1196,12 +1196,13 @@
         private static String PREFIX = "sun.net.www.protocol";
 
         public URLStreamHandler createURLStreamHandler(String protocol) {
             String name = PREFIX + "." + protocol + ".Handler";
             try {
-                Class<?> c = Class.forName(name);
-                return (URLStreamHandler)c.newInstance();
+                @SuppressWarnings("deprecation")
+                Object o = Class.forName(name).newInstance();
+                return (URLStreamHandler)o;
             } catch (ClassNotFoundException x) {
                 // ignore
             } catch (Exception e) {
                 // For compatibility, all Exceptions are ignored.
                 // any number of exceptions can get thrown here

@@ -1232,11 +1233,13 @@
                     if (cl != null) {
                         cls = cl.loadClass(clsName);
                     }
                 }
                 if (cls != null) {
-                    handler = (URLStreamHandler)cls.newInstance();
+                    @SuppressWarnings("deprecation")
+                    Object tmp = cls.newInstance();
+                    handler = (URLStreamHandler)tmp;
                 }
             } catch (Exception e) {
                 // any number of exceptions can get thrown here
             }
         }
< prev index next >