Package jadx.core.dex.nodes

Examples of jadx.core.dex.nodes.FieldNode


   */
  private static void processStaticFieldAssign(ClassNode cls, IndexInsnNode insn) {
    FieldInfo field = (FieldInfo) insn.getIndex();
    String thisClass = cls.getFullName();
    if (field.getDeclClass().getFullName().equals(thisClass)) {
      FieldNode fn = cls.searchField(field);
      if (fn != null && fn.getAccessFlags().isFinal()) {
        fn.remove(AType.FIELD_VALUE);
      }
    }
  }
View Full Code Here


        return ((ConstStringNode) parInsn).getString();
      case CONST_CLASS:
        return ((ConstClassNode) parInsn).getClsType();
      case SGET:
        FieldInfo f = (FieldInfo) ((IndexInsnNode) parInsn).getIndex();
        FieldNode fieldNode = dex.resolveField(f);
        if (fieldNode != null) {
          FieldValueAttr attr = fieldNode.get(AType.FIELD_VALUE);
          if (attr != null) {
            return attr.getValue();
          }
        } else {
          LOG.warn("Field {} not found in dex {}", f, dex);
View Full Code Here

    if (classAnnotationsOffset != 0) {
      cls.addAttr(readAnnotationSet(classAnnotationsOffset));
    }

    for (int i = 0; i < fieldsCount; i++) {
      FieldNode f = cls.searchFieldById(section.readInt());
      f.addAttr(readAnnotationSet(section.readInt()));
    }

    for (int i = 0; i < annotatedMethodsCount; i++) {
      MethodNode m = cls.searchMethodById(section.readInt());
      m.addAttr(readAnnotationSet(section.readInt()));
View Full Code Here

    }
    EnumMapInfo enumMapInfo = checkEnumMapAccess(mth, wrapInsn);
    if (enumMapInfo == null) {
      return null;
    }
    FieldNode enumMapField = enumMapInfo.getMapField();
    InsnArg invArg = enumMapInfo.getArg();

    EnumMapAttr.KeyValueMap valueMap = getEnumMap(mth, enumMapField);
    if (valueMap == null) {
      return null;
    }
    Object[] keys = insn.getKeys();
    for (Object key : keys) {
      Object newKey = valueMap.get(key);
      if (newKey == null) {
        return null;
      }
    }
    // replace confirmed
    if (!insn.replaceArg(arg, invArg)) {
      return null;
    }
    for (int i = 0; i < keys.length; i++) {
      keys[i] = valueMap.get(keys[i]);
    }
    enumMapField.add(AFlag.DONT_GENERATE);
    checkAndHideClass(enumMapField.getParentClass());
    return null;
  }
View Full Code Here

    EnumMapInfo mapInfo = checkEnumMapAccess(mth, aputInsn);
    if (mapInfo == null) {
      return;
    }
    InsnArg enumArg = mapInfo.getArg();
    FieldNode field = mapInfo.getMapField();
    if (field == null || !enumArg.isInsnWrap()) {
      return;
    }
    InsnNode sget = ((InsnWrapArg) enumArg).getWrapInsn();
    if (!(sget instanceof IndexInsnNode)) {
      return;
    }
    Object index = ((IndexInsnNode) sget).getIndex();
    if (!(index instanceof FieldInfo)) {
      return;
    }
    FieldNode fieldNode = mth.dex().resolveField((FieldInfo) index);
    if (fieldNode == null) {
      return;
    }
    int literal = (int) ((LiteralArg) litArg).getLiteral();
    mapAttr.add(field, literal, fieldNode);
View Full Code Here

    }
    Object index = ((IndexInsnNode) sgetInsn).getIndex();
    if (!(index instanceof FieldInfo)) {
      return null;
    }
    FieldNode enumMapField = mth.dex().resolveField((FieldInfo) index);
    if (enumMapField == null || !enumMapField.getAccessFlags().isSynthetic()) {
      return null;
    }
    return new EnumMapInfo(inv.getArg(0), enumMapField);
  }
View Full Code Here

  @Test
  public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();

    FieldNode field = cls.searchFieldByName("field");
    MethodNode func = cls.searchMethodByName("func()V");
    ClassNode inner = cls.getInnerClasses().get(0);
    MethodNode innerFunc = inner.searchMethodByName("innerFunc()V");
    MethodNode innerFunc2 = inner.searchMethodByName("innerFunc2()V");
    MethodNode innerFunc3 = inner.searchMethodByName("innerFunc3()V");
    FieldNode innerField = inner.searchFieldByName("innerField");

    // check source lines (available only for instructions and methods)
    int testClassLine = 18;
    assertEquals(testClassLine + 3, func.getSourceLine());
    assertEquals(testClassLine + 9, innerFunc.getSourceLine());
View Full Code Here

    return TypeGen.literalToString(arg.getLiteral(), arg.getType());
  }

  private void instanceField(CodeWriter code, FieldInfo field, InsnArg arg) throws CodegenException {
    ClassNode pCls = mth.getParentClass();
    FieldNode fieldNode = pCls.searchField(field);
    while (fieldNode == null
        && pCls.getParentClass() != pCls
        && pCls.getParentClass() != null) {
      pCls = pCls.getParentClass();
      fieldNode = pCls.searchField(field);
    }
    if (fieldNode != null) {
      FieldReplaceAttr replace = fieldNode.get(AType.FIELD_REPLACE);
      if (replace != null) {
        FieldInfo info = replace.getFieldInfo();
        if (replace.isOuterClass()) {
          useClass(code, info.getDeclClass());
          code.add(".this");
View Full Code Here

      } else {
        clsGen.useClass(code, declClass);
      }
      code.add('.');
    }
    FieldNode fieldNode = clsGen.getClassNode().dex().resolveField(field);
    if (fieldNode != null) {
      code.attachAnnotation(fieldNode);
    }
    code.add(field.getName());
  }
View Full Code Here

      List<Object> keys = sw.getKeys().get(i);
      IContainer c = sw.getCases().get(i);
      for (Object k : keys) {
        code.startLine("case ");
        if (k instanceof FieldNode) {
          FieldNode fn = (FieldNode) k;
          if (fn.getParentClass().isEnum()) {
            code.add(fn.getName());
          } else {
            staticField(code, fn.getFieldInfo());
          }
        } else if (k instanceof IndexInsnNode) {
          staticField(code, (FieldInfo) ((IndexInsnNode) k).getIndex());
        } else {
          code.add(TypeGen.literalToString((Integer) k, arg.getType()));
View Full Code Here

TOP

Related Classes of jadx.core.dex.nodes.FieldNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.