RFR: [MVT] MethodHandlesTest fails with assertions enabled

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Mon Jul 24 16:28:55 UTC 2017


Thanks for taking care of it, Maurizio!

========================================
+    static final class Carrier_Q {
+        @Stable
+        final Object boxedValue;
+        @Stable
+        final MethodHandle unboxHandle;

@Stable isn't needed. Final fields in java.lang.invoke are trusted by 
JIT-compilers.

========================================
+        static final MethodHandle BOX_VALUE_GETTER;
+        static final MethodHandle UNBOX_HANDLE_GETTER;

+                NamedFunction unboxGetter = new 
NamedFunction(Carrier_Q.UNBOX_HANDLE_GETTER);

+                NamedFunction boxedValue = new 
NamedFunction(Carrier_Q.BOX_VALUE_GETTER);

Maybe cache NamedFunctions right away?

========================================
-        return mh.copyWithExtendL(type2, form2, value)
-                 .copyWithExtendL(type2, form2, unbox);
+        try {
+            return mh.copyWithExtendL(type2, form2, new 
Carrier_Q(value, unbox));
+        } catch (Throwable ex) {
+            throw new IllegalStateException(ex);
+        }

Why do you need a try-catch block here?

Otherwise, looks good.

Best regards,
Vladimir Ivanov

On 7/24/17 7:14 PM, Maurizio Cimadamore wrote:
> Hi,
> this is a fix for a problem when running MethodHandlesTest with 
> assertions enabled (-esa). Currently, bound method handles with value 
> types are handled by encoding a bound value as a boxed value + unbox MH 
> pair - but doing so breaks some arity invariants for BMHs. This makes 
> the pair encoding explicit, by adding a small carrier class for the 
> box/MH pair, which is then used to encode the bound value.
> 
> http://cr.openjdk.java.net/~mcimadamore/8185142-jdk/
> 
> Maurizio
> 


More information about the valhalla-dev mailing list