本文整理匯總了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;
}