本文整理汇总了Java中java.lang.InstantiationException类的典型用法代码示例。如果您正苦于以下问题:Java InstantiationException类的具体用法?Java InstantiationException怎么用?Java InstantiationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InstantiationException类属于java.lang包,在下文中一共展示了InstantiationException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import java.lang.InstantiationException; //导入依赖的package包/类
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
InstantiationException object1 = new InstantiationException();
harness.check(object1 != null);
harness.check(object1.toString(), "java.lang.InstantiationException");
InstantiationException object2 = new InstantiationException("nothing happens");
harness.check(object2 != null);
harness.check(object2.toString(), "java.lang.InstantiationException: nothing happens");
InstantiationException object3 = new InstantiationException(null);
harness.check(object3 != null);
harness.check(object3.toString(), "java.lang.InstantiationException");
}
示例2: test
import java.lang.InstantiationException; //导入依赖的package包/类
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
// flag that is set when exception is caught
boolean caught = false;
try {
throw new InstantiationException("InstantiationException");
}
catch (InstantiationException e) {
// correct exception was caught
caught = true;
}
harness.check(caught);
}
示例3: mixinCreateTest3
import java.lang.InstantiationException; //导入依赖的package包/类
@Test
public void mixinCreateTest3( ) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
Query query = new Query( )
.setFirstRank( 0 )
.setNofRanks( 20 )
.addWeightingScheme(
new WeightingScheme( "bm25" )
.addParameter( "b", 0.77f )
.addParameter( "k1", 2 )
.addParameter( "avgdoclen", 11943 )
.addParameter( "metadata_doclen", "doclen" )
.addParameter( "match", "feat" ) )
.addSummarizer(
new SummarizerConfiguration( "docid", "attribute" )
.addParameter( "name", "docid" ) )
.addSummarizer(
new SummarizerConfiguration( "attr1", "attribute" )
.addParameter( "name", "attr1" ) )
.addSummarizer(
new SummarizerConfiguration( "doclen", "metadata" )
.addParameter( "name", "doclen" ) )
.defineFeature( "feat", "word", "aword0", 1.0f )
.defineFeature( "feat", new Term( "word", "aword1" ), 1.0f )
.defineFeature( "sel",
new Term( "word", "aword1" ), 1.0f )
.defineFeature( "sel",
new Expression( "contains", 0, 0 )
.addExpression(
new Expression( "contains", 0, 0 )
.addTerm( "word", "aword0" )
.addTerm( "word", "aword1" ) )
.addTerm( "word", "aword2" ), 1.0f )
.addSelect( "sel" )
// AND of OR-groups (CNF), first is a shortcut for a single and condition
.addMetadataRestriction(
new MetadataRestriction( MetadataCondition.COMPARE_GREATER_OR_EQUALS, "doclen", 2 )
)
.addMetadataRestriction(
new MetadataRestriction( )
.addCondition( MetadataCondition.COMPARE_GREATER, "doclen", 3 )
.addCondition( MetadataCondition.COMPARE_LESS_OR_EQUALS, "doclen", 100 )
);
// long for:
// QueryResponse response = new QueryResponse( query );
// in private static class in WebService:
Class<?> queryRequestClazz = Class.forName( "net.strus.service.impl.ws.WebService$QueryRequest" );
Constructor<?> constructor = queryRequestClazz.getDeclaredConstructor( Query.class );
constructor.setAccessible( true );
Object request = constructor.newInstance( query );
LOGGER.fine( request.toString( ) );
}
示例4: makeParser
import java.lang.InstantiationException; //导入依赖的package包/类
/**
* Create a new SAX parser using the `org.xml.sax.parser' system property.
*
* <p>The named class must exist and must implement the
* {@link org.xml.sax.Parser Parser} interface.</p>
*
* @exception java.lang.NullPointerException There is no value
* for the `org.xml.sax.parser' system property.
* @exception java.lang.ClassNotFoundException The SAX parser
* class was not found (check your CLASSPATH).
* @exception IllegalAccessException The SAX parser class was
* found, but you do not have permission to load
* it.
* @exception InstantiationException The SAX parser class was
* found but could not be instantiated.
* @exception java.lang.ClassCastException The SAX parser class
* was found and instantiated, but does not implement
* org.xml.sax.Parser.
* @see #makeParser(java.lang.String)
* @see org.xml.sax.Parser
*/
public static Parser makeParser ()
throws ClassNotFoundException,
IllegalAccessException,
InstantiationException,
NullPointerException,
ClassCastException
{
String className = System.getProperty("org.xml.sax.parser");
if (className == null) {
throw new NullPointerException("No value for sax.parser property");
} else {
return makeParser(className);
}
}