Comments (3)
This is only a problem when you want to make the method/field id outlive the method it's obtained from, correct?
Correct.
It shouldn't be able to escape the extern method that where it first gets looked up, since the JNIEnv can't either.
Actually, it can. The JNIEnv
object obtained by a JNI function can be kept in thread-local storage, and it can be used as long as that thread is attached to the JVM. That thread can also cache identifiers of methods and fields.
from jni-rs.
This is only a problem when you want to make the method/field id outlive the method it's obtained from, correct? It shouldn't be able to escape the extern method that where it first gets looked up, since the JNIEnv can't either. We might need something like you've got above in order to give out "Global" Method/FieldIDs.
from jni-rs.
Is there a better way to cache these rather than having to use std::mem::transmute()
? At the very least classes are cacheable without an issue by using new_global_ref
, but I kinda feel hacky having to std::mem::transmute()
on these ones
from jni-rs.
Related Issues (20)
- CallNonvirtual<type>Method support request HOT 2
- Can i load native function on exec self ? HOT 3
- Question: How I use `GetObjectRefType` HOT 4
- Make methods `const fn` when it makes sense HOT 1
- `get_rust_field()` exclusive access to `JNIEnv` HOT 8
- How I use `MonitorEnter` and `MonitorExit`
- use catch_unwind to ensure balanced push/pop_local_frame in with_local_frame
- `JNIEnv::get_version()` should be infallible
- JNIVersion should implement `Ord` and be able to hold unknown, newer versions as u32 values
- JNIEnv::exception_check should just return a bool and REQUIRES JNI 1.2 as a minimum supported version! HOT 1
- Can't use JNI_GetCreatedJavaVMs HOT 1
- `ensure_local_capacity` doesn't check for errors correctly
- `attach_current_thread_as_daemon` (and any notion that we support 'daemon' threads) should probably be removed
- Remove/deprecate Executor API?
- The performance seems to be only 80% of that of cpp (jni) HOT 2
- `direct_buffer` APIs need to check for JNI >= 1.4
- Remove `get_native_interface` or `get_raw`
- `new_global_ref` docs could make it clearer that it doesn't delete / replace the given reference
- Double check the soundness of `delete_local_ref` HOT 4
- `push/pop_local_frame` should be internal-only APIs or removed altogether
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jni-rs.