本文整理汇总了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();
}
}
}
}
示例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);
}
示例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);
}
}
}
示例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();
}
示例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);
}
示例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));
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}