The difference in both of those cases are that you can create a micro framework yourself for the few abstractions that you need. (Not saying that you should!)
Doing this with Java entails reflection and various other runtime extending toolery, which requires a huge panel of tests because of a lack of ability to type the more difficult aspects. This is certainly not impossible and I have done this many times, but it's not practical and it is not cheap.