Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: FEST-Reflect 1.2
-
Fix Version/s: FEST-Reflect 1.2
-
Component/s: Reflect
-
Labels:None
-
Number of attachments :
Description
From Francis.ANDRE.2007:
What steps will reproduce the problem?
package fest; import org.fest.reflect.core.Reflection; class MyRuntimeException extends RuntimeException { private static final long serialVersionUID = 1L; public MyRuntimeException(String text) { super(text); } } public class Main { public void set() { throw new MyRuntimeException("set"); } public static void main(String[] args) { Main main = new Main(); try { Reflection.method("set").in(main).invoke(); } catch(RuntimeException e) { System.out.println(e.getMessage()); } } }
What is the expected output?
set
What do you see instead?
Exception in thread "main" org.fest.reflect.exception.ReflectionError: Unable to invoke method 'set' with arguments [] at org.fest.reflect.method.Invoker.invoke(Invoker.java:101) at fest.Main.main(Main.java:20) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.fest.reflect.method.Invoker.invoke(Invoker.java:99) ... 1 more Caused by: fest.MyRuntimeException: set at fest.Main.set(Main.java:14) ... 6 more
What version of the product are you using? On what operating system?
fest-reflect-1.1.jar
Please provide any additional information below.
When replacing throw MyRuntimeException by throw RuntimeException, one get the error message
Unable to invoke method 'set' with arguments []
while it should be also
set
Original report: Issue 310 (Google Code)
Method invocation and constructor invocation now throw the original exception thrown by this invocations, instead of wrapping them with a ReflectionError.