You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bval.apache.org by mb...@apache.org on 2014/12/07 20:59:27 UTC

svn commit: r1643714 - /bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java

Author: mbenson
Date: Sun Dec  7 19:59:27 2014
New Revision: 1643714

URL: http://svn.apache.org/r1643714
Log:
no requirement that validated types have public access modifiers; therefore we will set accessible on anything that needs it, which is anything not public-and-declared-by-public

Modified:
    bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java

Modified: bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java?rev=1643714&r1=1643713&r2=1643714&view=diff
==============================================================================
--- bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java (original)
+++ bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java Sun Dec  7 19:59:27 2014
@@ -201,28 +201,13 @@ public class Reflection {
             return false;
         }
         final Member m = (Member) o;
-        if (Modifier.isPublic(m.getModifiers())) {
-            /*
-             * For objects with public accessibility, we do nothing and return with one exception.
-             * 
-             * Following explanation copied from Apache Commons [lang] MemberUtils:
-             * When a {@code public} class has a default access superclass with {@code public} members,
-             * these members are accessible. Calling them from compiled code works fine.
-             * Unfortunately, on some JVMs, using reflection to invoke these members
-             * seems to (wrongly) prevent access even when the modifier is {@code public}.
-             * Calling {@code setAccessible(true)} solves the problem but will only work from
-             * sufficiently privileged code.
-             */
-            if (!isPackageAccess(m.getDeclaringClass().getModifiers())) {
-                return false;
-            }
+
+        // For public members whose declaring classes are public, we need do nothing:
+        if (Modifier.isPublic(m.getModifiers()) && Modifier.isPublic(m.getDeclaringClass().getModifiers())) {
+            return false;
         }
         o.setAccessible(accessible);
         return true;
     }
 
-    private static boolean isPackageAccess(final int modifiers) {
-        return (modifiers & (Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC)) == 0;
-    }
-
 }