db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1745043 - in /db/derby/code/branches/10.11: ./ 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 13:48:23 GMT
Author: kahatlen
Date: Sun May 22 13:48:23 2016
New Revision: 1745043

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

Merged revision 1745031 from the 10.12 branch.

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

Propchange: db/derby/code/branches/10.11/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May 22 13:48:23 2016
@@ -1,5 +1,5 @@
-/db/derby/code/branches/10.12:1741311
+/db/derby/code/branches/10.12:1741311,1745031
 /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:1614963,1615140,1615565,1615821,1615982,1616111-1616112,1616163,1616299,1616332,1616334-1616335,1616365,1616523,1617641,1617737,1618088,1618114,1618544,1618821,1618859,1618881,1618930,1618955,1619154,1619456,1620378-1620379,1620385,1620539,1620608,1620961,1620964,1621215,1622631,1625904,1626094,1626825,1627671,1627851,1628008,1628960,1629099,1629192,1629251,1630598,1636509,1636668,1636798,1639804,1692008,1725139,1737188-1737189
+/db/derby/code/trunk:1614963,1615140,1615565,1615821,1615982,1616111-1616112,1616163,1616299,1616332,1616334-1616335,1616365,1616523,1617641,1617737,1618088,1618114,1618544,1618821,1618859,1618881,1618930,1618955,1619154,1619456,1620378-1620379,1620385,1620539,1620608,1620961,1620964,1621215,1622631,1625904,1626094,1626825,1627671,1627851,1628008,1628960,1629099,1629192,1629251,1630598,1636509,1636668,1636798,1639804,1692008,1725139,1737188-1737189,1744989

Modified: db/derby/code/branches/10.11/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.11/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java?rev=1745043&r1=1745042&r2=1745043&view=diff
==============================================================================
--- db/derby/code/branches/10.11/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
(original)
+++ db/derby/code/branches/10.11/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
Sun May 22 13:48:23 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.11/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.11/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java?rev=1745043&r1=1745042&r2=1745043&view=diff
==============================================================================
--- db/derby/code/branches/10.11/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java
(original)
+++ db/derby/code/branches/10.11/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java
Sun May 22 13:48:23 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.11/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.11/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java?rev=1745043&r1=1745042&r2=1745043&view=diff
==============================================================================
--- db/derby/code/branches/10.11/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
(original)
+++ db/derby/code/branches/10.11/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
Sun May 22 13:48:23 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