@Override public int hashCode( final Object o ) { final FieldGen THIS = (FieldGen) o; return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); } };
/** * Return string representation close to declaration format, * `public static final short MAX = 100', e.g.. * * @return String representation of field */ public final String toString() { String name, signature, access; // Short cuts to constant pool access = Utility.accessToString(access_flags); access = access.equals("")? "" : (access + " "); signature = type.toString(); name = getName(); StringBuffer buf = new StringBuffer(access + signature + " " + name); String value = getInitValue(); if(value != null) buf.append(" = " + value); return buf.toString(); }
/** * Return string representation close to declaration format, * `public static final short MAX = 100', e.g.. * * @return String representation of field */ @Override public final String toString() { String name; String signature; String access; // Short cuts to constant pool access = Utility.accessToString(super.getAccessFlags()); access = access.isEmpty() ? "" : (access + " "); signature = super.getType().toString(); name = getName(); final StringBuilder buf = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber buf.append(access).append(signature).append(" ").append(name); final String value = getInitValue(); if (value != null) { buf.append(" = ").append(value); } return buf.toString(); }
try { java.lang.reflect.Field f = proxyClass .getDeclaredField(dataFieldGens[i].getName());
.getName(), handlerField.getType()));
static void emitInitializerConstructor(ClassGen stubClass, FieldGen handlerField, FieldGen initializerField) { String stubClassName = stubClass.getClassName(); ConstantPoolGen cp = stubClass.getConstantPool(); InstructionList il = new InstructionList(); MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, null, "<init>", stubClassName, il, cp); InstructionFactory fac = new InstructionFactory(stubClass, cp); // call super-constructor il.append(InstructionFactory.createThis()); il.append(fac.createInvoke(stubClass.getSuperclassName(), "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); // push "this" il.append(InstructionFactory.createThis()); // get static initializer il.append(fac.createGetStatic(stubClassName, initializerField.getName(), initializerField.getType())); emitInvoke(il, fac, getStubHandlerRef); // checkCast il.append(fac.createCast(Type.OBJECT, handlerField.getType())); // put handlerField il.append(new PUTFIELD(cp.addFieldref(stubClassName, handlerField .getName(), handlerField.getSignature()))); // return il.append(InstructionConstants.RETURN); // compute stack and locals... mg.setMaxStack(); mg.setMaxLocals(); stubClass.addMethod(mg.getMethod()); }
static void emitOneArgConstructor(ClassGen stubClass, FieldGen handlerField) { String stubClassName = stubClass.getClassName(); ConstantPoolGen cp = stubClass.getConstantPool(); InstructionList il = new InstructionList(); Type[] args = new Type[] { handlerField.getType() }; MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, args, null, "<init>", stubClassName, il, cp); InstructionFactory fac = new InstructionFactory(stubClass, cp); // call super-constructor il.append(InstructionFactory.createThis()); il.append(fac.createInvoke(stubClass.getSuperclassName(), "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); // push this again... il.append(InstructionFactory.createThis()); // push the handler il.append(InstructionFactory.createLoad(handlerField.getType(), 1)); // put handlerField il.append(new PUTFIELD(cp.addFieldref(stubClassName, handlerField .getName(), handlerField.getSignature()))); // return il.append(InstructionConstants.RETURN); // compute stack and locals... mg.setMaxStack(); mg.setMaxLocals(); stubClass.addMethod(mg.getMethod()); }