Closed ablaette closed 2 years ago
One year later, we now get this error (not warning), that cannot be muted:
java.lang.IllegalAccessException: class RJavaTools cannot access a member of class java.util.Arrays$ArrayList (in module java.base) with modifiers "public"
One reason may be that the ArrayList we instantiate is notthe kind of ArrayLiost we think it is: https://stackoverflow.com/questions/28851652/java-lang-classcastexception-java-util-arraysarraylist-cannot-be-cast-to-java
The Stackoverflow discussion pointed to the relevant direction. I instantiated the wrong ArrayList
. This is what works now:
self$obj <- .jnew("java.util.ArrayList")
.jnew("java.util.Collections")$addAll(self$obj, anno_array)
When calling
AnnotationList$as.data.table()
you may (almost certainly) see the following warning:To reproduce this, use the following example for the
AnnotationList
class:The warning is issued the first time you access the enriched ArrayList with the annotations, see the following minimal example.
The warning results from Java and is a frequent matter of discussions. As I understand it, the concept of modules introduced with Java 9 is less permissive to access classes/methods across modules if they are not exposed/imported properly. You can control the behavior of reflective access using java parameters, but you cannot turn off the warning. No matter what setting you choose for "--illegal-access" (for options, see this), the warning is issued at least once:
As we know that this warning does not necessarily indicate a serious problem, we might consider suppressing it. But my experiments with traditional R functions such as
capture.output()
,sink()
,suppressWarnings()
have not been successful.So at this stage, it seems to me that we have to live with this warning and that we might have to leave it with explaining in the documentation that users will see this warning which can be safely ignored.
To conclude, there are two things I have not tried yet: