bind( C.class ).toProvider( new LoadedClass<C>( CImpl.class ).asProvider() );
bind( CImpl.class ).toProvider( new Provider<CImpl>()
{
public CImpl get()
{
throw new ProvisionException( "Broken Provider" );
}
} );
}
} ).getInstance( C.class );
fail( "Expected ProvisionException" );
}
catch ( final ProvisionException e )
{
}
try
{
Guice.createInjector( new AbstractModule()
{
@Override
protected void configure()
{
bind( C.class ).toProvider( new LoadedClass<C>( CImpl.class ).asProvider() );
bind( CImpl.class ).toProvider( new Provider<CImpl>()
{
public CImpl get()
{
throw new LinkageError( "Broken Provider" );
}
} );
}
} ).getInstance( C.class );
fail( "Expected LinkageError" );
}
catch ( final LinkageError e )
{
}
try
{
Guice.createInjector( new AbstractModule()
{
@Override
protected void configure()
{
bind( C.class ).toProvider( new LoadedClass<C>( CImpl.class ).asProvider() );
bind( CImpl.class ).toProvider( new Provider<CImpl>()
{
public CImpl get()
{
throw new IllegalArgumentException( new IllegalStateException( new ThreadDeath() ) );
}
} );
}
} ).getInstance( C.class );
fail( "Expected ThreadDeath" );
}
catch ( final ThreadDeath e )
{
}
final ClassSpace space = new URLClassSpace( C.class.getClassLoader(), null );
try
{
Guice.createInjector( new AbstractModule()
{
@Override
protected void configure()
{
bind( C.class ).toProvider( new NamedClass<C>( space, CImpl.class.getName() ).asProvider() );
bind( CImpl.class ).toProvider( new Provider<CImpl>()
{
public CImpl get()
{
throw new ProvisionException( "Broken Provider" );
}
} );
}
} ).getInstance( C.class );