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

pub keyword in "jni" functions causing weird compiler error about unrelated code. #29

Open
testmaster217 opened this issue Jun 11, 2023 · 2 comments

Comments

@testmaster217
Copy link

I am trying to set up a project using the robusta_jni crate, and today I started seeing a weird issue where the pub keyword in my "jni" (implemented on the rust side of the program) function causes a compiler error. The rust diagnostic looks like this:

error[E0599]: no method named `description` found for enum `robusta_jni::jni::errors::Error` in the current scope
   --> src\lib.rs:13:9
    |
13  |         pub extern "jni" fn printFromRust() -> JniResult<()> {
    |         ^^^ method not found in `Error`
    |
   ::: C:\Users\MY_NAME\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\error.rs:110:8
    |
110 |     fn description(&self) -> &str {
    |        ----------- the method is available for `robusta_jni::jni::errors::Error` here
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
5   +     use std::error::Error;
    |

Meanwhile, the code that's causing the error is very simple (because I'm just trying to make sure everything works at this point). The file it's in doesn't even use robusta_jni::jni::errors::Error.

...
pub extern "jni" fn printFromRust() -> JniResult<()> {
    println!("Rust called from Java.");
    Ok(())
}

Adding the use statement like the diagnostic suggests turns the error into a warning about the description method being deprecated, and this may be what I have to do for now to get the code to build.

I also tried copying and pasting the example code from this GitHub repo into the file and all of the "jni" functions in that code had the exact same issue, which is why I think it may be a bug in the robusta_jni crate. The last time the code didn't have this issue was before Rust 1.70 was released, so maybe that update broke something,

@giovanniberti
Copy link
Owner

Very probably related to #25, I'll try to fix it and check :)

@giovanniberti
Copy link
Owner

I also tried copying and pasting the example code from this GitHub repo into the file and all of the "jni" functions in that code had the exact same issue

robusta_jni::jni is just a re-export of the jni crate, I'll start by updating the dependency and see if that's enough :)

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

Successfully merging a pull request may close this issue.

2 participants