Proposal: Automatic Resource Management
neal at gafter.com
Sat Mar 7 11:12:38 PST 2009
On Sat, Mar 7, 2009 at 10:31 AM, Joshua Bloch <jjb at google.com> wrote:
>> I don't see how that solves the problem. Are you suggesting that
>> everywhere someone handles an exception they should also check for a
>> chain of ignored exceptions and log them?
> I am not suggesting this. Most people have no need to look at these
Given that they may represent programming errors, I don't see how you
can conclude that.
> Those who do can read them by calling
> the getSuppressedExceptions()method.
While one may be interested in a small number of these dynamically
occurring exceptions, there is no reasonable way to know ahead of time
where, statically in the program, they might occur. Therefore taking
your advice would require doing this everywhere an exception is
caught, which seems cumbersome in the extreme. The right solution is
to allow programmers to register handlers for them, to filter and/or
log them centrally.
> If people think it's worth it, the
> stack trace printing code could be modified to include suppressed
> exceptions. In many cases, that would cause suppressed exceptions to be
> logged automatically. But I have some misgivings about this approach: I
> suspect there are programs that parse stack traces. While I frown on this
> behavior, and the spec does not guarantee that it works, I'd hate to be
> responsible for breaking these programs.
I agree this is a poor 'solution' to the problem.
More information about the coin-dev