method.javadoc().append(doc);
JFieldRef fr = JExpr.ref(fieldName);
JExpression test;
JConditional jc;
JInvocation invocation;
invocation = JExpr.invoke("tryOverwrite");
invocation.arg(JExpr.dotclass(type.boxify()));
invocation.arg(JExpr.lit(fieldName));
JVar tmp = method.body().decl(type.boxify(), "_" + fieldName,
invocation);
test = JOp.not(JOp.eq(JExpr._null(), tmp));
jc = method.body()._if(test);
jc._then()._return(tmp);
test = JOp.not(JOp.eq(JExpr._null(), fr));
jc = method.body()._if(test);
jc._then()._return(fr);
invocation = JExpr.invoke("tryFallback");
invocation.arg(JExpr.dotclass(type.boxify()));
invocation.arg(JExpr.lit(fieldName));
// tmp = method.body().decl(type.boxify(), "_" + fieldName, invocation);
method.body().assign(tmp, invocation);
test = JOp.not(JOp.eq(JExpr._null(), tmp));
jc = method.body()._if(test);
jc._then()._return(tmp);
// add the original block
method.body().add(block);