private boolean hasForNameCall(Program program) { for (BasicBlock block : program.getBasicBlocks()) { for (Instruction instruction : block) { if (!(instruction instanceof InvokeInstruction)) { continue; } InvokeInstruction invoke = (InvokeInstruction) instruction; if (invoke.getMethod().equals(forNameMethod) || invoke.getMethod().equals(forNameShortMethod)) { return true; } } } return false; }
@Override public void methodReached(DependencyAgent agent, MethodDependency method) { if (method.getReference().equals(fieldGet)) { handleFieldGet(agent, method); } else if (method.getReference().equals(fieldSet)) { handleFieldSet(agent, method); } else if (method.getReference().equals(newInstance)) { handleNewInstance(agent, method); } else if (method.getReference().equals(invokeMethod)) { handleInvoke(agent, method); } else if (method.getReference().equals(getFields)) { method.getVariable(0).getClassValueNode().addConsumer(type -> { if (!type.getName().startsWith("[")) { } else if (method.getReference().equals(getConstructors) || method.getReference().equals(getMethods)) { method.getVariable(0).getClassValueNode().addConsumer(type -> { if (!type.getName().startsWith("[")) { } else if (method.getReference().equals(forName) || method.getReference().equals(forNameShort)) { allClasses.connect(method.getResult().getClassValueNode()); } else if (method.getReference().equals(fieldGetType) || method.getReference().equals(methodGetReturnType)) { method.getResult().propagate(agent.getType("java.lang.Class")); typesInReflectableSignaturesNode.connect(method.getResult().getClassValueNode()); } else if (method.getReference().equals(methodGetParameterTypes) || method.getReference().equals(constructorGetParameterTypes)) { method.getResult().getArrayItem().propagate(agent.getType("java.lang.Class")); typesInReflectableSignaturesNode.connect(method.getResult().getArrayItem().getClassValueNode());
exportedMethod.getAnnotations().add(annot); if (methodRef.equals(functorMethod)) { addFunctorField(classHolder, exportedMethod.getReference());
if (instruction instanceof InvokeInstruction) { InvokeInstruction invoke = (InvokeInstruction) instruction; if (invoke.getMethod().equals(getNameMethod)) { if (invoke.getReceiver() != null) { nameIndexes[invoke.getReceiver().getIndex()] = invoke.getInstance().getIndex(); if (!invoke.getMethod().equals(forNameMethod) && !invoke.getMethod().equals(forNameShortMethod)) { continue;
@Override public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { if (method.getReference().equals(getMessageRef)) { allClasses.connect(method.getVariable(1)); } } }
exportedMethod.getAnnotations().add(annot); if (methodRef.equals(functorMethod)) { addFunctorField(classHolder, exportedMethod.getReference());
public DependencyChecker(ClassReaderSource classSource, ClassLoader classLoader, ServiceRepository services, Diagnostics diagnostics) { this.diagnostics = diagnostics; this.classSource = new DependencyClassSource(classSource, diagnostics); this.classLoader = classLoader; this.services = services; methodReaderCache = new CachedMapper<>(preimage -> this.classSource.resolveMutable(preimage)); fieldReaderCache = new CachedMapper<>(preimage -> this.classSource.resolveMutable(preimage)); methodCache = new CachedMapper<>(preimage -> { MethodHolder method = methodReaderCache.map(preimage); if (method != null && !method.getReference().equals(preimage)) { return methodCache.map(method.getReference()); } return createMethodDep(preimage, method); }); fieldCache = new CachedMapper<>(preimage -> { FieldReader field = fieldReaderCache.map(preimage); if (field != null && !field.getReference().equals(preimage)) { return fieldCache.map(field.getReference()); } return createFieldNode(preimage, field); }); classCache = new CachedMapper<>(this::createClassDependency); agent = new DependencyAgent(this); }