RFR: JDK-8282798 java.lang.runtime.Carrier
Brian Goetz
brian.goetz at oracle.com
Tue Mar 8 20:25:44 UTC 2022
MethodType is a useful shape for describing a pattern, in reverse; the “parameter” types are really the pattern bindings, and the “return” type is really the (minimal) type of the target. With such a description, the MethodType for a pattern is the right input to get the carrier for the pattern.
> On Mar 8, 2022, at 3:10 PM, Jim Laskey <jlaskey at openjdk.java.net> wrote:
>
> On Tue, 8 Mar 2022 16:00:48 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>
>>> We propose to provide a runtime anonymous carrier class object generator; java.lang.runtime.Carrier. This generator class is designed to share anonymous classes when shapes are similar. For example, if several clients require objects containing two integer fields, then Carrier will ensure that each client generates carrier objects using the same underlying anonymous class.
>>>
>>> See JBS for details.
>>
>> src/java.base/share/classes/java/lang/runtime/Carrier.java line 852:
>>
>>> 850: * @throws IllegalArgumentException if number of component slots exceeds maximum
>>> 851: */
>>> 852: public static MethodHandle constructor(MethodType methodType) {
>>
>> What happens to the methodType return type? (both here and in the components method). Should javadoc say anything?
>
> The return type is ignored. Going back to John's notion of just passing in the parameterTypes would work okay. I think when Brian wrote the original code he may have been thinking about keying on the MethodType (interned). I'll add a note about the return type.
>
> -------------
>
> PR: https://git.openjdk.java.net/jdk/pull/7744
More information about the core-libs-dev
mailing list