You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2010/06/15 12:11:17 UTC
svn commit: r954786 - in
/harmony/enhanced/java/trunk/classlib/modules/luni/src:
main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java
test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java
Author: tellison
Date: Tue Jun 15 10:11:17 2010
New Revision: 954786
URL: http://svn.apache.org/viewvc?rev=954786&view=rev
Log:
Apply patch for HARMONY-6511 ([classlib][luni]ProxyMethod.matchMethod() should not replace the parent exception with the sub class if they are both in the throw list)
Modified:
harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java
harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java
Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java?rev=954786&r1=954785&r2=954786&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java (original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyMethod.java Tue Jun 15 10:11:17 2010
@@ -109,7 +109,11 @@ class ProxyMethod {
}
if (cException.isAssignableFrom(oException)) {
// oException is a subclass, keep it instead
- commonExceptions[c] = cException = oException;
+ if(!containsClass(commonExceptions, oException)){
+ //if exceptions in throw list have Parent-Child relationship just ignore it
+ //otherwise, keep the subclass
+ commonExceptions[c] = cException = oException;
+ }
continue nextException;
}
}
@@ -130,7 +134,16 @@ class ProxyMethod {
}
return true;
}
-
+
+ private boolean containsClass(Class<?>[] classArray, Class<?> clazz) {
+ for (Class<?> c : classArray) {
+ if (c.equals(clazz)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
Class getDeclaringClass() {
return declaringClass;
}
Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java?rev=954786&r1=954785&r2=954786&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java (original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ProxyTest.java Tue Jun 15 10:11:17 2010
@@ -17,6 +17,7 @@
package org.apache.harmony.luni.tests.java.lang.reflect;
+import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -24,6 +25,7 @@ import java.lang.reflect.UndeclaredThrow
import java.security.AllPermission;
import java.security.ProtectionDomain;
+import java.util.ArrayList;
import tests.support.Support_Proxy_I1;
import tests.support.Support_Proxy_I2;
@@ -251,6 +253,19 @@ public class ProxyTest extends junit.fra
}
}
+
+ @SuppressWarnings("unchecked")
+ public void test_ProxyClass_withParentAndSubInThrowList() throws SecurityException, NoSuchMethodException{
+ TestParentIntf myImpl = new MyImplWithParentAndSubInThrowList();
+ Class<?> c = Proxy.getProxyClass(myImpl.getClass().getClassLoader(), myImpl.getClass().getInterfaces());
+ Method m = c.getMethod("test", (Class<?> [])null);
+ Class<?> []exceptions = m.getExceptionTypes();
+ ArrayList<Class> exps = new ArrayList<Class>();
+ for(Class<?> exp : exceptions){
+ exps.add(exp);
+ }
+ assertTrue(exps.contains(Exception.class));
+ }
public static interface ITestReturnObject {
Object f();
@@ -295,6 +310,11 @@ public class ProxyTest extends junit.fra
}
}
+ class MyImplWithParentAndSubInThrowList implements TestSubIntf{
+ public void test() throws Exception{
+ throw new Exception();
+ }
+ }
protected void setUp() {
@@ -305,3 +325,10 @@ public class ProxyTest extends junit.fra
}
interface PkgIntf {}
+
+interface TestParentIntf {
+ //IOException is a subclass of Exception
+ public void test() throws IOException, Exception;
+}
+
+interface TestSubIntf extends TestParentIntf{}