@Override public void decorate(MutableClass mutableClass) { mutableClass.addInterface(Type.getInternalName(ShadowedObject.class)); mutableClass.addField(0, new FieldNode(Opcodes.ACC_PUBLIC, ShadowConstants.CLASS_HANDLER_DATA_FIELD_NAME, OBJECT_DESC, OBJECT_DESC, null)); addRoboGetDataMethod(mutableClass); }
((FieldNode) cf.fields.get(i)).accept(cv);
public AnnotationNode visitAnnotation(final String desc, final boolean visible) { return (AnnotationNode) fn.visitAnnotation(desc, visible); } };
/** * Checks that this class node is compatible with the given ASM API version. * This methods checks that this node, and all its nodes recursively, do not * contain elements that were introduced in more recent versions of the ASM * API than the given version. * * @param api * an ASM API version. Must be one of {@link Opcodes#ASM4} or * {@link Opcodes#ASM5}. */ public void check(final int api) { if (api == Opcodes.ASM4) { if (visibleTypeAnnotations != null && visibleTypeAnnotations.size() > 0) { throw new RuntimeException(); } if (invisibleTypeAnnotations != null && invisibleTypeAnnotations.size() > 0) { throw new RuntimeException(); } for (FieldNode f : fields) { f.check(api); } for (MethodNode m : methods) { m.check(api); } } }
fields.get(i).check(api);
@SuppressWarnings("unchecked") protected void writeSystemInfo() { node.fields.add(new FieldNode( ACC_PUBLIC + ACC_FINAL + ACC_STATIC, "$FN", Type.getDescriptor(String.class), node.fields.add(new FieldNode( ACC_PUBLIC + ACC_STATIC, "$TRC", Type.getDescriptor(TraceInfo[].class), node.fields.add(new FieldNode( ACC_PUBLIC + ACC_STATIC, "$MEM", Type.getDescriptor(Memory[].class), node.fields.add(new FieldNode( ACC_PUBLIC + ACC_STATIC, "$AMEM", Type.getDescriptor(Memory[][].class), node.fields.add(new FieldNode( ACC_PUBLIC + ACC_STATIC, "$CALL_FUNC_CACHE", Type.getDescriptor(FunctionCallCache.class), node.fields.add(new FieldNode( ACC_PUBLIC + ACC_STATIC, "$CALL_METH_CACHE", Type.getDescriptor(MethodCallCache.class), node.fields.add(new FieldNode( ACC_PUBLIC + ACC_STATIC, "$CALL_PROP_CACHE", Type.getDescriptor(PropertyCallCache.class),
@RequiresNonNull("type") private void addMixin(ClassNode mixinClassNode) { List<FieldNode> fieldNodes = mixinClassNode.fields; for (FieldNode fieldNode : fieldNodes) { if (!Modifier.isTransient(fieldNode.access)) { // this is needed to avoid serialization issues (even if the new field is // serializable, this can still cause issues in a cluster if glowroot is not // deployed on all nodes) throw new IllegalStateException( "@Mixin fields must be marked transient: " + mixinClassNode.name); } fieldNode.accept(this); } List<MethodNode> methodNodes = mixinClassNode.methods; for (MethodNode mn : methodNodes) { if (mn.name.equals("<init>")) { continue; } String[] exceptions = Iterables.toArray(mn.exceptions, String.class); MethodVisitor mv = cw.visitMethod(mn.access, mn.name, mn.desc, mn.signature, exceptions); mn.accept(new MethodRemapper(mv, new SimpleRemapper(mixinClassNode.name, type.getInternalName()))); } }
@Override public AnnotationVisitor visitAnnotation( final String desc, final boolean visible) { if (OBFUSCATE_DESCRIPTOR.equals(desc)) { needsObfuscation = true; if (value instanceof String) value = null; // erase return null; } else { return super.visitAnnotation(desc, visible); } } }
fn=new FieldNode(0,null,null,null,null); cn.fields.add(fn);
field.accept(this);
@Override public AnnotationVisitor visitAnnotation( final String desc, final boolean visible) { if (OBFUSCATE_DESCRIPTOR.equals(desc)) { needsObfuscation = true; if (value instanceof String) value = null; // erase return null; } else { return super.visitAnnotation(desc, visible); } } }
public FieldNode fieldNode() { return new FieldNode( ACC_PRIVATE + ACC_STATIC + ACC_FINAL, fieldName, fieldType.getDescriptor(), null, null); }
fields.get(i).accept(cv);
@Override public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) { FieldNode fn = new FieldNode(access, name, desc, signature, value); fields.add(fn); return fn; }
fields.get(i).accept(classVisitor);
@Override public FieldVisitor visitField( final int access, final String name, final String descriptor, final String signature, final Object value) { FieldNode field = new FieldNode(access, name, descriptor, signature, value); fields.add(field); return field; }
/** * Creates the static field that contains the txFactory for a transactional method. * * @return the created FieldNode. */ private FieldNode createTransactionFactoryField() { int access = ACC_FINAL + ACC_PUBLIC + ACC_STATIC + ACC_SYNTHETIC; String name = "___transactionFactory_" + System.nanoTime(); //todo: improve, use better name String desc = Type.getDescriptor(TransactionFactory.class); String sig = null; Object value = null; return new FieldNode(access, name, desc, sig, value); }
/** * Visit a field. * Call the field collector visitor. * * @param access : field access. * @param name : field name * @param desc : field descriptor * @param signature : field signature * @param value : field value (static field only) * @return the field visitor. * @see org.objectweb.asm.ClassVisitor#visitField(int, java.lang.String, java.lang.String, java.lang.String, * java.lang.Object) */ public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { return new FieldMetadataCollector(workbench, new FieldNode(access, name, desc, signature, value)); }
/** * Create field node helper. */ public FieldNode createField(int access, String name, String desc, String[] signature, Object initialValue) { StringBuilder sig = new StringBuilder(); for(String string : signature) { sig.append(string); } FieldNode fieldNode = new FieldNode(access, name, desc, sig.toString(), initialValue); return fieldNode; } }
@Override boolean processFields(List<FieldNode> fields) { logger.log(Level.INFO, "\tAdding new fields to EntityPlayer"); fields.add(fields.size(), new FieldNode(ACC_PUBLIC, "specialActionTimer", "I", null, 0)); fields.add(fields.size(), new FieldNode(ACC_PUBLIC, "isShielding", "Z", null, false)); return true; }