2

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

tinku_jai
  • 23
  • 2

2 Answers2

5

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 ...

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • 1
    Great thanks for the information, it’s really helpful! I have to use beanshell because my security tool doesn’t support jshell. Yes, may have to wait for an update then! – tinku_jai Jul 10 '21 at 06:23
  • .... or you could get involved with the Beanshell project to make it happen sooner rather than later. Or pressure your security tool vendor to do something about it. – Stephen C Jul 10 '21 at 06:51
  • The version of Beanshell used in IIQ *does* support generics, but in a limited way. Specifically, it does not support generics with more than one parameter or the diamond syntax. So it will support ``, but not `` or `<>`. It does NOT support either the lambda arrow syntax or method references. However, you can easily implement any lambda using an anonymous class, which it does support. – Devin R Oct 05 '21 at 15:39
1

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.

shikida
  • 485
  • 2
  • 10