import java.lang.reflect.*;

class NonsenseDemo
{
    public static void main( String[] args )
    {
        pack.Outer out = new pack.Outer( 100 );
        System.out.println( "Using normal access through out ref" );
        System.out.println( "Outer's x is " + out.getX( ) );
        
        pack.Outer.Inner in = out.new Inner( );
        System.out.println( "Using normal access through in ref" );
        System.out.println( "Inner's x is " + in.getX( ) );
        System.out.println( "Outer's x is " + in.getOuterX( ) );

        Class outerClass = pack.Outer.class;
        
        try
        {
                // Use reflection to invoke the accessor wrapper for private x
            Method wrapper = outerClass.getDeclaredMethod( "access$000",
                                                    new Class[] { outerClass  } );
            Object value = wrapper.invoke( null, new Object[]  { out } );
            System.out.println( "Using reflection and hidden accessor" );
            System.out.println( "Outer's x is " + value );
        }
        catch( Exception e )
        {
            e.printStackTrace( );
        }
    }
}
        
        

