openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1557616 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/intercept/ main/java/org/apache/webbeans/proxy/ main/java/org/apache/webbeans/util/ test/java/org/apache/webbeans/util/
Date Sun, 12 Jan 2014 21:53:37 GMT
Author: struberg
Date: Sun Jan 12 21:53:36 2014
New Revision: 1557616

URL: http://svn.apache.org/r1557616
Log:
OWB-923 exclude bridge methods already in classUtil

We better do not handle bridge methods at all. So we can already
ignore them from the beginning. This also prevents us from trying
to handle them in the proxy code. See OWB-828 for the original issue.

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java?rev=1557616&r1=1557615&r2=1557616&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
Sun Jan 12 21:53:36 2014
@@ -564,12 +564,6 @@ public class InterceptorResolutionServic
         Set<AnnotatedMethod> annotatedMethods = annotatedType.getMethods();
         for (Method interceptableMethod : interceptableMethods)
         {
-            //don't proxy bridge methods - see OWB-828
-            if (interceptableMethod.isBridge())
-            {
-                continue;
-            }
-
             for (AnnotatedMethod<?> annotatedMethod : annotatedMethods)
             {
                 if (annotatedMethod.getJavaMember().equals(interceptableMethod))

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java?rev=1557616&r1=1557615&r2=1557616&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
Sun Jan 12 21:53:36 2014
@@ -273,7 +273,6 @@ public abstract class AbstractProxyFacto
     {
         int modifiers = delegatedMethod.getModifiers();
 
-        //X TODO how to deal with native functions?
         return (modifiers & (Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL | Modifier.NATIVE))
> 0 ||
                "finalize".equals(delegatedMethod.getName()) || delegatedMethod.isBridge();
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=1557616&r1=1557615&r2=1557616&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
Sun Jan 12 21:53:36 2014
@@ -237,6 +237,8 @@ public final class ClassUtil
     /**
      * collect all non-private, non-static and non-abstract methods from the given class.
      * This method removes any overloaded methods from the list automatically.
+     * We also do skip bridge methods as they exist for and are handled solely
+     * by the JVM itself.
      *
      * The returned Map contains the methods divided by the methodName as key in the map
      * following all the methods with the same methodName in a List.
@@ -244,19 +246,25 @@ public final class ClassUtil
      * There is some special rule for package-private methods. Any non-visible
      * package-private method will get skipped and treated similarly to private methods.
      *
-     * Note: we filter out the {@link Object#finalize()} method as users must not deal with
it
+     * Note: we filter out the {@link Object#finalize()} method as users must not deal with
it.
      */
-    public static List<Method> getNonPrivateMethods(Class<?> rootClazz, boolean
noFinalMethods)
+    public static List<Method> getNonPrivateMethods(Class<?> topClass, boolean
noFinalMethods)
     {
         Map<String, List<Method>> methodMap = new HashMap<String, List<Method>>();
         List<Method> allMethods = new ArrayList<Method>(10);
 
-        Class<?> clazz = rootClazz;
+        Class<?> clazz = topClass;
 
         while (clazz != null)
         {
             for (Method method : clazz.getDeclaredMethods())
             {
+                if (method.isBridge())
+                {
+                    // we have no interest in generics bridge methods
+                    continue;
+                }
+
                 final int modifiers = method.getModifiers();
 
                 if (Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers))
@@ -279,7 +287,7 @@ public final class ClassUtil
                 {
                     // private already got handled above, so we only had to check for not
public nor protected
                     // we cannot see those methods if they are not in the same package as
the rootClazz
-                    if (!clazz.getPackage().getName().equals(rootClazz.getPackage().getName()))
+                    if (!clazz.getPackage().getName().equals(topClass.getPackage().getName()))
                     {
                         continue;
                     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java?rev=1557616&r1=1557615&r2=1557616&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java
Sun Jan 12 21:53:36 2014
@@ -34,7 +34,9 @@ public class ClassUtilTest {
     {
         List<Method> nonPrivateMethods = ClassUtil.getNonPrivateMethods(SpecificClass.class,
false);
         nonPrivateMethods.removeAll(Arrays.asList(Object.class.getDeclaredMethods()));
-        Assert.assertEquals(SpecificClass.class.getDeclaredMethods().length, nonPrivateMethods.size());
+
+        // getDeclaredMethods also contains the bridge method, so it's really only 1
+        Assert.assertEquals(1, nonPrivateMethods.size());
     }
 
     @Test



Mime
View raw message