< prev index next >

src/java.logging/share/classes/java/util/logging/LogManager.java

Print this page

        

@@ -227,17 +227,19 @@
                 String cname = null;
                 try {
                     cname = System.getProperty("java.util.logging.manager");
                     if (cname != null) {
                         try {
-                            Class<?> clz = ClassLoader.getSystemClassLoader()
-                                    .loadClass(cname);
-                            mgr = (LogManager) clz.newInstance();
+                            @SuppressWarnings("deprecation")
+                            Object tmp = ClassLoader.getSystemClassLoader()
+                                .loadClass(cname).newInstance();
+                            mgr = (LogManager) tmp;
                         } catch (ClassNotFoundException ex) {
-                            Class<?> clz = Thread.currentThread()
-                                    .getContextClassLoader().loadClass(cname);
-                            mgr = (LogManager) clz.newInstance();
+                            @SuppressWarnings("deprecation")
+                            Object tmp = Thread.currentThread()
+                                .getContextClassLoader().loadClass(cname).newInstance();
+                            mgr = (LogManager) tmp;
                         }
                     }
                 } catch (Exception ex) {
                     System.err.println("Could not load Logmanager \"" + cname + "\"");
                     ex.printStackTrace();

@@ -974,12 +976,13 @@
     {
         String names[] = parseClassNames(handlersPropertyName);
         List<Handler> handlers = new ArrayList<>(names.length);
         for (String type : names) {
             try {
-                Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(type);
-                Handler hdl = (Handler) clz.newInstance();
+                @SuppressWarnings("deprecation")
+                Object o = ClassLoader.getSystemClassLoader().loadClass(type).newInstance();
+                Handler hdl = (Handler) o;
                 // Check if there is a property defining the
                 // this handler's level.
                 String levs = getProperty(type + ".level");
                 if (levs != null) {
                     Level l = Level.findLevel(levs);

@@ -1313,15 +1316,17 @@
                 // Instantiate the named class.  It is its constructor's
                 // responsibility to initialize the logging configuration, by
                 // calling readConfiguration(InputStream) with a suitable stream.
                 try {
                     Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(cname);
-                    clz.newInstance();
+                    @SuppressWarnings("deprecation")
+                    Object witness = clz.newInstance();
                     return;
                 } catch (ClassNotFoundException ex) {
                     Class<?> clz = Thread.currentThread().getContextClassLoader().loadClass(cname);
-                    clz.newInstance();
+                    @SuppressWarnings("deprecation")
+                    Object witness = clz.newInstance();
                     return;
                 }
             } catch (Exception ex) {
                 System.err.println("Logging configuration class \"" + cname + "\" failed");
                 System.err.println("" + ex);

@@ -1544,11 +1549,12 @@
                 String names[] = parseClassNames("config");
 
                 for (String word : names) {
                     try {
                         Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(word);
-                        clz.newInstance();
+                        @SuppressWarnings("deprecation")
+                        Object witness = clz.newInstance();
                     } catch (Exception ex) {
                         System.err.println("Can't load config class \"" + word + "\"");
                         System.err.println("" + ex);
                         // ex.printStackTrace();
                     }

@@ -2290,12 +2296,13 @@
     // we return the defaultValue.
     Filter getFilterProperty(String name, Filter defaultValue) {
         String val = getProperty(name);
         try {
             if (val != null) {
-                Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(val);
-                return (Filter) clz.newInstance();
+                @SuppressWarnings("deprecation")
+                Object o = ClassLoader.getSystemClassLoader().loadClass(val).newInstance();
+                return (Filter) o;
             }
         } catch (Exception ex) {
             // We got one of a variety of exceptions in creating the
             // class or creating an instance.
             // Drop through.

@@ -2311,12 +2318,13 @@
     // we return the defaultValue.
     Formatter getFormatterProperty(String name, Formatter defaultValue) {
         String val = getProperty(name);
         try {
             if (val != null) {
-                Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(val);
-                return (Formatter) clz.newInstance();
+                @SuppressWarnings("deprecation")
+                Object o = ClassLoader.getSystemClassLoader().loadClass(val).newInstance();
+                return (Formatter) o;
             }
         } catch (Exception ex) {
             // We got one of a variety of exceptions in creating the
             // class or creating an instance.
             // Drop through.
< prev index next >