Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 39490 invoked from network); 10 Nov 2006 16:39:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Nov 2006 16:39:50 -0000 Received: (qmail 10374 invoked by uid 500); 10 Nov 2006 16:40:01 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 10310 invoked by uid 500); 10 Nov 2006 16:40:01 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 10299 invoked by uid 99); 10 Nov 2006 16:40:01 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Nov 2006 08:40:01 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Nov 2006 08:39:49 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 23AC41A9846; Fri, 10 Nov 2006 08:39:21 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r473387 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java Date: Fri, 10 Nov 2006 16:39:21 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061110163921.23AC41A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djd Date: Fri Nov 10 08:39:20 2006 New Revision: 473387 URL: http://svn.apache.org/viewvc?view=rev&rev=473387 Log: DERBY-2040 (partial) Create the class loaders (JarLoader instances) for database class loading within a privileged block. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java?view=diff&rev=473387&r1=473386&r2=473387 ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java Fri Nov 10 08:39:20 2006 @@ -40,12 +40,13 @@ import org.apache.derby.iapi.reference.Property; import java.io.InputStream; +import java.security.AccessController; import org.apache.derby.iapi.reference.MessageId; import org.apache.derby.iapi.reference.Module; import org.apache.derby.iapi.services.i18n.MessageService; -public class UpdateLoader { +class UpdateLoader { private JarLoader[] jarList; private HeaderPrintWriter vs; @@ -61,7 +62,7 @@ private boolean needReload; private JarReader jarReader; - public UpdateLoader(String classpath, DatabaseClasses parent, boolean verbose, boolean normalizeToUpper) + UpdateLoader(String classpath, DatabaseClasses parent, boolean verbose, boolean normalizeToUpper) throws StandardException { this.normalizeToUpper = normalizeToUpper; @@ -81,15 +82,25 @@ private void initializeFromClassPath(String classpath) throws StandardException { - String[][] elements = IdUtil.parseDbClassPath(classpath, normalizeToUpper); + final String[][] elements = IdUtil.parseDbClassPath(classpath, normalizeToUpper); - int jarCount = elements.length; + final int jarCount = elements.length; jarList = new JarLoader[jarCount]; - for (int i = 0; i < jarCount; i++) { - jarList[i] = new JarLoader(this, elements[i], vs); - } - + if (jarCount != 0) { + // Creating class loaders is a restricted operation + // so we need to use a privileged block. + AccessController.doPrivileged + (new java.security.PrivilegedAction(){ + + public Object run(){ + for (int i = 0; i < jarCount; i++) { + jarList[i] = new JarLoader(UpdateLoader.this, elements[i], vs); + } + return null; + } + }); + } if (vs != null) { vs.println(MessageService.getTextMessage(MessageId.CM_CLASS_LOADER_START, classpath)); } @@ -103,7 +114,7 @@ @exception ClassNotFoundException Class can not be found */ - public Class loadClass(String className, boolean resolve) + Class loadClass(String className, boolean resolve) throws ClassNotFoundException { @@ -154,7 +165,7 @@ } } - public InputStream getResourceAsStream(String name) { + InputStream getResourceAsStream(String name) { InputStream is = (myLoader == null) ? ClassLoader.getSystemResourceAsStream(name) : @@ -201,7 +212,7 @@ } } - public synchronized void modifyClasspath(String classpath) + synchronized void modifyClasspath(String classpath) throws StandardException { // lock transaction classloader exclusively @@ -214,7 +225,7 @@ } - public synchronized void modifyJar(boolean reload) throws StandardException { + synchronized void modifyJar(boolean reload) throws StandardException { // lock transaction classloader exclusively lockClassLoader(ShExQual.EX); @@ -278,7 +289,7 @@ return null; } - public void close() { + void close() { for (int i = 0; i < jarList.length; i++) { jarList[i].setInvalid(false); @@ -297,7 +308,7 @@ initDone = true; } - public int getClassLoaderVersion() { + int getClassLoaderVersion() { return version; }