On 07/11/2014 08:16 PM, Paul Sandoz wrote:
On Jul 11, 2014, at 7:56 PM, Remi Forax <fo...@univ-mlv.fr> wrote:
On 07/11/2014 06:18 PM, Vladimir Ivanov wrote:
http://cr.openjdk.java.net/~vlivanov/8050052/webrev.00
https://bugs.openjdk.java.net/browse/JDK-8050052
I've found myself writing the very same code as
MethodHandleStatics.uncaughException several times
and I wonder if it should not be an instance method of Throwable.
Something like:
public <E extends Throwable> E rethrow(Function<? super Throwable, ? extends E>
uncaughtHandler) {
if (this instanceof RuntimeException) {
throw (RuntimeException)this;
}
if (this instanceof Error) {
throw (Error)this;
}
return uncaughtHandler.apply(this);
}
in that case, throw uncaughtException(ex) can be replaced by throw
ex.rethrow(::newInternalError);
I suspect there could be a risk of some bootstrap/initialization issues using a
method ref in such code.
Paul.
yes, right, using invokedynamic in java.lang.invoke is not a good idea.
Rémi