String strippedClassName = strippedClassName(method);
String newClassName =
StringUtil.strcat(newClassNamePrefix(strippedClassName), "_",
methodType(isSetter), "Method_", method.getName());
String javaFileName = StringUtil.strcat(strippedClassName, ".java");
ClassGen classGen = new ClassGen(newClassName,
CompiledAccessor.class.getName(),
javaFileName,
Constants.ACC_PUBLIC | Constants.ACC_FINAL | Constants.ACC_SUPER,
EmptyStringArray);
classGen.addEmptyConstructor(Constants.ACC_PUBLIC);
ConstantPoolGen constantPoolGen = classGen.getConstantPool();
InstructionFactory instructionFactory = new InstructionFactory(classGen,
constantPoolGen);
org.apache.bcel.classfile.Method accessorMethod = null;
if (isSetter) {
accessorMethod =
constructSetterMethod(newClassName, constantPoolGen,
instructionFactory, method);
}
else {
accessorMethod =
constructGetterMethod(newClassName, constantPoolGen,
instructionFactory, method);
}
classGen.addMethod(accessorMethod);
return generateClassAndGetInstance(classGen, newClassName,
method.getDeclaringClass().getProtectionDomain());
}