-
Bug
-
Resolution: Fixed
-
P4
-
8
Resolution of inference variables, 18.4, gives special treatment to variables appearing in 'throws' clauses that don't have "extra" bounds. Specifically:
"Otherwise, if the bound set contains throws αi, and the proper upper bounds of αi are, at most, Exception, Throwable, and Object, then Ti = RuntimeException."
The idea here is that RuntimeException satisfies any of these upper bounds, and is also less intrusive, since it isn't a checked exception type.
The type Serializable is also a supertype of RuntimeException, and there's no particular reason such a bound couldn't also be ignored. Proposed new rule:
"Otherwise, if the bound set contains throws αi, and ***each*** proper upper ***bound*** of αi ***is a supertype of RuntimeException***, then Ti = RuntimeException."
This rule is also more future-proof -- if, say, a new interface is added as a supertype of Throwable; and it supports intersection types and type variables as upper bounds, should that situation arise.
"Otherwise, if the bound set contains throws αi, and the proper upper bounds of αi are, at most, Exception, Throwable, and Object, then Ti = RuntimeException."
The idea here is that RuntimeException satisfies any of these upper bounds, and is also less intrusive, since it isn't a checked exception type.
The type Serializable is also a supertype of RuntimeException, and there's no particular reason such a bound couldn't also be ignored. Proposed new rule:
"Otherwise, if the bound set contains throws αi, and ***each*** proper upper ***bound*** of αi ***is a supertype of RuntimeException***, then Ti = RuntimeException."
This rule is also more future-proof -- if, say, a new interface is added as a supertype of Throwable; and it supports intersection types and type variables as upper bounds, should that situation arise.
- relates to
-
JDK-8164399 inference of thrown variable does not work correctly
-
- Closed
-
-
JDK-8157149 Inference: weird propagation of thrown inference variables
-
- Closed
-