






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: INTRO TO LOW-LEVEL PROG; Subject: Computer Science; University: University of Maryland; Term: Spring 2007;
Typology: Study notes
1 / 12
This page cannot be seen from the preview
Don't miss anything!







Java Compiler (javac) Helloworld.java
Helloworld.class Helloworld.hgcc HelloworldC.c
Javah –jni
jni.h stdio.h Hello.so
#include <jni.h>#include "HelloWorld.h"#include <stdio.h>JNIEXPORT void JNICALLJava_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj){ printf("Hello world!\n");return;}
z^ Mapping Types
Jlong Long
Jint Int
Jshort Short
Jchar Char
8, unsigned
Jboolean Boolean
Jbyte Byte
Native Type
Size (bits)
Java Type
z^ Need to call special functions to get data and size z^ Example:JNIEXPORT jfloat JNICALLJava_FloatArray_sumArray(JNIEnv env, jobject obj, jfloatArray arr) {jfloat body, sum = 0;jsize I, len;len = (env)->GetArrayLength(env, arr);body = (env)->GetFloatArrayElements(env, arr, 0);for (i=0; i<len; i++) {
sum += body[i];} (*env)->ReleaseFloatArrayElements(env, arr, body, 0);return sum;}