本文整理汇总了Java中java.lang.reflect.InvocationTargetException.toString方法的典型用法代码示例。如果您正苦于以下问题:Java InvocationTargetException.toString方法的具体用法?Java InvocationTargetException.toString怎么用?Java InvocationTargetException.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.reflect.InvocationTargetException
的用法示例。
在下文中一共展示了InvocationTargetException.toString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compare
import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
/**
* Compare two JavaBeans by their shared property.
* If {@link #getProperty} is null then the actual objects will be compared.
*
* @param o1 Object The first bean to get data from to compare against
* @param o2 Object The second bean to get data from to compare
* @return int negative or positive based on order
*/
public int compare( final T o1, final T o2 ) {
if ( property == null ) {
// compare the actual objects
return internalCompare( o1, o2 );
}
try {
final Object value1 = PropertyUtils.getProperty( o1, property );
final Object value2 = PropertyUtils.getProperty( o2, property );
return internalCompare( value1, value2 );
}
catch ( final IllegalAccessException iae ) {
throw new RuntimeException( "IllegalAccessException: " + iae.toString() );
}
catch ( final InvocationTargetException ite ) {
throw new RuntimeException( "InvocationTargetException: " + ite.toString() );
}
catch ( final NoSuchMethodException nsme ) {
throw new RuntimeException( "NoSuchMethodException: " + nsme.toString() );
}
}
示例2: getSolver
import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
public Solver getSolver(SolverManager solverManager){
if (solver == null){
try{
Class classRef = Class.forName(className);
Class[] argTypes = {SolverManager.class};
Method newInstanceMethod = classRef.getMethod("newInstance", argTypes);
Object[] args = {solverManager};
solver = (Solver)newInstanceMethod.invoke(null, args);
} catch (ClassNotFoundException cnfe){
throw new InternalError(cnfe.toString());
} catch (IllegalAccessException iae){
throw new InternalError(iae.toString());
} catch (NoSuchMethodException nsme){
throw new InternalError("Method newInstance(SolverManager) is missing in class " + className);
} catch (InvocationTargetException ite){
ite.printStackTrace();
throw new InternalError(ite.toString());
}
}
return solver;
}