couple questions on method handle combinators

Paul Sandoz paul.sandoz at
Sat Jun 10 00:18:22 UTC 2017

Hi Roland,

I think the general problem here is two distinct value worlds are colliding, the shadowy MVT value world, and the "avoiding the syntax bike shed painting" __ByValue value world.

AFAICT the MVT API assumes that if the ACC_VALUE modifier is set on a class (Q type) then it should have a particular naming convention related to the value capable class from which the value type class was derived (the latter being named <C>$Value, where <C> is the name of the value capable class. This is why 6 characters are chopped of the end of the name of the class MyValue5.

(There is some “magic” in the VM that detects, when class file parsing, if a class is a value capable class and if so derives the value type class via an up call to Java, see valhalla.shady.MinimalValueTypes_1_0.createDerivedValueType)

That assumption is encoded in areas of the method handle implementation, such as here:

private static MethodHandle makeIdentity(Class<?> ptype) {
    if (!MinimalValueTypes_1_0.isValueType(ptype)) {
        MethodType mtype = MethodType.methodType(ptype, ptype);
        LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
        return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.IDENTITY);
    } else {
        try {
            return ValueType.forClass(MinimalValueTypes_1_0.getValueCapableClass(ptype)).identity();
        } catch (ReflectiveOperationException ex) {
            throw new IllegalStateException(ex);

I am unsure how to unify these two worlds. For now it might be easiest if you keep tests for the two worlds separate i.e. when working with MethodHandles work in the MVT world.


> On 9 Jun 2017, at 09:03, Roland Westrelin <rwestrel at> wrote:
> test78() attempts to build a loop whose result is a value type but
> creation of the loop combinator fails with:
> java.lang.ExceptionInInitializerError
>        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
>        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
>        at java.base/java.lang.reflect.Method.invoke(
>        at com.sun.javatest.regtest.agent.MainWrapper$
>        at java.base/
> Caused by: java.lang.IllegalStateException: java.lang.ClassNotFoundException: compiler.valhalla.valuetypes.My
>        at java.base/java.lang.invoke.MethodHandles.makeIdentity(
>        at java.base/java.lang.invoke.MethodHandles.identity(
>        at java.base/java.lang.invoke.MethodHandles.countedLoop(
>        at java.base/java.lang.invoke.MethodHandles.countedLoop(
>        at compiler.valhalla.valuetypes.ValueTypeTestBench.<clinit>(
>        ... 6 more
> Caused by: java.lang.ClassNotFoundException: compiler.valhalla.valuetypes.My
>        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(
>        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
>        at java.base/java.lang.ClassLoader.loadClass(
>        at java.base/java.lang.Class.forName0(Native Method)
>        at java.base/java.lang.Class.forName(
>        at java.base/valhalla.shady.MinimalValueTypes_1_0.getValueCapableClass(
>        at java.base/java.lang.invoke.MethodHandles.makeIdentity(
>        ... 10 more
> Anyone has any idea how to build the loop combinator?
> Roland.

More information about the valhalla-dev mailing list