tinku_jai
tinku_jai

Reputation: 33

Does BeanShell supports Java 8 streams?

When trying to execute below snippet where iterating values of Map<String,List>, it is throwing BeanShell parse exception at symbol > . Any solution I could get to resolve this one?

map.entrySet().stream().forEach(map -> {
    if (map.getValue().stream().anyMatch(s -> groupDN.startsWith(s.toUpperCase()))) {
        return "DONE";
    }
    ;
});
Exception running rule: BeanShell script error: bsh.ParseException: Parse error at line 30, column 22. Encountered: > BSF info: Test_RO at line: 0 column: columnNo

Upvotes: 3

Views: 1036

Answers (2)

shikida
shikida

Reputation: 505

Sailpoint IIQ 8.1 uses Bsh 2.1.8 jar, which was the beanshell released in Feb 2014 at the old beanshell repo at https://code.google.com/archive/p/beanshell2/ - this is what is known as "Beanshell2"

Nowadays, the official beanshell home is at https://github.com/beanshell/beanshell/releases and the latest release is 2.1.0 (don't ask me why), released in Dec 2020.

Java Streams were introduced to the Java language in Java 8, which was released in Mar 2014, after Bsh 2.1.8 was released.

So the answer is, no, Sailpoint IIQ currently has no support to Java Streams in its beanshell code.

However, you can still encapsulate Java streams into some jar and your beanshell code will be able to access methods that use that jar, as it currently does with all jars in the IIQ web application. Of course, the drawback is that it's not possible to dynamically change your IIQ rule code.

In Jul 2021, Sailpoint has released IIQ 8.2 and this very latest version still uses the same Bsh 2.1.8 jar.

Upvotes: 1

Stephen C
Stephen C

Reputation: 719376

Java 8+ Streams per se are actually "just" a bunch of Java library classes.

What you are really asking here is whether BeanShell supports the following Java language features which are needed for writing idiomatic Java code that uses Streams:

  • generic types from Java 5,
  • lambdas and type inference from Java 8.

As far as I can tell, the answer is "No" to all of those. Generic types are on the roadmap for BeanShell 3.0 (see https://github.com/beanshell/beanshell#development-road-map), but lambdas and type inference are not mentioned.


If you want an interactive Java REPL that supports all of the Java language, you might do better looking at "jshell" which is part of standard Java SE from Java 9 onwards. Apparently it can be embedded ...

Upvotes: 7

Related Questions