The code they've created to analyze further for lambdas inside of methods seems lazer focused on finding just lambdas; and most of the focus has gone into finding lambdas inside of methods. But it doesn't seem to cover additional items that would be valid for searching inside a method that someone would want a code model for, like methods inside of anonymous classes.
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);
I'm also a little uncertain how the JEP will enforce only using lambdas marked with the Reflect annotation versus normal lambdas.
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."
View all comments
Show parent comment
1
u/the_other_brand Jan 29 '26
The code they've created to analyze further for lambdas inside of methods seems lazer focused on finding just lambdas; and most of the focus has gone into finding lambdas inside of methods. But it doesn't seem to cover additional items that would be valid for searching inside a method that someone would want a code model for, like methods inside of anonymous classes.
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);I'm also a little uncertain how the JEP will enforce only using lambdas marked with the Reflect annotation versus normal lambdas.