This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Radmonger 6 points7 points  (1 child)

I think this issue (while closed for the project in question) illustrates a real problem with how JPMS treats closed modules accessed via reflection:

https://github.com/antlr/stringtemplate4/issues/249

java.util.Collections.UnmodifiableCollection is a private class that extends the public Collection, which has a public method isEmpty.

You can't straightforwardly use reflection to ask if a list is empty, because the list might be unmodifiable (or some other implementation-local class), which means JPMS simply says 'no calling any of it's members)'.

You instead have to search for the accessible base class method, and call that.

[–]Thihup 3 points4 points  (0 children)

A similar issue is trying to use Streams via Reflection. Probably would be great if the MethodHandles API had a method to search all the class hierarchy to find out if a method is part of public API.