--- old/src/java.base/share/classes/jdk/internal/reflect/MethodAccessorGenerator.java 2018-09-07 12:05:52.707195533 -0400 +++ new/src/java.base/share/classes/jdk/internal/reflect/MethodAccessorGenerator.java 2018-09-07 12:05:51.899130237 -0400 @@ -159,6 +159,12 @@ // [CONSTANT_Class_info] for above // [UTF-8] [Target class's name] // [CONSTANT_Class_info] for above + // ^ [UTF-8] [Serialization: Class's name in which to invoke constructor] + // ^ [CONSTANT_Class_info] for above + // [UTF-8] target method or constructor name + // [UTF-8] target method or constructor signature + // [CONSTANT_NameAndType_info] for above + // [CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info] for target method // [UTF-8] descriptor for type of non-primitive parameter 1 // [CONSTANT_Class_info] for type of non-primitive parameter 1 // ... @@ -167,12 +173,6 @@ // [UTF-8] descriptor for declared value types if not present in CP // [CONSTANT_Class_info] for declared value types if not present in CP // ... - // ^ [UTF-8] [Serialization: Class's name in which to invoke constructor] - // ^ [CONSTANT_Class_info] for above - // [UTF-8] target method or constructor name - // [UTF-8] target method or constructor signature - // [CONSTANT_NameAndType_info] for above - // [CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info] for target method // [UTF-8] "invoke" or "newInstance" // [UTF-8] invoke or newInstance descriptor // + [UTF-8] "java/lang/Exception" @@ -312,11 +312,7 @@ } asm.emitConstantPoolClass(asm.cpi()); superClass = asm.cpi(); - - // emit constant pool entries for declaring class, parameter types and return type - cpClassPool.emitConstantPoolEntries(); targetClass = cpClassPool.cpIndex(declaringClass); - short serializationTargetClassIdx = (short) 0; if (forSerialization) { asm.emitConstantPoolUTF8(getClassName(serializationTargetClass, false)); @@ -336,6 +332,10 @@ } } targetMethodRef = asm.cpi(); + + // emit constant pool entries for parameter types and return type + cpClassPool.emitConstantPoolEntries(); + if (isConstructor) { asm.emitConstantPoolUTF8("newInstance"); } else { @@ -841,7 +841,7 @@ void emitConstantPoolEntries() { for (Class c : types) { - cpEntries.put(c, emitConstantPoolEntries(c)); + cpEntries.computeIfAbsent(c, this::emitConstantPoolEntries); } } @@ -856,7 +856,7 @@ } short cpIndex(Class c) { - return cpEntries.get(c); + return cpEntries.computeIfAbsent(c, this::emitConstantPoolEntries); } short[] declaredValueTypes() {