8201440: javac should create unique DynamicMethodSymbols at LambdaToMethod
Reviewed-by: mcimadamore
This commit is contained in:
parent
d3760023e6
commit
9c570aaf85
src/jdk.compiler/share/classes/com/sun/tools/javac
test/langtools/tools/javac/lambda/deduplication
@ -67,6 +67,7 @@ import static com.sun.tools.javac.code.Flags.*;
|
||||
import static com.sun.tools.javac.code.Kinds.Kind.*;
|
||||
import static com.sun.tools.javac.code.TypeTag.*;
|
||||
import static com.sun.tools.javac.tree.JCTree.Tag.*;
|
||||
import static com.sun.tools.javac.jvm.Pool.DynamicMethod;
|
||||
|
||||
import javax.lang.model.element.ElementKind;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
@ -208,6 +209,8 @@ public class LambdaToMethod extends TreeTranslator {
|
||||
|
||||
private Map<DedupedLambda, DedupedLambda> dedupedLambdas;
|
||||
|
||||
private Map<DynamicMethod, DynamicMethodSymbol> dynMethSyms = new HashMap<>();
|
||||
|
||||
/**
|
||||
* list of deserialization cases
|
||||
*/
|
||||
@ -1200,9 +1203,10 @@ public class LambdaToMethod extends TreeTranslator {
|
||||
(MethodSymbol)bsm,
|
||||
indyType,
|
||||
staticArgs.toArray());
|
||||
|
||||
JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
|
||||
qualifier.sym = dynSym;
|
||||
DynamicMethodSymbol existing = kInfo.dynMethSyms.putIfAbsent(
|
||||
new DynamicMethod(dynSym, types), dynSym);
|
||||
qualifier.sym = existing != null ? existing : dynSym;
|
||||
qualifier.type = indyType.getReturnType();
|
||||
|
||||
JCMethodInvocation proxyCall = make.Apply(List.nil(), qualifier, indyArgs);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2018, Oracle 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
|
||||
@ -180,10 +180,10 @@ public class Pool {
|
||||
}
|
||||
}
|
||||
|
||||
static class DynamicMethod extends Method {
|
||||
public static class DynamicMethod extends Method {
|
||||
public Object[] uniqueStaticArgs;
|
||||
|
||||
DynamicMethod(DynamicMethodSymbol m, Types types) {
|
||||
public DynamicMethod(DynamicMethodSymbol m, Types types) {
|
||||
super(m, types);
|
||||
uniqueStaticArgs = getUniqueTypeArray(m.staticArgs, types);
|
||||
}
|
||||
|
@ -32,6 +32,12 @@ public class Deduplication {
|
||||
void group(Object... xs) {}
|
||||
|
||||
void test() {
|
||||
|
||||
group(
|
||||
(Runnable) () -> { ( (Runnable) () -> {} ).run(); },
|
||||
(Runnable) () -> { ( (Runnable) () -> {} ).run(); }
|
||||
);
|
||||
|
||||
group((Function<String, Integer>) x -> x.hashCode());
|
||||
group((Function<Object, Integer>) x -> x.hashCode());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user