Android NDK学习之旅
文章平均质量分 66
hkustwsh
靠软件开发吃饭的计算经济学学生...
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
JNI - Getting Started
开始第一个JNI程序原创 2016-04-07 17:26:33 · 266 阅读 · 0 评论 -
JNI - Prevent JVM from crashing on Error Signals
In the previous article, Divide by Zero. A comparison between Java and C, we concluded that C++ programs will crash when it meets a DivideByZero Exception. Even with a handler, it will crash anyway.原创 2016-05-22 01:47:40 · 973 阅读 · 0 评论 -
JNI - Process ID
Conclustion: Java and C++ are in the same process.原创 2016-05-20 18:58:02 · 418 阅读 · 0 评论 -
JNI - Divide by Zero. A comparison between Java and C(1)
A comparison of DivideByZero(c++ and Java)原创 2016-05-19 17:00:55 · 570 阅读 · 0 评论 -
JNI - Exception Handling
.java file:class CatchThrow{ private native void doit() throws IllegalArgumentException; private void callback() throws NullPointerException{ throw new NullPointerException("CathThrow.callback原创 2016-04-20 16:01:20 · 430 阅读 · 0 评论 -
JNI - Call Method(Callback Call java methods from c)
.c file#include #include #include "InstanceMethodCall.h"JNIEXPORT void JNICALL Java_InstanceMethodCall_nativeMethod (JNIEnv *env, jobject obj){ jclass cls = (*env)->GetObjectClass(env,obj);原创 2016-04-09 21:14:42 · 1402 阅读 · 1 评论 -
JNI - Caching IDs
Method 1. Caching at the Point of Usestatic jmethodID cid = NULL;if (cid == NULL){ cid = (*env)->GetMethodID(env,stringClass,"","([C)V"); if (cid == NULL){ return NULL; }}Method 2原创 2016-04-18 19:51:17 · 280 阅读 · 0 评论 -
JNI - Static method. Method of SuperClass.
Call static method.jclass cls = *(env)->GetObjectClass(env,obj);jmethodID mid = (*env)->GetStaticMethodID(env, cls, "callback", "()V";(*env)->CallStaticVoidMethod(env, cls, mid);Attention:原创 2016-04-10 00:21:15 · 357 阅读 · 0 评论 -
JNI - Method Signature.
Command line :javap -s -p Method_Call_NameJava method:class MethodDescriptor { MethodDescriptor(); private native java.lang.String getLine(java.lang.String); private native int GetLine(i原创 2016-04-09 22:12:06 · 847 阅读 · 0 评论 -
JNI - Field Descriptors.
class FieldDescriptors{ int intvalue; double doublevalue; float floatvalue; String stringvalue = new String(); int intarrayvalue[] = new int[5]; MyClass myclassvalue = new MyClass();}How原创 2016-04-09 17:06:14 · 1536 阅读 · 0 评论 -
JNI - Access static field
class StaticFieldAccess{ private static int si; private native void accessField(); public static void main(String args[]){ StaticFieldAccess c = new StaticFieldAccess(); StaticFieldAccess.si =原创 2016-04-09 17:02:54 · 461 阅读 · 0 评论 -
JNI - Access an instance Field
.java File:class InstanceFieldAccess{ private String s; private native void accessField(); public static void main(String args[]){ InstanceFieldAccess c = new InstanceFieldAccess(); c.s =原创 2016-04-09 16:17:45 · 549 阅读 · 0 评论 -
JNI - PASS ARGUMENT. ObjectARRAY
.java fileclass ObjectArrayTest{ private static native int[][] initInt2DArray(int size); public static void main(String[] args){ int[][] i2arr = initInt2DArray(3); for (int i=0;i<3;i++){ fo原创 2016-04-08 19:31:20 · 402 阅读 · 0 评论 -
JNI - PASS ARGUMENT. array
.java fileclass IntArray{ private native int sumArray(int arr[]); public static void main(String[] args){ IntArray p = new IntArray(); int arr[] = new int[10]; for ( int i=0; i<10;i++) ar原创 2016-04-08 19:22:53 · 358 阅读 · 0 评论 -
JNI - PASS ARGUMENT. string
.c file:#include #include #include #include #include "Prompt.h"JNIEXPORT jstring JNICALL Java_Prompt_getLine (JNIEnv *env, jobject this, jstring prompt){ char buf[128]; const jbyte *str;原创 2016-04-08 19:05:07 · 493 阅读 · 0 评论 -
JNI - AttachCurrentThread
•The JNI interface pointer(JNIEnv) isvalid only in the current thread.•Should another thread need to access theJava VM, it must first call AttachCurrentThread() toattach itself to the VM and obt原创 2016-06-13 06:10:06 · 1688 阅读 · 1 评论
分享