mitchdowd / jnipp Goto Github PK
View Code? Open in Web Editor NEWC++ wrapper for the Java Native Interface
License: MIT License
C++ wrapper for the Java Native Interface
License: MIT License
Individual get/set element actions involves a lot of JNI back and forth if operating over large arrays. Provide some bulk operations which set whole array segments, and allow "offline" array editing with a sync-up option.
how to set a object?
for example:
class a {
private String aa;
private int bb;
public static b bobj;
}
class b {.....}
b bobj = new b();
a native method param is b, how to set class a.b = bobj;
jniexport void java_com_daaa_xx(JNIEVN env*, jobject thiz, jobject bobj) {
// in here , how to set class a.b = bobj;
}
So that we can do things like super.onEvent(event).
Hello! I couldn't find a simpler way of messaging you so I thought I would open an issue.
Are you aware of JNI Bind? It looks like you're trying to do a lot of the same things that I am. Some of your open issues are actually already supported.
Just thought I'd reach out.
Hey guys, great project! I've noticed that there is no option to load a custom jar, because JavaVMInitArgs is hidden [1] from the public access. AFAIK, to load a custom jar/class from JNI, it neads to set JavaVMOption
. Something like this (not tested):
JavaVMInitArgs args;
JavaVMOption options[1];
options[0].optionString = "-Djava.class.path=path/to/lib1.jar;path/to/lib2.jar"
args.options=options;
args.nOptions=1;
Maybe a version of Vm
constructor with JavaVMOption migth do the trick? Like:
Vm::Vm(const char *path, JavaVMOption *opts = nullptr) { ... }
[1] https://github.com/mitchdowd/jnipp/blob/master/jnipp.cpp#L1462
the header file is likely to produce multiple definitions if used in multiple files
Should provide as close to 100% test coverage as possible.
Don't leverage off any specific unit test framework, just an application which executes and shows a pass/fail result.
A call to DeleteLocalRef() needs to be made on the generated handle at some point after the method call to come.
now the jnipp code will cast array to object
and call deleteglobalref or localref to free array
google suggest:https://developer.android.com/training/articles/perf-jni#primitive-arrays
Allow getting/setting indexed values within a Java array.
Using Class.call(method)
Don't require a "UNICODE" and "ANSI" build, support both wide and UTF8 strings as Java parameters in the same build.
In preparation for marking it as a feature-complete release.
instead of separate "doStuff" name and "(Ljava/lang/String;)V" type signature, allow "doStuff(Ljava/lang/String;)V" name/signature combination.
Other primitive types are automatically cast (e.g. int, long, char, short) but so far, byte is not automatically cast to a C++ primitive type.
Create a byte_t
cast to/from Java.
GetStringUTFChars cannot support emoji ,such as 👇
Using Class.get() and Class.set(value)
Rather than dealing with JNI's "modified UTF-8" that isn't quite UTF-8. Currently, some UTF-8 encodings will be misrepresented.
now only support CallNonvirtualXXXXMethodA
sometimes it will not convenient to use
Hi,
First off thanks a lot for this project, it makes working with the JNI much nicer!
Now to my issue: I have a native method that is expected to return a newly generated object (an ArrayList in my case, but the issue is the same for all object types). I successfully created it using your Object::newInstance()
helper method and could also modify it as I wanted, but then when I want to return it to Java (the native method returns a jobject
, so I used Object::getHandle()
as the return value), the calling Java code receives a null pointer. After some digging I found out that this is because just before returning, the Object that I created inside my native method is destroyed, leading to the destructor being called and the JVM reference being deleted. My current workaround is to add a new boolean flag to Object
that is set to true if the object should be "persistent" in the JVM, making the destructor return without further actions. But I'm wondering whether there is a better way to do it that I simply didn't discover yet.
The JavaVM member in particular.
Currently it is Windows only.
when i run,at if (JNI_CreateJavaVM == NULL || JNI_CreateJavaVM(&javaVm, (void**) &env, &args) != 0).
Exception thrown at 0x000001EDD53F03B4 (located in tests.exe) : 0xC0000005: Access conflict occurred at read position 0x0000000000000000.
why???what should i do? please
such as
registerReceiver(null,new IntentFilter())
in jnipp
context.calljni::Object(register_method,NULL,intentFilter)
this will cause compile error
error: call to 'valueArg' is ambiguous valueArg(values, arg);
try {
jni::Class ctx("android/content/Context1");
} catch (jni::NameResolutionException &e) {
LOGE("the exception %s",e.what());
}
in demo,this action will crash ,because java class Context1 can not find
add handleJavaExcption for getClass getxxxField getxxxMethod before throw std::exception
Allow a null path to be supplied, in which case we try to find jvm.dll ourselves.
Hi,
Thanks for clean and simple API.
Do you have plan to support ByteBuffer or ByteArray(byte[]) support to jnipp?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.