if (m_classGen == null) throw new IllegalStateException("attribute enhancer is not initialized");
byte[] serializedAttribute = serialize(attribute);
Field[] classfileField = m_classGen.getFields();
for (int i = 0; i < classfileField.length; i++) {
if (classfileField[i].getName().equals(field.getName())) {
FieldGen fieldGen = new FieldGen(classfileField[i], m_constantPoolGen);
Attribute attr = new Unknown(
m_constantPoolGen.addUtf8("Custom"),
serializedAttribute.length,
serializedAttribute,
m_constantPoolGen.getConstantPool()
);
fieldGen.addAttribute(attr);
Field newField = fieldGen.getField();
m_classGen.replaceField(classfileField[i], newField);
}
}
}