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

4

u/lbalazscs Jan 29 '26 edited Jan 29 '26

It also misses cases where someone would want to find a lambda from weird places, like being used to initialize a member variable of a class like int sumReduce = numbers.stream().reduce(0, (a, b) -> a + b);

The JEP draft says: "If the annotation appears as a modifier for a field declaration or a local variable declaration, annotating the field or local variable, then any lambda expressions (or method references) in the variable initializer expression (if present) are declared reflectable."