private List<MethodInvocationTree> resolveReflectiveMethod(MethodInvocationTree tree,AnnotatedTypeFactory reflectionFactory){
  assert isReflectiveMethodInvocation(tree);
  JCMethodInvocation methodInvocation=(JCMethodInvocation)tree;
  Context context=((JavacProcessingEnvironment)processingEnv).getContext();
  TreeMaker make=TreeMaker.instance(context);
  TreePath path=reflectionFactory.getPath(tree);
  JavacScope scope=(JavacScope)trees.getScope(path);
  Env<AttrContext> env=scope.getEnv();
  List<MethodInvocationTree> methods=new ArrayList<>();
  boolean unknown=isUnknownMethod(tree);
  AnnotationMirror estimate=getMethodVal(tree);
  if (estimate == null) {
    debugReflection("MethodVal is unknown for: " + tree);
    debugReflection("UnknownMethod annotation: " + unknown);
    return methods;
  }
  debugReflection("MethodVal type system annotations: " + estimate);
  List<String> listClassNames=AnnotationUtils.getElementValueArray(estimate,"className",String.class,true);
  List<String> listMethodNames=AnnotationUtils.getElementValueArray(estimate,"methodName",String.class,true);
  List<Integer> listParamLenghts=AnnotationUtils.getElementValueArray(estimate,"params",Integer.class,true);
  assert listClassNames.size() == listMethodNames.size() && listClassNames.size() == listParamLenghts.size();
  for (int i=0; i < listClassNames.size(); ++i) {
    String className=listClassNames.get(i);
    String methodName=listMethodNames.get(i);
    int paramLength=listParamLenghts.get(i);
    JCExpression receiver=methodInvocation.args.head;
    com.sun.tools.javac.util.List<JCExpression> args=methodInvocation.args.tail;
    for (    Symbol symbol : getMethodSymbolsfor(className,methodName,paramLength,env)) {
      if ((symbol.flags() & Flags.PUBLIC) > 0) {
        debugReflection("Resolved public method: " + symbol.owner + "."+ symbol);
      }
 else {
        debugReflection("Resolved non-public method: " + symbol.owner + "."+ symbol);
      }
      JCExpression method=make.Select(receiver,symbol);
      args=getCorrectedArgs(symbol,args);
      JCMethodInvocation syntTree=paramLength > 0 ? make.App(method,args) : make.App(method);
      methods.add(syntTree);
    }
  }
  return methods;
}

private List < MethodInvocationTree > resolveReflectiveMethod ( MethodInvocationTree tree , AnnotatedTypeFactory reflectionFactory ) { assert isReflectiveMethodInvocation ( tree ) ; JCMethodInvocation methodInvocation = ( JCMethodInvocation ) tree ; Context context = ( ( JavacProcessingEnvironment ) processingEnv ) . getContext ( ) ; TreeMaker make = TreeMaker . instance ( context ) ; TreePath path = reflectionFactory . getPath ( tree ) ; JavacScope scope = ( JavacScope ) trees . getScope ( path ) ; Env < AttrContext > env = scope . getEnv ( ) ; List < MethodInvocationTree > methods = new ArrayList < > ( ) ; boolean unknown = isUnknownMethod ( tree ) ; AnnotationMirror estimate = getMethodVal ( tree ) ; if ( estimate == null ) { debugReflection ( "MethodVal is unknown for: " + tree ) ; debugReflection ( "UnknownMethod annotation: " + unknown ) ; return methods ; } debugReflection ( "MethodVal type system annotations: " + estimate ) ; List < String > listClassNames = AnnotationUtils . getElementValueArray ( estimate , "className" , String . class , true ) ; List < String > listMethodNames = AnnotationUtils . getElementValueArray ( estimate , "methodName" , String . class , true ) ; List < Integer > listParamLenghts = AnnotationUtils . getElementValueArray ( estimate , "params" , Integer . class , true ) ; assert listClassNames . size ( ) == listMethodNames . size ( ) && listClassNames . size ( ) == listParamLenghts . size ( ) ; for ( int i = 0 ; i < listClassNames . size ( ) ; ++ i ) { String className = listClassNames . get ( i ) ; String methodName = listMethodNames . get ( i ) ; int paramLength = listParamLenghts . get ( i ) ; JCExpression receiver = methodInvocation . args . head ; com . sun . tools . javac . util . List < JCExpression > args = methodInvocation . args . tail ; for ( Symbol symbol : getMethodSymbolsfor ( className , methodName , paramLength , env ) ) { if ( ( symbol . flags ( ) & Flags . PUBLIC ) > 0 ) { debugReflection ( "Resolved public method: " + symbol . owner + "." + symbol ) ; } else { debugReflection ( "Resolved non-public method: " + symbol . owner + "." + symbol ) ; } JCExpression method = make . Select ( receiver , symbol ) ; args = getCorrectedArgs ( symbol , args ) ; JCMethodInvocation syntTree = paramLength > 0 ? make . App ( method , args ) : make . App ( method ) ; methods . add ( syntTree ) ; } } return methods ; }
resolves a reflective method call and returns all possible corresponding method calls .
