4

I'm working on a Product (Sailpoint IdentityIQ that runs in Tomcat) which uses Beanshell env for product customization hooks. I want to write some code to parse a large csv file and want to leverage Java 8 Streams. But I'm facing issue with Beanshell env throwing errors and didn't recognize the Lambda expressions though we are using Java 8

Is there any way we can tell beanshell to recognize the lambdas or escape in the code

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
Madhu K
  • 43
  • 3

1 Answers1

3

Lambda expressions still not supported in beanshell

Lambdas are coming, rest assured! With the new approach of using Method Handles we are one step closer to utilise Lambda Meta Factory for creating function objects, unless we don't simply go the same route as with Java EL... we have options.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • You should, however, be able to use [anonymous inner classes](http://beanshell.org/manual/bshmanual.html#Anonymous_Inner-Class_Style) (since lambdas are just syntactic sugar to represent anonymous inner classes in a new way). I haven't tested this though... – Erk Sep 14 '21 at 15:27
  • @Erk same as you can't use lambda in Java 1 – Ori Marko Sep 14 '21 at 15:32
  • oh yes, it's not going to be pretty either way, but if OP is forced to use lambdas from BeanShell, with a heroic effort, it should be kind of possible (though my recommendation would probably be to wrap it in helper classes instead). – Erk Sep 14 '21 at 15:40