db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1745031 - in /db/derby/code/branches/10.12: ./ java/engine/org/apache/derby/impl/services/bytecode/ java/testing/org/apache/derbyTesting/functionTests/tests/tools/ java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/
Date Sun, 22 May 2016 11:49:06 GMT
Author: kahatlen
Date: Sun May 22 11:49:06 2016
New Revision: 1745031

URL: http://svn.apache.org/viewvc?rev=1745031&view=rev
Log:
DERBY-6854: Make it possible to run Derby tests on early access
versions of JDK 9

Merged revision 1744989 from trunk.

Modified:
    db/derby/code/branches/10.12/   (props changed)
    db/derby/code/branches/10.12/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
    db/derby/code/branches/10.12/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java
    db/derby/code/branches/10.12/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java

Propchange: db/derby/code/branches/10.12/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May 22 11:49:06 2016
@@ -1,4 +1,4 @@
 /db/derby/code/branches/10.7:1061570,1061578,1082235
 /db/derby/code/branches/10.8:1177474,1234973,1464951
 /db/derby/code/branches/10.9:1373148
-/db/derby/code/trunk:1063809,1702820-1702830,1702836,1725139,1727680,1737188-1737189,1738368
+/db/derby/code/trunk:1063809,1702820-1702830,1702836,1725139,1727680,1737188-1737189,1738368,1744989

Modified: db/derby/code/branches/10.12/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.12/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java?rev=1745031&r1=1745030&r2=1745031&view=diff
==============================================================================
--- db/derby/code/branches/10.12/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
(original)
+++ db/derby/code/branches/10.12/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
Sun May 22 11:49:06 2016
@@ -22,11 +22,11 @@
 package org.apache.derby.impl.services.bytecode;
 
 import java.lang.reflect.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
 import org.apache.derby.shared.common.sanity.SanityManager;
 import java.util.Hashtable;
-import org.apache.derby.iapi.services.loader.*;
-import org.apache.derby.iapi.services.context.*;
 
 /**
  * Validate BC calls.
@@ -75,7 +75,7 @@ class d_BCValidate
 
 				Class[] params = NO_PARAMS;
 
-				Class<?> declaring = loadClass(declaringClass);
+                final Class<?> declaring = loadClass(declaringClass);
 
 				if (debugParameterTypes != null) {
 					params = new Class[debugParameterTypes.length];
@@ -92,15 +92,27 @@ class d_BCValidate
 				// and members from classes loaded by the same class loader. Thus
 				// we try to fall into these categories to avoid having to grant
 				// permissions to derby jars for the function tests.
-				
-				ClassLoader declareLoader = declaring.getClassLoader();
+
 				ClassLoader myLoader = d_BCValidate.class.getClassLoader();
-				
-				boolean sameClassLoader = false;
-				if (declareLoader == myLoader)
-					sameClassLoader = true;
-				else if (declareLoader != null)
-					sameClassLoader = declareLoader.equals(myLoader);
+                boolean sameClassLoader;
+                try {
+                    ClassLoader declareLoader = AccessController.doPrivileged(
+                            new PrivilegedAction<ClassLoader>() {
+                                public ClassLoader run() {
+                                    return declaring.getClassLoader();
+                                }
+                            });
+                    sameClassLoader = (myLoader == declareLoader) ||
+                        (myLoader != null && myLoader.equals(declareLoader));
+                } catch (SecurityException se) {
+                    // getClassLoader is not a mandatory permission for
+                    // derby.jar, so expect that it might fail. If it fails,
+                    // however, we know that it is not the same as myLoader,
+                    // since no permissions are needed for calling
+                    // getClassLoader() on a class that lives in the caller's
+                    // class loader.
+                    sameClassLoader = false;
+                }
 				
 				String actualReturnType;
 

Modified: db/derby/code/branches/10.12/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.12/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java?rev=1745031&r1=1745030&r2=1745031&view=diff
==============================================================================
--- db/derby/code/branches/10.12/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java
(original)
+++ db/derby/code/branches/10.12/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java
Sun May 22 11:49:06 2016
@@ -166,7 +166,13 @@ public class SysinfoLocaleTest extends B
         } else {
             urls = new URL[] { sysinfoURL };
         }
-        URLClassLoader loader = new URLClassLoader(urls, null);
+
+        // Create a new class loader that loads the Derby classes afresh.
+        // Its parent (platformLoader) is a class loader that is able to
+        // load the JDBC classes and other core classes needed by the Derby
+        // classes.
+        ClassLoader platformLoader = java.sql.Connection.class.getClassLoader();
+        URLClassLoader loader = new URLClassLoader(urls, platformLoader);
 
         Class<?> copy = Class.forName(className, true, loader);
         Method main = copy.getMethod("main", new Class[] { String[].class });

Modified: db/derby/code/branches/10.12/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.12/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java?rev=1745031&r1=1745030&r2=1745031&view=diff
==============================================================================
--- db/derby/code/branches/10.12/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
(original)
+++ db/derby/code/branches/10.12/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
Sun May 22 11:49:06 2016
@@ -181,10 +181,12 @@ public class UpgradeClassLoader
 
             }
         }
-        
-        // Specify null for parent class loader to avoid mixing up 
-        // jars specified in the system classpath
-        ClassLoader oldVersionLoader = new URLClassLoader(url, null);
+
+        // Create a class loader which loads Derby classes from the specified
+        // URL, and JDBC classes and other system classes from the platform
+        // class loader.
+        ClassLoader oldVersionLoader =
+            new URLClassLoader(url, java.sql.Connection.class.getClassLoader());
 
         // DERBY-5316: We need to unload the JDBC driver when done with it,
         // but that can only be done if the DriverUnloader class lives in a



Mime
View raw message