final ClassWriter cw,
final String aspectFieldName,
final CodeVisitor cv,
final String joinPointClassName) {
final CrossCuttingInfo info = adviceTuple.getAspectManager().getAspectContainer(adviceTuple.getAspectIndex())
.getCrossCuttingInfo();
final String aspectClassName = info.getAspectClass().getName().replace('.', '/');
final String aspectClassSignature = L + aspectClassName + SEMICOLON;
// add the aspect field
cw.visitField(ACC_PRIVATE + ACC_FINAL + ACC_STATIC, aspectFieldName, aspectClassSignature, null, null);
// retrieve the aspect set it to the field
cv.visitFieldInsn(GETSTATIC, joinPointClassName, SYSTEM_FIELD_NAME, SYSTEM_CLASS_SIGNATURE);
cv.visitLdcInsn(info.getUuid());
cv.visitMethodInsn(INVOKEVIRTUAL,
SYSTEM_CLASS_NAME,
GET_ASPECT_MANAGER_METHOD_NAME,
GET_ASPECT_MANAGER_METHOD_SIGNATURE);
cv.visitIntInsn(BIPUSH, adviceTuple.getAspectIndex());
cv.visitMethodInsn(INVOKEVIRTUAL,
ASPECT_MANAGER_CLASS_NAME,
GET_ASPECT_CONTAINER_METHOD_NAME,
GET_ASPECT_CONTAINER_METHOD_SIGNATURE);
switch (info.getDeploymentModel()) {
case DeploymentModel.PER_JVM:
cv.visitMethodInsn(INVOKEINTERFACE,
ASPECT_CONTAINER_CLASS_NAME,
GET_PER_JVM_ASPECT_METHOD_NAME,
GET_PER_JVM_ASPECT_METHOD_SIGNATURE);
break;
case DeploymentModel.PER_CLASS:
cv.visitMethodInsn(INVOKEINTERFACE,
ASPECT_CONTAINER_CLASS_NAME,
GET_PER_CLASS_ASPECT_METHOD_NAME,
GET_PER_CLASS_ASPECT_METHOD_SIGNATURE);
break;
default:
throw new UnsupportedOperationException(
"JITGen - unsupported deployment model - " + aspectFieldName + " " + DeploymentModel.getDeploymentModelAsString(
info.getDeploymentModel()));
//return true;
}
cv.visitTypeInsn(CHECKCAST, aspectClassName);
cv.visitFieldInsn(PUTSTATIC, joinPointClassName, aspectFieldName, aspectClassSignature);