rJava
rJava copied to clipboard
Allow J() convenience on Java 17+
With current implementation, some legitimate Java calls fail because of access to private methods in Java 17+, where setAccessible doesn't work anymore.
For example, the following fails though the Map class and all the methods are public:
java_iter <- J("java.util.Map")$of("A", "B")$entrySet()$iterator()
In this case, and in similar cases, you have to resort to .jcall which is cumbersome because you have to remember the actual parameter classes, and the return type.
Expected behavior:
> str(J("java.util.Map")$of("A", "B")$entrySet()$iterator())
Formal class 'jobjRef' [package "rJava"] with 2 slots
..@ jobj :<externalptr>
..@ jclass: chr "java/util/ImmutableCollections$Set12$1"