8374643: Fix reference to implMethodKind in LambdaToMethod debug printf statement

Reviewed-by: vromero, liach
This commit is contained in:
Liam Miller-Cushon 2026-01-22 10:05:05 +00:00
parent ddbd4617a6
commit e8eb218ca2
5 changed files with 63 additions and 12 deletions

View File

@ -142,6 +142,9 @@ public class LambdaToMethod extends TreeTranslator {
/** dump statistics about lambda code generation */
private final boolean dumpLambdaToMethodStats;
/** dump statistics about lambda deserialization code generation */
private final boolean dumpLambdaDeserializationStats;
/** force serializable representation, for stress testing **/
private final boolean forceSerializable;
@ -187,6 +190,7 @@ public class LambdaToMethod extends TreeTranslator {
transTypes = TransTypes.instance(context);
Options options = Options.instance(context);
dumpLambdaToMethodStats = options.isSet("debug.dumpLambdaToMethodStats");
dumpLambdaDeserializationStats = options.isSet("debug.dumpLambdaDeserializationStats");
attr = Attr.instance(context);
forceSerializable = options.isSet("forceSerializable");
boolean lineDebugInfo =
@ -714,8 +718,9 @@ public class LambdaToMethod extends TreeTranslator {
String implMethodName = refSym.getQualifiedName().toString();
String implMethodSignature = typeSig(types.erasure(refSym.type));
int implMethodKind = refSym.referenceKind();
JCExpression kindTest = eqTest(syms.intType, deserGetter("getImplMethodKind", syms.intType),
make.Literal(refSym.referenceKind()));
make.Literal(implMethodKind));
ListBuffer<JCExpression> serArgs = new ListBuffer<>();
int i = 0;
for (Type t : indyType.getParameterTypes()) {
@ -743,16 +748,16 @@ public class LambdaToMethod extends TreeTranslator {
stmts = new ListBuffer<>();
kInfo.deserializeCases.put(implMethodName, stmts);
}
/* **
System.err.printf("+++++++++++++++++\n");
System.err.printf("*functionalInterfaceClass: '%s'\n", functionalInterfaceClass);
System.err.printf("*functionalInterfaceMethodName: '%s'\n", functionalInterfaceMethodName);
System.err.printf("*functionalInterfaceMethodSignature: '%s'\n", functionalInterfaceMethodSignature);
System.err.printf("*implMethodKind: %d\n", implMethodKind);
System.err.printf("*implClass: '%s'\n", implClass);
System.err.printf("*implMethodName: '%s'\n", implMethodName);
System.err.printf("*implMethodSignature: '%s'\n", implMethodSignature);
****/
if (dumpLambdaDeserializationStats) {
log.note(pos, Notes.LambdaDeserializationStat(
functionalInterfaceClass,
functionalInterfaceMethodName,
functionalInterfaceMethodSignature,
implMethodKind,
implClass,
implMethodName,
implMethodSignature));
}
stmts.append(stmt);
}

View File

@ -1701,6 +1701,17 @@ compiler.note.mref.stat.1=\
alternate metafactory = {0}\n\
bridge method = {1}
# 0: string, 1: string, 2: string, 3: number, 4: string, 5: string, 6: string
compiler.note.lambda.deserialization.stat=\
Generating lambda deserialization\n\
functionalInterfaceClass: {0}\n\
functionalInterfaceMethodName: {1}\n\
functionalInterfaceMethodSignature:{2}\n\
implMethodKind: {3}\n\
implClass: {4}\n\
implMethodName: {5}\n\
implMethodSignature: {6}
compiler.note.note=\
Note:\u0020

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2026, Google LLC and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// key: compiler.note.lambda.deserialization.stat
// options: --debug=dumpLambdaDeserializationStats
import java.io.Serializable;
class LambdaDeserializationStat {
Runnable r = (Runnable & Serializable) () -> {};
}

View File

@ -25,7 +25,7 @@
* @test
* @bug 8282080
* @summary Check that serializable lambdas referring to j.l.Object methods work.
* @compile SerializableObjectMethods.java
* @compile/ref=SerializableObjectMethods.out -XDrawDiagnostics --debug=dumpLambdaDeserializationStats SerializableObjectMethods.java
* @run main SerializableObjectMethods
*/
import java.io.ByteArrayInputStream;

View File

@ -0,0 +1,4 @@
SerializableObjectMethods.java:59:35: compiler.note.lambda.deserialization.stat: SerializableObjectMethods$F, apply, (Ljava/lang/Object;)Ljava/lang/Object;, 5, java/lang/Object, hashCode, ()I
SerializableObjectMethods.java:60:35: compiler.note.lambda.deserialization.stat: SerializableObjectMethods$F, apply, (Ljava/lang/Object;)Ljava/lang/Object;, 9, SerializableObjectMethods$I2, hashCode, ()I
- compiler.note.unchecked.filename: SerializableObjectMethods.java
- compiler.note.unchecked.recompile