You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 17, 2026. It is now read-only.
Try to run the following class e.g. on final2.subtests.ValidCommandLineArgumentsTest#orderArgumentTest:
packagereflectiontest;
importjava.lang.reflect.InvocationTargetException;
publicclassTest {
publicstaticvoidmain(String[] args) {
newTest();
}
publicTest() {
try {
getClass().getMethod("test").invoke(this);
} catch (IllegalAccessExceptione) {
e.printStackTrace();
} catch (IllegalArgumentExceptione) {
e.printStackTrace();
} catch (InvocationTargetExceptione) {
e.printStackTrace();
} catch (NoSuchMethodExceptione) {
e.printStackTrace();
} catch (SecurityExceptione) {
e.printStackTrace();
}
// if using the following instead of invoke, everything works fine:// test();
}
publicvoidtest() {
System.exit(0);
}
}
leads to the following exception (stacktrace printed on System.out):
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at reflectiontest.Test.<init>(Test.java:13)
at reflectiontest.Test.main(Test.java:8)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at test.TestObject.run(TestObject.java:651)
at test.TestObject.runStaticVoid(TestObject.java:468)
at test.TestObject.runStaticVoid(TestObject.java:481)
at test.InteractiveConsoleTest.noOutputTest(InteractiveConsoleTest.java:450)
at test.InteractiveConsoleTest.noOutputTest(InteractiveConsoleTest.java:433)
at final2.subtests.ValidCommandLineArgumentsTest.orderArgumentTest(ValidCommandLineArgumentsTest.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)
Caused by: test.framework.ExitException: The method called System.exit(0)
at test.framework.NoExitSecurityManager.checkExit(NoExitSecurityManager.java:33)
at java.lang.Runtime.exit(Runtime.java:107)
at java.lang.System.exit(System.java:962)
at reflectiontest.Test.test(Test.java:30)
... 26 more
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at reflectiontest.Test.<init>(Test.java:13)
at reflectiontest.Test.main(Test.java:8)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at test.TestObject.run(TestObject.java:651)
at test.TestObject.runStaticVoid(TestObject.java:468)
at test.TestObject.runStaticVoid(TestObject.java:481)
at test.InteractiveConsoleTest.noOutputTest(InteractiveConsoleTest.java:450)
at test.InteractiveConsoleTest.noOutputTest(InteractiveConsoleTest.java:433)
at final2.subtests.ValidCommandLineArgumentsTest.orderArgumentTest(ValidCommandLineArgumentsTest.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)
Caused by: test.framework.ExitException: The method called System.exit(0)
at test.framework.NoExitSecurityManager.checkExit(NoExitSecurityManager.java:33)
at java.lang.Runtime.exit(Runtime.java:107)
at java.lang.System.exit(System.java:962)
at reflectiontest.Test.test(Test.java:30)
... 26 more
even though ValidCommandLineArgumentsTest calls setAllowedSystemExitStatus(SystemExitStatus.WITH_0) in its constructor.
When calling System.exit(0) directly without Method#invoke, the test succeeds without exceptions (as expected).
Try to run the following class e.g. on final2.subtests.ValidCommandLineArgumentsTest#orderArgumentTest:
leads to the following exception (stacktrace printed on System.out):
even though ValidCommandLineArgumentsTest calls
setAllowedSystemExitStatus(SystemExitStatus.WITH_0)in its constructor.When calling System.exit(0) directly without Method#invoke, the test succeeds without exceptions (as expected).