Return-Path: X-Original-To: apmail-tuscany-commits-archive@www.apache.org Delivered-To: apmail-tuscany-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1A0FC9AC5 for ; Tue, 20 Dec 2011 19:32:33 +0000 (UTC) Received: (qmail 79035 invoked by uid 500); 20 Dec 2011 19:32:33 -0000 Delivered-To: apmail-tuscany-commits-archive@tuscany.apache.org Received: (qmail 79008 invoked by uid 500); 20 Dec 2011 19:32:33 -0000 Mailing-List: contact commits-help@tuscany.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tuscany.apache.org Delivered-To: mailing list commits@tuscany.apache.org Received: (qmail 79001 invoked by uid 99); 20 Dec 2011 19:32:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2011 19:32:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED 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, 20 Dec 2011 19:32:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D614223888E7 for ; Tue, 20 Dec 2011 19:32:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1221454 - in /tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl: JavaInterfaceIntrospectorImpl.java JavaIntrospectionHelper.java Date: Tue, 20 Dec 2011 19:32:07 -0000 To: commits@tuscany.apache.org From: antelder@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111220193207.D614223888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: antelder Date: Tue Dec 20 19:32:07 2011 New Revision: 1221454 URL: http://svn.apache.org/viewvc?rev=1221454&view=rev Log: TUSCANY-3992: Apply patch from Greg Dritschler to fix AccessControlException occurs when calling SCAClientFactory.getService Modified: tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java Modified: tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java?rev=1221454&r1=1221453&r2=1221454&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java (original) +++ tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java Tue Dec 20 19:32:07 2011 @@ -28,6 +28,8 @@ import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.rmi.Remote; import java.rmi.RemoteException; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -147,33 +149,39 @@ public class JavaInterfaceIntrospectorIm // Check if any methods have disallowed annotations // Check if any private methods have illegal annotations that should be raised as errors - Set methods = JavaIntrospectionHelper.getMethods(clazz); - for (Method method : methods) { - checkMethodAnnotations(method, javaInterface); - } // end for + checkMethodAnnotations(clazz, javaInterface); } // end method introspectInterface - private void checkMethodAnnotations(Method method, JavaInterface javaInterface) throws InvalidAnnotationException { - for ( Annotation a : method.getAnnotations() ) { - if( a instanceof Remotable ) { - // [JCA90053] @Remotable annotation cannot be on a method that is not a setter method - if( !JavaIntrospectionHelper.isSetter(method) ) { - throw new InvalidAnnotationException("[JCA90053] @Remotable annotation present on an interface method" + - " which is not a Setter method: " + javaInterface.getName() + "/" + method.getName(), Remotable.class); - } // end if - } // end if - } // end for + private void checkMethodAnnotations(Class clazz, JavaInterface javaInterface) throws InvalidAnnotationException { - // Parameter annotations - for (Annotation[] parmAnnotations : method.getParameterAnnotations()) { - for (Annotation annotation : parmAnnotations) { - if (annotation instanceof Remotable ) { - throw new InvalidAnnotationException("[JCA90053] @Remotable annotation present on an interface method" + - " parameter: " + javaInterface.getName() + "/" + method.getName(), Remotable.class); - } // end if - } // end for - } // end for - method.getParameterAnnotations(); + final Class _clazz = clazz; + Method[] declaredMethods = (Method[])AccessController.doPrivileged(new PrivilegedAction() { + public Method[] run() { + return _clazz.getDeclaredMethods(); + } + }); + + for (final Method method : declaredMethods) { + for ( Annotation a : method.getAnnotations() ) { + if( a instanceof Remotable ) { + // [JCA90053] @Remotable annotation cannot be on a method that is not a setter method + if( !JavaIntrospectionHelper.isSetter(method) ) { + throw new InvalidAnnotationException("[JCA90053] @Remotable annotation present on an interface method" + + " which is not a Setter method: " + javaInterface.getName() + "/" + method.getName(), Remotable.class); + } // end if + } // end if + } // end for + + // Parameter annotations + for (Annotation[] parmAnnotations : method.getParameterAnnotations()) { + for (Annotation annotation : parmAnnotations) { + if (annotation instanceof Remotable ) { + throw new InvalidAnnotationException("[JCA90053] @Remotable annotation present on an interface method" + + " parameter: " + javaInterface.getName() + "/" + method.getName(), Remotable.class); + } // end if + } // end for + } // end for + } } // end method checkMethodAnnotations private Class[] getActualTypes(Type[] types, Class[] rawTypes, Map typeBindings, boolean ignoreAsyncHolder) { Modified: tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java?rev=1221454&r1=1221453&r2=1221454&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java (original) +++ tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java Tue Dec 20 19:32:07 2011 @@ -616,16 +616,6 @@ public final class JavaIntrospectionHelp return Class.forName(buf.toString(), false, componentType.getClassLoader()); } - public static Set getMethods(Class clazz) { - Set methods = new HashSet(); - Method[] declaredMethods = clazz.getDeclaredMethods(); - for (final Method declaredMethod : declaredMethods) { - methods.add(declaredMethod); - } // end for - - return methods; - } // end method getMethods - public static Set getPrivateFields(Class clazz) { Set fields = new HashSet(); Field[] declaredFields = clazz.getDeclaredFields();