@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); }
@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),
fn=new FieldNode(0,null,null,null,null); cn.fields.add(fn);
@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; }
@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; }
public FieldNode fieldNode() { return new FieldNode( ACC_PRIVATE + ACC_STATIC + ACC_FINAL, fieldName, fieldType.getDescriptor(), null, null); }
/** * 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; }
public FieldNode getFieldNode() { FieldNode node = new FieldNode(modifiers, fieldName, signature, null, value); node.visibleAnnotations = new ArrayList<VisibleAnnotation>(); for (VisibleAnnotation annotation : annotations) { node.visibleAnnotations.add(annotation.getNode()); } return node; }
@Override boolean processFields(List<FieldNode> fields) { logger.log(Level.INFO, "\tAdding new fields to ItemRenderer"); fields.add(fields.size(), new FieldNode(ACC_PUBLIC, "equippedItemOffhandSlot", "I", null, 0)); return true; }
private FieldNode instanceField() { return new FieldNode( ACC_PUBLIC + ACC_FINAL + ACC_STATIC, instanceFieldName(), thisClassType().getDescriptor(), null, null); }
private FieldNode instanceFieldNode() { return new FieldNode( ACC_PRIVATE + ACC_FINAL, instanceFieldName(), instanceType().getDescriptor(), null, null); }
@Nonnull @Override public ClassNode transform(ClassNode input, ITransformerVotingContext context) { FieldNode fn = new FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "testfield", "Ljava/lang/String;", null, "CHEESE!"); input.fields.add(fn); return input; }
@Nonnull @Override public ClassNode transform(ClassNode input, ITransformerVotingContext context) { FieldNode fn = new FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "testfield", "Ljava/lang/String;", null, "CHEESE!"); input.fields.add(fn); return input; }
@Nonnull @Override public ClassNode transform(ClassNode input, ITransformerVotingContext context) { input.superName="java/lang/Object"; FieldNode fn = new FieldNode(Opcodes.ACC_PUBLIC, "testfield", "Ljava/lang/String;", null, null); input.fields.add(fn); return input; }
private void addUpvalueFields() { for (UpVar uv : fn.upvals()) { String name = toFieldName(ensureUnique(upvalueFieldNames.values(), preferredUpvalueName(uv))); upvalueFieldNames.put(uv, name); FieldNode fieldNode = new FieldNode( ACC_PROTECTED + ACC_FINAL, name, Type.getDescriptor(Variable.class), null, null); classNode.fields.add(fieldNode); } }
private List<FieldNode> remapManagedFields() { List<FieldNode> result = new LinkedList<FieldNode>(); for (FieldNode fieldNode : (List<FieldNode>) clazz.fields) { FieldMetadata fieldMetadata = clazzMetadata.getFieldMetadata(fieldNode.name); if (fieldMetadata.isManagedField()) { FieldNode fixedFieldNode = new FieldNode( upgradeToPublic(fieldNode.access), fieldNode.name, fieldNode.desc, fieldNode.signature, fieldNode.value); result.add(fixedFieldNode); } } return result; }
public void instrument() { makeClassPublic(classNode); classNode.access = classNode.access & ~ACC_FINAL; // Need Java version >=7 to allow invokedynamic classNode.version = Math.max(classNode.version, V1_7); classNode.fields.add(0, new FieldNode(ACC_PUBLIC | ACC_FINAL, ShadowConstants.CLASS_HANDLER_DATA_FIELD_NAME, OBJECT_DESC, OBJECT_DESC, null)); Set<String> foundMethods = instrumentMethods(); // If there is no constructor, adds one addNoArgsConstructor(foundMethods); addDirectCallConstructor(); // Do not override final #equals, #hashCode, and #toString for all classes instrumentInheritedObjectMethod(classNode, foundMethods, "equals", "(Ljava/lang/Object;)Z"); instrumentInheritedObjectMethod(classNode, foundMethods, "hashCode", "()I"); instrumentInheritedObjectMethod(classNode, foundMethods, "toString", "()Ljava/lang/String;"); addRoboInitMethod(); addRoboGetDataMethod(); doSpecialHandling(); }