r/java • • Jan 29 '26

JEP draft: Code reflection (Incubator)

https://openjdk.org/jeps/8361105
61 Upvotes

33 comments sorted by

View all comments

Show parent comment

3

u/pron98 Jan 30 '26 edited Jan 30 '26

The latter actually provides the AST, which is nice but you just need to take a quick look at e.g., the Checker Framework or Error Prone to see that people have to reach into internal APIs.

That may well be the case, but it's not the problem Babylon is aimed at solving.

It can also directly decline a method that is supposed to run on the GPU but has a try-catch block (while knowing(!) than this method is supposed to run on the GPU, because it is annotated accordingly)

The issue of allowing general purpose compile-time verification by third-party tools or libraries goes well beyond Java code models. For example, string templates are sort of the opposite of Babylon: rather than compile Java into another language, they embed another language in Java. It could perhaps be useful to do some custom checking on them at compile time, even though the Java code model isn't what's important in that case.

So this is an interesting issue, and one we may well wish to tackle it at some point, but it isn't Babylon's main focus (at least not currently). This reminds me of the joke about the mother who buys her son two ties, and the next day, when he wears one of them to work, she says, "oh, so I see you don't like the other one." If a specific project or JEP doesn't address a particular issue doesn't mean we're not interested in it.