db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r321124 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
Date Fri, 14 Oct 2005 14:01:47 GMT
Author: djd
Date: Fri Oct 14 06:59:46 2005
New Revision: 321124

URL: http://svn.apache.org/viewcvs?rev=321124&view=rev
Log:
DERBY-624 Remove requirement for the permission accessDeclaredMembers to be granted to all
code in the stack when running the embedded engine. Changed calls to use Class.getConstructor/getMethod
where possible instead of the getDeclared versions that require the permission.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java?rev=321124&r1=321123&r2=321124&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java Fri
Oct 14 06:59:46 2005
@@ -104,10 +104,10 @@
 						  public Object run() throws NoSuchMethodException, SecurityException
 						  {
 							  if (listenAddress == null)
-								  return serverClass.getDeclaredConstructor(null);
+								  return serverClass.getConstructor(null);
 							  else
 								  return
-									  serverClass.getDeclaredConstructor(new
+									  serverClass.getConstructor(new
 										  Class[] {java.net.InetAddress.class,
 												   Integer.TYPE});}
 					  }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java?rev=321124&r1=321123&r2=321124&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java
Fri Oct 14 06:59:46 2005
@@ -57,7 +57,7 @@
 
 
 		if (SanityManager.DEBUG) {
-			String reason;
+			String reason = null;
 			try {
 
 				String declaringClass = dt.javaName();
@@ -84,33 +84,89 @@
 					}
 
 				}
-
+				
+				// If the class is not in the same class loader then it
+				// it must be a non-Derby class. In that case any method etc.
+				// being accessed must be public, so don't use the getDeclared
+				// methods. Default SecurityManager behaviour is to grant access to public members
+				// 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);
+				
 				String actualReturnType;
 
 				if (methodName.equals("<init>")) {
-					Constructor c = declaring.getDeclaredConstructor(params);
+					Constructor c;
+					
+					if (sameClassLoader)
+					{
+						c = declaring.getDeclaredConstructor(params);
+					}
+					else
+					{
+						c = declaring.getConstructor(params);
+						
+						// check this construct is declared by this
+						// class, has to be, right? But no harm checking.
+						if (!c.getDeclaringClass().equals(declaring))
+						{
+							reason = "constructor " + c.toString() + " declared on " + c.getDeclaringClass() +
" expected " + declaring;
+						}
+					}
+					
 					actualReturnType = "void";
 				} else {
-					Method m = declaring.getDeclaredMethod(methodName, params);
+					Method m;
+					
+					if (sameClassLoader)
+					{
+						m = declaring.getDeclaredMethod(methodName, params);
+					}
+					else
+					{
+						m = declaring.getMethod(methodName, params);
+						
+						// check this method is declared by this
+						// class? But no harm checking.
+						if (!m.getDeclaringClass().equals(declaring))
+						{
+							reason = "method " + m.toString() + " declared on " + m.getDeclaringClass() + " expected
" + declaring;
+						}
+					}
+					
 					actualReturnType = m.getReturnType().getName();
 				}
-
-				Class requestedReturnType = loadClass(rt.javaName());
-
-				// check the return type
-				if (actualReturnType.equals(requestedReturnType.getName())) {
-
-					// check the inteface match
-					if (opcode != VMOpcode.INVOKEINTERFACE)
-						return;
-
-					if (declaring.isInterface())
-						return;
-
-					reason = "declaring class is not an interface";
-
-				} else {
-					reason = "return type is " + actualReturnType;
+				
+				// do we already have a problem?
+				if (reason == null)
+				{
+
+					Class requestedReturnType = loadClass(rt.javaName());
+	
+					// check the return type
+					if (actualReturnType.equals(requestedReturnType.getName())) {
+	
+						// check the inteface match
+						if (opcode != VMOpcode.INVOKEINTERFACE)
+							return;
+	
+						if (declaring.isInterface())
+							return;
+	
+						reason = "declaring class is not an interface";
+	
+					} else {
+						reason = "return type is " + actualReturnType;
+					}
 				}
 
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy?rev=321124&r1=321123&r2=321124&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
Fri Oct 14 06:59:46 2005
@@ -36,10 +36,6 @@
   // BUG DERBY-622 derbynet/sysinfo.java
   permission java.io.FilePermission "${csinfo.codedir}${/}*", "read";
   
-  // BUG DERBY-624 - required for sane=true, checking method signatures
-  // of compiled code - 17 tests fail including derbynet/callable
-  permission java.lang.RuntimePermission "accessDeclaredMembers";
-  
   // sane=true, jdbcapi/secureUsers1.sql
   permission java.io.FilePermission "${user.dir}${/}CloudLDAP.out", "write"; 
  
@@ -69,10 +65,6 @@
   permission java.util.PropertyPermission "derby.monitor.verbose", "read";
   permission java.util.PropertyPermission "derby.debug.*", "read";
   
-  // BUG DERBY-624 - required for sane=true, checking method signatures
-  // of compiled code - 17 tests fail including derbynet/callable
-  permission java.lang.RuntimePermission "accessDeclaredMembers";
-  
 };
 
 //
@@ -102,17 +94,6 @@
   permission java.io.FilePermission "${user.dir}${/}extin${/}*", "read";
   permission java.io.FilePermission "${user.dir}${/}extinout${/}*", "read, write";
   permission java.io.FilePermission "${user.dir}${/}extout${/}*", "write"; 
-  
-  // BUG DERBY-624 - required for sane=true, checking method signatures
-  // of compiled code - 17 tests fail including derbynet/callable
-  permission java.lang.RuntimePermission "accessDeclaredMembers";
 };
 
-// grant to all code, really don't want a section like this
-// remove once the bug is fixed. This is because it will grant
-// permissions to the generated code as well.
-grant {
-  // BUG DERBY-624 - required for sane=true, checking method signatures
-  // of compiled code
-  permission java.lang.RuntimePermission "accessDeclaredMembers";
-};
+



Mime
View raw message