I doubt such a thing is possible, but without attaching a debugger to a java application, is it possible to have some collection populated with information about every exception that is generated in a java application, regardless of if it is caught or not? I know that in .NET, messages get generated by the application about exceptions which at that point are called "First Chance Exceptions", which may or may not subsequently be handled by the application. I'm wondering if there might be a similar mechanism in java I can exploit to view information about all the exceptions generated at runtime.
Just to clarify. This has nothing to do with the context in which an exception occurs. This question is not about what I do in a catch block, or unhandled exceptions. Its about knowing if the JVM provides a mechanism to see every exception generated at runtime, regardless of what generated it, or the context.
-agentlib
is the way to go. If you need this at all time and also in production then maybe editing every catch clause would be better (This could be done fairly easy with search and replace) – Exuberance-agentlib
has nothing to do with debug connection. Java debugger is just an example of a particular agent, but not all agents are debuggers. Using an agent library is a standard way to do such things. It is much more reliable and safer than patching Java system classes. – Prolong