}
// Next, create static initializer, that initializes
// field created above.
JiapiMethod clinit = null;
try {
clinit = currentClass.getDeclaredMethod("<clinit>",new String[]{});
}
catch(NoSuchMethodException nsme) {
// It did not exists, so create one
try {
clinit =
currentClass.addMethod(Modifier.STATIC, "<clinit>",
new Signature("void",
new String[0]));
// create 'return' from <clinit>
clinit.getInstructionList().add(clinit.getInstructionList().getInstructionFactory().returnMethod(clinit));
}
catch(MethodExistsException mee) {
mee.printStackTrace();
}
}
InstructionList il = clinit.getInstructionList();
InstructionFactory factory = il.getInstructionFactory();
InstructionList initializer = il.createEmptyList();
try {
JiapiClass er = currentClass.getLoader().loadClass("alt.jiapi.event.EventRuntime");
JiapiMethod gfv =
er.getDeclaredMethod("getFieldValue",
new String[] {"java.lang.String"});
// Get the field value from runtime
initializer.add(factory.pushConstant(fieldName));