Package java.lang.reflect

Examples of java.lang.reflect.ReflectPermission


        }

        private static void setInstance(ServiceIteratorProvider sip) throws SecurityException {
            SecurityManager security = System.getSecurityManager();
            if (security != null) {
                ReflectPermission rp = new ReflectPermission("suppressAccessChecks");
                security.checkPermission(rp);
            }
            synchronized (ServiceIteratorProvider.class) {
                ServiceIteratorProvider.sip = sip;
            }
View Full Code Here


  /**
   * @tests java.lang.reflect.ReflectPermission#ReflectPermission(java.lang.String)
   */
  public void test_ConstructorLjava_lang_String() {
    // Test for method java.lang.reflect.ReflectPermission(java.lang.String)
    String permString = new ReflectPermission("Blah").toString();
    assertTrue("Incorrect permission constructed", permString.indexOf(
        "java.lang.reflect.ReflectPermission Blah") >= 0);
  }
View Full Code Here

   *        java.lang.String)
   */
  public void test_ConstructorLjava_lang_StringLjava_lang_String() {
    // Test for method java.lang.reflect.ReflectPermission(java.lang.String,
    // java.lang.String)
    assertTrue("Incorrect permission constructed", new ReflectPermission(
        "Blah", "suppressAccessChecks").toString().indexOf(
        "java.lang.reflect.ReflectPermission Blah") >= 0);
  }
View Full Code Here

    }
  }

  private boolean canAccessPrivateMethods() {
    try {
      System.getSecurityManager().checkPermission(new ReflectPermission("suppressAccessChecks"));
      return true;
    } catch (SecurityException e) {
      return false;
    } catch (NullPointerException e) {
      return true;
View Full Code Here

    return sb.toString();
  }

  private boolean canAccessPrivateMethods() {
    try {
      System.getSecurityManager().checkPermission(new ReflectPermission("suppressAccessChecks"));
      return true;
    } catch (SecurityException e) {
      return false;
    } catch (NullPointerException e) {
      return true;
View Full Code Here

    return sb.toString();
  }

  private boolean canAccessPrivateMethods() {
    try {
      System.getSecurityManager().checkPermission(new ReflectPermission("suppressAccessChecks"));
      return true;
    } catch (SecurityException e) {
      return false;
    } catch (NullPointerException e) {
      return true;
View Full Code Here

    private static volatile RuntimeDelegate delegate;

    public static void setInstance(RuntimeDelegate delegate) throws SecurityException {
        SecurityManager secManager = System.getSecurityManager();
        if (secManager != null) {
            secManager.checkPermission(new ReflectPermission("suppressAccessChecks"));
        }
        RuntimeDelegate.delegate = delegate;
    }
View Full Code Here

  private static boolean canAccessPrivateMethods() {
    try {
      SecurityManager securityManager = System.getSecurityManager();
      if (null != securityManager) {
        securityManager.checkPermission(new ReflectPermission("suppressAccessChecks"));
      }
    } catch (SecurityException e) {
      return false;
    }
    return true;
View Full Code Here

    }

    public static void main(String [] args) {
        RuntimeException re = new RuntimeException("no exception thrown");
        try {
            new ReflectPermission(null);
            fail("null", re);
        } catch (NullPointerException x) {
            pass();
        } catch (Exception x) {
            fail("null", x);
        }
        try {
            new ReflectPermission("");
            fail("\"\"", re);
        } catch (IllegalArgumentException x) {
            pass();
        } catch (Exception x) {
            fail("\"\"", x);
        }

        try {
            new ReflectPermission(null, null);
            fail("null, null", re);
        } catch (NullPointerException x) {
            pass();
        } catch (Exception x) {
            fail("null, null", x);
        }
        try {
            new ReflectPermission("", null);
            fail("\"\", null", re);
        } catch (IllegalArgumentException x) {
            pass();
        } catch (Exception x) {
            fail("\"\", null", x);
View Full Code Here

   public void testCoreJavaMethodsNotMadeAccessible(final Method testMethod) {
      // a nice mock is required because plenty of other checks will be made
      SecurityManager mockSecurityManager = createNiceMock(SecurityManager.class);
      // clunky way of failing if the following method is ever called
      mockSecurityManager.checkPermission(new ReflectPermission("suppressAccessChecks"));
      expectLastCall().andStubAnswer(new IAnswer<Void>() {
            @Override
            public Void answer() throws Throwable {
               try {
                  // generate a stacktrace
View Full Code Here

TOP

Related Classes of java.lang.reflect.ReflectPermission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.