@ Override public void visitReference ( JCMemberReference tree ) { ReferenceTranslationContext localContext = ( ReferenceTranslationContext ) context ; //first determine the method symbol to be used to generate the sam instance //this is either the method reference symbol, or the bridged reference symbol Symbol refSym = localContext . isSignaturePolymorphic ( ) ? localContext . sigPolySym : tree . sym ; //the qualifying expression is treated as a special captured arg JCExpression init ; switch ( tree . kind ) { case IMPLICIT_INNER : /** Inner :: new */ case SUPER : /** super :: instMethod */ init = makeThis ( localContext . owner . enclClass ( ) . asType ( ) , localContext . owner . enclClass ( ) ) ; break ; case BOUND : /** Expr :: instMethod */ init = tree . getQualifierExpression ( ) ; init = attr . makeNullCheck ( init ) ; break ; case UNBOUND : /** Type :: instMethod */ case STATIC : /** Type :: staticMethod */ case TOPLEVEL : /** Top level :: new */ case ARRAY_CTOR : /** ArrayType :: new */ init = null ; break ; default : throw new InternalError ( "Should not have an invalid kind" ) ; } List < JCExpression > indy_args = init == null ? List . nil ( ) : translate ( List . of ( init ) , localContext . prev ) ; //build a sam instance using an indy call to the meta-factory result = makeMetafactoryIndyCall ( localContext , localContext . referenceKind ( ) , refSym , indy_args ) ; }
Translate a method reference into an invokedynamic call to the meta - factory .