Package java.lang.reflect

Examples of java.lang.reflect.AccessibleObject


        Class<?>[] argClasses = new Class<?>[arguments.length];
        for(int i = 0; i < arguments.length; i++) {
            argClasses[i] = (arguments[i] == null) ? null : arguments[i].getClass();
        }

        AccessibleObject m = null;
        if (target instanceof Class) {
            /*
            For class methods, simluate the effect of a meta class
            by taking the union of the static methods of the
            actual class, with the instance methods of "Class.class"
View Full Code Here


   */
  public static final AccessibleObject
  getAccessibleObject(Class cls, String name, Class[] argTypes, int flags)
  throws NoSuchMethodException {
    final AOInfo aoi = new AOInfo(cls, name, argTypes, flags);
    AccessibleObject ao = (AccessibleObject)_acsos.get(aoi);
    if (ao != null)
      return ao;

    ao = myGetAcsObj(cls, name, argTypes, flags);
    _acsos.put(aoi, ao);
View Full Code Here

   * or method (prefixed with get).
   */
  public static final Object get(Object obj, String name)
  throws NoSuchMethodException {
    try {
      final AccessibleObject acs = Classes.getAccessibleObject(
        obj.getClass(), name, null,
        Classes.B_GET|Classes.B_PUBLIC_ONLY);
      return   acs instanceof Method ?
        ((Method)acs).invoke(obj, null): ((Field)acs).get(obj);
    } catch (NoSuchMethodException ex) {
View Full Code Here

   * or method (prefixed with set).
   */
  public static final void set(Object obj, String name, Object val,
  boolean autoCoerce) throws NoSuchMethodException, ModificationException {
    try {
      AccessibleObject acs;
      try {
        acs = Classes.getAccessibleObject(
          obj.getClass(),
          name, new Class[] {val != null ? val.getClass(): null},
          Classes.B_SET|Classes.B_PUBLIC_ONLY);
View Full Code Here

        instantiationGuard.setGuardedContainer(container);
        return (T) instantiationGuard.observe(getComponentImplementation());
    }

    private Object decorateComponentInstance(Parameter[] matchingParameters, ComponentMonitor componentMonitor, Object componentInstance, PicoContainer container, PicoContainer guardedContainer) {
        AccessibleObject member = null;
        Object injected[] = new Object[injectionMembers.size()];
        Object lastReturn = null;
        try {
            for (int i = 0; i < injectionMembers.size(); i++) {
                member = injectionMembers.get(i);
View Full Code Here

      JsValueGlue.set(jsValue, classLoader, field.getType(),
          javaDispatch.getFieldValue(dispId));
      return;
    } else {
      MethodAdaptor method = javaDispatch.getMethod(dispId);
      AccessibleObject obj = method.getUnderlyingObject();
      DispatchMethod dispMethod = (DispatchMethod) classLoader.getWrapperForObject(obj);
      if (dispMethod == null) {
        dispMethod = new MethodDispatch(classLoader, method);
        classLoader.putWrapperForObject(obj, dispMethod);
      }
View Full Code Here

    private static AnnotatedElement elementForInjectionTarget(final DeploymentUnit unit, final InjectionTarget injectionTarget) throws DeploymentUnitProcessingException {
        final Module module = unit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
        final DeploymentReflectionIndex deploymentReflectionIndex = unit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
        final String injectionTargetClassName = injectionTarget.getClassName();
        final String injectionTargetName = getInjectionTargetName(injectionTarget);
        final AccessibleObject fieldOrMethod = getInjectionTarget(injectionTargetClassName, injectionTargetName, module.getClassLoader(), deploymentReflectionIndex);
        return fieldOrMethod;
    }
View Full Code Here

        final Module module = unit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
        final DeploymentReflectionIndex deploymentReflectionIndex = unit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
        final ResourceInjectionTargetMetaData injectionTarget = injectionTargets.iterator().next();
        final String injectionTargetClassName = injectionTarget.getInjectionTargetClass();
        final String injectionTargetName = injectionTarget.getInjectionTargetName();
        final AccessibleObject fieldOrMethod = getInjectionTarget(injectionTargetClassName, injectionTargetName, module.getClassLoader(), deploymentReflectionIndex);
        processAnnotatedElement(fieldOrMethod, serviceRefUMDM);
    }
View Full Code Here

   * @tests java.lang.reflect.AccessibleObject#isAccessible()
   */
  public void test_isAccessible() throws Exception {
    // Test for method boolean
    // java.lang.reflect.AccessibleObject.isAccessible()
                AccessibleObject ao = TestClass.class.getField("aField");
                ao.setAccessible(true);
                assertTrue("Returned false to isAccessible", ao.isAccessible());
                ao.setAccessible(false);
                assertTrue("Returned true to isAccessible", !ao.isAccessible());
  }
View Full Code Here

   */
  public void test_setAccessible$Ljava_lang_reflect_AccessibleObjectZ() throws Exception {
    // Test for method void
    // java.lang.reflect.AccessibleObject.setAccessible(java.lang.reflect.AccessibleObject
    // [], boolean)
                AccessibleObject ao = TestClass.class.getField("aField");
                AccessibleObject[] aoa = new AccessibleObject[] { ao };
                AccessibleObject.setAccessible(aoa, true);
                assertTrue("Returned false to isAccessible", ao.isAccessible());
                AccessibleObject.setAccessible(aoa, false);
                assertTrue("Returned true to isAccessible", !ao.isAccessible());
  }
View Full Code Here

TOP

Related Classes of java.lang.reflect.AccessibleObject

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.