Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 24385 invoked from network); 15 Jun 2010 10:12:06 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 15 Jun 2010 10:12:06 -0000 Received: (qmail 27003 invoked by uid 500); 15 Jun 2010 10:12:06 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 26912 invoked by uid 500); 15 Jun 2010 10:12:04 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 26905 invoked by uid 99); 15 Jun 2010 10:12:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jun 2010 10:12:04 +0000 X-ASF-Spam-Status: No, hits=-1209.6 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jun 2010 10:12:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0AD0D23889E1; Tue, 15 Jun 2010 10:11:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Tue, 15 Jun 2010 10:11:17 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100615101118.0AD0D23889E1@eris.apache.org> 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 exps = new ArrayList(); + 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{}