コード例 #1
0
  public void processClassReferences(ClassNode node) {

    ClassWrapper wrapper = node.wrapper;

    //		int major_version = wrapper.getClassStruct().major_version;
    //		int minor_version = wrapper.getClassStruct().minor_version;
    //
    //		if(major_version > 48 || (major_version == 48 && minor_version > 0)) {
    //			// version 1.5 or above
    //			return;
    //		}

    if (wrapper.getClassStruct().isVersionGE_1_5()) {
      // version 1.5 or above
      return;
    }

    // find the synthetic method Class class$(String) if present
    HashMap<ClassWrapper, MethodWrapper> mapClassMeths = new HashMap<ClassWrapper, MethodWrapper>();
    mapClassMethods(node, mapClassMeths);

    if (mapClassMeths.isEmpty()) {
      return;
    }

    HashSet<ClassWrapper> setFound = new HashSet<ClassWrapper>();
    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()));
      }
    }
  }
コード例 #2
0
  private static void processClassRec(
      ClassNode node,
      final HashMap<ClassWrapper, MethodWrapper> mapClassMeths,
      final HashSet<ClassWrapper> setFound) {

    final ClassWrapper wrapper = node.wrapper;

    // search code
    for (MethodWrapper meth : wrapper.getMethods()) {

      RootStatement root = meth.root;
      if (root != null) {

        DirectGraph graph = meth.getOrBuildGraph();

        graph.iterateExprents(
            new DirectGraph.ExprentIterator() {
              public int processExprent(Exprent exprent) {
                for (Entry<ClassWrapper, MethodWrapper> ent : mapClassMeths.entrySet()) {
                  if (replaceInvocations(exprent, ent.getKey(), ent.getValue())) {
                    setFound.add(ent.getKey());
                  }
                }
                return 0;
              }
            });
      }
    }

    // search initializers
    for (int j = 0; j < 2; j++) {
      VBStyleCollection<Exprent, String> initializers =
          j == 0 ? wrapper.getStaticFieldInitializers() : wrapper.getDynamicFieldInitializers();

      for (int i = 0; i < initializers.size(); i++) {
        for (Entry<ClassWrapper, MethodWrapper> ent : mapClassMeths.entrySet()) {
          Exprent exprent = initializers.get(i);
          if (replaceInvocations(exprent, ent.getKey(), ent.getValue())) {
            setFound.add(ent.getKey());
          }

          String cl = isClass14Invocation(exprent, ent.getKey(), ent.getValue());
          if (cl != null) {
            initializers.set(
                i, new ConstExprent(VarType.VARTYPE_CLASS, cl.replace('.', '/'), exprent.bytecode));
            setFound.add(ent.getKey());
          }
        }
      }
    }

    // iterate nested classes
    for (ClassNode nd : node.nested) {
      processClassRec(nd, mapClassMeths, setFound);
    }
  }