@Override public boolean isApplicable(MethodReference methodReference) { if (!methodReference.getClassName().equals(ExceptionHandling.class.getName())) { return false; } switch (methodReference.getName()) { case "findCallSiteById": return true; } return false; }
@Override public boolean canHandle(MethodReference method) { if (!method.getClassName().equals(ExceptionHandling.class.getName())) { return false; } switch (method.getName()) { case "findCallSiteById": return true; default: return false; } }
@Override public boolean isApplicable(MethodReference methodReference) { if (!methodReference.getClassName().equals(Mutator.class.getName())) { return false; } switch (methodReference.getName()) { case "getStaticGCRoots": return true; default: return false; } }
@Override public boolean isApplicable(MethodReference methodReference) { if (!methodReference.getClassName().equals(DateTimeZoneProvider.class.getName())) { return false; } switch (methodReference.getName()) { case "timeZoneDetectionEnabled": return true; default: return false; } }
@Override public boolean canHandle(MethodReference method) { if (!method.getClassName().equals(Array.class.getName())) { return false; } switch (method.getName()) { case "getImpl": return true; default: return false; } }
public String forVirtualMethod(MethodReference method) { return virtualMethodNames.computeIfAbsent(method, k -> { Set<String> occupied = occupiedVtableNames.computeIfAbsent(k.getClassName(), c -> new HashSet<>(Arrays.asList("parent"))); return pickUnoccupied("virt_" + k.getName(), occupied); }); }
private boolean isSpecialCallInstruction(Instruction insn) { if (!(insn instanceof InvokeInstruction)) { return false; } MethodReference method = ((InvokeInstruction) insn).getMethod(); return method.getClassName().equals(ExceptionHandling.class.getName()) && method.getName().startsWith("throw"); }
default MethodReader resolve(MethodReference method) { return getAncestors(method.getClassName()) .map(cls -> cls.getMethod(method.getDescriptor())) .filter(Objects::nonNull) .findFirst().orElse(null); }
@Override public boolean isApplicable(MethodReference methodReference) { return methodReference.getClassName().equals("java.lang.Class") && isApplicableToMethod(methodReference.getDescriptor()); }
default Stream<MethodReader> overriddenMethods(MethodReference method) { return getAncestorClasses(method.getClassName()) .map(cls -> cls.getMethod(method.getDescriptor())) .filter(Objects::nonNull); }
public VirtualTableEntry lookup(MethodReference method) { VirtualTable vtable = virtualTables.get(interfaceMapping.mapClass(method.getClassName())); if (vtable == null) { return null; } return vtable.getEntries().get(method.getDescriptor()); }
public ValueType getMetaParameterType(int index) { if (!isStatic) { if (index == 0) { return ValueType.object(method.getClassName()); } else { --index; } } return method.parameterType(index); }
private static ValueType[] getStaticSignature(MethodReference method) { ValueType[] signature = method.getSignature(); ValueType[] staticSignature = new ValueType[signature.length + 1]; for (int i = 0; i < signature.length; ++i) { staticSignature[i + 1] = signature[i]; } staticSignature[0] = ValueType.object(method.getClassName()); return staticSignature; }
@Override public boolean isVirtual(VirtualMethodContributorContext context, MethodReference methodRef) { ClassReader cls = context.getClassSource().get(methodRef.getClassName()); if (cls == null || !cls.getInterfaces().contains(PlatformAnnotationProvider.class.getName())) { return false; } return methodRef.getName().equals("getAnnotations"); } }
@Override public void methodReached(final DependencyAgent agent, MethodDependency method) { if (!method.getReference().getClassName().equals(Platform.class.getName())) { return; } switch (method.getReference().getName()) { case "objectFromResource": allClasses.connect(method.getResult()); break; } } }
private void addOverriddenToFamily(MethodReference methodRef) { asyncFamilyMethods.put(methodRef, true); ClassReader cls = classSource.get(methodRef.getClassName()); if (cls == null) { return; } for (MethodReference overriddenMethod : findOverriddenMethods(cls, methodRef.getDescriptor())) { addOverriddenToFamily(overriddenMethod); } }
@Override public void methodReached(DependencyAgent agent, MethodDependency method) { if (!method.getReference().getClassName().equals(ResourceAccessor.class.getName())) { return; } switch (method.getReference().getName()) { case "castToString": method.getResult().propagate(agent.getType("java.lang.String")); break; } } }
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 public MethodDependency getMethodImplementation(MethodReference methodRef) { MethodReader method = getMethodHolder(methodRef.getClassName(), methodRef.getDescriptor()); return method != null ? getMethod(method.getReference()) : null; }
private void renderSetStackTrace() throws IOException { ClassReader cls = classSource.get(SET_STACK_TRACE_METHOD.getClassName()); boolean supported = cls != null && cls.getMethod(SET_STACK_TRACE_METHOD.getDescriptor()) != null; writer.append("function $rt_setStack(e,").ws().append("stack)").ws().append("{").indent().softNewLine(); if (supported) { writer.appendMethodBody(SET_STACK_TRACE_METHOD); writer.append("(e,").ws().append("stack);").softNewLine(); } writer.outdent().append("}").newLine(); } }