Skip to content

Allow J() convenience on Java 17+ #345

@vpinna80

Description

@vpinna80

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions