List of usage examples for org.aspectj.lang.reflect CodeSignature getExceptionTypes
Class[] getExceptionTypes();
From source file:ajia.util.JoinPointUtil.java
License:Apache License
public static void rethrow(JoinPoint.StaticPart jp, Throwable ex) { Signature signature = jp.getSignature(); if (!(signature instanceof CodeSignature)) { throw new IncompatibleRethrownException(); }// w w w.j a va2s . co m boolean mayThrow = false; if (ex instanceof RuntimeException) { mayThrow = true; } else { CodeSignature codeSignature = (CodeSignature) signature; for (Class exceptionType : codeSignature.getExceptionTypes()) { if (exceptionType.isAssignableFrom(ex.getClass())) { mayThrow = true; break; } } } if (!mayThrow) { throw new IncompatibleRethrownException(); } try { synchronized (CheckedExceptionThrower.class) { CheckedExceptionThrower.exception = ex; CheckedExceptionThrower.class.newInstance(); } } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }