|
37 | 37 | import java.util.regex.Pattern;
|
38 | 38 |
|
39 | 39 | import jdk.graal.compiler.bytecode.BytecodeStream;
|
| 40 | +import jdk.graal.compiler.debug.GraalError; |
40 | 41 | import jdk.graal.compiler.util.Digest;
|
41 | 42 | import jdk.vm.ci.common.JVMCIError;
|
42 | 43 | import jdk.vm.ci.meta.ConstantPool;
|
@@ -141,18 +142,28 @@ public static boolean isLambdaName(String name) {
|
141 | 142 | return isLambdaClassName(name) && lambdaMatcher(name).find();
|
142 | 143 | }
|
143 | 144 |
|
144 |
| - private static String createStableLambdaName(ResolvedJavaType lambdaType, List<JavaMethod> targetMethods) { |
| 145 | + private static String createStableLambdaName(ResolvedJavaType lambdaType, List<JavaMethod> invokedMethods) { |
145 | 146 | final String lambdaName = lambdaType.getName();
|
146 | 147 | assert lambdaMatcher(lambdaName).find() : "Stable name should be created for lambda types: " + lambdaName;
|
147 | 148 |
|
148 | 149 | Matcher m = lambdaMatcher(lambdaName);
|
| 150 | + /* Generate lambda signature by hashing its composing parts. */ |
149 | 151 | StringBuilder sb = new StringBuilder();
|
150 |
| - targetMethods.forEach((targetMethod) -> sb.append(targetMethod.format("%H.%n(%P)%R"))); |
151 |
| - // Take parameter types of constructor into consideration, see GR-52837 |
| 152 | + /* Append invoked methods. */ |
| 153 | + for (JavaMethod method : invokedMethods) { |
| 154 | + sb.append(method.format("%H.%n(%P)%R")); |
| 155 | + } |
| 156 | + /* Append constructor parameter types. */ |
152 | 157 | for (JavaMethod ctor : lambdaType.getDeclaredConstructors()) {
|
153 | 158 | sb.append(ctor.format("%P"));
|
154 | 159 | }
|
155 |
| - return m.replaceFirst(Matcher.quoteReplacement(LAMBDA_CLASS_NAME_SUBSTRING + ADDRESS_PREFIX + Digest.digestAsHex(sb.toString()) + ";")); |
| 160 | + /* Append implemented interfaces. */ |
| 161 | + for (ResolvedJavaType iface : lambdaType.getInterfaces()) { |
| 162 | + sb.append(iface.toJavaName()); |
| 163 | + } |
| 164 | + String signature = Digest.digestAsHex(sb.toString()); |
| 165 | + GraalError.guarantee(signature.length() == 32, "Expecting a 32 digits long hex value."); |
| 166 | + return m.replaceFirst(Matcher.quoteReplacement(LAMBDA_CLASS_NAME_SUBSTRING + ADDRESS_PREFIX + signature + ";")); |
156 | 167 | }
|
157 | 168 |
|
158 | 169 | private static Matcher lambdaMatcher(String value) {
|
|
0 commit comments