mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
Use --debug=dumpLambdaDeserializationStats in test
This commit is contained in:
parent
5d79a7977a
commit
9dc6020194
@ -29,28 +29,14 @@
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
* jdk.jdeps/com.sun.tools.javap
|
||||
* @build toolbox.ToolBox toolbox.JavacTask
|
||||
* @run main SerializableObjectMethodReferencesOnInterfaces
|
||||
* @compile/ref=SerializableObjectMethodReferencesOnInterfaces.out -XDrawDiagnostics --debug=dumpLambdaDeserializationStats SerializableObjectMethodReferencesOnInterfaces.java
|
||||
*/
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.classfile.*;
|
||||
import java.lang.classfile.ClassFile;
|
||||
import java.lang.classfile.ClassModel;
|
||||
import java.lang.classfile.CodeElement;
|
||||
import java.lang.classfile.MethodModel;
|
||||
import java.lang.classfile.instruction.ConstantInstruction;
|
||||
import java.lang.classfile.instruction.InvokeInstruction;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class SerializableObjectMethodReferencesOnInterfaces {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
new SerializableObjectMethodReferencesOnInterfaces().run();
|
||||
}
|
||||
|
||||
static class Test {
|
||||
interface I1 extends Serializable {}
|
||||
|
||||
@ -74,80 +60,4 @@ public class SerializableObjectMethodReferencesOnInterfaces {
|
||||
F<Object, Integer> f4 = Object::hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
URL url =
|
||||
SerializableObjectMethodReferencesOnInterfaces.class.getResource(
|
||||
"SerializableObjectMethodReferencesOnInterfaces$Test.class");
|
||||
Path file = Paths.get(url.toURI());
|
||||
|
||||
ClassModel cf = ClassFile.of().parse(file);
|
||||
String actual = printDeserializationTests(cf);
|
||||
String expected =
|
||||
"""
|
||||
getImplMethodKind 5
|
||||
getFunctionalInterfaceClass SerializableObjectMethodReferencesOnInterfaces$Test$F
|
||||
getFunctionalInterfaceMethodName apply
|
||||
getFunctionalInterfaceMethodSignature (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
getImplClass java/lang/Object
|
||||
getImplMethodSignature ()I
|
||||
getImplMethodKind 5
|
||||
getFunctionalInterfaceClass SerializableObjectMethodReferencesOnInterfaces$Test$F
|
||||
getFunctionalInterfaceMethodName apply
|
||||
getFunctionalInterfaceMethodSignature (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
getImplClass java/lang/Object
|
||||
getImplMethodSignature ()I
|
||||
getImplMethodKind 5
|
||||
getFunctionalInterfaceClass SerializableObjectMethodReferencesOnInterfaces$Test$F
|
||||
getFunctionalInterfaceMethodName apply
|
||||
getFunctionalInterfaceMethodSignature (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
getImplClass java/lang/Enum
|
||||
getImplMethodSignature ()I
|
||||
getImplMethodKind 5
|
||||
getFunctionalInterfaceClass SerializableObjectMethodReferencesOnInterfaces$Test$F
|
||||
getFunctionalInterfaceMethodName apply
|
||||
getFunctionalInterfaceMethodSignature (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
getImplClass java/lang/Object
|
||||
getImplMethodSignature ()I
|
||||
""";
|
||||
if (!actual.equals(expected)) {
|
||||
throw new AssertionError(
|
||||
"Unexpected deserialization tests, expected:\n"
|
||||
+ expected
|
||||
+ "\nactual:\n"
|
||||
+ actual);
|
||||
}
|
||||
}
|
||||
|
||||
private static String printDeserializationTests(ClassModel cf) {
|
||||
MethodModel m =
|
||||
cf.methods().stream()
|
||||
.filter(
|
||||
x ->
|
||||
x.methodName()
|
||||
.stringValue()
|
||||
.contentEquals("$deserializeLambda$"))
|
||||
.findFirst()
|
||||
.get();
|
||||
Iterator<CodeElement> it = m.code().get().iterator();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (it.hasNext()) {
|
||||
CodeElement curr = it.next();
|
||||
if (curr instanceof InvokeInstruction i
|
||||
&& i.method()
|
||||
.owner()
|
||||
.asInternalName()
|
||||
.contentEquals("java/lang/invoke/SerializedLambda")) {
|
||||
CodeElement next = it.next();
|
||||
if (next instanceof ConstantInstruction c) {
|
||||
sb.append(
|
||||
i.method().name().stringValue()
|
||||
+ " "
|
||||
+ c.constantValue().toString()
|
||||
+ "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
SerializableObjectMethodReferencesOnInterfaces.java:57:33: compiler.note.lambda.deserialization.stat: SerializableObjectMethodReferencesOnInterfaces$Test$F, apply, (Ljava/lang/Object;)Ljava/lang/Object;, 5, java/lang/Object, hashCode, ()I
|
||||
SerializableObjectMethodReferencesOnInterfaces.java:58:33: compiler.note.lambda.deserialization.stat: SerializableObjectMethodReferencesOnInterfaces$Test$F, apply, (Ljava/lang/Object;)Ljava/lang/Object;, 5, java/lang/Object, hashCode, ()I
|
||||
SerializableObjectMethodReferencesOnInterfaces.java:59:32: compiler.note.lambda.deserialization.stat: SerializableObjectMethodReferencesOnInterfaces$Test$F, apply, (Ljava/lang/Object;)Ljava/lang/Object;, 5, java/lang/Enum, hashCode, ()I
|
||||
SerializableObjectMethodReferencesOnInterfaces.java:60:37: compiler.note.lambda.deserialization.stat: SerializableObjectMethodReferencesOnInterfaces$Test$F, apply, (Ljava/lang/Object;)Ljava/lang/Object;, 5, java/lang/Object, hashCode, ()I
|
||||
@ -1,4 +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
|
||||
SerializableObjectMethods.java:60:35: compiler.note.lambda.deserialization.stat: SerializableObjectMethods$F, apply, (Ljava/lang/Object;)Ljava/lang/Object;, 5, java/lang/Object, hashCode, ()I
|
||||
- compiler.note.unchecked.filename: SerializableObjectMethods.java
|
||||
- compiler.note.unchecked.recompile
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user