[BVAL-137] Attempt to skip Weld proxy classes when discovering method 
validation metadata


Project: http://git-wip-us.apache.org/repos/asf/bval/repo
Commit: http://git-wip-us.apache.org/repos/asf/bval/commit/889333ac
Tree: http://git-wip-us.apache.org/repos/asf/bval/tree/889333ac
Diff: http://git-wip-us.apache.org/repos/asf/bval/diff/889333ac

Branch: refs/heads/master
Commit: 889333ac975d719a018df50d4f88a35266be38e5
Parents: 3a1ac76
Author: Matt Benson <[email protected]>
Authored: Wed Oct 19 21:14:24 2016 +0000
Committer: Matt Benson <[email protected]>
Committed: Wed Oct 19 21:14:24 2016 +0000

----------------------------------------------------------------------
 .../java/org/apache/bval/jsr/util/Proxies.java    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bval/blob/889333ac/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java 
b/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java
index 0722d4e..9df07a9 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java
@@ -18,7 +18,19 @@
  */
 package org.apache.bval.jsr.util;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
 public final class Proxies {
+    private static final Set<String> KNOWN_PROXY_CLASSNAMES;
+
+    static {
+        final Set<String> s = new HashSet<String>();
+        s.add("org.jboss.weld.bean.proxy.ProxyObject");
+        KNOWN_PROXY_CLASSNAMES = Collections.unmodifiableSet(s); 
+    }
+
     // get rid of proxies which probably contains wrong annotation metamodel
     public static <T> Class<?> classFor(final Class<?> clazz) { // TODO: do we 
want a SPI with impl for guice, owb, openejb, ...?
         if (isProxyClass(clazz)) {
@@ -31,7 +43,11 @@ public final class Proxies {
     }
 
     private static boolean isProxyClass(Class<?> clazz) {
-        return clazz.getSimpleName().contains("$$");// a lot of proxies use 
this convention to avoid conflicts with inner/anonymous classes
+        final String simpleName = clazz.getSimpleName();
+        if (KNOWN_PROXY_CLASSNAMES.contains(simpleName)) {
+            return true;
+        }
+        return simpleName.contains("$$");// a lot of proxies use this 
convention to avoid conflicts with inner/anonymous classes
     }
 
     private Proxies() {

Reply via email to