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 <jlas...@openjdk.java.net> wrote: > > On Tue, 8 Mar 2022 16:00:48 GMT, Maurizio Cimadamore > <mcimadam...@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