Author: mbenson
Date: Tue Dec 9 23:49:56 2014
New Revision: 1644241
URL: http://svn.apache.org/r1644241
Log:
don't unset accessible when there is no SecurityManager
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=1644241&r1=1644240&r2=1644241&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
Tue Dec 9 23:49:56 2014
@@ -34,6 +34,7 @@ import org.apache.commons.weaver.privili
* @version $Rev$ $Date$
*/
public class Reflection {
+ private static final boolean hasSecurityManager =
System.getSecurityManager() != null;
/**
* Get the named {@link Class} from the specified {@link ClassLoader}.
@@ -191,7 +192,9 @@ public class Reflection {
}
/**
- * Set the accessibility of {@code o} to {@code accessible}.
+ * Set the accessibility of {@code o} to {@code accessible}. If running
without a {@link SecurityManager}
+ * and {@code accessible == false}, this call is ignored (because any code
could reflectively make any
+ * object accessible at any time).
* @param o
* @param accessible
* @return whether a change was made.
@@ -200,6 +203,9 @@ public class Reflection {
if (o == null || o.isAccessible() == accessible) {
return false;
}
+ if (!accessible && !hasSecurityManager) {
+ return false;
+ }
final Member m = (Member) o;
// For public members whose declaring classes are public, we need do
nothing: