Class FactoryHelper


  • public class FactoryHelper
    extends java.lang.Object
    A helper class for implementing ProxyFactory. The users of ProxyFactory do not have to see this class.
    See Also:
    ProxyFactory
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int[] dataSize
      The data size of primitive types.
      private static java.lang.reflect.Method defineClass1  
      private static java.lang.reflect.Method defineClass2  
      static java.lang.Class[] primitiveTypes
      Class objects representing primitive types.
      static java.lang.String[] unwarpMethods
      The names of methods for obtaining a primitive value from a wrapper object.
      static java.lang.String[] unwrapDesc
      The descriptors of the unwrapping methods contained in unwrapMethods.
      static java.lang.String[] wrapperDesc
      The descriptors of the constructors of wrapper classes.
      static java.lang.String[] wrapperTypes
      The fully-qualified names of wrapper classes for primitive types.
    • Constructor Summary

      Constructors 
      Constructor Description
      FactoryHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static byte[] toBytecode​(ClassFile cf)  
      static java.lang.Class toClass​(ClassFile cf, java.lang.ClassLoader loader)
      Loads a class file by a given class loader.
      static java.lang.Class toClass​(ClassFile cf, java.lang.ClassLoader loader, java.security.ProtectionDomain domain)
      Loads a class file by a given class loader.
      private static java.lang.Class toClass2​(java.lang.reflect.Method method, java.lang.ClassLoader loader, java.lang.Object[] args)  
      static int typeIndex​(java.lang.Class type)
      Returns an index for accessing arrays in this class.
      static void writeFile​(ClassFile cf, java.lang.String directoryName)
      Writes a class file.
      private static void writeFile0​(ClassFile cf, java.lang.String directoryName)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • defineClass1

        private static java.lang.reflect.Method defineClass1
      • defineClass2

        private static java.lang.reflect.Method defineClass2
      • primitiveTypes

        public static final java.lang.Class[] primitiveTypes
        Class objects representing primitive types.
      • wrapperTypes

        public static final java.lang.String[] wrapperTypes
        The fully-qualified names of wrapper classes for primitive types.
      • wrapperDesc

        public static final java.lang.String[] wrapperDesc
        The descriptors of the constructors of wrapper classes.
      • unwarpMethods

        public static final java.lang.String[] unwarpMethods
        The names of methods for obtaining a primitive value from a wrapper object. For example, intValue() is such a method for obtaining an integer value from a java.lang.Integer object.
      • unwrapDesc

        public static final java.lang.String[] unwrapDesc
        The descriptors of the unwrapping methods contained in unwrapMethods.
      • dataSize

        public static final int[] dataSize
        The data size of primitive types. long and double are 2; the others are 1.
    • Constructor Detail

      • FactoryHelper

        public FactoryHelper()
    • Method Detail

      • typeIndex

        public static final int typeIndex​(java.lang.Class type)
        Returns an index for accessing arrays in this class.
        Throws:
        java.lang.RuntimeException - if a given type is not a primitive type.
      • toClass

        public static java.lang.Class toClass​(ClassFile cf,
                                              java.lang.ClassLoader loader,
                                              java.security.ProtectionDomain domain)
                                       throws CannotCompileException
        Loads a class file by a given class loader.
        Parameters:
        domain - if it is null, a default domain is used.
        Throws:
        CannotCompileException
        Since:
        3.3
      • toClass2

        private static java.lang.Class toClass2​(java.lang.reflect.Method method,
                                                java.lang.ClassLoader loader,
                                                java.lang.Object[] args)
                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • toBytecode

        private static byte[] toBytecode​(ClassFile cf)
                                  throws java.io.IOException
        Throws:
        java.io.IOException