public MethodWrapper getMethodWrapper(String name, String descriptor) { return methods.getWithKey(InterpreterUtil.makeUniqueKey(name, descriptor)); }
public StructMethod getMethod(String name, String descriptor) { return methods.getWithKey(InterpreterUtil.makeUniqueKey(name, descriptor)); }
public StructField getField(String name, String descriptor) { return fields.getWithKey(InterpreterUtil.makeUniqueKey(name, descriptor)); }
public static void processClassReferences(ClassNode node) { // find the synthetic method Class class$(String) if present Map<ClassWrapper, MethodWrapper> mapClassMeths = new HashMap<>(); mapClassMethods(node, mapClassMeths); if (mapClassMeths.isEmpty()) { return; } Set<ClassWrapper> setFound = new HashSet<>(); processClassRec(node, mapClassMeths, setFound); if (!setFound.isEmpty()) { for (ClassWrapper wrp : setFound) { StructMethod mt = mapClassMeths.get(wrp).methodStruct; wrp.getHiddenMembers().add(InterpreterUtil.makeUniqueKey(mt.getName(), mt.getDescriptor())); } } }
private static boolean isAssertionField(Exprent exprent, String classname, String key, boolean throwInIf) { if (throwInIf) { if (exprent.type == Exprent.EXPRENT_FUNCTION) { FunctionExprent fparam = (FunctionExprent)exprent; if (fparam.getFuncType() == FunctionExprent.FUNCTION_BOOL_NOT && fparam.getLstOperands().get(0).type == Exprent.EXPRENT_FIELD) { FieldExprent fdparam = (FieldExprent)fparam.getLstOperands().get(0); return classname.equals(fdparam.getClassname()) && key.equals(InterpreterUtil.makeUniqueKey(fdparam.getName(), fdparam.getDescriptor().descriptorString)); } } return false; } else { if (exprent.type == Exprent.EXPRENT_FIELD) { FieldExprent fdparam = (FieldExprent) exprent; return classname.equals(fdparam.getClassname()) && key.equals(InterpreterUtil.makeUniqueKey(fdparam.getName(), fdparam.getDescriptor().descriptorString)); } return false; } } }
private boolean isVarArgCall() { StructClass cl = DecompilerContext.getStructContext().getClass(classname); if (cl != null) { StructMethod mt = cl.getMethod(InterpreterUtil.makeUniqueKey(name, stringDescriptor)); if (mt != null) { return mt.hasModifier(CodeConstants.ACC_VARARGS); } } else { // TODO: tap into IDEA indices to access libraries methods details // try to check the class on the classpath Method mtd = ClasspathHelper.findMethod(classname, name, descriptor); return mtd != null && mtd.isVarArgs(); } return false; }
wrapper.getHiddenMembers().add(InterpreterUtil.makeUniqueKey(name, descriptor)); wrapper.getHiddenMembers().add(InterpreterUtil.makeUniqueKey(name, descriptor)); String descriptor = fd.getDescriptor(); if (fd.isSynthetic() && descriptor.equals("[L" + cl.qualifiedName + ";")) { wrapper.getHiddenMembers().add(InterpreterUtil.makeUniqueKey(fd.getName(), descriptor));
@Override public int processExprent(Exprent exprent) { if (exprent.type == Exprent.EXPRENT_ASSIGNMENT) { AssignmentExprent assignExpr = (AssignmentExprent)exprent; if (assignExpr.getLeft().type == Exprent.EXPRENT_FIELD) { FieldExprent fExpr = (FieldExprent)assignExpr.getLeft(); String qName = child.classStruct.qualifiedName; if (fExpr.getClassname().equals(qName) && // process this class only mapFieldsToNewVars.containsKey(InterpreterUtil.makeUniqueKey(qName, fExpr.getName(), fExpr.getDescriptor().descriptorString))) { return 2; } } } if (child.type == ClassNode.CLASS_ANONYMOUS && CodeConstants.INIT_NAME.equals(method.methodStruct.getName()) && exprent.type == Exprent.EXPRENT_INVOCATION) { InvocationExprent invokeExpr = (InvocationExprent)exprent; if (invokeExpr.getFunctype() == InvocationExprent.TYP_INIT) { // invocation of the super constructor in an anonymous class child.superInvocation = invokeExpr; // FIXME: save original names of parameters return 2; } } replaceExprent(exprent); return 0; }
private static void addTracer(StructClass cls, StructMethod method, BytecodeMappingTracer tracer) { StructLineNumberTableAttribute table = method.getAttribute(StructGeneralAttribute.ATTRIBUTE_LINE_NUMBER_TABLE); tracer.setLineNumberTable(table); String key = InterpreterUtil.makeUniqueKey(method.getName(), method.getDescriptor()); DecompilerContext.getBytecodeSourceMapper().addTracer(cls.qualifiedName, key, tracer); }
public ClassNode(String content_class_name, String content_method_name, String content_method_descriptor, int content_method_invocation_type, String lambda_class_name, String lambda_method_name, String lambda_method_descriptor, StructClass classStruct) { // lambda class constructor this.type = CLASS_LAMBDA; this.classStruct = classStruct; // 'parent' class containing the static function lambdaInformation = new LambdaInformation(); lambdaInformation.method_name = lambda_method_name; lambdaInformation.method_descriptor = lambda_method_descriptor; lambdaInformation.content_class_name = content_class_name; lambdaInformation.content_method_name = content_method_name; lambdaInformation.content_method_descriptor = content_method_descriptor; lambdaInformation.content_method_invocation_type = content_method_invocation_type; lambdaInformation.content_method_key = InterpreterUtil.makeUniqueKey(lambdaInformation.content_method_name, lambdaInformation.content_method_descriptor); anonymousClassType = new VarType(lambda_class_name, true); boolean is_method_reference = (content_class_name != classStruct.qualifiedName); if (!is_method_reference) { // content method in the same class, check synthetic flag StructMethod mt = classStruct.getMethod(content_method_name, content_method_descriptor); is_method_reference = !mt.isSynthetic(); // if not synthetic -> method reference } lambdaInformation.is_method_reference = is_method_reference; lambdaInformation.is_content_method_static = (lambdaInformation.content_method_invocation_type == CodeConstants.CONSTANT_MethodHandle_REF_invokeStatic); // FIXME: redundant? }
String key = InterpreterUtil.makeUniqueKey(fExpr.getClassname(), fExpr.getName(), fExpr.getDescriptor().descriptorString); if (mapFieldsToNewVars.containsKey(key)) {
node.classStruct.qualifiedName.equals(attr.getClassName()) && node.classStruct.getMethod(attr.getMethodName(), attr.getMethodDescriptor()) != null) { child.enclosingMethod = InterpreterUtil.makeUniqueKey(attr.getMethodName(), attr.getMethodDescriptor()); continue;
public static void buildAssertions(ClassNode node) { ClassWrapper wrapper = node.getWrapper(); StructField field = findAssertionField(node); if (field != null) { String key = InterpreterUtil.makeUniqueKey(field.getName(), field.getDescriptor()); boolean res = false; for (MethodWrapper meth : wrapper.getMethods()) { RootStatement root = meth.root; if (root != null) { res |= replaceAssertions(root, wrapper.getClassStruct().qualifiedName, key); } } if (res) { // hide the helper field wrapper.getHiddenMembers().add(key); } } }
.add(InterpreterUtil.makeUniqueKey(fd.getName(), fd.getDescriptor())); // hide synthetic field return ((ConstExprent)invexpr.getLstParameters().get(0)).getValue().toString();
private static boolean collapseInlinedClass14(Statement stat) { boolean ret = class14Builder.match(stat); if (ret) { String class_name = (String)class14Builder.getVariableValue("$classname$"); AssignmentExprent assignment = (AssignmentExprent)class14Builder.getVariableValue("$assignfield$"); FieldExprent fieldExpr = (FieldExprent)class14Builder.getVariableValue("$field$"); assignment.replaceExprent(assignment.getRight(), new ConstExprent(VarType.VARTYPE_CLASS, class_name, null)); List<Exprent> data = new ArrayList<>(stat.getFirst().getExprents()); stat.setExprents(data); SequenceHelper.destroyAndFlattenStatement(stat); ClassWrapper wrapper = (ClassWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_WRAPPER); if (wrapper != null) { wrapper.getHiddenMembers().add(InterpreterUtil.makeUniqueKey(fieldExpr.getName(), fieldExpr.getDescriptor().descriptorString)); } } return ret; } }
String keyField = InterpreterUtil.makeUniqueKey(fExpr.getName(), fExpr.getDescriptor().descriptorString); if (!wrapper.getStaticFieldInitializers().containsKey(keyField)) { wrapper.getStaticFieldInitializers().addWithKey(assignExpr.getRight(), keyField);
(fd.isSynthetic() || noSynthFlag && possiblySyntheticField(fd))) { field = InterpreterUtil.makeUniqueKey(left.getName(), left.getDescriptor().descriptorString); break;
String keyField = InterpreterUtil.makeUniqueKey(fd.getName(), fd.getDescriptor());
for (int i = 0; i < length; i++) { StructField field = new StructField(in, this); fields.addWithKey(field, InterpreterUtil.makeUniqueKey(field.getName(), field.getDescriptor())); for (int i = 0; i < length; i++) { StructMethod method = new StructMethod(in, this); methods.addWithKey(method, InterpreterUtil.makeUniqueKey(method.getName(), method.getDescriptor()));
fieldInClassInit = true; if (node.getWrapper() != null && node.getWrapper().getHiddenMembers().contains(InterpreterUtil.makeUniqueKey(fd.getName(), fd.getDescriptor()))) { hiddenField = true;