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

GlobalRef‘s copy assignment operator is implicitly deleted #158

Open
0Litost0 opened this issue Dec 19, 2023 · 2 comments
Open

GlobalRef‘s copy assignment operator is implicitly deleted #158

0Litost0 opened this issue Dec 19, 2023 · 2 comments

Comments

@0Litost0
Copy link

当我将 snap-djinni 移植到自己的项目,并尝试使用 DataRef时,有以下报错:
DataRef_jni.cpp:34:25: error: object of type 'GlobalRef<jclass>' (aka 'GlobalRef<_jclass *>') cannot be assigned because its copy assignment operator is implicitly deleted classObject = jniFindClass("java/nio/ByteBuffer");

The tips are as follows:
copy assignment operator is implicitly deleted because 'GlobalRef<_jclass *>' has a user-declared move constructor GlobalRef(GlobalRef && obj)

Have you encountered similar problems?
I did not encounter the above problems when I tried to compile and run the demo.

@li-feng-sc
Copy link
Contributor

li-feng-sc commented Dec 20, 2023

What compiler are you using?

Line 34 of DataRef_jni.cpp is

            classObject = jniFindClass("java/nio/ByteBuffer");

which is indeed a call to the assignment but it should be a call to the move assignment because on the right hand is a function calljniFindClass(), so it should be an r-value.

@li-feng-sc
Copy link
Contributor

li-feng-sc commented Dec 20, 2023

the GlobalRef class has a user defined move assignment operator

     GlobalRef& operator=(GlobalRef&& other) noexcept {

So I don't see why this would fail to compile.

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