Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "Sorry, parameter type 'X' is ambiguous or not supported." #317

Closed
aalucaci opened this issue Nov 25, 2023 · 2 comments
Closed

Error: "Sorry, parameter type 'X' is ambiguous or not supported." #317

aalucaci opened this issue Nov 25, 2023 · 2 comments

Comments

@aalucaci
Copy link

Hello,
I recently had an error while trying to send an email using the package mailR. After some digging I learned that the error was due to the fact that the email subject was created with the glue package, something like this:

subject <- glue::glue("test - {strftime(Sys.Date(),'%B %Y')}") 
class(subject)
#[1] "glue"      "character"

The resulting error message:
"Sorry, parameter type `glue' is ambiguous or not supported."

To my understanding, the problem actually comes from rJava:
https://github.com/s-u/rJava/blob/master/R/reflection.R#L58
stop("Sorry, parameter type", class(a)[1] ,"' is ambiguous or not supported.")

I found similar issues:

Both packages depend on rJava. The latter issue was fixed by adding as.character().
My naive guess is that a better idea would be to make the necessary modifications in rJava. In reflection.R, class(x)[1] is checked.
Checking is.character(x) instead could help to avoid the errors described above.

Thank you in advance for your help,
Angela

@s-u
Copy link
Owner

s-u commented Dec 8, 2023

The problem is that the packages use reflection API with classes that are not native types (packages shouldn't be using the reflection API to start with as it is inherently unsafe). This was not supported, because it relies on undefined behavior. Just because the class inherits from one of the native types it doesn't necessarily mean that it is safe to drop the class structure for conversion. The glue example is a bit of a special case, because the class is used just as a tag and doesn't really change the object structure or the semantics of the object, but rJava has no way of knowing that.

rJava could dispatch on superclasses, but I'll have to check if that causes a fall-out in any rev-deps.

@s-u
Copy link
Owner

s-u commented Dec 8, 2023

Reproducible example:

> new(J("java.lang.String"), structure("foo", class=c("bar","character")))
Error in FUN(X[[i]], ...) : 
  Sorry, parameter type `bar' is ambiguous or not supported.

with subclass dispatch enabled:

> new(J("java.lang.String"), structure("foo", class=c("bar","character")))
[1] "Java-Object{foo}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants