You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2022/04/19 14:49:31 UTC

svn commit: r1900040 [4/8] - in /db/derby/code/trunk/java: org.apache.derby.client/org/apache/derby/client/ org.apache.derby.client/org/apache/derby/client/am/ org.apache.derby.client/org/apache/derby/client/net/ org.apache.derby.commons/org/apache/der...

Modified: db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/jmx/JMXManagementService.java?rev=1900040&r1=1900039&r2=1900040&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/jmx/JMXManagementService.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/jmx/JMXManagementService.java Tue Apr 19 14:49:30 2022
@@ -22,11 +22,6 @@
 package org.apache.derby.impl.services.jmx;
 
 import java.lang.management.ManagementFactory;
-import java.security.AccessControlException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -167,26 +162,9 @@ public final class JMXManagementService
      * boot() to allow future changes where the jmx management
      * can be enabled on the fly.
      */
-    // AccessController deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     private synchronized void findServer() {
         
-        try {
-            mbeanServer = AccessController
-                    .doPrivileged(new PrivilegedAction<MBeanServer>() {
-                        public MBeanServer run() {
-                            return ManagementFactory.getPlatformMBeanServer();
-                        }
-                    });
-            
-        } catch (SecurityException se) {
-            // Ignoring inability to create or
-            // find the mbean server. MBeans can continue
-            // to be registered with this service and
-            // startMangement() can be called to get
-            // them registered with JMX if someone else
-            // starts the MBean server.
-        }
+        mbeanServer = ManagementFactory.getPlatformMBeanServer();
     }
 
     /**
@@ -245,8 +223,6 @@ public final class JMXManagementService
     /**
      * Register an mbean with the platform mbean server.
      */
-    // AccessController deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     private void jmxRegister(final StandardMBean standardMBean,
             final ObjectName beanName) throws JMException
     {
@@ -255,25 +231,7 @@ public final class JMXManagementService
         if (mbeanServer.isRegistered(beanName))
             return;
             
-        try {
-
-            AccessController
-               .doPrivileged(new PrivilegedExceptionAction<Object>() {
-
-                    public Object run() throws JMException {
-                        mbeanServer.registerMBean(standardMBean, beanName);
-                        return null;
-                    }
-
-                });
-
-        } catch (PrivilegedActionException pae) {
-            throw (JMException) pae.getException();
-        } catch (SecurityException se) {
-            // If we can't register the MBean then so be it.
-            // The application can later enabled the MBeans
-            // by using org.apache.derby.mbeans.Management
-        }
+        mbeanServer.registerMBean(standardMBean, beanName);
     }
     
     /**
@@ -312,36 +270,20 @@ public final class JMXManagementService
      * all vaid mbeans (that are still registered with this service).
      * @param mbeanName
      */
-    // AccessController deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     private void jmxUnregister(final ObjectName mbeanName) {
 
         if (!mbeanServer.isRegistered(mbeanName))
             return;
 
         try {
-
-            AccessController
-                    .doPrivileged(new PrivilegedExceptionAction<Object>() {
-
-                        public Object run() throws JMException {
-                            mbeanServer.unregisterMBean(mbeanName);
-                            return null;
-                        }
-
-                    });
-
-        } catch (PrivilegedActionException pae) {
-            // TODO - this is called on shutdown where
-            // we don't really care about errors.
-            // JMException jme = (JMException) pae.getException();
-            //if (!(jme instanceof InstanceNotFoundException))
-                // throw StandardException.plainWrapException(jme);
-        } catch (SecurityException se) {
-            // Can't unregister the MBean we registered due to permission
-            // problems, oh-well just leave it there. We are fail-safe
-            // if we attempt to re-register it.
+            mbeanServer.unregisterMBean(mbeanName);
         }
+        // TODO - this is called on shutdown where
+        // we don't really care about errors.
+        // JMException jme = (JMException) pae.getException();
+        //if (!(jme instanceof InstanceNotFoundException))
+        // throw StandardException.plainWrapException(jme);
+        catch (Exception infe) {}
     }
 
     public synchronized boolean isManagementActive() {
@@ -413,21 +355,10 @@ public final class JMXManagementService
                 SystemPermission.JMX, SystemPermission.CONTROL);
 
     /**
-     * Require SystemPermission("jmx", "control") to change
-     * the management state.
+     * This method used to require SystemPermission("jmx", "control") to change
+     * the management state. 
      */
-    // AccessControlException and SecurityManager deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     private void checkJMXControl() {
-        try {
-            if (System.getSecurityManager() != null)
-                AccessController.checkPermission(CONTROL);
-        } catch (AccessControlException e) {
-            // Need to throw a simplified version as AccessControlException
-            // will have a reference to Derby's SystemPermission which most likely
-            // will not be available on the client.
-            throw new SecurityException(e.getMessage());
-        }
     }
 
     public synchronized String getSystemIdentifier() {
@@ -440,23 +371,12 @@ public final class JMXManagementService
     }
     
     /**
-     * Privileged Monitor lookup. Must be private so that user code
+     * Must be private so that user code
      * can't call this entry point.
      */
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     private  static  ModuleFactory  getMonitor()
     {
-        return AccessController.doPrivileged
-            (
-             new PrivilegedAction<ModuleFactory>()
-             {
-                 public ModuleFactory run()
-                 {
-                     return Monitor.getMonitor();
-                 }
-             }
-             );
+        return Monitor.getMonitor();
     }
 
 }

Modified: db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/locks/Deadlock.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/locks/Deadlock.java?rev=1900040&r1=1900039&r2=1900040&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/locks/Deadlock.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/locks/Deadlock.java Tue Apr 19 14:49:30 2022
@@ -32,8 +32,6 @@ import org.apache.derby.iapi.services.co
 import org.apache.derby.iapi.store.access.TransactionController;
 import org.apache.derby.iapi.store.access.TransactionInfo;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.Hashtable;
 import java.util.Dictionary;
 import java.util.Stack;
@@ -567,30 +565,12 @@ inner:		for (;;) {
 	}
 
     /**
-     * Privileged lookup of a Context. Must be package protected so that user code
+     * Must be package protected so that user code
      * can't call this entry point.
      */
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     static  Context    getContext( final String contextID )
     {
-        if ( System.getSecurityManager() == null )
-        {
-            return ContextService.getContext( contextID );
-        }
-        else
-        {
-            return AccessController.doPrivileged
-                (
-                 new PrivilegedAction<Context>()
-                 {
-                     public Context run()
-                     {
-                         return ContextService.getContext( contextID );
-                     }
-                 }
-                 );
-        }
+        return ContextService.getContext( contextID );
     }
 
 } 

Modified: db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/BaseMonitor.java?rev=1900040&r1=1900039&r2=1900040&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/BaseMonitor.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/BaseMonitor.java Tue Apr 19 14:49:30 2022
@@ -32,9 +32,6 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.URL;
-import java.security.PrivilegedAction;
-import java.security.AccessController;
-import java.security.AccessControlException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
@@ -232,163 +229,153 @@ abstract class BaseMonitor
 		}
 	}
 
-    // AccessControlException deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	protected final void runWithState(Properties properties, PrintWriter log) {
+    protected final void runWithState(Properties properties, PrintWriter log) {
 
-		bootProperties = properties;
-		logging = log;
+        bootProperties = properties;
+        logging = log;
 
-		// false indicates the full monitor is required, not the lite.
+        // false indicates the full monitor is required, not the lite.
         if (!initialize(false)) {
             dumpTempWriter(true);
             return;
         }
 
-		// if monitor is already set then the system is already
-		// booted or in the process of booting or shutting down.
-		if ( setMonitor( this ) ) { return; }
+        // if monitor is already set then the system is already
+        // booted or in the process of booting or shutting down.
+        if ( setMonitor( this ) ) { return; }
 
-		MessageService.setFinder(this);
+        MessageService.setFinder(this);
 
-		if (SanityManager.DEBUG) {
-			reportOn = Boolean.valueOf(PropertyUtil.getSystemProperty("derby.monitor.verbose")).booleanValue();
-		}
-
-		// Set up the application properties
-		applicationProperties = readApplicationProperties();
+        if (SanityManager.DEBUG) {
+            reportOn = Boolean.valueOf(PropertyUtil.getSystemProperty("derby.monitor.verbose")).booleanValue();
+        }
 
-		// The security manager may not let us get the System properties
-		// object itself, although it may let us look at the properties in it.
-		Properties systemProperties = null;
+        // Set up the application properties
+        applicationProperties = readApplicationProperties();
 
-		if (SanityManager.DEBUG) {
-			// In a production system having this call would
-			// mean would we have to document it for security
-			// permission reasons. Since we don't require it and
-			// its a big security hole to allow external code to
-			// overwrite our own implementations we just support
-			// it for debugging. This means VM executions such as
-			// java -Dderby.module.javaCompiler=com.ibm.db2j.impl.BasicServices.JavaCompiler.JavaLang.JLJava ...
-			// would only work with a sane codeline.
-			try {
-				systemProperties = System.getProperties();
-			} catch (SecurityException se) {
-			}
-		}
+        // The security manager may not let us get the System properties
+        // object itself, although it may let us look at the properties in it.
+        Properties systemProperties = null;
+
+        if (SanityManager.DEBUG) {
+            // In a production system having this call would
+            // mean would we have to document it for security
+            // permission reasons. Since we don't require it and
+            // its a big security hole to allow external code to
+            // overwrite our own implementations we just support
+            // it for debugging. This means VM executions such as
+            // java -Dderby.module.javaCompiler=com.ibm.db2j.impl.BasicServices.JavaCompiler.JavaLang.JLJava ...
+            // would only work with a sane codeline.
+            systemProperties = System.getProperties();
+        }
 
-		Vector<Class<?>> bootImplementations = getImplementations(bootProperties, false);
+        Vector<Class<?>> bootImplementations = getImplementations(bootProperties, false);
 
-		Vector<Class<?>> systemImplementations = null;
-		Vector<Class<?>> applicationImplementations = null;
+        Vector<Class<?>> systemImplementations = null;
+        Vector<Class<?>> applicationImplementations = null;
 
-		// TEMP - making this sanity only breaks the unit test code
-		// I will fix soon, djd.
-		if (true || SanityManager.DEBUG) {
-			// Don't allow external code to override our implementations.
-			systemImplementations = getImplementations(systemProperties, false);
-			applicationImplementations = getImplementations(applicationProperties, false);
-		}
+        // TEMP - making this sanity only breaks the unit test code
+        // I will fix soon, djd.
+        if (true || SanityManager.DEBUG) {
+            // Don't allow external code to override our implementations.
+            systemImplementations = getImplementations(systemProperties, false);
+            applicationImplementations = getImplementations(applicationProperties, false);
+        }
 
         Vector<Class<?>> defaultImplementations = getDefaultImplementations();
 
-		int implementationCount = 0;
-		if (bootImplementations != null)
-			implementationCount++;
-
-		// TEMP - making this sanity only breaks the unit test code
-		if (true || SanityManager.DEBUG) {
-			// Don't allow external code to override our implementations.
-			if (systemImplementations != null)
-				implementationCount++;
-			if (applicationImplementations != null)
-				implementationCount++;
-		}
+        int implementationCount = 0;
+        if (bootImplementations != null)
+            implementationCount++;
+
+        // TEMP - making this sanity only breaks the unit test code
+        if (true || SanityManager.DEBUG) {
+            // Don't allow external code to override our implementations.
+            if (systemImplementations != null)
+                implementationCount++;
+            if (applicationImplementations != null)
+                implementationCount++;
+        }
 
-		if (defaultImplementations != null)
-			implementationCount++;
+        if (defaultImplementations != null)
+            implementationCount++;
 
         implementationSets = new ArrayList<List<Class<?>>>(implementationCount);
 
-		if (bootImplementations != null)
+        if (bootImplementations != null)
             implementationSets.add(bootImplementations);
 		
-		if (true || SanityManager.DEBUG) {
-			// Don't allow external code to override our implementations.
-			if (systemImplementations != null)
+        if (true || SanityManager.DEBUG) {
+            // Don't allow external code to override our implementations.
+            if (systemImplementations != null)
                 implementationSets.add(systemImplementations);
-			if (applicationImplementations != null)
+            if (applicationImplementations != null)
                 implementationSets.add(applicationImplementations);
-		}
+        }
 
-		if (defaultImplementations != null)
+        if (defaultImplementations != null)
             implementationSets.add(defaultImplementations);
 
-		if (SanityManager.DEBUG) {
-			// Look for the derby.debug.* properties.
-			if (applicationProperties != null) {
-				addDebugFlags(applicationProperties.getProperty(Monitor.DEBUG_FALSE), false);
-				addDebugFlags(applicationProperties.getProperty(Monitor.DEBUG_TRUE), true);
-			}
+        if (SanityManager.DEBUG) {
+            // Look for the derby.debug.* properties.
+            if (applicationProperties != null) {
+                addDebugFlags(applicationProperties.getProperty(Monitor.DEBUG_FALSE), false);
+                addDebugFlags(applicationProperties.getProperty(Monitor.DEBUG_TRUE), true);
+            }
 
-			addDebugFlags(PropertyUtil.getSystemProperty(Monitor.DEBUG_FALSE), false);
-			addDebugFlags(PropertyUtil.getSystemProperty(Monitor.DEBUG_TRUE), true);
-		}
+            addDebugFlags(PropertyUtil.getSystemProperty(Monitor.DEBUG_FALSE), false);
+            addDebugFlags(PropertyUtil.getSystemProperty(Monitor.DEBUG_TRUE), true);
+        }
 
-		try {
-			systemStreams = (InfoStreams) Monitor.startSystemModule("org.apache.derby.shared.common.stream.InfoStreams");
+        try {
+            systemStreams = (InfoStreams) Monitor.startSystemModule("org.apache.derby.shared.common.stream.InfoStreams");
 
-			if (SanityManager.DEBUG) {
-				SanityManager.SET_DEBUG_STREAM(systemStreams.stream().getPrintWriter());
-			}
+            if (SanityManager.DEBUG) {
+                SanityManager.SET_DEBUG_STREAM(systemStreams.stream().getPrintWriter());
+            }
 
-			contextService = new ContextService();
+            contextService = new ContextService();
 
-			uuidFactory = (UUIDFactory) Monitor.startSystemModule("org.apache.derby.iapi.services.uuid.UUIDFactory");
+            uuidFactory = (UUIDFactory) Monitor.startSystemModule("org.apache.derby.iapi.services.uuid.UUIDFactory");
 
             timerFactory = (TimerFactory)Monitor.startSystemModule("org.apache.derby.iapi.services.timer.TimerFactory");
             
             Monitor.startSystemModule(Module.JMX);
 
-		} catch (StandardException se) {
-
-			// if we can't create an error log or a context then there's no point going on
-			reportException(se);
-			// dump any messages we have been saving ...
-			dumpTempWriter(true);
+        } catch (StandardException se) {
 
-			return;
-        } catch (AccessControlException e) {
+            // if we can't create an error log or a context then there's no point going on
+            reportException(se);
+            // dump any messages we have been saving ...
             dumpTempWriter(true);
-            throw e;
-        }
 
-		// switch cover to the real error stream and
-		// dump any messages we have been saving ...
-		dumpTempWriter(false);
+            return;
+        }
 
-		if (SanityManager.DEBUG && reportOn) {
-			dumpProperties("-- Boot Properties --", bootProperties);
-			dumpProperties("-- System Properties --", systemProperties);
-			dumpProperties("-- Application Properties --", applicationProperties);
-		}
-        
-        
+        // switch cover to the real error stream and
+        // dump any messages we have been saving ...
+        dumpTempWriter(false);
+
+        if (SanityManager.DEBUG && reportOn) {
+            dumpProperties("-- Boot Properties --", bootProperties);
+            dumpProperties("-- System Properties --", systemProperties);
+            dumpProperties("-- Application Properties --", applicationProperties);
+        }
 
-		// bootup all the service providers
-		determineSupportedServiceProviders();
+        // bootup all the service providers
+        determineSupportedServiceProviders();
 
-		// See if automatic booting of persistent services is required
-		boolean bootAll = Boolean.valueOf(PropertyUtil.getSystemProperty(Property.BOOT_ALL)).booleanValue();
+        // See if automatic booting of persistent services is required
+        boolean bootAll = Boolean.valueOf(PropertyUtil.getSystemProperty(Property.BOOT_ALL)).booleanValue();
 
 
-		startServices(bootProperties, bootAll);
-		startServices(systemProperties, bootAll);
-		startServices(applicationProperties, bootAll);
+        startServices(bootProperties, bootAll);
+        startServices(systemProperties, bootAll);
+        startServices(applicationProperties, bootAll);
 
-		if (bootAll) // only if automatic booting is required
-			bootPersistentServices( );
-	}
+        if (bootAll) // only if automatic booting is required
+        { bootPersistentServices( ); }
+    }
 
     public  String  getCanonicalServiceName( String userSpecifiedName )
         throws StandardException
@@ -2099,74 +2086,40 @@ nextModule:
     }
 
     /**
-     * Privileged lookup of the ContextService. Must be private so that user code
+     * Must be private so that user code
      * can't call this entry point.
      */
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     private  static  ContextService    getContextService()
     {
-        return AccessController.doPrivileged
-            (
-             new PrivilegedAction<ContextService>()
-             {
-                 public ContextService run()
-                 {
-                     return ContextService.getFactory();
-                 }
-             }
-             );
+        return ContextService.getFactory();
     }    
 
     /**
-     * Privileged shutdown of the ContextService. Must be private so that user code
+     *  Must be private so that user code
      * can't call this entry point.
      */
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     private  static  void    stopContextService()
     {
-        AccessController.doPrivileged
-            (
-             new PrivilegedAction<Object>()
-             {
-                 public Object run()
-                 {
-                     ContextService.stop();
-                     Monitor.clearMonitor();
-                     return null;
-                 }
-             }
-             );
+        ContextService.stop();
+        Monitor.clearMonitor();
     }    
 
     /**
-     * Privileged startup. Must be private so that user code
+     * Must be private so that user code
      * can't call this entry point. Returns true if the system is
      * already booted or in the process of shutting down.
      */
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     private  static  boolean    setMonitor( final BaseMonitor baseMonitor )
     {
-        return AccessController.doPrivileged
-            (
-             new PrivilegedAction<Boolean>()
-             {
-                 public Boolean run()
-                 {
-                     return !Monitor.setMonitor( baseMonitor );
-                 }
-             }
-             ).booleanValue();
+        return !Monitor.setMonitor( baseMonitor );
     }
 
     /**
-		Initialize the monitor wrt the current environemnt.
-		Returns false if the monitor cannot be initialized, true otherwise.
-	*/
-	abstract boolean initialize(boolean lite);
-
+       Initialize the monitor wrt the current environemnt.
+       Returns false if the monitor cannot be initialized, true otherwise.
+    */
+    abstract boolean initialize(boolean lite);
+    
     class ProviderEnumeration implements Enumeration<PersistentService>
     {
         private Enumeration<String> serviceProvidersKeys = (serviceProviders == null) ? null :

Modified: db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/FileMonitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/FileMonitor.java?rev=1900040&r1=1900039&r2=1900040&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/FileMonitor.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/FileMonitor.java Tue Apr 19 14:49:30 2022
@@ -26,9 +26,6 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -236,103 +233,62 @@ public final class FileMonitor extends B
                 MessageId.CANNOT_SET_DAEMON, e.toString()));
     }
 
-	/*
-	** Priv block code, moved out of the old Java2 version.
-	*/
+    /*
+    ** Priv block code, moved out of the old Java2 version.
+    */
 
-	/**
-		Initialize the system in a privileged block.
-	**/
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	final boolean initialize(final boolean lite)
-	{
-        // SECURITY PERMISSION - OP2, OP2a, OP2b
-        return (AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-            public Boolean run() {
-                return Boolean.valueOf(PBinitialize(lite));
-            }
-        })).booleanValue();
-	}
+    /**
+       Initialize the system.
+    **/
+    final boolean initialize(final boolean lite)
+    {
+        return Boolean.valueOf(PBinitialize(lite));
+    }
 
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	final Properties getDefaultModuleProperties() {
-        // SECURITY PERMISSION - IP1
-        return AccessController.doPrivileged(
-                new PrivilegedAction<Properties>() {
-            public Properties run() {
-                return FileMonitor.super.getDefaultModuleProperties();
-            }
-        });
+    final Properties getDefaultModuleProperties() {
+        return FileMonitor.super.getDefaultModuleProperties();
     }
 
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	public final String getJVMProperty(final String key) {
-		if (!key.startsWith("derby."))
-			return PBgetJVMProperty(key);
-
-        // SECURITY PERMISSION - OP1
-        return AccessController.doPrivileged(new PrivilegedAction<String>() {
-            public String run() {
-                return PBgetJVMProperty(key);
-            }
-        });
-	}
+    public final String getJVMProperty(final String key) {
+        if (!key.startsWith("derby."))
+        { return PBgetJVMProperty(key); }
+
+        return PBgetJVMProperty(key);
+    }
 
     /**
      * Warnings are suppressed because ThreadGroup.setDaemon() was slated
      * for removal by Open JDK build 16-ea+26-1764. See https://issues.apache.org/jira/browse/DERBY-7094
      */
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
     @SuppressWarnings("removal")
-	public synchronized final Thread getDaemonThread(
+    public synchronized final Thread getDaemonThread(
             final Runnable task,
             final String name,
             final boolean setMinPriority) {
-        return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
-            public Thread run() {
-                try {
-                    return FileMonitor.super.getDaemonThread(
-                            task, name, setMinPriority);
-                } catch (IllegalThreadStateException e) {
-                    // We may get an IllegalThreadStateException if all the
-                    // previously running daemon threads have completed and the
-                    // daemon group has been automatically destroyed. If that's
-                    // what happened, create a new daemon group and try again.
-                    if (daemonGroup != null && daemonGroup.isDestroyed()) {
-                        daemonGroup = createDaemonGroup();
-                        return FileMonitor.super.getDaemonThread(
-                                task, name, setMinPriority);
-                    } else {
-                        throw e;
-                    }
-                }
+        try {
+            return FileMonitor.super.getDaemonThread(
+                task, name, setMinPriority);
+        } catch (IllegalThreadStateException e) {
+            // We may get an IllegalThreadStateException if all the
+            // previously running daemon threads have completed and the
+            // daemon group has been automatically destroyed. If that's
+            // what happened, create a new daemon group and try again.
+            if (daemonGroup != null && daemonGroup.isDestroyed()) {
+                daemonGroup = createDaemonGroup();
+                return FileMonitor.super.getDaemonThread(
+                    task, name, setMinPriority);
+            } else {
+                throw e;
             }
-        });
+        }
     }
 
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	final InputStream applicationPropertiesStream()
-	  throws IOException {
-		try {
-			// SECURITY PERMISSION - OP3
-			return AccessController.doPrivileged(
-                    new PrivilegedExceptionAction<InputStream>() {
-                public InputStream run() throws IOException {
-                    return PBapplicationPropertiesStream();
-                }
-            });
-		}
-        catch (java.security.PrivilegedActionException pae)
-        {
-			throw (IOException) pae.getException();
-		}
-	}
+    final InputStream applicationPropertiesStream()
+        throws IOException {
+        return PBapplicationPropertiesStream();
+    }
 
-	public final ProductVersionHolder getEngineVersion() {
-		return engineVersion;
-	}
+    public final ProductVersionHolder getEngineVersion() {
+        return engineVersion;
+    }
 }

Modified: db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java?rev=1900040&r1=1900039&r2=1900040&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java Tue Apr 19 14:49:30 2022
@@ -60,10 +60,6 @@ import java.util.Enumeration;
 import java.util.NoSuchElementException;
 import java.util.Properties;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedExceptionAction;
-import java.security.PrivilegedActionException;
 import org.apache.derby.iapi.services.io.FileUtil;
 
 /**
@@ -83,8 +79,6 @@ final class StorageFactoryService implem
     private StorageFactory rootStorageFactory;
     private char separatorChar;
 
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     StorageFactoryService( String subSubProtocol, Class storageFactoryClass)
         throws StandardException
     {
@@ -97,29 +91,20 @@ final class StorageFactoryService implem
             final File relativeRoot = (File) monitorEnv;
             try
             {
-                AccessController.doPrivileged(
-                    new java.security.PrivilegedExceptionAction<Object>()
-                    {
-                        public Object run() throws IOException, StandardException
-                        {
-                            home = relativeRoot.getPath();
-                            canonicalHome = relativeRoot.getCanonicalPath();
-                            rootStorageFactory = getStorageFactoryInstance( true, null, null, null);
+                home = relativeRoot.getPath();
+                canonicalHome = relativeRoot.getCanonicalPath();
+                rootStorageFactory = getStorageFactoryInstance( true, null, null, null);
 
-                            if( home != null)
-                            {
-                                StorageFile rootDir = rootStorageFactory.newStorageFile( null);
-                                boolean created = rootDir.mkdirs();
-                                if (created) {
-                                    rootDir.limitAccessToOwner();
-                                }
-                            }
-                            return null;
-                        }
+                if( home != null)
+                {
+                    StorageFile rootDir = rootStorageFactory.newStorageFile( null);
+                    boolean created = rootDir.mkdirs();
+                    if (created) {
+                        rootDir.limitAccessToOwner();
                     }
-                    );
+                }
             }
-            catch( PrivilegedActionException pae)
+            catch(IOException pae)
             {
                 home = null;
                 canonicalHome = null;
@@ -133,16 +118,7 @@ final class StorageFactoryService implem
             }
             catch( IOException ioe){ throw Monitor.exceptionStartingModule(/*serviceName, */ ioe); }
         }
-        AccessController.doPrivileged(
-            new java.security.PrivilegedAction<Object>()
-            {
-                public Object run()
-                {
-                    separatorChar = rootStorageFactory.getSeparator();
-                    return null;
-                }
-            }
-            );
+        separatorChar = rootStorageFactory.getSeparator();
     } // end of constructor
 
     
@@ -177,8 +153,6 @@ final class StorageFactoryService implem
      * @exception IOException if create, the database directory does not exist, and it cannot be created;
      *                        if !create and the database does not exist as a directory.
      */
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     public StorageFactory getStorageFactoryInstance(final boolean useHome,
                                                     final String databaseName,
                                                     final String tempDirName,
@@ -187,24 +161,21 @@ final class StorageFactoryService implem
     {
         try
         {
-            return AccessController.doPrivileged(
-                new PrivilegedExceptionAction<StorageFactory>()
-                {
-                  public StorageFactory run() throws InstantiationException,
-                      IllegalAccessException, IOException, NoSuchMethodException, InvocationTargetException
-                    {
-                        return privGetStorageFactoryInstance( useHome, databaseName, tempDirName, uniqueName);
-                    }
-                });
-        }
-        catch (PrivilegedActionException pae)
-        {
-            Exception e = pae.getException();
-            throw StandardException.newException( SQLState.REGISTERED_CLASS_INSTANCE_ERROR,
-                                                  e, subSubProtocol, storageFactoryClass);
+            return privGetStorageFactoryInstance( useHome, databaseName, tempDirName, uniqueName);
         }
+        catch (IOException ioe) { throw registeredClassInstanceError(ioe); }
+        catch (InstantiationException ie) { throw registeredClassInstanceError(ie); }
+        catch (IllegalAccessException ia) { throw registeredClassInstanceError(ia); }
+        catch (NoSuchMethodException nsme) { throw registeredClassInstanceError(nsme); }
+        catch (InvocationTargetException ite) { throw registeredClassInstanceError(ite); }
     } // end of getStorageFactoryInstance
 
+    private StandardException registeredClassInstanceError(Exception e)
+    {
+        return StandardException.newException( SQLState.REGISTERED_CLASS_INSTANCE_ERROR,
+                                               e, subSubProtocol, storageFactoryClass);
+    }
+
     private StorageFactory privGetStorageFactoryInstance( boolean useHome,
                                                           String databaseName,
                                                           String tempDirName,
@@ -251,243 +222,197 @@ final class StorageFactoryService implem
     }
 
     /**
-		Open the service properties in the directory identified by the service name.
+       Open the service properties in the directory identified by the service name.
 
-		@return A Properties object or null if serviceName does not represent a valid service.
+       @return A Properties object or null if serviceName does not represent a valid service.
 
-		@exception StandardException Service appears valid but the properties cannot be created.
-	*/
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	public Properties getServiceProperties( final String serviceName, Properties defaultProperties)
-		throws StandardException
+       @exception StandardException Service appears valid but the properties cannot be created.
+    */
+    public Properties getServiceProperties( final String serviceName, Properties defaultProperties)
+        throws StandardException
     {
-		if (SanityManager.DEBUG) {
-			if (! serviceName.equals(getCanonicalServiceName(serviceName)))
-			{
-				SanityManager.THROWASSERT("serviceName (" + serviceName + 
-										  ") expected to equal getCanonicalServiceName(serviceName) (" +
-										  getCanonicalServiceName(serviceName) + ")");
-			}
-		}
+        if (SanityManager.DEBUG) {
+            if (! serviceName.equals(getCanonicalServiceName(serviceName)))
+            {
+                SanityManager.THROWASSERT("serviceName (" + serviceName + 
+                                          ") expected to equal getCanonicalServiceName(serviceName) (" +
+                                          getCanonicalServiceName(serviceName) + ")");
+            }
+        }
 
-		//recreate the service root  if requested by the user.
-		final String recreateFrom = recreateServiceRoot(serviceName, defaultProperties);
+        //recreate the service root  if requested by the user.
+        final String recreateFrom = recreateServiceRoot(serviceName, defaultProperties);
 
         final Properties serviceProperties = new Properties(defaultProperties);
-		try
+        try
         {
-            AccessController.doPrivileged(
-                new PrivilegedExceptionAction<Object>()
-                {
-                    public Object run()
-                        throws IOException, StandardException,
-                        InstantiationException, IllegalAccessException,
-                        NoSuchMethodException, InvocationTargetException
-                    {
-                        if( recreateFrom != null) // restore from a file
-                        {
-                            File propFile = new File(recreateFrom, PersistentService.PROPERTIES_NAME);
-                            InputStream is = new FileInputStream(propFile);
-                            try {
-                                serviceProperties.load(new BufferedInputStream(is));
-                            } finally {
-                                is.close();
-                            }
-                        }
-                        else
-                        {
-                            StorageFactory storageFactory = privGetStorageFactoryInstance( true, serviceName, null, null);
-                            StorageFile file = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);
-                            resolveServicePropertiesFiles(storageFactory, file);
-                            try {
-                                InputStream is = file.getInputStream();
-                                try {
-                                    // Need to load the properties before closing the
-                                    // StorageFactory.
-                                    serviceProperties.load(new BufferedInputStream(is));
-                                } finally {
-                                    is.close();
-                                }
-                            } finally {
-                               storageFactory.shutdown();
-                            }
-                        }
-                        return null;
+            if( recreateFrom != null) // restore from a file
+            {
+                File propFile = new File(recreateFrom, PersistentService.PROPERTIES_NAME);
+                InputStream is = new FileInputStream(propFile);
+                try {
+                    serviceProperties.load(new BufferedInputStream(is));
+                } finally {
+                    is.close();
+                }
+            }
+            else
+            {
+                StorageFactory storageFactory = privGetStorageFactoryInstance( true, serviceName, null, null);
+                StorageFile file = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);
+                resolveServicePropertiesFiles(storageFactory, file);
+                try {
+                    InputStream is = file.getInputStream();
+                    try {
+                        // Need to load the properties before closing the
+                        // StorageFactory.
+                        serviceProperties.load(new BufferedInputStream(is));
+                    } finally {
+                        is.close();
                     }
+                } finally {
+                    storageFactory.shutdown();
                 }
-                );
+            }
 
-			return serviceProperties;
-		}
-        catch (PrivilegedActionException pae)
-        {
-            if( pae.getException() instanceof FileNotFoundException)
-                return null;
-            throw Monitor.exceptionStartingModule( pae.getException());
+            return serviceProperties;
         }
-		catch (SecurityException se) { throw Monitor.exceptionStartingModule(/*serviceName, */ se);	}
-	} // end of getServiceProperties
+        catch (FileNotFoundException fnfe) { return null; }
+        catch (IOException ioe) { throw Monitor.exceptionStartingModule(ioe); }
+        catch (InstantiationException ie) { throw Monitor.exceptionStartingModule(ie); }
+        catch (IllegalAccessException ia) { throw Monitor.exceptionStartingModule(ia); }
+        catch (NoSuchMethodException nsme) { throw Monitor.exceptionStartingModule(nsme); }
+        catch (InvocationTargetException ite) { throw Monitor.exceptionStartingModule(ite); }
+    } // end of getServiceProperties
 
 
-	/**
-		@exception StandardException Properties cannot be saved.
-	*/
-
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	public void saveServiceProperties( final String serviceName,
+    /**
+       @exception StandardException Properties cannot be saved.
+    */
+    public void saveServiceProperties( final String serviceName,
                                        StorageFactory sf,
                                        final Properties properties,
                                        final boolean replace)
-		throws StandardException
+        throws StandardException
     {
-		if (SanityManager.DEBUG)
+        if (SanityManager.DEBUG)
         {
-			SanityManager.ASSERT(serviceName.equals(getCanonicalServiceName(serviceName)), serviceName);
+            SanityManager.ASSERT(serviceName.equals(getCanonicalServiceName(serviceName)), serviceName);
         }
         if( ! (sf instanceof WritableStorageFactory))
             throw StandardException.newException(SQLState.READ_ONLY_SERVICE);
         final WritableStorageFactory storageFactory = (WritableStorageFactory) sf;
         // Write the service properties to file.
+        StorageFile backupFile = replace
+            ? storageFactory.newStorageFile(
+                PersistentService.PROPERTIES_NAME.concat("old"))
+            : null;
+        StorageFile servicePropertiesFile = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);
+        FileOperationHelper foh = new FileOperationHelper();
+
+        if (replace)
+        {
+            foh.renameTo(
+                servicePropertiesFile, backupFile, true);
+        }
+
+        OutputStream os = null;
         try
         {
-            AccessController.doPrivileged(
-                new PrivilegedExceptionAction<Object>()
+            os = servicePropertiesFile.getOutputStream();
+            properties.store(os, serviceName +
+                             MessageService.getTextMessage(
+                                 MessageId.SERVICE_PROPERTIES_DONT_EDIT));
+            // The eof token should match the ISO-8859-1 encoding 
+            // of the rest of the properties file written with store.
+            BufferedWriter bOut = new BufferedWriter(
+                new OutputStreamWriter(os,"ISO-8859-1"));
+            bOut.write(SERVICE_PROPERTIES_EOF_TOKEN);
+            bOut.newLine();
+            storageFactory.sync( os, false);
+            bOut.close();
+            os.close();
+            os = null; 
+        }
+        catch (IOException ioe)
+        {
+            if (backupFile != null)
+            {
+                // Rename the old properties file back again.
+                foh.renameTo(backupFile, servicePropertiesFile,
+                             false);
+            }
+            if (replace)
+            {
+                throw StandardException.newException(
+                    SQLState.SERVICE_PROPERTIES_EDIT_FAILED,
+                    ioe);
+            }
+            else
+            {
+                throw Monitor.exceptionStartingModule(ioe);
+            }
+        }
+        finally
+        {
+            if (os != null)
+            {
+                try
                 {
-                    public Object run() throws StandardException
-                    {
-                        StorageFile backupFile = replace
-                            ? storageFactory.newStorageFile(
-                                PersistentService.PROPERTIES_NAME.concat("old"))
-                            : null;
-                        StorageFile servicePropertiesFile = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);
-                        FileOperationHelper foh = new FileOperationHelper();
-
-                        if (replace)
-                        {
-                            foh.renameTo(
-                                    servicePropertiesFile, backupFile, true);
-                        }
-
-                        OutputStream os = null;
-                        try
-                        {
-                            os = servicePropertiesFile.getOutputStream();
-                            properties.store(os, serviceName +
-                                MessageService.getTextMessage(
-                                    MessageId.SERVICE_PROPERTIES_DONT_EDIT));
-                            // The eof token should match the ISO-8859-1 encoding 
-                            // of the rest of the properties file written with store.
-                            BufferedWriter bOut = new BufferedWriter(
-                                    new OutputStreamWriter(os,"ISO-8859-1"));
-                            bOut.write(SERVICE_PROPERTIES_EOF_TOKEN);
-                            bOut.newLine();
-                            storageFactory.sync( os, false);
-                            bOut.close();
-                            os.close();
-                            os = null; 
-                        }
-                        catch (IOException ioe)
-                        {
-                            if (backupFile != null)
-                            {
-                                // Rename the old properties file back again.
-                                foh.renameTo(backupFile, servicePropertiesFile,
-                                        false);
-                            }
-                            if (replace)
-                            {
-                                throw StandardException.newException(
-                                        SQLState.SERVICE_PROPERTIES_EDIT_FAILED,
-                                        ioe);
-                            }
-                            else
-                            {
-                                throw Monitor.exceptionStartingModule(ioe);
-                            }
-                        }
-                        finally
-                        {
-                            if (os != null)
-                            {
-                                try
-                                {
-                                    os.close();
-                                }
-                                catch (IOException ioe)
-                                {
-                                    // Ignore exception on close
-                                }
-                            }
-                        }
+                    os.close();
+                }
+                catch (IOException ioe)
+                {
+                    // Ignore exception on close
+                }
+            }
+        }
 		
-                        if (backupFile != null)
-                        {
-                            if (!foh.delete(backupFile, false))
-                            {
-                                Monitor.getStream().printlnWithHeader(
-                                    MessageService.getTextMessage(
-                                        MessageId.SERVICE_PROPERTIES_BACKUP_DEL_FAILED,
-                                        getMostAccuratePath(backupFile)));
+        if (backupFile != null)
+        {
+            if (!foh.delete(backupFile, false))
+            {
+                Monitor.getStream().printlnWithHeader(
+                    MessageService.getTextMessage(
+                        MessageId.SERVICE_PROPERTIES_BACKUP_DEL_FAILED,
+                        getMostAccuratePath(backupFile)));
                                 
-                            }
-                        }
-                        return null;
-                    }
-                }
-                );
+            }
         }
-        catch( PrivilegedActionException pae) { throw (StandardException) pae.getException();}
-	} // end of saveServiceProperties
+    } // end of saveServiceProperties
 
 	
     /** @see PersistentService#createDataWarningFile */
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     public void createDataWarningFile(StorageFactory sf) throws StandardException {
         if( ! (sf instanceof WritableStorageFactory))
             throw StandardException.newException(SQLState.READ_ONLY_SERVICE);
         final WritableStorageFactory storageFactory = (WritableStorageFactory) sf;
-        try
+        OutputStreamWriter osw=null; 
+        try 
+        {
+            StorageFile fileReadMe = storageFactory.newStorageFile(
+                PersistentService.DB_README_FILE_NAME);
+            osw = new OutputStreamWriter(fileReadMe.getOutputStream(),"UTF8");
+            osw.write(MessageService.getTextMessage(
+                          MessageId.README_AT_DB_LEVEL));
+        }
+        catch (IOException ioe)
         {
-            AccessController.doPrivileged(
-            	    new PrivilegedExceptionAction<Object>()
-                    {
-                        public Object run() throws StandardException
-                        {
-                            OutputStreamWriter osw=null; 
-                            try 
-                            {
-                                StorageFile fileReadMe = storageFactory.newStorageFile(
-                                    PersistentService.DB_README_FILE_NAME);
-                                osw = new OutputStreamWriter(fileReadMe.getOutputStream(),"UTF8");
-                                osw.write(MessageService.getTextMessage(
-                                        MessageId.README_AT_DB_LEVEL));
-                            }
-                            catch (IOException ioe)
-                            {
-                            }
-                            finally
-                            {
-                                if (osw != null)
-                                {
-                                    try
-                                    {
-                                        osw.close();
-                                    }
-                                    catch (IOException ioe)
-                                    {
-                                        // Ignore exception on close
-                                    }
-                                }
-                            }
-                            return null;
-                        }
-                    }
-                );
         }
-        catch( PrivilegedActionException pae) { throw (StandardException) pae.getException();}
+        finally
+        {
+            if (osw != null)
+            {
+                try
+                {
+                    osw.close();
+                }
+                catch (IOException ioe)
+                {
+                    // Ignore exception on close
+                }
+            }
+        }
     } // end of createDataWarningFile
 
     /**
@@ -498,56 +423,40 @@ final class StorageFactoryService implem
      *
      * @exception StandardException Properties cannot be saved.
      */
