Package sun.reflect

Examples of sun.reflect.ReflectionFactory


    private final Constructor mungedConstructor;

    public SunReflectionFactoryInstantiator(final Class type) {

        final ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
        Constructor javaLangObjectConstructor;

        try {
            javaLangObjectConstructor = Object.class.getConstructor( (Class[]) null );
        } catch ( final NoSuchMethodException e ) {
            throw new Error( "Cannot find constructor for java.lang.Object!" );
        }
        this.mungedConstructor = reflectionFactory.newConstructorForSerialization( type,
                                                                              javaLangObjectConstructor );
        this.mungedConstructor.setAccessible( true );
    }
View Full Code Here


        return true;
    }

    private static Field[] copyFields(Field[] arg) {
        Field[] out = new Field[arg.length];
        ReflectionFactory fact = getReflectionFactory();
        for (int i = 0; i < arg.length; i++) {
            out[i] = fact.copyField(arg[i]);
        }
        return out;
    }
View Full Code Here

        return out;
    }

    private static Method[] copyMethods(Method[] arg) {
        Method[] out = new Method[arg.length];
        ReflectionFactory fact = getReflectionFactory();
        for (int i = 0; i < arg.length; i++) {
            out[i] = fact.copyMethod(arg[i]);
        }
        return out;
    }
View Full Code Here

        return out;
    }

    private static Constructor[] copyConstructors(Constructor[] arg) {
        Constructor[] out = new Constructor[arg.length];
        ReflectionFactory fact = getReflectionFactory();
        for (int i = 0; i < arg.length; i++) {
            out[i] = fact.copyConstructor(arg[i]);
        }
        return out;
    }
View Full Code Here

         throws NoSuchMethodException
   {
      try
      {
         Constructor<T> constructor;
         ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
         constructor = reflectionFactory.newConstructorForSerialization(proxyClass, Object.class.getDeclaredConstructor());
         return constructor;
      }
      catch (NoSuchMethodException e)
      {
         return null;
View Full Code Here

      proxyFactory.setHandler(interceptorMethodHandler);

      try
      {
         Class<T> clazz = proxyFactory.createClass();
         ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
         Constructor<T> c = reflectionFactory.newConstructorForSerialization(clazz, Object.class.getDeclaredConstructor());
         T proxyObject = c.newInstance();
         ((ProxyObject)proxyObject).setHandler(interceptorMethodHandler);
         return proxyObject;
      } catch (Exception e)
      {
View Full Code Here

   private final Constructor mungedConstructor;

   public SunReflectionFactorySerializationInstantiator(Class type) {
    
    Class nonSerializableAncestor = SerializationInstantiatorHelper.getNonSerializableSuperClass(type);
      ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
      Constructor nonSerializableAncestorConstructor;
      try {
         nonSerializableAncestorConstructor = nonSerializableAncestor
            .getConstructor((Class[]) null);
      }
      catch(NoSuchMethodException e) {
         /**
          * @todo (Henri) I think we should throw a NotSerializableException just to put the same
          *       message a ObjectInputStream. Otherwise, the user won't know if the null returned
          *       if a "Not serializable", a "No default constructor on ancestor" or a "Exception in
          *       constructor"
          */
         throw new ObjenesisException(new NotSerializableException(type+" has no suitable superclass constructor"));        
      }

      mungedConstructor = reflectionFactory.newConstructorForSerialization(type,
         nonSerializableAncestorConstructor);
      mungedConstructor.setAccessible(true);
   }
View Full Code Here

   private final Constructor mungedConstructor;

   public SunReflectionFactoryInstantiator(Class type) {

      ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
      Constructor javaLangObjectConstructor;

      try {
         javaLangObjectConstructor = Object.class.getConstructor((Class[]) null);
      }
      catch(NoSuchMethodException e) {
         throw new Error("Cannot find constructor for java.lang.Object!");
      }
      mungedConstructor = reflectionFactory.newConstructorForSerialization(type,
         javaLangObjectConstructor);
      mungedConstructor.setAccessible(true);
   }
View Full Code Here

   private final Constructor mungedConstructor;

   public SunReflectionFactorySerializationInstantiator(Class type) {
    
    Class nonSerializableAncestor = SerializationInstantiatorHelper.getNonSerializableSuperClass(type);
      ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
      Constructor nonSerializableAncestorConstructor;
      try {
         nonSerializableAncestorConstructor = nonSerializableAncestor
            .getConstructor((Class[]) null);
      }
      catch(NoSuchMethodException e) {
         /**
          * @todo (Henri) I think we should throw a NotSerializableException just to put the same
          *       message a ObjectInputStream. Otherwise, the user won't know if the null returned
          *       if a "Not serializable", a "No default constructor on ancestor" or a "Exception in
          *       constructor"
          */
         throw new ObjenesisException(new NotSerializableException(type+" has no suitable superclass constructor"));        
      }

      mungedConstructor = reflectionFactory.newConstructorForSerialization(type,
         nonSerializableAncestorConstructor);
      mungedConstructor.setAccessible(true);
   }
View Full Code Here

   public <T> T createProxyInstance(Class<T> proxyClass, MethodHandler interceptorMethodHandler)
   {
      try
      {
         ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
         Constructor<T> c = reflectionFactory.newConstructorForSerialization(proxyClass, Object.class.getDeclaredConstructor());
         T proxyObject = c.newInstance();
         if (interceptorMethodHandler != null)
         {
            ((ProxyObject) proxyObject).setHandler(interceptorMethodHandler);
         }
View Full Code Here

TOP

Related Classes of sun.reflect.ReflectionFactory

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.