-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0, 6
-
generic
-
generic, solaris_8
Currently, the language provides no way to throw a checked excption without
either catching it or declaring it to be thrown in the current method.
(Notwithstanding a deprecated methon in Thread) The generics prototype
introduces a way to throw a checked exception with only a warning, which
is suppressed by default.
I believe this is a serious regression in the language. We should not
introduce such loopholes in type checking.
class Main {
static void hiddenThrow(Throwable t) {
class ExceptionHider<E extends Throwable> {
void hiddenThrow(Throwable e) throws E {
throw (E) e;
}
}
new ExceptionHider<RuntimeException>().hiddenThrow(t);
}
public static void main(String[] args) // no exception in method declaration
{
hiddenThrow(new java.io.IOException()); // throws IOException, hidden
}
}
either catching it or declaring it to be thrown in the current method.
(Notwithstanding a deprecated methon in Thread) The generics prototype
introduces a way to throw a checked exception with only a warning, which
is suppressed by default.
I believe this is a serious regression in the language. We should not
introduce such loopholes in type checking.
class Main {
static void hiddenThrow(Throwable t) {
class ExceptionHider<E extends Throwable> {
void hiddenThrow(Throwable e) throws E {
throw (E) e;
}
}
new ExceptionHider<RuntimeException>().hiddenThrow(t);
}
public static void main(String[] args) // no exception in method declaration
{
hiddenThrow(new java.io.IOException()); // throws IOException, hidden
}
}
- duplicates
-
JDK-6490045 Checked exceptions can be thrown without declaring them
-
- Closed
-
-
JDK-8061418 Add reification of generic type parameters to the Java programming language
-
- Closed
-