Example #1
0
  public MethodDependency linkMethod(MethodReference methodRef, CallLocation callLocation) {
    if (methodRef == null) {
      throw new IllegalArgumentException();
    }
    MethodReader methodReader = methodReaderCache.map(methodRef);
    if (methodReader != null) {
      methodRef = methodReader.getReference();
    }

    if (completing && getMethod(methodRef) == null) {
      throw new IllegalStateException("Can't submit class during completion phase");
    }
    callGraph.getNode(methodRef);
    boolean added = true;
    if (callLocation != null && callLocation.getMethod() != null) {
      added =
          callGraph
              .getNode(callLocation.getMethod())
              .addCallSite(methodRef, callLocation.getSourceLocation());
    } else {
      added = methodsAddedByRoot.add(methodRef);
    }
    MethodDependency graph = methodCache.map(methodRef);
    if (!graph.isMissing() && added) {
      for (DependencyListener listener : listeners) {
        listener.methodReached(agent, graph, callLocation);
      }
      activateDependencyPlugin(graph, callLocation);
    }
    return graph;
  }
Example #2
0
 public FieldDependency linkField(FieldReference fieldRef, CallLocation location) {
   if (completing) {
     throw new IllegalStateException("Can't submit class during completion phase");
   }
   boolean added = true;
   if (location != null) {
     added =
         callGraph
             .getNode(location.getMethod())
             .addFieldAccess(fieldRef, location.getSourceLocation());
   } else {
     added = fieldsAddedByRoot.add(fieldRef);
   }
   FieldDependency dep = fieldCache.map(fieldRef);
   if (!dep.isMissing()) {
     tasks.add(() -> linkClass(fieldRef.getClassName(), location).initClass(location));
   }
   if (!dep.isMissing() && added) {
     for (DependencyListener listener : listeners) {
       listener.fieldReached(agent, dep, location);
     }
   }
   return dep;
 }
Example #3
0
 public ClassDependency linkClass(String className, CallLocation callLocation) {
   if (completing && getClass(className) == null) {
     throw new IllegalStateException("Can't link class during completion phase");
   }
   ClassDependency dep = classCache.map(className);
   boolean added = true;
   if (callLocation != null && callLocation.getMethod() != null) {
     DefaultCallGraphNode callGraphNode = callGraph.getNode(callLocation.getMethod());
     if (!addClassAccess(callGraphNode, className, callLocation.getSourceLocation())) {
       added = false;
     }
   } else {
     added = classesAddedByRoot.add(className);
   }
   if (!dep.isMissing() && added) {
     tasks.add(
         () -> {
           for (DependencyListener listener : listeners) {
             listener.classReached(agent, className, callLocation);
           }
         });
   }
   return dep;
 }