RFR: 8284871: Use covariant overrides for the resolveConstantDesc(Lookup) method in sub‑interfaces of java.lang.constant.ConstantDesc

Chen Liang liach at openjdk.org
Fri Mar 31 15:25:20 UTC 2023


On Fri, 31 Mar 2023 15:14:42 GMT, ExE Boss <duke at openjdk.org> wrote:

>> Also remove redundant casts to avoid javac warnings.
>
> src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java line 197:
> 
>> 195:      * @apiNote {@linkplain MethodTypeDesc} can represent method type descriptors
>> 196:      * that are not representable by {@linkplain MethodType}, such as methods with
>> 197:      * more than 255 parameter slots, so attempts to resolve these may result in errors.
> 
> Should this also be added to `MethodHandleDesc::resolveConstantDesc(Lookup)`?

Nah. Since such a MethodTypeDesc is never valid, such a MethodHandleDesc or DynamicConstantDesc should always fail to resolve for such a method handle can never be found. The only problem we need to be concerned about is that the failure in those Descs should be ReflectiveOperationException instead of some sort of UncheckedException (which I think MethodTypeDesc.resolveConstantDesc currently throws), but that belongs to another issue, given currently, MethodTypeDesc even throws unchecked exceptions when it tries to resolve an nonexistent class.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/12986#discussion_r1154609525


More information about the core-libs-dev mailing list