Skip to content

Commit

Permalink
Fix #65
Browse files Browse the repository at this point in the history
  • Loading branch information
Rdeisenroth committed Oct 10, 2023
1 parent 5b3c795 commit 133a90f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@ public String identifier() {
}

@Override
public <T> T invokeStatic(Object... args) throws Exception {
public <T> T invokeStatic(Object... args) throws Throwable {
try {
//noinspection unchecked
return (T) method.invoke(null, args);
} catch (IllegalAccessException e) {
throw new RuntimeException(e); // TODO
} catch (InvocationTargetException e) {
throw (Exception) e.getCause();
throw e.getCause();
}
}

@Override
public <T> T invoke(Object instance, Object... args) throws Exception {
public <T> T invoke(Object instance, Object... args) throws Throwable {
try {
//noinspection unchecked
return (T) method.invoke(instance, args);
} catch (IllegalAccessException e) {
throw new RuntimeException(e); // TODO
} catch (InvocationTargetException e) {
throw (Exception) e.getCause();
throw e.getCause();
}
}

Expand All @@ -98,9 +98,9 @@ public CtMethod<?> getCtElement() {
}
element = (CtMethod<?>) parentElement.getDirectChildren().stream()
.filter(e ->
e instanceof CtMethod<?> m &&
reflection().getName().equals(m.getSimpleName()) &&
reflection().getReturnType().getSimpleName().equals(m.getType().getSimpleName())
e instanceof CtMethod<?> m
&& reflection().getName().equals(m.getSimpleName())
&& reflection().getReturnType().getSimpleName().equals(m.getType().getSimpleName())
).findFirst().orElse(null);
return element;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ public interface MethodLink extends WithModifiers, WithName, WithType, WithTypeL
* @param arguments the arguments
* @param <T> the type of the return value
* @return the return value
* @throws Throwable if the method throws an exception
*/
<T> T invoke(Object instance, Object... arguments) throws Exception;
<T> T invoke(Object instance, Object... arguments) throws Throwable;

/**
* <p>Invokes the method linked by this method link with the given arguments.</p>
*
* @param arguments the arguments
* @param <T> the type of the return value
* @return the return value
* @throws Throwable if the method throws an exception
*/
<T> T invokeStatic(Object... arguments) throws Exception;
<T> T invokeStatic(Object... arguments) throws Throwable;


@Override
Expand Down

0 comments on commit 133a90f

Please sign in to comment.