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

Mandy Chung mchung at openjdk.org
Fri Mar 31 18:39:24 UTC 2023


On Fri, 31 Mar 2023 15:22:05 GMT, Chen Liang <liach at openjdk.org> wrote:

>> 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.

agree, this `@apiNote` is specific for `MethodTypeDesc` only.

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

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


More information about the core-libs-dev mailing list