// would indicate an abstract method, continue to next method
continue;
}
try {
CodeIterator itr = codeAttr.iterator();
while ( itr.hasNext() ) {
int index = itr.next();
int op = itr.byteAt( index );
if ( op != Opcode.PUTFIELD && op != Opcode.GETFIELD ) {
continue;
}
int constIndex = itr.u16bitAt( index+1 );
final String fieldName = constPool.getFieldrefName( constIndex );
final PersistentAttributeDescriptor attributeDescriptor = attributeDescriptorMap.get( fieldName );
if ( attributeDescriptor == null ) {
// its not a field we have enhanced for interception, so skip it
continue;
}
log.tracef(
"Transforming access to field [%s] from method [%s]",
fieldName,
methodName
);
if ( op == Opcode.GETFIELD ) {
int read_method_index = constPool.addMethodrefInfo(
constPool.getThisClassInfo(),
attributeDescriptor.getReader().getName(),
attributeDescriptor.getReader().getSignature()
);
itr.writeByte( Opcode.INVOKESPECIAL, index );
itr.write16bit( read_method_index, index+1 );
}
else {
int write_method_index = constPool.addMethodrefInfo(
constPool.getThisClassInfo(),
attributeDescriptor.getWriter().getName(),
attributeDescriptor.getWriter().getSignature()
);
itr.writeByte( Opcode.INVOKESPECIAL, index );
itr.write16bit( write_method_index, index+1 );
}
}
StackMapTable smt = MapMaker.make( classPool, methodInfo );
methodInfo.getCodeAttribute().setAttribute(smt);