Skip to content

Commit

Permalink
Clarify we're wrapping exceptions with InvocationTargetException to m…
Browse files Browse the repository at this point in the history
…atch JDK reflection behaviour
  • Loading branch information
mcculls committed Jun 6, 2020
1 parent 6f29cde commit 1386c48
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Expand Up @@ -81,7 +81,7 @@ public T newInstance(Object... arguments) throws InvocationTargetException {
try {
return (T) fastConstructor.apply(null, arguments);
} catch (Throwable e) {
throw new InvocationTargetException(e);
throw new InvocationTargetException(e); // match JDK reflection behaviour
}
}

Expand Down
5 changes: 2 additions & 3 deletions core/src/com/google/inject/internal/ProviderMethod.java
Expand Up @@ -257,12 +257,11 @@ private static final class FastClassProviderMethod<T> extends ProviderMethod<T>

@SuppressWarnings("unchecked")
@Override
public T doProvision(Object[] parameters)
throws IllegalAccessException, InvocationTargetException {
public T doProvision(Object[] parameters) throws InvocationTargetException {
try {
return (T) fastMethod.apply(instance, parameters);
} catch (Throwable e) {
throw new InvocationTargetException(e);
throw new InvocationTargetException(e); // match JDK reflection behaviour
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/com/google/inject/internal/SingleMethodInjector.java
Expand Up @@ -46,11 +46,11 @@ private MethodInvoker createMethodInvoker(final Method method) {
return new MethodInvoker() {
@Override
public Object invoke(Object target, Object... parameters)
throws IllegalAccessException, InvocationTargetException {
throws InvocationTargetException {
try {
return fastMethod.apply(target, parameters);
} catch (Throwable e) {
throw new InvocationTargetException(e);
throw new InvocationTargetException(e); // match JDK reflection behaviour
}
}
};
Expand Down

0 comments on commit 1386c48

Please sign in to comment.