An explicit call to the throw statement is represented at the bytecode level with an athrow instruction.
For instance, the code snippet below:
private static SQLException thrower() throws SQLException
{
throw new SQLException();
}
Is translated into the following bytecode:
private static java.sql.SQLException thrower() throws java.sql.SQLException;
Signature: ()Ljava/sql/SQLException;
Code:
0: new #29; //class java/sql/SQLException
3: dup
4: invokespecial #31; //Method java/sql/SQLException."<init>":()V
7: athrow
My question is: how do I know, by only analyzing the bytecode, the type of the exception being thrown?
Obs.: It is worth mentioning that it is not always the case that we instantiate a new exception type when we call the throw statement in the source code. Thus, looking the type of the argument of the new instruction is not a solution.