ARM: preserve supressed exceptions due to throw in finally block
Osvaldo Doederlein
opinali at gmail.com
Thu Apr 8 11:45:36 PDT 2010
There is already some "previous art" in making try/finally blocks larger --
the suppression of JSR bytecode (mandatory in JavaSE6).
But for the issue of suppressed exceptions, I guess the JVM could just
handle this dynamically, perhaps when started in debug mode or with -ea or
some new options like -verbose:exceptions. (And I could add more scenarios
to be detected/logged by such options; e.g. empty catch blocks that swallow
exceptions without any action.) Java is a dynamic platform, let's use this
to our advantage. I see no reason to make everybody's code more bloated, all
the time, just to support some feature that's clearly only useful for
development or monitoring/troubleshooting. Just add a JMX hook that allows
me to enable/disable "verbose exceptions" from VisualVM or other monitoring
app.
A+
Osvaldo
2010/4/8 Neal Gafter <neal at gafter.com>
> Carlos-
>
> This has the same problem as the proposal for handling suppressed
> exceptions
> in ARM: we have no experience to suggest that this way of preserving
> suppressed exceptions is usable in realistic programs. This
> software-engineering aspect of ARM language design seems to have been
> largely ignored. I think more study of such software engineering aspects
> would be well advised before ARM or any extensions to it are moved into the
> jdk.
>
> Cheers,
> Neal
>
> On Thu, Apr 8, 2010 at 2:55 AM, Carlos Costa e Silva <carlos at keysoft.pt
> >wrote:
>
> > Hi everyone,
> >
> > Small suggestion for an improvement in the ARM proposal.
> >
> > In a try/finally block:
> >
> > try {
> > // try code
> > }
> > finally {
> > // finally code
> > }
> >
> >
> > If an exception is thrown in the finally block, any exception thrown in
> > the try block is lost.
> >
> >
> > As the ARM proposal adds suppressed exceptions, how about adding the
> > "try" exception to the suppressed exceptions of the "finally" exception?
> >
> >
> > Compiler generated pseudo code:
> >
> > try {
> > // try code
> > }
> > finally {
> >
> > Throwable tryException = (exception thrown in try block, if any);
> > try {
> > // finally code
> > }
> > catch (Throwable t) {
> > if (tryException != null) {
> > t.addSupressedException(tryException);
> > }
> > throw t;
> > }
> > }
> >
> >
> > IMHO, this is a small change and would help catch some non obvious
> > mistakes.
> >
> > Carlos
> >
> >
> >
>
>
More information about the coin-dev
mailing list