List of usage examples for java.lang IllegalAccessError setStackTrace
public void setStackTrace(StackTraceElement[] stackTrace)
From source file:hm.binkley.util.XPropsConverter.java
@SuppressWarnings("unchecked") private static <T, E extends Exception> Conversion<T, E> invokeValueOf(final Class<T> token) throws NoSuchMethodError { try {//from ww w .ja va2 s . co m final Method method = token.getMethod("valueOf", String.class); return value -> { try { return (T) method.invoke(null, value); } catch (final IllegalAccessException e) { final IllegalAccessError x = new IllegalAccessError(e.getMessage()); x.setStackTrace(e.getStackTrace()); throw x; } catch (final InvocationTargetException e) { final Throwable root = getRootCause(e); final RuntimeException x = new RuntimeException(root); x.setStackTrace(root.getStackTrace()); throw x; } }; } catch (final NoSuchMethodException ignored) { return null; } }
From source file:hm.binkley.util.XPropsConverter.java
@SuppressWarnings("unchecked") private static <T, E extends Exception> Conversion<T, E> invokeOf(final Class<T> token) throws NoSuchMethodError { try {/*from www. j a va2 s .c om*/ final Method method = token.getMethod("of", String.class); return value -> { try { return (T) method.invoke(null, value); } catch (final IllegalAccessException e) { final IllegalAccessError x = new IllegalAccessError(e.getMessage()); x.setStackTrace(e.getStackTrace()); throw x; } catch (final InvocationTargetException e) { final Throwable root = getRootCause(e); final RuntimeException x = new RuntimeException(root); x.setStackTrace(root.getStackTrace()); throw x; } }; } catch (final NoSuchMethodException ignored) { return null; } }
From source file:hm.binkley.util.XPropsConverter.java
private static <T, E extends Exception> Conversion<T, E> invokeConstructor(final Class<T> token) throws NoSuchMethodError { try {// w w w . j a v a 2 s .com final Constructor<T> ctor = token.getConstructor(String.class); return value -> { try { return ctor.newInstance(value); } catch (final IllegalAccessException e) { final IllegalAccessError x = new IllegalAccessError(e.getMessage()); x.setStackTrace(e.getStackTrace()); throw x; } catch (final InvocationTargetException e) { final Throwable root = getRootCause(e); final RuntimeException x = new RuntimeException(root); x.setStackTrace(root.getStackTrace()); throw x; } catch (final InstantiationException e) { final InstantiationError x = new InstantiationError(e.getMessage()); x.setStackTrace(e.getStackTrace()); throw x; } }; } catch (final NoSuchMethodException ignored) { return null; } }