bval-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@gmail.com>
Subject Re: svn commit: r1644241 - /bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java
Date Wed, 10 Dec 2014 00:03:32 GMT
It can. I'll make the call dynamic.

Matt

On Tue, Dec 9, 2014 at 5:54 PM, Romain Manni-Bucau
<rmannibucau@gmail.com> wrote:
> Can hasSecurityManager be static? Cant it be set at runtime?
> ---------- Message transféré ----------
> De : <mbenson@apache.org>
> Date : 10 déc. 2014 00:50
> Objet : svn commit: r1644241 -
> /bval/branches/bval-11/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java
> À : <commits@bval.apache.org>
> Cc :
>
> 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:

Mime
View raw message