src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java

changeset 2202
4fa835472e3c
parent 2165
864dafc5ab7a
child 2222
8832b6048e65
equal deleted inserted replaced
2201:ef44a2971cb1 2202:4fa835472e3c
355 public void visitReference(JCMemberReference tree) { 355 public void visitReference(JCMemberReference tree) {
356 ReferenceTranslationContext localContext = (ReferenceTranslationContext)context; 356 ReferenceTranslationContext localContext = (ReferenceTranslationContext)context;
357 357
358 //first determine the method symbol to be used to generate the sam instance 358 //first determine the method symbol to be used to generate the sam instance
359 //this is either the method reference symbol, or the bridged reference symbol 359 //this is either the method reference symbol, or the bridged reference symbol
360 Symbol refSym = localContext.needsBridge() ? 360 Symbol refSym = localContext.needsBridge()
361 localContext.bridgeSym : 361 ? localContext.bridgeSym
362 tree.sym; 362 : localContext.isSignaturePolymorphic()
363 ? localContext.sigPolySym
364 : tree.sym;
363 365
364 //build the bridge method, if needed 366 //build the bridge method, if needed
365 if (localContext.needsBridge()) { 367 if (localContext.needsBridge()) {
366 bridgeMemberReference(tree, localContext); 368 bridgeMemberReference(tree, localContext);
367 } 369 }
1993 */ 1995 */
1994 private class ReferenceTranslationContext extends TranslationContext<JCMemberReference> { 1996 private class ReferenceTranslationContext extends TranslationContext<JCMemberReference> {
1995 1997
1996 final boolean isSuper; 1998 final boolean isSuper;
1997 final Symbol bridgeSym; 1999 final Symbol bridgeSym;
2000 final Symbol sigPolySym;
1998 2001
1999 ReferenceTranslationContext(JCMemberReference tree) { 2002 ReferenceTranslationContext(JCMemberReference tree) {
2000 super(tree); 2003 super(tree);
2001 this.isSuper = tree.hasKind(ReferenceKind.SUPER); 2004 this.isSuper = tree.hasKind(ReferenceKind.SUPER);
2002 this.bridgeSym = needsBridge() 2005 this.bridgeSym = needsBridge()
2003 ? makePrivateSyntheticMethod(isSuper ? 0 : STATIC, 2006 ? makePrivateSyntheticMethod(isSuper ? 0 : STATIC,
2004 referenceBridgeName(), null, 2007 referenceBridgeName(), null,
2005 owner.enclClass()) 2008 owner.enclClass())
2009 : null;
2010 this.sigPolySym = isSignaturePolymorphic()
2011 ? makePrivateSyntheticMethod(tree.sym.flags(),
2012 tree.sym.name,
2013 bridgedRefSig(),
2014 tree.sym.enclClass())
2006 : null; 2015 : null;
2007 if (dumpLambdaToMethodStats) { 2016 if (dumpLambdaToMethodStats) {
2008 String key = bridgeSym == null ? 2017 String key = bridgeSym == null ?
2009 "mref.stat" : "mref.stat.1"; 2018 "mref.stat" : "mref.stat.1";
2010 log.note(tree, key, needsAltMetafactory(), bridgeSym); 2019 log.note(tree, key, needsAltMetafactory(), bridgeSym);
2104 types.erasure(tree.sym.enclClass().asType()), 2113 types.erasure(tree.sym.enclClass().asType()),
2105 types.erasure(owner.enclClass().asType())); 2114 types.erasure(owner.enclClass().asType()));
2106 } 2115 }
2107 2116
2108 /** 2117 /**
2118 * Signature polymorphic methods need special handling.
2119 * e.g. MethodHandle.invoke() MethodHandle.invokeExact()
2120 */
2121 final boolean isSignaturePolymorphic() {
2122 return tree.sym.kind == MTH &&
2123 types.isSignaturePolymorphic((MethodSymbol)tree.sym);
2124 }
2125
2126 /**
2109 * Does this reference needs a bridge (i.e. var args need to be 2127 * Does this reference needs a bridge (i.e. var args need to be
2110 * expanded or "super" is used) 2128 * expanded or "super" is used)
2111 */ 2129 */
2112 final boolean needsBridge() { 2130 final boolean needsBridge() {
2113 return isSuper || needsVarArgsConversion() || isArrayOp() || 2131 return isSuper || needsVarArgsConversion() || isArrayOp() ||

mercurial