3

Sorry for this very basic question, but I am stuck with this and m not able to find a solution.

I have a Core Java application (Java version is 1.6). From my application I am calling a method in a jar, which is throwing a custom runtime exception.

I am not catching this exception, but still JVM is not printing the stack trace.

Does JVM by default will not print the stack trace, when a runtime exception is thrown and not caught? Or am I missing something which I can check?

Thanks in advance.

-Sandeep

6
  • Check the method inside the jar. You can use a java decompiler if you don't have source code inside the jar. Commented Sep 29, 2015 at 8:04
  • I have access to the code of jar, and even it does not catch any exceptions. It is only throwing runtime exception when certain condition is met. Commented Sep 29, 2015 at 8:08
  • Please show us the code. Commented Sep 29, 2015 at 8:12
  • 1
    It's possible to subclass Exception(String message,..., boolean writableStackTrace), i.e., whether or not the stack trace should be writable. Commented Sep 29, 2015 at 8:13
  • 1
    And I've just checked: catching and calling printStackTrace doesn't work, and getStackTrace gives you nothing. - If you have the code, you can see how the custom exception is defined, whether my assumption is correct. class Custom extends Exception { public Custom( String msg ){ super( msg, null, false, **false** ); } } -- The last false is the one. Commented Sep 29, 2015 at 8:21

1 Answer 1

0

AFAIK, JRE should print a stacktrace of an uncaught exception. But you can always do it yourself:

try {
  someObject.someMethod();
} catch (Throwable t) {
  t.printStackTrace();
  throw t;
}
Sign up to request clarification or add additional context in comments.

1 Comment

You mean writableStackTrace set to false, as in a comment to the question? In that case, it's true.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.