You cannot do this statically because there is no such difference.
Any exception defined in the standard Java class libraries may be caused by software or third-party library code. In some cases, it is a bad (or even terrible) idea to throw a standard exception, but in others it is recommended to do so.
The only possible way to distinguish between the exception thrown by the JVM and the application code is to examine the stack frames from the generated exception to find out which class threw the exception. (Strictly speaking, this does not tell you where the exception was thrown ... but it is close enough, given that the exceptions are almost always thrown and thrown in the same expression.)
But even this is not particularly useful. I mean, what is the semantic difference between the exception generated by the application code and the class library? Of course, he does not say anything about the root cause of the problem.
Stephen c
source share