--- old/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Type.java 2019-05-15 13:57:56.463798637 -0400 +++ new/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Type.java 2019-05-15 13:57:56.087796772 -0400 @@ -59,6 +59,7 @@ package jdk.internal.org.objectweb.asm; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** @@ -667,13 +668,11 @@ stringBuilder.append(descriptor); } else { String name = currentClass.getName(); - // Workarounds nasgen build that depends on ASM but compiled with - // the bootstrap JDK. Can't use Class::isValue and Class::asValueType - int index = currentClass.getTypeName().lastIndexOf("/val"); - if (index > 0) { - stringBuilder.append('Q'); - } else { + if (Helper.isNullableType(currentClass)) { stringBuilder.append('L'); + } else { + stringBuilder.append('Q'); + } int nameLength = name.length(); for (int i = 0; i < nameLength; ++i) { @@ -684,6 +683,34 @@ } } + // Workarounds nasgen build that depends on ASM but compiled with + // the bootstrap JDK. Can't reference Class::isNullableType + static class Helper { + static final Method isNullableTypeMethod = isNullableTypeMethod(); + static Method isNullableTypeMethod() { + try { + return Class.class.getMethod("isNullableType"); + } catch (NoSuchMethodException e) { + return null; + } + } + + static boolean isNullableType(Class clazz) { + int mods = clazz.getModifiers(); + if ((mods & 0x00000100) != 0) { // inline class + assert isNullableTypeMethod != null; + try { + return (boolean)isNullableTypeMethod.invoke(clazz); + } catch (InvocationTargetException e) { + throw new InternalError(e.getCause()); + } catch (IllegalAccessException e) { + throw new InternalError(e); + } + } + return true; + } + } + // ----------------------------------------------------------------------------------------------- // Methods to get the sort, dimension, size, and opcodes corresponding to a Type or descriptor. // -----------------------------------------------------------------------------------------------