-
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	public void saveServiceProperties(final String serviceName, 
+    public void saveServiceProperties(final String serviceName, 
                                       final Properties properties)
-		throws StandardException {
-
-        try
-        {
-            AccessController.doPrivileged(
-                new PrivilegedExceptionAction<Object>()
-                {
-                    public Object run() throws StandardException
-                    {
-                        // Since this is the backup location, we cannot use
-                        // storageFactory.newStorageFile as in the other
-                        // variant of this method:
-                        File servicePropertiesFile = 
-                            new File(serviceName, PersistentService.PROPERTIES_NAME);
-
-                        FileOutputStream fos = null;
-                        try {
-
-                            fos = new FileOutputStream(servicePropertiesFile);
-                            FileUtil.limitAccessToOwner(servicePropertiesFile);
-
-                            properties.store(fos, 
-                                             serviceName + 
-                                             MessageService.getTextMessage(
-                                                  MessageId.SERVICE_PROPERTIES_DONT_EDIT));
-                            fos.getFD().sync();
-                            fos.close();
-                            fos = null;
-                        } catch (IOException ioe) {
-                            if (fos != null) {
-                                try {
-                                    fos.close();
-                                } catch (IOException ioe2) {
-                                }
-                                fos = null;
-                            }
+        throws StandardException {
 
-                            throw Monitor.exceptionStartingModule(ioe);
-                        }
-		
-                        return null;
-                    }
+        // Since this is the backup location, we cannot use
+        // storageFactory.newStorageFile as in the other
+        // variant of this method:
+        File servicePropertiesFile = 
+            new File(serviceName, PersistentService.PROPERTIES_NAME);
+
+        FileOutputStream fos = null;
+        try {
+
+            fos = new FileOutputStream(servicePropertiesFile);
+            FileUtil.limitAccessToOwner(servicePropertiesFile);
+
+            properties.store(fos, 
+                             serviceName + 
+                             MessageService.getTextMessage(
+                                 MessageId.SERVICE_PROPERTIES_DONT_EDIT));
+            fos.getFD().sync();
+            fos.close();
+            fos = null;
+        } catch (IOException ioe) {
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException ioe2) {
                 }
-                );
-        }catch( PrivilegedActionException pae) { throw (StandardException) pae.getException();}
+                fos = null;
+            }
+
+            throw Monitor.exceptionStartingModule(ioe);
+        }
     }
     
     /**
@@ -657,225 +566,197 @@ final class StorageFactoryService implem
 	** from the service dir and  recreated with the properties from backup.
 	*/
 
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	protected String recreateServiceRoot( final String serviceName,
-										  Properties properties) throws StandardException
-	{
-		//if there are no propertues then nothing to do in this routine
-		if(properties == null) {
-			return null;
-		}
+    protected String recreateServiceRoot( final String serviceName,
+                                          Properties properties) throws StandardException
+    {
+        //if there are no propertues then nothing to do in this routine
+        if(properties == null) {
+            return null;
+        }
 
-		String restoreFrom; //location where backup copy of service properties available
-		boolean createRoot = false;
-		boolean deleteExistingRoot = false;
+        String restoreFrom; //location where backup copy of service properties available
+        boolean createRoot = false;
+        boolean deleteExistingRoot = false;
         
-		//check if user wants to create a database from a backup copy
-		restoreFrom = properties.getProperty(Attribute.CREATE_FROM);
-		if(restoreFrom !=null)
-		{
-			//create root dicretory if it  does not exist.
-			createRoot =true;
-			deleteExistingRoot = false;
-		}
+        //check if user wants to create a database from a backup copy
+        restoreFrom = properties.getProperty(Attribute.CREATE_FROM);
+        if(restoreFrom !=null)
+        {
+            //create root dicretory if it  does not exist.
+            createRoot =true;
+            deleteExistingRoot = false;
+        }
         else
-		{	//check if user requested a complete restore(version recovery) from backup
-			restoreFrom = properties.getProperty(Attribute.RESTORE_FROM);
-			//create root dir if it does not exists and  if there exists one already delete and recreate
-			if(restoreFrom !=null)
+        {	//check if user requested a complete restore(version recovery) from backup
+            restoreFrom = properties.getProperty(Attribute.RESTORE_FROM);
+            //create root dir if it does not exists and  if there exists one already delete and recreate
+            if(restoreFrom !=null)
             {
-				createRoot =true;
-				deleteExistingRoot = true;
-			}
+                createRoot =true;
+                deleteExistingRoot = true;
+            }
             else
-			{
-				//check if user has requested roll forward recovery using a backup
-				restoreFrom = properties.getProperty(Attribute.ROLL_FORWARD_RECOVERY_FROM);
-				if(restoreFrom !=null)
-				{
-					//if service root does not exist then only create one
-					//This is useful when logDevice was on some other device
-					//and the device on which data directorties existied has
-					//failed and user is trying to restore it some other device.
+            {
+                //check if user has requested roll forward recovery using a backup
+                restoreFrom = properties.getProperty(Attribute.ROLL_FORWARD_RECOVERY_FROM);
+                if(restoreFrom !=null)
+                {
+                    //if service root does not exist then only create one
+                    //This is useful when logDevice was on some other device
+                    //and the device on which data directorties existied has
+                    //failed and user is trying to restore it some other device.
                     try
                     {
-                        if( AccessController.doPrivileged(
-                                new PrivilegedExceptionAction<Object>()
-                                {
-                                    public Object run()
-                                        throws IOException, StandardException,
-                                      InstantiationException, IllegalAccessException,
-                                      NoSuchMethodException, InvocationTargetException
-                                      
-                                    {
-                                        StorageFactory storageFactory
-                                          = privGetStorageFactoryInstance( true, serviceName, null, null);
-                                        try
-                                        {
-                                            StorageFile serviceDirectory = storageFactory.newStorageFile( null);
-                                            return serviceDirectory.exists() ? this : null;
-                                        }
-                                        finally {storageFactory.shutdown();}
-                                    }
-                                }
-                                ) == null)
+                        Object sfs = null;
+                        StorageFactory storageFactory
+                            = privGetStorageFactoryInstance( true, serviceName, null, null);
+                        try
+                        {
+                            StorageFile serviceDirectory = storageFactory.newStorageFile( null);
+                            sfs = serviceDirectory.exists() ? this : null;
+                        }
+                        finally {storageFactory.shutdown();}
+
+                        if (sfs == null)
                         {
                             createRoot =true;
                             deleteExistingRoot = false;
                         }
                         
                     }
-                    catch( PrivilegedActionException pae)
-                    {
-                        throw Monitor.exceptionStartingModule( (IOException) pae.getException());
-                    }
-				}
-			}
-		}
+                    catch (IOException ioe) { throw Monitor.exceptionStartingModule(ioe); }
+                    catch (InstantiationException ie) { throw Monitor.exceptionStartingModule(ie); }
+                    catch (IllegalAccessException ia) { throw Monitor.exceptionStartingModule(ia); }
+                    catch (NoSuchMethodException nsme) { throw Monitor.exceptionStartingModule(nsme); }
+                    catch (InvocationTargetException ite) { throw Monitor.exceptionStartingModule(ite); }
+                }
+            }
+        }
 
-		//restore the service properties from backup
-		if(restoreFrom != null)
-		{
-			//First make sure backup service directory exists in the specified path
-			File backupRoot = new File(restoreFrom);
-			if (fileExists(backupRoot))
-			{
-				//First make sure backup have service.properties
-				File bserviceProp = new File(restoreFrom, PersistentService.PROPERTIES_NAME);
-				if(fileExists(bserviceProp))
-				{
-					//create service root if required
-					if(createRoot)
-						createServiceRoot(serviceName, deleteExistingRoot);
+        //restore the service properties from backup
+        if(restoreFrom != null)
+        {
+            //First make sure backup service directory exists in the specified path
+            File backupRoot = new File(restoreFrom);
+            if (fileExists(backupRoot))
+            {
+                //First make sure backup have service.properties
+                File bserviceProp = new File(restoreFrom, PersistentService.PROPERTIES_NAME);
+                if(fileExists(bserviceProp))
+                {
+                    //create service root if required
+                    if(createRoot)
+                    { createServiceRoot(serviceName, deleteExistingRoot); }
                     try
                     {
-                        AccessController.doPrivileged(
-                            new PrivilegedExceptionAction<Object>()
+                        WritableStorageFactory storageFactory =
+                            (WritableStorageFactory) privGetStorageFactoryInstance( true,
+                                                                                    serviceName,
+                                                                                    null,
+                                                                                    null);
+                        try
+                        {
+                            StorageFile cserviceProp = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);
+
+                            if(cserviceProp.exists())
                             {
-                                public Object run()
-                                    throws IOException, StandardException,
-                                    InstantiationException, IllegalAccessException,
-                                    NoSuchMethodException, InvocationTargetException
-                                {
-                                    WritableStorageFactory storageFactory =
-                                      (WritableStorageFactory) privGetStorageFactoryInstance( true,
-                                                                                              serviceName,
-                                                                                              null,
-                                                                                              null);
-                                    try
-                                    {
-                                        StorageFile cserviceProp = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);
-
-                                        if(cserviceProp.exists())
-                                            if(!cserviceProp.delete())
-                                                throw StandardException.newException(SQLState.UNABLE_TO_DELETE_FILE,
-                                                                                     cserviceProp);
-                                        return null;
-                                    }
-                                    finally { storageFactory.shutdown();}
-                                }
+                                if(!cserviceProp.delete())
+                                { throw StandardException.newException(SQLState.UNABLE_TO_DELETE_FILE, cserviceProp); }
                             }
-                            );
+                        }
+                        finally { storageFactory.shutdown();}
                     }
-                    catch( PrivilegedActionException pae)
-                    { throw Monitor.exceptionStartingModule( (IOException)pae.getException());}
-				}
+                    catch (IOException ioe) { throw Monitor.exceptionStartingModule(ioe); }
+                    catch (InstantiationException ie) { throw Monitor.exceptionStartingModule(ie); }
+                    catch (IllegalAccessException ia) { throw Monitor.exceptionStartingModule(ia); }
+                    catch (NoSuchMethodException nsme) { throw Monitor.exceptionStartingModule(nsme); }
+                    catch (InvocationTargetException ite) { throw Monitor.exceptionStartingModule(ite); }
+                }
                 else
-					throw StandardException.newException(SQLState.PROPERTY_FILE_NOT_FOUND_IN_BACKUP, bserviceProp);
-			}
+                { throw StandardException.newException(SQLState.PROPERTY_FILE_NOT_FOUND_IN_BACKUP, bserviceProp); }
+            }
             else
-				throw StandardException.newException(SQLState.SERVICE_DIRECTORY_NOT_IN_BACKUP, backupRoot);
+            { throw StandardException.newException(SQLState.SERVICE_DIRECTORY_NOT_IN_BACKUP, backupRoot); }
 
-			properties.put(Property.IN_RESTORE_FROM_BACKUP,"True");
-			if(createRoot)
-				properties.put(Property.DELETE_ROOT_ON_ERROR, "True");
-		}
-		return restoreFrom;
-	} // end of recreateServiceRoot
+            properties.put(Property.IN_RESTORE_FROM_BACKUP,"True");
+            if(createRoot)
+            { properties.put(Property.DELETE_ROOT_ON_ERROR, "True"); }
+        }
+        return restoreFrom;
+    } // end of recreateServiceRoot
 
