Code review request for 8012044: Give more information about self-suppression from Throwable.addSuppressed
Jason Mehrens
jason_mehrens at hotmail.com
Fri Apr 12 18:22:19 UTC 2013
The landmines are the retrofitted exception classes as shown here https://netbeans.org/bugzilla/show_bug.cgi?id=150969 and https://issues.jboss.org/browse/JBREM-552. Really, if the ISE or IAE is thrown it is going to suppress 'this' and 'cause'. It would be nice to see the given 'cause' show up in a log file when tracking down this type of bug. Date: Fri, 12 Apr 2013 10:35:40 -0700
From: joe.darcy at oracle.com
To: jason_mehrens at hotmail.com
CC: core-libs-dev at openjdk.java.net
Subject: Re: Code review request for 8012044: Give more information about self-suppression from Throwable.addSuppressed
Hi Jason,
Hmm. This is the current initCause implementation from JDK 8:
public synchronized Throwable initCause(Throwable cause) {
if (this.cause != this)
throw new IllegalStateException("Can't overwrite
cause");
if (cause == this)
throw new IllegalArgumentException("Self-causation not
permitted");
this.cause = cause;
return this;
}
It wouldn't be unreasonable to change the second throw to
if (cause == this)
throw new IllegalArgumentException("Self-causation not
permitted", cause);
but I think there is less motivation to do so than in the
addSuppressed case since addSuppressed gets called in
compiler-generated code that isn't visible in the original
sources.
-Joe
More information about the core-libs-dev
mailing list