Skip to content

How to kill java objects from R #308

Answered by s-u
sgum asked this question in Q&A
May 10, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You cannot remove loaded classes from Java*.

However what you seem to want is to simply to load another version of the class which you can if you simply use another class loader. That's exactly what .jpackage(.., own.loader=TRUE) does so you can have a look here:

rJava/R/loader.R

Lines 42 to 50 in 6d362c1

if (isTRUE(own.loader)) {
lib <- "libs"
if (nchar(.Platform$r_arch))
lib <- file.path("libs", .Platform$r_arch)
ns <- asNamespace(name)
loader <- ns$.rJava.class.loader <-
.jnew("RJavaClassLoader", .rJava.base.path,
file.path(.rJava.base.path, lib), .rJava.class.loader, check = FALSE)
}

Once you have a new loader, just use it as c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sgum
Comment options

Answer selected by sgum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants