In terms of what we "write into" the bytecode we should consider:
defining more granular interfaces representing the specific types of enhancement done (laziness, bi-directionality, dirty-tracking, etc).
we could implement a lot of functionality simply as default impls of these methods on the interfaces. This is a Java 8 feature we can use, so we should. It makes manually writing specific bytecode into the classes unnecessary in most (all?) cases. Easier to read, spot bugs, etc -> easier maintenance!
had some good ideas (including the ones above) on the subject. , anything else you'd add?
What do you mean by "a more specialized approach"? Based on our conversations last week, I would assume you mean that as we develop specialized interfaces for each enhancement capability we allow possibility of attaching interceptor per each capability?
You writing an agent for runtime enhancement in non-EE uses? We discussed that last week. It's an idea we've discussed for a long time. Problem is none of the team has ever been comfortable writing agents I've looked into it and there are a lot of intricacies to it. I'm more than willing to consider this if someone (1) does the work or (2) gives me practical lessons in how to write them.
Also swears this can be done after classes are loaded. , did you find more about that?
Well you can change method bodies of already loaded classes, but e.g. adding or removing fields is not possible.
Ok, that does not meet our needs as we absolutely need to add fields and methods.