-	/**
-		Properties cannot be saved
-	*/
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	public String createServiceRoot(final String name, final boolean deleteExisting)
-		throws StandardException
+    /**
+       Properties cannot be saved
+    */
+    public String createServiceRoot(final String name, final boolean deleteExisting)
+        throws StandardException
     {
         if( !( rootStorageFactory instanceof WritableStorageFactory))
-            throw StandardException.newException(SQLState.READ_ONLY_SERVICE);
-		// we need to create the directory before we can call
-		// getCanonicalPath() on it, because if intermediate directories
-		// need to be created the getCanonicalPath() will fail.
+        { throw StandardException.newException(SQLState.READ_ONLY_SERVICE); }
+        // we need to create the directory before we can call
+        // getCanonicalPath() on it, because if intermediate directories
+        // need to be created the getCanonicalPath() will fail.
 
-		Throwable t = null;
+        String instantiationString = null;
         try
         {
-            return getProtocolLeadIn() + (String) AccessController.doPrivileged(
-                new PrivilegedExceptionAction<Object>()
+            StorageFactory storageFactory = privGetStorageFactoryInstance( true, name, null, null);
+            try
+            {
+                StorageFile serviceDirectory = storageFactory.newStorageFile( null);
+
+                if (serviceDirectory.exists())
                 {
-                    public Object run()
-                        throws StandardException, IOException,
-                        InstantiationException, IllegalAccessException,
-                        NoSuchMethodException, InvocationTargetException
+                    if (deleteExisting)
                     {
-                        StorageFactory storageFactory = privGetStorageFactoryInstance( true, name, null, null);
-                        try
-                        {
-                            StorageFile serviceDirectory = storageFactory.newStorageFile( null);
-
-                            if (serviceDirectory.exists())
-                            {
-                                if (deleteExisting)
-                                {
-                                    if (!serviceDirectory.deleteAll())
-                                        throw StandardException.newException(SQLState.SERVICE_DIRECTORY_REMOVE_ERROR,
-                                                                             getDirectoryPath( name));
-                                }
-                                else
-                                {
-                                    vetService( storageFactory, name );
-                                    throw StandardException.newException(SQLState.SERVICE_DIRECTORY_EXISTS_ERROR,
-                                                                         getDirectoryPath( name));
-                                }
-                            }
+                        if (!serviceDirectory.deleteAll())
+                            throw StandardException.newException(SQLState.SERVICE_DIRECTORY_REMOVE_ERROR,
+                                                                 getDirectoryPath( name));
+                    }
+                    else
+                    {
+                        vetService( storageFactory, name );
+                        throw StandardException.newException(SQLState.SERVICE_DIRECTORY_EXISTS_ERROR,
+                                                             getDirectoryPath( name));
+                    }
+                }
 
-                            if (serviceDirectory.mkdirs())
-                            {
-                                serviceDirectory.limitAccessToOwner();
-                                // DERBY-5096. The storageFactory canonicalName may need to be adjusted
-                                // for casing after the directory is created. Just reset it after making the 
-                                // the directory to make sure.
-                                String serviceDirCanonicalPath = serviceDirectory.getCanonicalPath();
-                                storageFactory.setCanonicalName(serviceDirCanonicalPath);
-                                try
-                                {
-                                    return storageFactory.getCanonicalName();
-                                }
-                                catch (IOException ioe)
-                                {
-                                    serviceDirectory.deleteAll();
-                                    throw ioe;
-                                }
-                            }
-                            throw StandardException.newException(SQLState.SERVICE_DIRECTORY_CREATE_ERROR, serviceDirectory);
-                        }
-                        finally { storageFactory.shutdown(); }
+                if (serviceDirectory.mkdirs())
+                {
+                    serviceDirectory.limitAccessToOwner();
+                    // DERBY-5096. The storageFactory canonicalName may need to be adjusted
+                    // for casing after the directory is created. Just reset it after making the 
+                    // the directory to make sure.
+                    String serviceDirCanonicalPath = serviceDirectory.getCanonicalPath();
+                    storageFactory.setCanonicalName(serviceDirCanonicalPath);
+                    try
+                    {
+                        instantiationString = storageFactory.getCanonicalName();
+                    }
+                    catch (IOException ioe)
+                    {
+                        serviceDirectory.deleteAll();
+                        throw ioe;
                     }
                 }
-                );
-		}
-        catch (SecurityException se) { t = se; }
-        catch (PrivilegedActionException pae)
-        {
-            t = pae.getException();
-            if( t instanceof StandardException)
-                throw (StandardException) t;
+            }
+            finally { storageFactory.shutdown(); }
         }
+        catch (IOException ioe) { throw serviceDirectoryCreateError(ioe, name); }
+        catch (InstantiationException ie) { throw serviceDirectoryCreateError(ie, name); }
+        catch (IllegalAccessException ia) { throw serviceDirectoryCreateError(ia, name); }
+        catch (NoSuchMethodException nsme) { throw serviceDirectoryCreateError(nsme, name); }
+        catch (InvocationTargetException ite) { throw serviceDirectoryCreateError(ite, name); }
+
+        return getProtocolLeadIn() + instantiationString;
 
-        throw StandardException.newException(SQLState.SERVICE_DIRECTORY_CREATE_ERROR, t, name);
     } // end of createServiceRoot
 
