--- old/src/java.base/share/classes/java/lang/invoke/ValueBootstrapMethods.java 2019-05-15 13:57:40.695720447 -0400 +++ new/src/java.base/share/classes/java/lang/invoke/ValueBootstrapMethods.java 2019-05-15 13:57:40.331718642 -0400 @@ -107,7 +107,7 @@ } static MethodHandle[] getters(Lookup lookup, Comparator comparator) { - Class type = lookup.lookupClass().asValueType(); + Class type = lookup.lookupClass().asPrimaryType(); // filter static fields and synthetic fields Stream s = Arrays.stream(type.getDeclaredFields()) .filter(f -> !Modifier.isStatic(f.getModifiers()) && !f.isSynthetic()) @@ -173,8 +173,8 @@ * of the given value class are substitutable. */ static MethodHandle valueEquals(Class c) { - assert c.isValue(); - Class type = c.asValueType(); + assert c.isInlineClass(); + Class type = c.asPrimaryType(); MethodType mt = methodType(boolean.class, type, type); MethodHandles.Lookup lookup = new MethodHandles.Lookup(type); MethodHandle[] getters = getters(lookup, TYPE_SORTER); @@ -217,7 +217,7 @@ private static boolean isSameValueClass(Object a, Object b) { if (a == null || b == null) return false; - return a.getClass().isValue() && a.getClass().asBoxType() == b.getClass().asBoxType(); + return a.getClass().isInlineClass() && a.getClass().asNullableType() == b.getClass().asNullableType(); } private static boolean valueEq(Object a, Object b) { @@ -348,7 +348,7 @@ * Produces a method handle that computes the hashcode */ private static MethodHandle hashCodeInvoker(Lookup lookup, String name, MethodType mt) { - Class type = lookup.lookupClass().asValueType(); + Class type = lookup.lookupClass().asPrimaryType(); MethodHandle target = dropArguments(constant(int.class, SALT), 0, type); MethodHandle cls = dropArguments(constant(Class.class, type),0, type); MethodHandle classHashCode = filterReturnValue(cls, hashCodeForType(Class.class)); @@ -376,8 +376,11 @@ * Produces a method handle that invokes the toString method of a value object. */ private static MethodHandle toStringInvoker(Lookup lookup, String name, MethodType mt) { - Class type = lookup.lookupClass().asValueType(); + Class type = lookup.lookupClass().asPrimaryType(); MethodHandle[] getters = MethodHandleBuilder.getters(lookup); + if (VERBOSE) { + System.out.println("getter: " + Arrays.toString(getters)); + } int length = getters.length; StringBuilder format = new StringBuilder(); Class[] parameterTypes = new Class[length]; @@ -387,6 +390,9 @@ for (int i = 0; i < length; i++) { MethodHandle getter = getters[i]; MethodHandleInfo fieldInfo = lookup.revealDirect(getter); + if (VERBOSE) { + System.out.println("getter: " + getter + " field info: " + fieldInfo); + } Class ftype = fieldInfo.getMethodType().returnType(); format.append(separator) .append(fieldInfo.getName()) @@ -412,7 +418,7 @@ * Produces a method handle that tests if two arguments are equals. */ private static MethodHandle equalsInvoker(Lookup lookup, String name, MethodType mt) { - Class type = lookup.lookupClass().asValueType(); + Class type = lookup.lookupClass().asPrimaryType(); // MethodHandle to compare all fields of two value objects MethodHandle[] getters = MethodHandleBuilder.getters(lookup, TYPE_SORTER); MethodHandle accumulator = dropArguments(TRUE, 0, type, type); @@ -520,7 +526,7 @@ if (a.getClass() != b.getClass()) return false; try { - Class type = a.getClass().isValue() ? a.getClass().asValueType() : a.getClass(); + Class type = a.getClass().isInlineClass() ? a.getClass().asPrimaryType() : a.getClass(); return (boolean) substitutableInvoker(type).invoke(a, b); } catch (Error|RuntimeException e) { throw e; @@ -566,7 +572,7 @@ if (type.isInterface() || type == Object.class) return MethodHandleBuilder.interfaceEquals(type); - if (type.isValue()) + if (type.isInlineClass()) return SUBST_TEST_METHOD_HANDLES.get(type); return MethodHandleBuilder.referenceEquals(type);