本文整理汇总了Java中gov.nasa.jpf.Config.NO_ARGTYPES属性的典型用法代码示例。如果您正苦于以下问题:Java Config.NO_ARGTYPES属性的具体用法?Java Config.NO_ARGTYPES怎么用?Java Config.NO_ARGTYPES使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gov.nasa.jpf.Config
的用法示例。
在下文中一共展示了Config.NO_ARGTYPES属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
public static <T> T getInstance(Class<?> cls, Class<T> type, Class<?>[] argTypes,
Object[] args) throws JPFException {
Object o = null;
Constructor<?> ctor = null;
if (cls == null) {
return null;
}
while (o == null) {
try {
ctor = cls.getConstructor(argTypes);
o = ctor.newInstance(args);
} catch (NoSuchMethodException nmx) {
if ((argTypes.length > 1) || ((argTypes.length == 1) && (argTypes[0] != Config.class))) {
// fallback 1: try a single Config param
argTypes = Config.CONFIG_ARGTYPES;
args = config.CONFIG_ARGS;
} else if (argTypes.length > 0) {
// fallback 2: try the default ctor
argTypes = Config.NO_ARGTYPES;
args = Config.NO_ARGS;
} else {
// Ok, there is no suitable ctor, bail out
throw new JPFException("no suitable ctor found for the peer class " + cls.getName());
}
} catch (IllegalAccessException iacc) {
throw new JPFException("ctor not accessible: "
+ config.getMethodSignature(ctor));
} catch (IllegalArgumentException iarg) {
throw new JPFException("illegal constructor arguments: "
+ config.getMethodSignature(ctor));
} catch (InvocationTargetException ix) {
Throwable tx = ix.getCause();
throw new JPFException("exception " + tx + " occured in "
+ config.getMethodSignature(ctor));
} catch (InstantiationException ivt) {
throw new JPFException("abstract class cannot be instantiated");
} catch (ExceptionInInitializerError eie) {
throw new JPFException("static initialization failed:\n>> "
+ eie.getException(), eie.getException());
}
}
// check type
if (!cls.isInstance(o)) {
throw new JPFException("instance not of type: "
+ cls.getName());
}
return type.cast(o); // safe according to above
}