ExceptionTable addition?
Dave Brosius
dbrosius at baybroadband.net
Sat Dec 12 05:10:28 UTC 2015
Greetings,
From a byte code analysis--toolsy point of view, it would be nice
if you could deterministically find the end of a catch/finally block.
Unfortunately, the ExceptionTable attribute only lists the starts of
trys/catches/finallys.
Now obviously, there are times when you can determine the end of the
catch/finally block:
If for instance a try block exits normally, javac, will insert a GOTO,
from which you can clean the 'continuation' PC.
You can also determine the end of a catch block if it is followed by
another catch or finally block.
However, there are pretty regular cases where you cannot, for instance
if a try block ends with a return or a throw, and there is only one
catch block or finally block, or those catch blocks that exist (before
the last one) also return or throw.
String someMethod() {
try {
return getSomething();
} catch (IOException e) {
LOGGER.log("Oops");
}
return doSomeMoreStuff();
}
In this scenario, there's no way to know if the 'doSomeMoreStuff() is in
the catch block or not.
Now from a program execution point of view, it doesn't really matter.
You can consider everything below the catch, (or finally) block to be
part of that catch (or finally) block.
But there are cases, where for code analysis, you would really like to know.
---
It would be really nice if the ExceptionTable also listed a
'continuation pc'.
More information about the core-libs-dev
mailing list