FastVirtualCallConsumer getVirtualCallConsumer(MethodReference method) { return virtualCallConsumers.computeIfAbsent(method, key -> { FastVirtualCallConsumer consumer = new FastVirtualCallConsumer(instancesNode, key.getDescriptor(), this); defer(() -> { getSubtypeNode(method.getClassName()).addConsumer(consumer); }); return consumer; }); }
@Override protected void invokeVirtual(VariableReader receiver, VariableReader instance, MethodReference method, List<? extends VariableReader> arguments) { dependencyAnalyzer.getVirtualCallConsumer(method).addLocation(impreciseLocation); }
@Override protected void invokeSpecial(VariableReader receiver, VariableReader instance, MethodReference method, List<? extends VariableReader> arguments) { CallLocation callLocation = impreciseLocation; if (instance == null) { dependencyAnalyzer.linkClass(method.getClassName()).initClass(callLocation); } MethodDependency methodDep = dependencyAnalyzer.linkMethod(method); methodDep.addLocation(callLocation); methodDep.use(); }
DependencyNode node = createNode(); defer(() -> { int degree = 0; while (degree < key.length() && key.charAt(degree) == '[') { String prefix = key.substring(0, degree) + "L"; String className = ((ValueType.Object) fullType).getClassName(); ClassReader cls = getClassSource().get(key); if (cls != null) { if (cls.getParent() != null) { node.connect(getSubtypeNode(prefix + cls.getParent().replace('.', '/') + ";")); } else { node.connect(getSubtypeNode("java.lang.Object")); node.connect(getSubtypeNode(prefix + itf.replace('.', '/') + ";")); node.connect(getSubtypeNode("java.lang.Object")); ClassReader cls = getClassSource().get(key); if (cls != null) { if (cls.getParent() != null) { node.connect(getSubtypeNode(cls.getParent())); node.connect(getSubtypeNode(itf));
@Override protected void processMethod(MethodDependency methodDep) { MethodReader method = methodDep.getMethod(); ProgramReader program = method.getProgram(); if (program != null) { FastInstructionAnalyzer instructionAnalyzer = new FastInstructionAnalyzer(this); instructionAnalyzer.setCaller(method.getReference()); for (BasicBlockReader block : program.getBasicBlocks()) { block.readAllInstructions(instructionAnalyzer); for (TryCatchBlockReader tryCatch : block.readTryCatchBlocks()) { if (tryCatch.getExceptionType() != null) { linkClass(tryCatch.getExceptionType()); } } } methodDep.variableNodes = new DependencyNode[program.variableCount()]; for (int i = 0; i < methodDep.variableNodes.length; ++i) { methodDep.variableNodes[i] = instancesNode; } } if (method.hasModifier(ElementModifier.SYNCHRONIZED)) { processAsyncMethod(methodDep); } }
private void processAsyncMethod(MethodDependency methodDep) { if (asyncSupported) { linkMethod(MONITOR_ENTER_METHOD).use(); } linkMethod(MONITOR_ENTER_SYNC_METHOD).use(); if (asyncSupported) { linkMethod(MONITOR_EXIT_METHOD).use(); } linkMethod(MONITOR_EXIT_SYNC_METHOD).use(); }
public FastDependencyAnalyzer(ClassReaderSource classSource, ClassLoader classLoader, ServiceRepository services, Diagnostics diagnostics) { super(classSource, classLoader, services, diagnostics); instancesNode = new DependencyNode(this, null); classesNode = new DependencyNode(this, null); instancesNode.addConsumer(type -> { getSubtypeNode(type.getName()).propagate(type); }); }