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(); } } } }
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); }
@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); } } }
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(); }
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); }
@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)); } }
/** * 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; } }
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; }
@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; }
/** * 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; }
@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; }
@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; }
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; }
@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; }
/*** * * * @param fn * @param inst * @param dsi */ private void writeValue(String owner, FieldNode fn, InsnList inst, PdxSItem dsi) { String desc = new StringBuffer("(Ljava/lang/String;").append(fn.desc) .append(")Lcom/gemstone/gemfire/pdx/PdxWriter;").toString(); inst.add(new VarInsnNode(ALOAD, 1)); inst.add(new LdcInsnNode(fn.name)); inst.add(new VarInsnNode(ALOAD, 0)); inst.add(new FieldInsnNode(GETFIELD, owner, fn.name, fn.desc)); // add INVOKEVIRTUAL method if (PdxConstants.TYPE_BYTECODE_BYTE_B.equals(fn.desc)) // data type ->byte inst.add(AsmHelper.newMethodInsnNode(INVOKEVIRTUAL, PdxConstants.TYPE_BYTECODE_BYTE, "byteValue", fn.desc, false)); else if (PdxConstants.TYPE_BYTECODE_BOOL_Z.equals(fn.desc)) // data type -> // boolean inst.add(AsmHelper.newMethodInsnNode(INVOKEVIRTUAL, PdxConstants.TYPE_BYTECODE_BOOL, "booleanValue", fn.desc, false)); inst.add(AsmHelper.newMethodInsnNode(INVOKEINTERFACE, PdxConstants.PDX_WRITER_VALUE, dsi.toMethod, desc, true)); inst.add(new InsnNode(POP)); }
/*** * * @param inst * @param dsi */ private void fieldValueIsNull(FieldNode fn, InsnList inst) { if ("Ljava/lang/Integer;".equals(fn.desc)) { inst.add(new InsnNode(ICONST_0)); inst.add(AsmHelper.newMethodInsnNode(INVOKESTATIC, "java/lang/Integer", "valueOf", "(J)Ljava/lang/Integer;", false)); } else if ("Ljava/lang/Long;".equals(fn.desc)) { inst.add(new InsnNode(LCONST_0)); inst.add(AsmHelper.newMethodInsnNode(INVOKESTATIC, "java/lang/Lang", "valueOf", "(J)Ljava/lang/Long;", false)); } else if ("Ljava/lang/Double;".equals(fn.desc)) { inst.add(new InsnNode(DCONST_0)); inst.add(AsmHelper.newMethodInsnNode(INVOKESTATIC, "java/lang/Double", "valueOf", "(J)Ljava/lang/Double;", false)); } else if("Ljava/lang/Short;".equals(fn.desc)) { inst.add(new InsnNode(DCONST_0)); inst.add(AsmHelper.newMethodInsnNode(INVOKESTATIC, "java/lang/Short", "valueOf", "(J)Ljava/lang/Short;", false)); } }
@Mapping(providesFields={ "net/minecraft/util/MainOrOffHand MAIN_HAND Lnet/minecraft/util/MainOrOffHand;", "net/minecraft/util/MainOrOffHand OFF_HAND Lnet/minecraft/util/MainOrOffHand;" }, depends="net/minecraft/util/MainOrOffHand") public boolean processMainOrOffHand() { ClassNode mainOrOffHand = getClassNodeFromMapping("net/minecraft/util/MainOrOffHand"); if (mainOrOffHand == null) return false; List<FieldNode> fields = getMatchingFields(mainOrOffHand, null, "L" + mainOrOffHand.name + ";"); if (fields.size() == 2) { addFieldMapping("net/minecraft/util/MainOrOffHand MAIN_HAND Lnet/minecraft/util/MainOrOffHand;", mainOrOffHand.name + " " + fields.get(0).name + " " + fields.get(0).desc); addFieldMapping("net/minecraft/util/MainOrOffHand OFF_HAND Lnet/minecraft/util/MainOrOffHand;", mainOrOffHand.name + " " + fields.get(1).name + " " + fields.get(1).desc); } return true; }
private void implementInterface(ClassNode cn) { MethodNode toMethod = new MethodNode(ACC_PUBLIC, "toData", "(Ljava/io/DataOutput;)V", null, new String[] { "java/io/IOException" }); InsnList instToMethod = toMethod.instructions; MethodNode fromMethod = new MethodNode(ACC_PUBLIC, "fromData", "(Ljava/io/DataInput;)V", null, new String[] { "java/io/IOException", "java/lang/ClassNotFoundException" }); InsnList instFromMethod = fromMethod.instructions; for (int i = 0; i < cn.fields.size(); i++) { FieldNode fn = (FieldNode) cn.fields.get(i); fp.toMethod(cn.name, fn, instToMethod); fp.fromMethod(cn.name, fn, instFromMethod); } instToMethod.add(new InsnNode(RETURN)); cn.methods.add(toMethod); instFromMethod.add(new InsnNode(RETURN)); cn.methods.add(fromMethod); // if (DomainMojoHelper.log().isDebugEnabled()) // DomainMojoHelper.log().debug(cn.name + " add toData and fromData method."); }
private boolean isKeyField(FieldNode fn) { if (fn.visibleAnnotations != null) { for (Object o : fn.visibleAnnotations) { AnnotationNode an = (AnnotationNode) o; if (AN_Key.equals(an.desc)) { if (DomainMojoHelper.log().isDebugEnabled()) DomainMojoHelper.log().debug("Found key field:" + fn.name + "," + fn.desc); return true; } } } return false; }
private void addValue2KeySimple(ClassNode domain, ClassNode mapper, FieldNode key) { if (DomainMojoHelper.log().isDebugEnabled()) DomainMojoHelper.log().debug("Add value2key(V)K method, key field:" + key.name); String s1 = key.name.substring(0, 1); String s2 = key.name.substring(1); String getMethod = "get" + s1.toUpperCase() + s2; String fullDesc = AsmHelper.toFullName(key.desc); MethodNode mn = new MethodNode(ACC_PUBLIC, "value2Key", "(L" + domain.name + ";)" + fullDesc, null, null); InsnList insn = mn.instructions; insn.add(new VarInsnNode(ALOAD, 1)); insn.add(AsmHelper.newMethodInsnNode(INVOKEVIRTUAL, domain.name, getMethod, "()" + key.desc, false)); AsmHelper.addTypeConvert(insn, key.desc); insn.add(new InsnNode(ARETURN)); mapper.methods.add(mn); if (DomainMojoHelper.log().isDebugEnabled()) DomainMojoHelper.log().debug("Add value2key(V)K method, key field:" + key.name + " done."); }
@Mapping(providesFields={ "net/minecraft/util/ItemUseResult SUCCESS Lnet/minecraft/util/ItemUseResult;", "net/minecraft/util/ItemUseResult PASS Lnet/minecraft/util/ItemUseResult;", "net/minecraft/util/ItemUseResult FAIL Lnet/minecraft/util/ItemUseResult;" }, depends={ "net/minecraft/util/ItemUseResult" }) public boolean processItemUseResultClass() { ClassNode itemUseResult = getClassNodeFromMapping("net/minecraft/util/ItemUseResult"); if (itemUseResult == null) return false; List<FieldNode> fields = getMatchingFields(itemUseResult, null, "L" + itemUseResult.name + ";"); if (fields.size() == 3) { addFieldMapping("net/minecraft/util/ItemUseResult SUCCESS Lnet/minecraft/util/ItemUseResult;", itemUseResult.name + " " + fields.get(0).name + " " + fields.get(0).desc); addFieldMapping("net/minecraft/util/ItemUseResult PASS Lnet/minecraft/util/ItemUseResult;", itemUseResult.name + " " + fields.get(1).name + " " + fields.get(1).desc); addFieldMapping("net/minecraft/util/ItemUseResult FAIL Lnet/minecraft/util/ItemUseResult;", itemUseResult.name + " " + fields.get(2).name + " " + fields.get(2).desc); } return true; }
private static FieldDeclaration fieldDeclaration(FieldNode fieldNode) { return new FieldDeclaration() { @Override public int getModifier() { return fieldNode.access; } @Override public String getTypeName() { return Type.getType(fieldNode.desc).getClassName(); } @Override public String getName() { return fieldNode.name; } @Override public FieldDom build(ClassDeclaration classDeclaration) { return null; } }; }
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { // purge based on FieldNode references for (FieldNode fieldToPurge : fieldsToPurge) { if (fieldToPurge.signature != null && signature != null) { if (fieldToPurge.signature.equals(signature)) { if (fieldToPurge.name.equals(name) && fieldToPurge.desc.equals(desc)) { // return null in order to remove this field Log.info("Purged Field: " + name); return null; } } } else { // signature was null, fall back to name and description only if (fieldToPurge.name.equals(name) && fieldToPurge.desc.equals(desc)) { // return null in order to remove this field Log.info("Purged Field: " + name); return null; } } } // make the next visitor visit this field, in order to keep it return super.visitField(access, name, desc, signature, value); }
public byte[] mixin_do() { ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); writer.visit(V1_6, ACC_PUBLIC, newType, null, parentType, traitNode.interfaces.toArray(new String[traitNode.interfaces.size()])); writer.visitSource(traitType.substring(traitType.lastIndexOf("/") + 1) + ".java", null); transferParentFields(writer); transferTraitFields(writer); bridgeMethods(writer); boolean hasSelfObject = false; for (FieldNode f : parentNode.fields) { if (f.name.equals("_self")) { hasSelfObject = true; break; } } if (!hasSelfObject) writer.visitField(ACC_PUBLIC | ACC_SYNTHETIC, "_self", "Ljava/lang/Object;", null, null); return writer.toByteArray(); }
private void transferTraitFields(ClassWriter writer) { for (FieldNode f : traitNode.fields) { if (f.name.equals("_super")) continue; FieldVisitor v = writer.visitField(ACC_PUBLIC, f.name, f.desc, null, f.value); if (f.visibleAnnotations != null) { for (AnnotationNode a : f.visibleAnnotations) { AnnotationVisitor av = v.visitAnnotation(a.desc, true); Iterator<Object> it = a.values.iterator(); while (it.hasNext()) av.visit((String) it.next(), it.next()); } } v.visitEnd(); } }
/** * Handle transformation of fields defined in this class */ @SuppressWarnings("unchecked") private void processFields() { List<FieldNode> fields = cn.fields; for (FieldNode field : fields) { if (DescriptorMapping.getInstance().isTransformedField(className, field.name, field.desc)) { String newDesc = transformFieldDescriptor(className, field.name, field.desc); logger.info("Transforming field " + field.name + " from " + field.desc + " to " + newDesc); if (!newDesc.equals(field.desc)) TransformationStatistics.transformBooleanField(); field.desc = newDesc; } } }
public static FieldNode getFieldNodeFromMapping(ClassNode cn, String deobfMapping) { String mapping = getFieldMapping(deobfMapping); if (cn == null || mapping == null) return null; String[] split = mapping.split(" "); if (split.length < 3) return null; for (FieldNode field : cn.fields) { if (field.name.equals(split[1]) && field.desc.equals(split[2])) { return field; } } return null; }
@Mapping(providesFields={ "net/minecraft/client/Minecraft itemColors Lnet/minecraft/client/renderer/color/ItemColors;" }, provides={ }, depends={ "net/minecraft/client/Minecraft", "net/minecraft/client/renderer/color/ItemColors" }) public boolean processMinecraftClass3() { ClassNode minecraft = getClassNodeFromMapping("net/minecraft/client/Minecraft"); ClassNode itemColors = getClassNodeFromMapping("net/minecraft/client/renderer/color/ItemColors"); if (!MeddleUtil.notNull(minecraft, itemColors)) return false; List<FieldNode> fields = getMatchingFields(minecraft, null, "L" + itemColors.name + ";"); if (fields.size() == 1) { addFieldMapping("net/minecraft/client/Minecraft itemColors Lnet/minecraft/client/renderer/color/ItemColors;", minecraft.name + " " + fields.get(0).name + " " + fields.get(0).desc); } return true; }
@Mapping(provides="net/minecraft/client/network/NetHandlerPlayClient", depends="net/minecraft/client/entity/EntityPlayerSP") public boolean getNetHandlerPlayClientClass() { ClassNode playerSP = getClassNodeFromMapping("net/minecraft/client/entity/EntityPlayerSP"); if (playerSP == null) return false; for (FieldNode field : playerSP.fields) { Type t = Type.getType(field.desc); if (t.getSort() != Type.OBJECT) continue; if (DynamicMappings.searchConstantPoolForStrings(t.getClassName(), "MC|Brand", "disconnect.lost", "minecraft:container")) { addClassMapping("net/minecraft/client/network/NetHandlerPlayClient", t.getClassName()); return true; } } return false; }
public FieldHook asFieldHook(ClassHook c, String classAndName, String realName) { if (classAndName == null) return null; String[] parts = classAndName.split("\\."); ClassNode cn = Context.current().getClassNodes().get(parts[0]); for (Object oF : cn.fields) { FieldNode f = (FieldNode) oF; if (parts[1].equals(f.name)) { // String owner = foundHook.obfuscated(); // if(!owner.equals(f.owner.name)) { // // System.out.printf("[%b] %s.%s doesn't match %s for %s.%n", // Modifier.isStatic(f.access), f.owner.name, f.name, // foundHook.obfuscated(), realName); // owner = f.owner.name; // } return new FieldHook(foundHook).obfuscated(f.name).refactored(realName) .var(Constants.REAL_OWNER, f.owner.name).var(Constants.DESC, f.desc) .var(Constants.STATIC, Boolean.toString(Modifier.isStatic(f.access))); } } return null; }
@Mapping(provides="net/minecraft/block/state/BlockState", depends="net/minecraft/block/Block") public boolean getBlockStateClass() { ClassNode block = getClassNode(getClassMapping("net/minecraft/block/Block")); if (block == null) return false; for (FieldNode fn : block.fields) { Type t = Type.getType(fn.desc); if (t.getSort() != Type.OBJECT) continue; if (searchConstantPoolForStrings(t.getClassName(), "block", "properties", "Block: ", " has invalidly named property: ")) { addClassMapping("net/minecraft/block/state/BlockState", t.getClassName()); return true; } } return false; }
@Override // override Type.getLocalChildVariable public Container getLocalChildVariable(String field_name) throws CompileException { @SuppressWarnings("unchecked") List<FieldNode> fields = class_node.fields; FieldNode field = null; String type_name = null; AbsType child_type = null; Container container = null; boolean is_singleton = false; int len = fields.size(); for (int i = 0; i < len; i++) { field = fields.get(i); if (field_name.equals(field.name)) { type_name = TypeUtil.dsc2name(field.desc); if (type_name == null) { throw new CompileException( "Invalid Field Description(" + getName() + "." + field.name + "[" + field.desc + "]"); } // child_type = (AbsType)cpLoader.findClassFull(type_name); child_type = (AbsType) cpLoader.findNamedTypeFull(type_name); if (child_type == null) { throw new CompileException( "Failed to fined field class (" + getName() + "." + field.name + "[" + type_name + "])"); } is_singleton = ((field.access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC); container = new Container(field_name, Container.FORM_OBJMEMBER_VAR, false, is_singleton); container.initializeType(child_type); return container; } } return null; }
public FieldNode findField(ClassNode node, String name) { Iterator<FieldNode> fields = node.fields.iterator(); while (fields.hasNext()) { FieldNode f = fields.next(); if (f.name.equals(name)) return f; } return null; }
@Override public void transform(ClassNode cn) { // Don't process the class if it already implements ValueAccessor if (cn.interfaces.contains("clientapi/value/holder/ValueAccessor")) return; // Clear the cache for the new class fieldCache.clear(); current = 0; // Assume that any values annotated with @Label should be given accessors for (FieldNode fn : cn.fields) { if (fn.visibleAnnotations != null) { for (AnnotationNode an : fn.visibleAnnotations) { if (an.desc.equals("Lclientapi/util/annotation/Label;")) { for (int i = 0; i < an.values.size(); i++) { if (i % 2 == 0 && an.values.get(i).equals("id")) fieldCache.put(an.values.get(i + 1).toString(), fn); } } } } } // Don't process the class if there weren't any labeled fields if (fieldCache.isEmpty()) return; // Add the ValueAccessor interface and implement the required methods cn.interfaces.add("clientapi/value/holder/ValueAccessor"); createFieldGetter(cn); createFieldSetter(cn); }
private void update(FieldInstance field) { if (field == null) { ownerLabel.setText("-"); nameLabel.setText("-"); typeLabel.setText("-"); accessLabel.setText("-"); sigLabel.setText("-"); parentLabel.setText("-"); childLabel.setText("-"); readRefLabel.setText("-"); writeRefLabel.setText("-"); mapCommentLabel.setText("-"); } else { ownerLabel.setText(ClassInfoTab.getName(field.getCls())); nameLabel.setText(ClassInfoTab.getName(field)); typeLabel.setText(ClassInfoTab.getName(field.getType())); accessLabel.setText(Util.formatAccessFlags(field.getAccess(), AFElementType.Method)); FieldNode asmNode = field.getAsmNode(); sigLabel.setText(asmNode == null || asmNode.signature == null ? "-" : asmNode.signature); parentLabel.setText(!field.getParents().isEmpty() ? ClassInfoTab.format(field.getParents()) : "-"); childLabel.setText(!field.isFinal() ? ClassInfoTab.format(field.getChildren()) : "-"); readRefLabel.setText(ClassInfoTab.format(field.getReadRefs())); writeRefLabel.setText(ClassInfoTab.format(field.getWriteRefs())); mapCommentLabel.setText(field.getMappedComment() != null ? field.getMappedComment() : "-"); } }
private FieldInstance(ClassInstance cls, String origName, String desc, FieldNode asmNode, boolean nameObfuscated, int position, boolean isStatic) { super(cls, getId(origName, desc), origName, nameObfuscated, position, isStatic); this.type = cls.getEnv().getCreateClassInstance(desc); this.asmNode = asmNode; type.fieldTypeRefs.add(this); }
public FieldNode getFieldNode() { return new FieldNode( toAccessModifier(access), name, type.getType(), type.getGenericSignature(), null); }
private FieldNode instanceFieldNode() { return new FieldNode( ACC_PRIVATE + ACC_FINAL, instanceFieldName(), instanceType().getDescriptor(), null, null); }
private FieldNode instanceField() { return new FieldNode( ACC_PUBLIC + ACC_FINAL + ACC_STATIC, instanceFieldName(), thisClassType().getDescriptor(), null, null); }