当前位置: 首页>>代码示例>>Java>>正文


Java FieldNode类代码示例

本文整理汇总了Java中org.objectweb.asm.tree.FieldNode的典型用法代码示例。如果您正苦于以下问题:Java FieldNode类的具体用法?Java FieldNode怎么用?Java FieldNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FieldNode类属于org.objectweb.asm.tree包,在下文中一共展示了FieldNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeBootstrapMethod

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
private static void removeBootstrapMethod(ClassNode classNode) {
    Iterator<MethodNode> iterator = classNode.methods.iterator();
    while (iterator.hasNext()) {
        MethodNode methodNode = iterator.next();
        if (methodNode.desc.equalsIgnoreCase("(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Class;Ljava/lang/String;I)Ljava/lang/invoke/CallSite;")) {
            iterator.remove();
        }
    }
    
    if (classNode.superName.equals("org/bukkit/plugin/java/JavaPlugin") || classNode.superName.equals("net/md_5/bungee/api/plugin/Plugin")) {
        for (Iterator<FieldNode> it = classNode.fields.iterator(); it.hasNext() ;) {
            FieldNode fieldNode = it.next();
            if (fieldNode.access == 9 && fieldNode.desc.equalsIgnoreCase("I") && fieldNode.name.length() == 36) {
                it.remove();
            } else if (fieldNode.access == 9 && fieldNode.desc.equalsIgnoreCase("Ljava/lang/String;") && fieldNode.name.length() == 36) {
                it.remove();
            }
        }
    }
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:21,代码来源:InjectorRemover.java

示例2: toClosureFieldInstance

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
public RunMethod.ClosureFieldInstance toClosureFieldInstance() {
  assert (this.isClosed());

  FieldNode fieldNode = instanceFieldNode();

  InsnList il = new InsnList();
  il.add(new VarInsnNode(ALOAD, 0));
  il.add(instantiationInsns());
  il.add(new FieldInsnNode(
      PUTFIELD,
      context.thisClassType().getInternalName(),
      instanceFieldName(),
      instanceType().getDescriptor()));

  return new RunMethod.ClosureFieldInstance(instanceFieldNode(), il);
}
 
开发者ID:kroepke,项目名称:luna,代码行数:17,代码来源:BytecodeEmitVisitor.java

示例3: process

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
@Override
public void process() {
  boolean issueFound;
  for (FieldNode fieldNode : getClassNode().fields) {
    int access = fieldNode.access;
    String name = fieldNode.name;
    String desc = fieldNode.desc;
    String signature = fieldNode.signature;
    Object value = fieldNode.value;
    logger.trace("visitField: access={}, name={}, desc={}, signature={}, value={}", access, name, desc, signature, value);
    issueFound = RuleHelper.isValidField(field, access, name, desc, signature, value);
    if (issueFound) {
      ReportItem reportItem = new ReportItem(getRuleName(), showInReport()).addProperty("Field name", name);
      itemsFound().add(reportItem);
      setIssueFound(issueFound);
    }
  }
}
 
开发者ID:fergarrui,项目名称:custom-bytecode-analyzer,代码行数:19,代码来源:CustomFieldVisitor.java

示例4: setupFieldsFrame

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
private void setupFieldsFrame() {
	frameFields = new JInternalFrame("Fields");
	frameFields.setResizable(true);
	frameFields.setIconifiable(true);
	frameFields.setBounds(frameClass.getWidth() + 11, 11, 180, 140);
	frameFields.setVisible(true);
	frameFields.setLayout(new BorderLayout());
	fields = new JList<>();
	fields.setCellRenderer(new MemberNodeRenderer());
	fields.addMouseListener(new MemberNodeClickListener(this, node, fields));
	DefaultListModel<FieldNode> model = new DefaultListModel<>();
	for (FieldNode fn : node.fields) {
		model.addElement(fn);
	}
	if (node.fields.size() == 0) {
		fields.setVisibleRowCount(5);
		fields.setPrototypeCellValue(new FieldNode(0, "Add_A_Field", "Ljava/lang/Object;", null, null));
	}
	fields.setModel(model);
	frameFields.add(new JScrollPane(fields), BorderLayout.CENTER);
	frameFields.pack();
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:23,代码来源:ClassDisplayPanel.java

示例5: searchField

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
private void searchField(String name, String desc, boolean exact) {
	DefaultTreeModel model = setup();
	search((cn) -> {
		for (FieldNode f : cn.fields) {
			boolean match = false;
			if (exact) {
				match = f.name.equals(name) && f.desc.equals(desc);
			} else {
				match = f.name.contains(name) && f.desc.contains(desc);
			}
			if (match) {
				ASMTreeNode genClass = Swing.getOrCreateNode(model, cn);
				ASMTreeNode genMethod = genClass.getChild(f.name);
				if (genMethod == null) {
					genMethod = new ASMFieldTreeNode(f.desc + " " + f.name, cn, f);
				}
				genClass.add(genMethod);
			}
		}
	});
	setTreeModel(model);
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:23,代码来源:SearchPanel.java

示例6: mouseReleased

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
@Override
public void mouseReleased(MouseEvent e) {
	int button = e.getButton();
	// If not left-click, enforce selection at the given location
	if (button != MouseEvent.BUTTON1) {
		int index = list.locationToIndex(e.getPoint());
		list.setSelectedIndex(index);
	}
	Object value = list.getSelectedValue();
	// Middle-click to open editor
	// Right-click to open context menu
	if (value != null && button == MouseEvent.BUTTON2) {
		// TODO: Allow users to choose custom middle-click actions
		if (value instanceof FieldNode) {
			display.openDefinition((FieldNode) value);
		} else if (value instanceof MethodNode) {
			display.openOpcodes((MethodNode) value);
		}
	} else if (button == MouseEvent.BUTTON3) {
		createContextMenu(value, e.getX(), e.getY(), isMethodList(list));
	}
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:23,代码来源:MemberNodeClickListener.java

示例7: modifyClass

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
/**
 * Modifies a {@link ClassNode} to clear final flags and rewrite byte code.
 */
@SuppressWarnings("unchecked")
private void modifyClass(ClassNode classNode) {
    // Make the class not final.
    classNode.access &= ~Opcodes.ACC_FINAL;
    
    List<MethodNode> methodNodes = classNode.methods;
    for (MethodNode methodNode : methodNodes) {
        methodNode.access &= ~Opcodes.ACC_FINAL;
        fixMethodBody(methodNode, classNode);
    }
    
    List<FieldNode> fieldNodes = classNode.fields;
    for (FieldNode fieldNode : fieldNodes) {
        // Make public instance fields non-final. This is needed e.g. to "mock" SyncResult.stats.
        if ((fieldNode.access & Opcodes.ACC_PUBLIC) != 0 &&
                (fieldNode.access & Opcodes.ACC_STATIC) == 0) {
            fieldNode.access &= ~Opcodes.ACC_FINAL;
        }
    }
    
    List<InnerClassNode> innerClasses = classNode.innerClasses;
    for (InnerClassNode innerClassNode : innerClasses) {
        innerClassNode.access &= ~Opcodes.ACC_FINAL;
    }
}
 
开发者ID:codezjx,项目名称:MockableJarGenerator,代码行数:29,代码来源:MockableJarGenerator.java

示例8: getAccess

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
public int getAccess(boolean field, String owner, String name, String descriptor) {
    ClassNode classNode = this.classNodes.get(owner);
    if (classNode != null) {
        if (field) {
            for (FieldNode fieldNode : classNode.fields) {
                if (fieldNode.name.equals(name) && fieldNode.desc.equals(descriptor)) {
                    return fieldNode.access;
                }
            }
        } else {
            for (MethodNode methodNode : classNode.methods) {
                if (methodNode.name.equals(name) && methodNode.desc.equals(descriptor)) {
                    return methodNode.access;
                }
            }
        }
    }
    return -1;
}
 
开发者ID:PaperModLoader,项目名称:Book,代码行数:20,代码来源:Mappings.java

示例9: obfuscate

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
@Override
public ArrayList<ClassNode> obfuscate(ArrayList<ClassNode> classes) throws Throwable {
	classes.parallelStream().forEach((cn) -> {
		ExecutorService service = Executors.newCachedThreadPool();
		((List<MethodNode>) cn.methods).parallelStream().forEach(mn -> service.submit(new CodeHider(mn)));
		((List<FieldNode>) cn.fields).parallelStream().forEach(fn -> service.submit(new CodeHider(fn)));

		service.shutdown();
		try {
			service.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
		} catch(Throwable t) {
			t.printStackTrace();
		}
	});

	return classes;
}
 
开发者ID:MoofMonkey,项目名称:NeonObf,代码行数:18,代码来源:CodeHider.java

示例10: modifyClass

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
/**
 * Modifies a {@link ClassNode} to clear final flags and rewrite byte code.
 */
@SuppressWarnings("unchecked")
private void modifyClass(ClassNode classNode) {
    // Make the class not final.
    classNode.access &= ~Opcodes.ACC_FINAL;

    List<MethodNode> methodNodes = classNode.methods;
    for (MethodNode methodNode : methodNodes) {
        methodNode.access &= ~Opcodes.ACC_FINAL;
        fixMethodBody(methodNode, classNode);
    }

    List<FieldNode> fieldNodes = classNode.fields;
    for (FieldNode fieldNode : fieldNodes) {
        // Make public instance fields non-final. This is needed e.g. to "mock" SyncResult.stats.
        if ((fieldNode.access & Opcodes.ACC_PUBLIC) != 0 &&
                (fieldNode.access & Opcodes.ACC_STATIC) == 0) {
            fieldNode.access &= ~Opcodes.ACC_FINAL;
        }
    }

    List<InnerClassNode> innerClasses = classNode.innerClasses;
    for (InnerClassNode innerClassNode : innerClasses) {
        innerClassNode.access &= ~Opcodes.ACC_FINAL;
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:MockableJarGenerator.java

示例11: isStaticInnerClass

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
/**
 * Returns true if the given class node represents a static inner class.
 *
 * @param classNode the inner class to be checked
 * @return true if the class node represents an inner class that is static
 */
public static boolean isStaticInnerClass(@NonNull ClassNode classNode) {
    // Note: We can't just filter out static inner classes like this:
    //     (classNode.access & Opcodes.ACC_STATIC) != 0
    // because the static flag only appears on methods and fields in the class
    // file. Instead, look for the synthetic this pointer.

    @SuppressWarnings("rawtypes") // ASM API
    List fieldList = classNode.fields;
    for (Object f : fieldList) {
        FieldNode field = (FieldNode) f;
        if (field.name.startsWith("this$") && (field.access & Opcodes.ACC_SYNTHETIC) != 0) {
            return false;
        }
    }

    return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:LintUtils.java

示例12: findField

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
@Nullable
private FieldNode findField(
        @NonNull ClassNode classNode,
        @NonNull String owner,
        @NonNull String name) {
    ClassNode current = classNode;
    while (current != null) {
        if (owner.equals(current.name)) {
            @SuppressWarnings("rawtypes") // ASM API
            List fieldList = current.fields;
            for (Object f : fieldList) {
                FieldNode field = (FieldNode) f;
                if (field.name.equals(name)) {
                    return field;
                }
            }
            return null;
        }
        current = getOuterClassNode(current);
    }
    return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:LintDriver.java

示例13: find

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
@Override
public List<FieldHook> find(ClassNode cn) {
	List<FieldHook> list = new ArrayList<FieldHook>();

	for (FieldNode fn : cn.fields) {
		String refactored = getRefactoredNameByType(fn.desc);

		if (refactored == null)
			continue;

		if (refactored.equals("Position"))
			list.add(asFieldHook(fn, "position"));
	}

	return list;
}
 
开发者ID:8BitPlus,项目名称:BitPlus,代码行数:17,代码来源:EntityAnalyser.java

示例14: transformResourceLoader

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
private byte[] transformResourceLoader(byte[] before) {
    ClassNode classNode = new ClassNode();
    ClassReader reader = new ClassReader(before);
    reader.accept(classNode, 0);

    for (MethodNode m : classNode.methods) {
        if (m.name.equals("preInit")) {
            m.visibleAnnotations.remove(0);// Remove @Mod.EventHandler
        }
    }

    for (FieldNode f : classNode.fields) {
        if (f.name.equals("INSTANCE"))
            f.visibleAnnotations.remove(0);// Remove @Mod.Instance("ResourceLoader")
    }

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    classNode.accept(cw);
    byte[] arr = cw.toByteArray();
    System.out.println("Transformed ResourceLoader!");
    return arr;
}
 
开发者ID:AlexIIL,项目名称:BetterLoadingScreen_1.7,代码行数:23,代码来源:BetterLoadingScreenTransformer.java

示例15: find

import org.objectweb.asm.tree.FieldNode; //导入依赖的package包/类
@Override
public List<FieldHook> find(ClassNode cn) {
	List<FieldHook> list = new ArrayList<FieldHook>();

	for (FieldNode fn : cn.fields) {
		String refactored = getRefactoredNameByType(fn.desc);

		if (refactored == null)
			continue;

		if (refactored.equals("BGMDownloader"))
			list.add(asFieldHook(fn, "instance"));
	}

	return list;
}
 
开发者ID:8BitPlus,项目名称:BitPlus,代码行数:17,代码来源:BGMDownloaderAnalyser.java


注:本文中的org.objectweb.asm.tree.FieldNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。