public PercSerializationInstantiator()

in lightning-core/src/main/java/org/apache/directmemory/lightning/internal/instantiator/perc/PercSerializationInstantiator.java [47:95]


    public PercSerializationInstantiator( Class<?> type )
    {

        // Find the first unserializable parent class
        Class<?> unserializableType = type;

        while ( Serializable.class.isAssignableFrom( unserializableType ) )
        {
            unserializableType = unserializableType.getSuperclass();
        }

        try
        {
            // Get the special Perc method to call
            Class<?> percMethodClass = Class.forName( "COM.newmonics.PercClassLoader.Method" );

            newInstanceMethod =
                ObjectInputStream.class.getDeclaredMethod( "noArgConstruct", new Class[] { Class.class, Object.class,
                    percMethodClass } );
            newInstanceMethod.setAccessible( true );

            // Create invoke params
            Class<?> percClassClass = Class.forName( "COM.newmonics.PercClassLoader.PercClass" );
            Method getPercClassMethod = percClassClass.getDeclaredMethod( "getPercClass", new Class[] { Class.class } );
            Object someObject = getPercClassMethod.invoke( null, new Object[] { unserializableType } );
            Method findMethodMethod =
                someObject.getClass().getDeclaredMethod( "findMethod", new Class[] { String.class } );
            Object percMethod = findMethodMethod.invoke( someObject, new Object[] { "<init>()V" } );

            typeArgs = new Object[] { unserializableType, type, percMethod };

        }
        catch ( ClassNotFoundException e )
        {
            throw new ObjenesisException( e );
        }
        catch ( NoSuchMethodException e )
        {
            throw new ObjenesisException( e );
        }
        catch ( InvocationTargetException e )
        {
            throw new ObjenesisException( e );
        }
        catch ( IllegalAccessException e )
        {
            throw new ObjenesisException( e );
        }
    }