use of java.lang.reflect.GenericSignatureFormatError in project leopard by tanhaichao.
the class ErrorUtil method parseMessage.
/**
* 获取异常信息.
*
* @param e
* @return
*/
public static String parseMessage(Throwable e) {
if (e == null) {
throw new IllegalArgumentException("exception不能为空?");
}
String className = e.getClass().getName();
String message = MESSAGE_MAP.get(className);
if (message != null) {
return message;
}
if (e instanceof GenericSignatureFormatError) {
printStartupTime();
return "更新程序后,还没有重启服务.";
}
if (e instanceof NoSuchMethodError) {
printStartupTime();
return "NoSuchMethodError:方法找不到.";
}
if (e instanceof SQLException) {
return "操作数据库出错,请稍后重试.";
}
if (e instanceof DataIntegrityViolationException) {
Exception exception = (Exception) e.getCause();
if (exception instanceof MysqlDataTruncation) {
return MessageParserImpl.parse((MysqlDataTruncation) exception);
} else {
return "操作数据库出错,请稍后重试.";
}
// try {
// return parseDataIntegrityViolationException((DataIntegrityViolationException) e);
// }
// catch (Exception e1) {
// e1.printStackTrace();
// return "字段太长,请稍后重试.";
// }
}
message = e.getMessage();
if (message == null) {
return null;
}
return fillterDebugInfo(message);
}
use of java.lang.reflect.GenericSignatureFormatError in project pentaho-platform by pentaho.
the class PojoComponent method callMethods.
protected void callMethods(List<Method> methods, Object value) throws Throwable {
if (value instanceof String) {
callMethodWithString(methods, value.toString());
return;
}
boolean done = false;
for (Method method : methods) {
Class<?>[] paramClasses = method.getParameterTypes();
if (paramClasses.length != 1) {
// we don't know how to handle this
throw new GenericSignatureFormatError();
}
Class<?> paramclass = paramClasses[0];
// do some type safety. this would be the point to do automatic type conversions
if (value instanceof IPentahoResultSet && paramclass.equals(IPentahoResultSet.class)) {
done = true;
method.invoke(pojo, new Object[] { (IPentahoResultSet) value });
break;
} else if (value instanceof java.lang.Boolean && (paramclass.equals(Boolean.class) || paramclass.equals(boolean.class))) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof java.lang.Integer && (paramclass.equals(Integer.class) || paramclass.equals(int.class))) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof java.lang.Long && (paramclass.equals(Long.class) || paramclass.equals(long.class))) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof java.lang.Double && (paramclass.equals(Double.class) || paramclass.equals(double.class))) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof java.lang.Float && (paramclass.equals(Float.class) || paramclass.equals(float.class))) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof IPentahoStreamSource && paramclass.equals(IPentahoStreamSource.class)) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof Date && paramclass.equals(Date.class)) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof BigDecimal && paramclass.equals(BigDecimal.class)) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof IContentItem && paramclass.equals(IContentItem.class)) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof IContentItem && paramclass.equals(String.class)) {
done = true;
method.invoke(pojo, new Object[] { value.toString() });
break;
} else if (paramclass.equals(IPentahoSession.class)) {
done = true;
method.invoke(pojo, new Object[] { (IPentahoSession) value });
break;
} else if (paramclass.equals(Log.class)) {
done = true;
method.invoke(pojo, new Object[] { (Log) value });
break;
}
}
if (!done) {
// Try invoking the first instance with what we have
try {
methods.get(0).invoke(pojo, new Object[] { value });
} catch (Exception ex) {
throw new IllegalArgumentException(// $NON-NLS-1$ //$NON-NLS-2$
"No implementation of method \"" + Method.class.getName() + "\" takes a " + value.getClass());
}
}
}
use of java.lang.reflect.GenericSignatureFormatError in project pentaho-platform by pentaho.
the class PojoComponent method callMethodWithString.
protected void callMethodWithString(List<Method> methodList, String value) throws Throwable {
boolean done = false;
value = applyInputsToFormat(value);
// that takes a single string
for (Method method : methodList) {
Class<?>[] paramClasses = method.getParameterTypes();
if (paramClasses.length != 1) {
// we don't know how to handle this
throw new GenericSignatureFormatError();
}
Class<?> paramclass = paramClasses[0];
if (paramclass.equals(String.class)) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
}
}
if (!done) {
for (Method method : methodList) {
Class<?>[] paramClasses = method.getParameterTypes();
if (paramClasses.length != 1) {
// we don't know how to handle this
throw new GenericSignatureFormatError();
}
Class<?> paramclass = paramClasses[0];
if (paramclass.equals(Boolean.class) || paramclass.equals(boolean.class)) {
done = true;
method.invoke(pojo, new Object[] { new Boolean(value) });
break;
} else if (paramclass.equals(Integer.class) || paramclass.equals(int.class)) {
done = true;
method.invoke(pojo, new Object[] { new Integer(value) });
break;
} else if (paramclass.equals(Long.class) || paramclass.equals(long.class)) {
done = true;
method.invoke(pojo, new Object[] { new Long(value) });
break;
} else if (paramclass.equals(Double.class) || paramclass.equals(double.class)) {
done = true;
method.invoke(pojo, new Object[] { new Double(value) });
break;
} else if (paramclass.equals(Float.class) || paramclass.equals(float.class)) {
done = true;
method.invoke(pojo, new Object[] { new Float(value) });
break;
} else if (paramclass.equals(BigDecimal.class)) {
done = true;
method.invoke(pojo, new Object[] { new BigDecimal(value) });
break;
}
}
}
if (!done) {
throw new GenericSignatureFormatError();
}
}
Aggregations