+    private StandardException serviceDirectoryCreateError(Exception t, String name)
+    {
+        return StandardException.newException(SQLState.SERVICE_DIRECTORY_CREATE_ERROR, t, name);
+    }
+
     /**
        Verify that the service directory looks ok before objecting that the database
        already exists.
@@ -912,60 +793,48 @@ final class StorageFactoryService implem
         return sb.toString();
     } // end of getDirectoryPath
 
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	public boolean removeServiceRoot(final String serviceName)
+    public boolean removeServiceRoot(final String serviceName)
     {
         if( !( rootStorageFactory instanceof WritableStorageFactory))
-            return false;
+        { return false; }
         try
         {
-            return AccessController.doPrivileged(
-                new PrivilegedExceptionAction<Object>()
+            StorageFactoryService sfs = null;
+            StorageFactory storageFactory = privGetStorageFactoryInstance( true, serviceName, null, null);
+            try
+            {
+                if (SanityManager.DEBUG)
                 {
-                    public Object run()
-                        throws StandardException, IOException,
-                        InstantiationException, IllegalAccessException,
-                        NoSuchMethodException, InvocationTargetException
-                    {
-                        StorageFactory storageFactory = privGetStorageFactoryInstance( true, serviceName, null, null);
-                        try
-                        {
-                            if (SanityManager.DEBUG)
-                            {
-                                // Run this through getCanonicalServiceName as
-                                // an extra sanity check. Prepending the
-                                // protocol lead in to the canonical name from
-                                // the storage factory should be enough.
-                                String tmpCanonical = getCanonicalServiceName(
-                                        getProtocolLeadIn() +
-                                        storageFactory.getCanonicalName());
-                                // These should give the same result.
-                                SanityManager.ASSERT(
-                                        tmpCanonical.equals(getProtocolLeadIn()
-                                        + storageFactory.getCanonicalName()));
-                                SanityManager.ASSERT(
-                                    serviceName.equals(tmpCanonical),
-                                    "serviceName = " + serviceName +
-                                    " ; protocolLeadIn + " +
-                                    "storageFactory.getCanoicalName = " +
-                                    tmpCanonical);
-                            }
-                            StorageFile serviceDirectory = storageFactory.newStorageFile( null);
-                            return serviceDirectory.deleteAll() ? this : null;
-                        }
-                        finally { storageFactory.shutdown(); }
-                    }
+                    // Run this through getCanonicalServiceName as
+                    // an extra sanity check. Prepending the
+                    // protocol lead in to the canonical name from
+                    // the storage factory should be enough.
+                    String tmpCanonical = getCanonicalServiceName(
+                        getProtocolLeadIn() +
+                        storageFactory.getCanonicalName());
+                    // These should give the same result.
+                    SanityManager.ASSERT(
+                        tmpCanonical.equals(getProtocolLeadIn()
+                                            + storageFactory.getCanonicalName()));
+                    SanityManager.ASSERT(
+                        serviceName.equals(tmpCanonical),
+                        "serviceName = " + serviceName +
+                        " ; protocolLeadIn + " +
+                        "storageFactory.getCanoicalName = " +
+                        tmpCanonical);
                 }
-                ) != null;
+                StorageFile serviceDirectory = storageFactory.newStorageFile( null);
+                sfs = serviceDirectory.deleteAll() ? this : null;
+            }
+            finally { storageFactory.shutdown(); }
+
+            return (sfs != null);
         }
-        catch( PrivilegedActionException pae){ return false;}
-	} // end of removeServiceRoot
+        catch(Exception pae){ return false;}
+    } // end of removeServiceRoot
 
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
-	public String getCanonicalServiceName(String name)
-		throws StandardException
+    public String getCanonicalServiceName(String name)
+        throws StandardException
     {
         int colon = name.indexOf( ':');
         // If no subsubprotocol is specified and the storage factory type isn't
@@ -986,31 +855,24 @@ final class StorageFactoryService implem
 
         try
         {
-            return getProtocolLeadIn() + AccessController.doPrivileged(
-                new PrivilegedExceptionAction<String>()
-                {
-                    public String run()
-                        throws StandardException, IOException,
-                        InstantiationException, IllegalAccessException,
-                        NoSuchMethodException, InvocationTargetException
-                    {
-                        StorageFactory storageFactory = privGetStorageFactoryInstance( true, nm, null, null);
-                        try
-                        {
-                            return storageFactory.getCanonicalName();
-                        }
-                        finally { storageFactory.shutdown();}
-                    }
-                }
-                );
+            String rawName = null;
+            StorageFactory storageFactory = privGetStorageFactoryInstance( true, nm, null, null);
+            try
+            {
+                rawName = storageFactory.getCanonicalName();
+            }
+            finally { storageFactory.shutdown();}
+            
+            return getProtocolLeadIn() + rawName;
+
         }
-		catch (PrivilegedActionException pae)
+        catch (Exception pae)
         {
-			throw Monitor.exceptionStartingModule(pae.getException());
-		}
-	} // end of getCanonicalServiceName
+            throw Monitor.exceptionStartingModule(pae);
+        }
+    } // end of getCanonicalServiceName
 
-	public String getUserServiceName(String serviceName)
+    public String getUserServiceName(String serviceName)
     {
 		if (home != null)
         {
@@ -1048,15 +910,8 @@ final class StorageFactoryService implem
      * @return {@code true} if the file exists, {@code false} if not.
      * @throws SecurityException if the required privileges are missing
      */
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     private final boolean fileExists(final File file) {
-        return (AccessController.doPrivileged(
-                new PrivilegedAction<Boolean>() {
-                    public Boolean run() {
-                        return file.exists();
-                    }
-            })).booleanValue();
+        return file.exists();
     }
 
     /**
@@ -1088,26 +943,15 @@ final class StorageFactoryService implem
     }
     
     /**
-     * Privileged Monitor lookup. Must be private so that user code
+     * Must be private so that user code
      * can't call this entry point.
      */
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
     private  static  ModuleFactory  getMonitor()
     {
-        return AccessController.doPrivileged
-            (
-             new PrivilegedAction<ModuleFactory>()
-             {
-                 public ModuleFactory run()
-                 {
-                     return Monitor.getMonitor();
-                 }
-             }
-             );
+        return Monitor.getMonitor();
     }
 
-    final class DirectoryList implements Enumeration, PrivilegedAction<DirectoryList>
+    final class DirectoryList implements Enumeration
     {
         private String[] contents;
         private StorageFile systemDirectory;	 
@@ -1119,16 +963,12 @@ final class StorageFactoryService implem
         private static final int INIT_ACTION = 0;
         private static final int HAS_MORE_ELEMENTS_ACTION = 1;
 
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
         DirectoryList()
         {
             actionCode = INIT_ACTION;
-            AccessController.doPrivileged( this);
+            run();
         }
 
-    // AccessController.doPrivileged() deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
-    @SuppressWarnings("removal")
         public boolean hasMoreElements()
         {
             if (contents == null)
@@ -1138,7 +978,7 @@ final class StorageFactoryService implem
                 return true;
 
             actionCode = HAS_MORE_ELEMENTS_ACTION;
-            return AccessController.doPrivileged( this) != null;
+            return run() != null;
         } // end of hasMoreElements
 
         public Object nextElement() throws NoSuchElementException