jaxp/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java
changeset 31497 4a6b2e733c0d
parent 25868 686eef1e7a79
child 45853 bfa06be36a17
--- a/jaxp/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java	Wed Jul 05 20:39:43 2017 +0200
+++ b/jaxp/src/java.xml/share/classes/org/w3c/dom/bootstrap/DOMImplementationRegistry.java	Tue Jun 30 12:04:27 2015 +0200
@@ -333,59 +333,36 @@
     }
 
     /**
-     * A simple JRE (Java Runtime Environment) 1.1 test
-     *
-     * @return <code>true</code> if JRE 1.1
-     */
-    private static boolean isJRE11() {
-        try {
-            Class c = Class.forName("java.security.AccessController");
-            // java.security.AccessController existed since 1.2 so, if no
-            // exception was thrown, the DOM application is running in a JRE
-            // 1.2 or higher
-            return false;
-        } catch (Exception ex) {
-            // ignore
-        }
-        return true;
-    }
-
-    /**
-     * This method returns the ContextClassLoader or <code>null</code> if
-     * running in a JRE 1.1
+     * This method returns the ContextClassLoader.
      *
      * @return The Context Classloader
      */
     private static ClassLoader getContextClassLoader() {
-        return isJRE11()
-            ? null
-            : (ClassLoader)
-              AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
-                        ClassLoader classLoader = null;
-                        try {
-                            classLoader =
-                                Thread.currentThread().getContextClassLoader();
-                        } catch (SecurityException ex) {
-                        }
-                        return classLoader;
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
+                @Override
+                public ClassLoader run() {
+                    ClassLoader classLoader = null;
+                    try {
+                        classLoader =
+                            Thread.currentThread().getContextClassLoader();
+                    } catch (SecurityException ex) {
                     }
-                });
+                    return classLoader;
+                }
+            });
     }
 
     /**
      * This method returns the system property indicated by the specified name
-     * after checking access control privileges. For a JRE 1.1, this check is
-     * not done.
+     * after checking access control privileges.
      *
      * @param name the name of the system property
      * @return the system property
      */
     private static String getSystemProperty(final String name) {
-        return isJRE11()
-            ? (String) System.getProperty(name)
-            : (String) AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
+                    @Override
+                    public String run() {
                         return System.getProperty(name);
                     }
                 });
@@ -394,7 +371,7 @@
     /**
      * This method returns an Inputstream for the reading resource
      * META_INF/services/org.w3c.dom.DOMImplementationSourceList after checking
-     * access control privileges. For a JRE 1.1, this check is not done.
+     * access control privileges.
      *
      * @param classLoader classLoader
      * @param name the resource
@@ -402,28 +379,18 @@
      */
     private static InputStream getResourceAsStream(final ClassLoader classLoader,
                                                    final String name) {
-        if (isJRE11()) {
-            InputStream ris;
-            if (classLoader == null) {
-                ris = ClassLoader.getSystemResourceAsStream(name);
-            } else {
-                ris = classLoader.getResourceAsStream(name);
-            }
-            return ris;
-        } else {
-            return (InputStream)
-                AccessController.doPrivileged(new PrivilegedAction() {
-                        public Object run() {
-                            InputStream ris;
-                            if (classLoader == null) {
-                                ris =
-                                    ClassLoader.getSystemResourceAsStream(name);
-                            } else {
-                                ris = classLoader.getResourceAsStream(name);
-                            }
-                            return ris;
-                        }
-                    });
-        }
+        return AccessController.doPrivileged(new PrivilegedAction<>() {
+                @Override
+                public InputStream run() {
+                    InputStream ris;
+                    if (classLoader == null) {
+                        ris =
+                            ClassLoader.getSystemResourceAsStream(name);
+                    } else {
+                        ris = classLoader.getResourceAsStream(name);
+                    }
+                    return ris;
+                }
+            });
     }
 }