diff --git a/apple/JavaNativeFoundation/doc/JNFRunLoop Class Reference.html b/apple/JavaNativeFoundation/doc/JNFRunLoop Class Reference.html new file mode 100644 index 0000000000..ff5e54d2b7 --- /dev/null +++ b/apple/JavaNativeFoundation/doc/JNFRunLoop Class Reference.html @@ -0,0 +1,242 @@ + + + + JNFRunLoop Class Reference + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Mac Developer Library + Developer +
Search
+
+
+ + +
+
+ + + + +
+ + + + +

JNFRunLoop Class Reference

Inherits from
Framework
/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaNativeFoundation.framework
Declared in
JavaNativeFoundation/JNFRunLoop.h
+ +

Overview

The JNFRunLoop class provides methods for executing selectors and blocks on an application’s main thread in the Java run-loop mode. Executing JNI tasks on the main thread lets you take advantage of the main thread’s existing JNI environment instead of creating a new environment for one-time use.

Tasks

+ +

Performing JNI Tasks on the Main Thread

+ + + + + + + +

Class Methods

javaRunLoopMode

Returns the string value of the Java run-loop mode.

+ (NSString *)javaRunLoopMode
Return Value

The string value of the Java run-loop mode.

performOnMainThread:on:withObject:waitUntilDone:

Performs a selector with a single argument on the application’s main thread in the Java run-loop mode.

+ (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait
Parameters
aSelector

The selector to perform.

target

The receiver of the selector.

arg

The selector’s single argument.

wait

A Boolean value that indicates whether the method should wait for the selector to finish executing before returning.

Discussion

Specifying YES for wait has undefined behavior if this method is called from the main thread.

performOnMainThreadWaiting:withBlock:

Executes a block on the application’s main thread in the Java run-loop mode.

+ (void)performOnMainThreadWaiting:(BOOL)waitUntilDone withBlock:(void (^)())block
Parameters
waitUntilDone

A Boolean value that indicates whether the method should wait for the block to finish executing before returning.

block

The block to execute.

Discussion

Specifying YES for waitUntilDone has undefined behavior if this method is called from the main thread.

+
+ + +
+
+
+
+
+ +
+
+
+
Feedback
+ + + + + + + + + + diff --git a/apple/JavaNativeFoundation/doc/JNFRunnable Class Reference.html b/apple/JavaNativeFoundation/doc/JNFRunnable Class Reference.html new file mode 100644 index 0000000000..97512fc3d5 --- /dev/null +++ b/apple/JavaNativeFoundation/doc/JNFRunnable Class Reference.html @@ -0,0 +1,232 @@ + + + + JNFRunnable Class Reference + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Mac Developer Library + Developer +
Search
+
+
+ + +
+
+ + + + +
+ + + + +

JNFRunnable Class Reference

Inherits from
Framework
/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaNativeFoundation.framework
Declared in
JavaNativeFoundation/JNFRunnable.h
+ +

Overview

The JNFRunnable class provides methods for converting java.lang.Runnable objects to NSInvocation objects and blocks.

Tasks

+ +

Converting Java Runnables

+ + + + + + + +

Class Methods

blockWithRunnable:withEnv:

Converts a java.lang.Runnable object to a block.

+ (void(^)()) blockWithRunnable:(jobject)runnable withEnv:(JNIEnv *)env
Parameters
runnable

The java.lang.Runnable object to convert.

env

The JNI environment of the calling thread.

Return Value

A block representation of runnable.

invocationWithRunnable:withEnv:

Converts a java.lang.Runnable object to an NSInvocation object.

+ (NSInvocation *) invocationWithRunnable:(jobject)runnable withEnv:(JNIEnv *)env
Parameters
runnable

The java.lang.Runnable object to convert.

env

The JNI environment of the calling thread.

Return Value

An NSInvocation representation of runnable.

+
+ + +
+
+
+
+
+ +
+
+
+
Feedback
+ + + + + + + + + + diff --git a/apple/JavaNativeFoundation/doc/Java Native Foundation Functions Reference.html b/apple/JavaNativeFoundation/doc/Java Native Foundation Functions Reference.html new file mode 100644 index 0000000000..06718caa79 --- /dev/null +++ b/apple/JavaNativeFoundation/doc/Java Native Foundation Functions Reference.html @@ -0,0 +1,1457 @@ + + + + Java Native Foundation Functions Reference + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Mac Developer Library + Developer +
Search
+
+
+ + +
+
+ + + + +
+ + + + +

Java Native Foundation Functions Reference

Framework
/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaNativeFoundation.framework
Declared in
JavaNativeFoundation/JNFJNI.h
JavaNativeFoundation/JNFNumber.h
JavaNativeFoundation/JNFObject.h
JavaNativeFoundation/JNFPath.h
JavaNativeFoundation/JNFString.h
JavaNativeFoundation/JNFThread.h

Overview

This document describes the functions, constants, and data types used to communicate between the Java virtual machine and the Objective-C runtime.

Functions by Task

+ + +

Handling Exceptions

+ + + + + + +

Caching Class and Member Information

+ + + + + + +

Accessing Basic Java Object Functionality

+ + + + + + +

Creating Java Arrays

+ + + + + + +

Getting Non-Static Fields of Java Objects

+ + + + + + +

Getting Static Fields of Java Objects

+ + + + + + +

Setting Non-Static Fields of Java Objects

+ + + + + + +

Setting Static Fields of Java Objects

+ + + + + + +

Calling Non-Static Methods of Java Objects

+ + + + + + +

Calling Static Methods of Java Objects

+ + + + + + +

Converting Between Java Numbers and NSNumbers

+ + + + + + +

Converting Between Java Strings and NSStrings

+ + + + + + +

Converting Between Java Dates and NSDates

+ + + + + + +

Converting Java Strings to Unicode

+ + + + + + +

Accessing the Current JNI Environment

+ + + + + + +

Managing Global References

+ + + +

Functions

JNFCallBooleanMethod

Calls a method of a Java object that returns a boolean.

+jboolean JNFCallBooleanMethod(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallByteMethod

Calls a method of a Java object that returns a byte.

+jbyte JNFCallByteMethod(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallCharMethod

Calls a method of a Java object that returns a char.

+jchar JNFCallCharMethod(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallDoubleMethod

Calls a method of a Java object that returns a double.

+jdouble JNFCallDoubleMethod(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallFloatMethod

Calls a method of a Java object that returns a float.

+jfloat JNFCallFloatMethod(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallIntMethod

Calls a method of a Java object that returns an int.

+jint JNFCallIntMethod(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallLongMethod

Calls a method of a Java object that returns a long.

+jlong JNFCallLongMethod(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallObjectMethod

Calls a method of a Java object that returns an object.

+jobject JNFCallObjectMethod(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallShortMethod

Calls a method of a Java object that returns a short.

+jshort JNFCallShortMethod(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallStaticBooleanMethod

Calls a static method of a Java object that returns a boolean.

+jboolean JNFCallStaticBooleanMethod(
+   JNIEnv *env,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallStaticByteMethod

Calls a static method of a Java object that returns a byte.

+jbyte JNFCallStaticByteMethod(
+   JNIEnv *env,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallStaticCharMethod

Calls a static method of a Java object that returns a char.

+jchar JNFCallStaticCharMethod(
+   JNIEnv *env,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallStaticDoubleMethod

Calls a static method of a Java object that returns a double.

+jdouble JNFCallStaticDoubleMethod(
+   JNIEnv *env,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallStaticFloatMethod

Calls a static method of a Java object that returns a float.

+jfloat JNFCallStaticFloatMethod(
+   JNIEnv *env,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallStaticIntMethod

Calls a static method of a Java object that returns an int.

+jint JNFCallStaticIntMethod(
+   JNIEnv *env,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallStaticLongMethod

Calls a static method of a Java object that returns a long.

+jlong JNFCallStaticLongMethod(
+   JNIEnv *env,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallStaticObjectMethod

Calls a static method of a Java object that returns an object.

+jobject JNFCallStaticObjectMethod(
+   JNIEnv *env,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallStaticShortMethod

Calls a static method of a Java object that returns a short.

+jshort JNFCallStaticShortMethod(
+   JNIEnv *env,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

method

The member information for the method.

...

The parameters to pass to the method.

Return Value

The result of the method.

See Also

JNFCallStaticVoidMethod

Calls a static method of a Java object that returns void.

+void JNFCallStaticVoidMethod(
+   JNIEnv *env,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

method

The member information for the method.

...

The parameters to pass to the method.

See Also

JNFCallVoidMethod

Calls a method of a Java object that returns void.

+void JNFCallVoidMethod(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *method,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

method

The member information for the method.

...

The parameters to pass to the method.

See Also

JNFDeleteGlobalRef

Deletes a global reference to a Java object.

+void JNFDeleteGlobalRef(
+   JNIEnv *env,
+   jobject globalRef
+);
+
Parameters
env

The JNI environment.

obj

The Java object.

JNFGetBooleanField

Gets a non-static boolean field of a Java object.

+jboolean JNFGetBooleanField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the boolean field.

Return Value

The boolean stored in field.

See Also

JNFGetByteField

Gets a non-static byte field of a Java object.

+jbyte JNFGetByteField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the byte field.

Return Value

The byte stored in field.

See Also

JNFGetCharField

Gets a non-static char field of a Java object.

+jchar JNFGetCharField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the char field.

Return Value

The char stored in field.

See Also

JNFGetDoubleField

Gets a non-static double field of a Java object.

+jdouble JNFGetDoubleField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the double field.

Return Value

The double stored in field.

See Also

JNFGetFloatField

Gets a non-static float field of a Java object.

+jfloat JNFGetFloatField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the float field.

Return Value

The float stored in field.

See Also

JNFGetIntField

Gets a non-static int field of a Java object.

+jint JNFGetIntField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the int field.

Return Value

The int stored in field.

See Also

JNFGetLongField

Gets a non-static long field of a Java object.

+jlong JNFGetLongField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the long field.

Return Value

The long stored in field.

See Also

JNFGetObjectField

Gets a non-static object field of a Java object.

+jobject JNFGetObjectField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the object field.

Return Value

The object stored in field.

See Also

JNFGetShortField

Gets a non-static short field of a Java object.

+jshort JNFGetShortField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the short field.

Return Value

The short stored in field.

See Also

JNFGetStaticBooleanField

Gets a static boolean field of a Java object.

+jboolean JNFGetStaticBooleanField(
+   JNIEnv *env,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the boolean field.

Return Value

The boolean stored in field.

See Also

JNFGetStaticByteField

Gets a static byte field of a Java object.

+jbyte JNFGetStaticByteField(
+   JNIEnv *env,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the byte field.

Return Value

The byte stored in field.

See Also

JNFGetStaticCharField

Gets a static char field of a Java object.

+jchar JNFGetStaticCharField(
+   JNIEnv *env,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the char field.

Return Value

The char stored in field.

See Also

JNFGetStaticDoubleField

Gets a static double field of a Java object.

+jdouble JNFGetStaticDoubleField(
+   JNIEnv *env,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the double field.

Return Value

The double stored in field.

See Also

JNFGetStaticFloatField

Gets a static float field of a Java object.

+jfloat JNFGetStaticFloatField(
+   JNIEnv *env,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the float field.

Return Value

The float stored in field.

See Also

JNFGetStaticIntField

Gets a static int field of a Java object.

+jint JNFGetStaticIntField(
+   JNIEnv *env,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the int field.

Return Value

The int stored in field.

See Also

JNFGetStaticLongField

Gets a static long field of a Java object.

+jlong JNFGetStaticLongField(
+   JNIEnv *env,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the long field.

Return Value

The long stored in field.

See Also

JNFGetStaticObjectField

Gets a static object field of a Java object.

+jobject JNFGetStaticObjectField(
+   JNIEnv *env,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the object field.

Return Value

The object stored in field.

See Also

JNFGetStaticShortField

Gets a static short field of a Java object.

+jshort JNFGetStaticShortField(
+   JNIEnv *env,
+   JNFMemberInfo *field
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the short field.

Return Value

The short stored in field.

See Also

JNFGetStringUTF16UniChars

Gets UTF-16 characters from a jstring object.

+const unichar *JNFGetStringUTF16UniChars(
+   JNIEnv *env,
+   jstring javaString
+);
+
Parameters
env

The JNI environment of the calling thread.

javaString

The jstring object to convert.

Return Value

A UTF-16 character array representation of javaString.

Discussion

This function raises a JNFException if UTF-16 characters cannot be obtained.

You need to release the return value with JNFReleaseStringUTF16UniChars.

Declared In
JNFString.h

JNFGetStringUTF8Chars

Gets UTF-8 characters from a jstring object.

+const char *JNFGetStringUTF8Chars(
+   JNIEnv *env,
+   jstring javaString
+);
+
Parameters
env

The JNI environment of the calling thread.

javaString

The jstring object to convert.

Return Value

A UTF-8 character array representation of javaString.

Discussion

This function raises a JNFException if UTF-8 characters cannot be obtained.

You need to release the return value with JNFReleaseStringUTF8Chars.

Declared In
JNFString.h

JNFIsInstanceOf

Returns the result of applying the instanceof operator to a given Java object with a given class.

+BOOL JNFIsInstanceOf(
+   JNIEnv *env,
+   jobject obj,
+   JNFClassInfo *clazz
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

clazz

The class to compare against.

Return Value

YES if obj is an instance of clazz; otherwise, NO.

Declared In
JNFJNI.h

JNFJavaMillisToNSTimeInterval

Converts a millisecond time interval calculated from Java’s January 1, 1970 epoch to an NSTimeInterval object calculated from the January 1, 2001 epoch of OS X.

+NSTimeInterval JNFJavaMillisToNSTimeInterval(
+   jlong javaMillisSince1970
+);
+
Parameters
javaMillisSince1970

The Java interval to convert.

Return Value

An NSTimeInterval representation of javaMillisSince1970.

Declared In
JNFDate.h

JNFJavaToNSDate

Converts a java.util.Calendar object or a java.util.Date object to an NSDate object.

+NSDate *JNFJavaToNSDate(
+   JNIEnv *env,
+   jobject date
+);
+
Parameters
env

The JNI environment of the calling thread.

date

The java.util.Calendar object or java.util.Date object to convert.

Return Value

An autoreleased NSDate representation of date.

Declared In
JNFDate.h

JNFJavaToNSNumber

Converts a java.lang.Number object to an NSNumber object.

+NSNumber *JNFJavaToNSNumber(
+   JNIEnv *env,
+   jobject n
+);
+
Parameters
env

The JNI environment of the calling thread.

n

The java.lang.Number object.

Return Value

An autoreleased NSNumber representation of n.

Declared In
JNFNumber.h

JNFJavaToNSString

Converts a jstring object to an NSString object.

+NSString *JNFJavaToNSString(
+   JNIEnv *env,
+   jstring javaString
+);
+
Parameters
env

The JNI environment of the calling thread.

javaString

The jstring object to convert.

Return Value

An autoreleased NSString representation of javaString.

Declared In
JNFString.h

JNFNewBooleanArray

Creates a Java boolean array of a specified size.

+jbooleanArray JNFNewBooleanArray(
+   JNIEnv *env,
+   jsize length
+);
+
Parameters
env

The JNI environment of the calling thread.

length

The length of the array.

Return Value

The created array.

JNFNewByteArray

Creates a Java byte array of a specified size.

+jbyteArray JNFNewByteArray(
+   JNIEnv *env,
+   jsize length
+);
+
Parameters
env

The JNI environment of the calling thread.

length

The length of the array.

Return Value

The created array.

JNFNewCharArray

Creates a Java char array of a specified size.

+jcharArray JNFNewCharArray(
+   JNIEnv *env,
+   jsize length
+);
+
Parameters
env

The JNI environment of the calling thread.

length

The length of the array.

Return Value

The created array.

JNFNewDoubleArray

Creates a Java double array of a specified size.

+jdoubleArray JNFNewDoubleArray(
+   JNIEnv *env,
+   jsize length
+);
+
Parameters
env

The JNI environment of the calling thread.

length

The length of the array.

Return Value

The created array.

JNFNewFloatArray

Creates a Java long array of a specified size.

+jfloatArray JNFNewFloatArray(
+   JNIEnv *env,
+   jsize length
+);
+
Parameters
env

The JNI environment of the calling thread.

length

The length of the array.

Return Value

The created array.

JNFNewGlobalRef

Creates a global reference to a Java object.

+jobject JNFNewGlobalRef(
+   JNIEnv *env,
+   jobject obj
+);
+
Parameters
env

The JNI environment.

obj

The Java object.

Return Value

A new global reference to obj.

JNFNewIntArray

Creates a Java int array of a specified size.

+jintArray JNFNewIntArray(
+   JNIEnv *env,
+   jsize length
+);
+
Parameters
env

The JNI environment of the calling thread.

length

The length of the array.

Return Value

The created array.

JNFNewLongArray

Creates a Java long array of a specified size.

+jlongArray JNFNewLongArray(
+   JNIEnv *env,
+   jsize length
+);
+
Parameters
env

The JNI environment of the calling thread.

length

The length of the array.

Return Value

The created array.

JNFNewObject

Creates a new Java object of a given class with a given constructor.

+jobject JNFNewObject(
+   JNIEnv *env,
+   JNFMemberInfo *constructor,
+   ...
+);
+
Parameters
env

The JNI environment of the calling thread.

constructor

The member information for the constructor.

...

The parameters to pass to the constructor.

Return Value

The created Java object.

See Also
Declared In
JNFJNI.h

JNFNewObjectArray

Creates an array of a specified size for instances of a specified Java class.

+jobjectArray JNFNewObjectArray(
+   JNIEnv *env,
+   JNFClassInfo *clazz,
+   jsize length
+);
+
Parameters
env

The JNI environment of the calling thread.

clazz

The class the array holds instances of.

length

The length of the array.

Return Value

The created array.

JNFNewShortArray

Creates a Java short array of a specified size.

+jshortArray JNFNewShortArray(
+   JNIEnv *env,
+   jsize length
+);
+
Parameters
env

The JNI environment of the calling thread.

length

The length of the array.

Return Value

The created array.

JNFNormalizedJavaStringForPath

Converts an NSString object to a jstring object suited for file system paths.

+jstring JNFNormalizedJavaStringForPath(
+   JNIEnv *env,
+   NSString *path
+);
+
Parameters
env

The JNI environment of the calling thread.

path

The NSString object to convert.

Return Value

A jstring representation of path in precomposed UTF-16 format.

Declared In
JNFPath.h

JNFNormalizedNSStringForPath

Converts a jstring object to an NSString object suited for file system paths.

+NSString *JNFNormalizedNSStringForPath(
+   JNIEnv *env,
+   jstring *path
+);
+
Parameters
env

The JNI environment of the calling thread.

path

The jstring object to convert.

Return Value

An autoreleased NSString representation of path in decomposed UTF-16 format.

Declared In
JNFPath.h

JNFNSTimeIntervalToJavaMillis

Converts an NSTimeInterval object calculated from the January 1, 2001 epoch of OS X to a millisecond time interval calculated from Java’s January 1, 1970 epoch.

+jlong JNFNSTimeIntervalToJavaMillis(
+   NSTimeInterval intervalSince2001
+);
+
Parameters
intervalSince2001

The NSTimeInterval object to convert.

Return Value

A jlong representation of intervalSince2001.

Declared In
JNFDate.h

JNFNSToJavaCalendar

Converts an NSDate object to a java.util.Calendar object.

+jobject JNFNSToJavaCalendar(
+   JNIEnv *env,
+   NSDate *date
+);
+
Parameters
env

The JNI environment of the calling thread.

date

The NSDate object to convert.

Return Value

A java.util.Calendar representation of date.

Declared In
JNFDate.h

JNFNSToJavaNumber

Converts an NSNumber object to a java.lang.Number object.

+jobject *JNFNSToJavaNumber(
+   JNIEnv *env,
+   NSNumber *n
+);
+
Parameters
env

The JNI environment of the calling thread.

n

The NSNumber object.

Return Value

A java.lang.Long representation of n if n is integral; otherwise, a java.lang.Double representation of n.

Discussion

The return value is a JNI local reference. Code that calls this function must call DeleteLocalRef with the return value.

Declared In
JNFNumber.h

JNFNSToJavaString

Converts an NSString object to a jstring object.

+jstring JNFNSToJavaString(
+   JNIEnv *env,
+   NSString *nsString
+);
+
Parameters
env

The JNI environment of the calling thread.

nsString

The NSString object to convert.

Return Value

A jstring representation of nsString.

Discussion

The return value is a JNI local reference. Code that calls this function must call DeleteLocalRef with the return value.

Declared In
JNFString.h

JNFObjectClassName

Returns the result of calling Object.getClass().toString() on a given Java object.

+NSString *JNFObjectClassName(
+   JNIEnv* env,
+   jobject obj,
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

Return Value

The result of obj.getClass().toString() returned as an NSString object.

Declared In
JNFObject.h

JNFObjectEquals

Returns the result of calling Object.equals() with two given Java objects.

+BOOL JNFObjectEquals(
+   JNIEnv* env,
+   jobject a,
+   jobject b
+);
+
Parameters
env

The JNI environment of the calling thread.

a

The first Java object to compare.

b

The second Java object to compare.

Return Value

YES if a and b are equal according to a.equals(b); otherwise, NO.

Declared In
JNFObject.h

JNFObjectToString

Returns the result of calling Object.toString() on a given Java object.

+NSString *JNFObjectToString(
+   JNIEnv* env,
+   jobject obj,
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

Return Value

The result of obj.toString() returned as an NSString object.

Declared In
JNFObject.h

JNFObtainEnv

Attaches the current thread to the Java VM and obtains a JNI environment to interact with it.

+JNIEnv *JNFObtainEnv(
+   JNFThreadContext *context
+);
+
Parameters
context

The current thread’s context.

Return Value

The JNI environment.

Discussion

You should use this function only when it is otherwise impossible to pass the JNI environment to the current context, such as in a callback.

JNFPerformEnvBlock

Sets up a JNI environment and executes a specified block in it.

+void JNFPerformEnvBlock(
+   JNFThreadContext context,
+   JNIEnvBlock block
+);
+
Parameters
context

The current thread’s context.

block

The block to execute.

Discussion

This function calls JNFObtainEnv before executing block and calls JNFReleaseEnv afterwards. Call this function when you otherwise do not have access to a JNI environment. The JNI environment created by this function is valid only for the duration of the execution of block.

See Also

JNFReleaseEnv

Releases this thread’s JNI environment and detaches the thread from the Java VM.

+void JNFReleaseEnv(
+   JNIEnv *env,
+   JNFThreadContext *context
+);
+
Parameters
env

The JNI environment.

context

The current thread’s context.

JNFReleaseStringUTF16UniChars

Releases UTF-16 characters obtained with JNFGetStringUTF16UniChars.

+void JNFReleaseStringUTF16UniChars(
+   JNIEnv *env,
+   jstring javaString,
+   const unichar *unichars
+);
+
Parameters
env

The JNI environment of the calling thread.

javaString

The jstring object that the characters were obtained from.

unichars

The UTF-16 characters to release.

Declared In
JNFString.h

JNFReleaseStringUTF8Chars

Releases UTF-8 characters obtained with JNFGetStringUTF8Chars.

+void JNFReleaseStringUTF8Chars(
+   JNIEnv *env,
+   jstring javaString,
+   const char *chars
+);
+
Parameters
env

The JNI environment of the calling thread.

javaString

The jstring object that the characters were obtained from.

chars

The UTF-8 characters to release.

Declared In
JNFString.h

JNFSetBooleanField

Sets a non-static boolean field of a Java object.

+void JNFSetBooleanField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field,
+   jboolean val
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetByteField

Sets a non-static byte field of a Java object.

+void JNFSetByteField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field,
+   jbyte val
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetCharField

Sets a non-static char field of a Java object.

+void JNFSetCharField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field,
+   jchar val
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetDoubleField

Sets a non-static double field of a Java object.

+void JNFSetDoubleField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field,
+   jdouble val
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetFloatField

Sets a non-static float field of a Java object.

+void JNFSetFloatField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field,
+   jfloat val
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetIntField

Sets a non-static int field of a Java object.

+void JNFSetIntField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field,
+   jint val
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetLongField

Sets a non-static long field of a Java object.

+void JNFSetLongField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field,
+   jlong val
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetObjectField

Sets a non-static object field of a Java object.

+void JNFSetObjectField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field,
+   jobject val
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetShortField

Sets a non-static short field of a Java object.

+void JNFSetShortField(
+   JNIEnv *env,
+   jobject obj,
+   JNFMemberInfo *field,
+   jshort val
+);
+
Parameters
env

The JNI environment of the calling thread.

obj

The Java object.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetStaticBooleanField

Sets a static boolean field of a Java object.

+void JNFSetStaticBooleanField(
+   JNIEnv *env,
+   JNFMemberInfo *field,
+   jboolean val
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetStaticByteField

Sets a static byte field of a Java object.

+void JNFSetStaticByteField(
+   JNIEnv *env,
+   JNFMemberInfo *field,
+   jbyte val
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetStaticCharField

Sets a static char field of a Java object.

+void JNFSetStaticCharField(
+   JNIEnv *env,
+   JNFMemberInfo *field,
+   jchar val
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetStaticDoubleField

Sets a static double field of a Java object.

+void JNFSetStaticDoubleField(
+   JNIEnv *env,
+   JNFMemberInfo *field,
+   jdouble val
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetStaticFloatField

Sets a static float field of a Java object.

+void JNFSetStaticFloatField(
+   JNIEnv *env,
+   JNFMemberInfo *field,
+   jfloat val
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetStaticIntField

Sets a static int field of a Java object.

+void JNFSetStaticIntField(
+   JNIEnv *env,
+   JNFMemberInfo *field,
+   jint val
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetStaticLongField

Sets a static long field of a Java object.

+void JNFSetStaticLongField(
+   JNIEnv *env,
+   JNFMemberInfo *field,
+   jlong val
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetStaticObjectField

Sets a static object field of a Java object.

+void JNFSetStaticObjectField(
+   JNIEnv *env,
+   JNFMemberInfo *field,
+   jobject val
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the object field.

val

The new value of field.

See Also

JNFSetStaticShortField

Sets a static short field of a Java object.

+void JNFSetStaticShortField(
+   JNIEnv *env,
+   JNFMemberInfo *field,
+   jshort val
+);
+
Parameters
env

The JNI environment of the calling thread.

field

The member information for the object field.

val

The new value of field.

See Also

JNF_CLASS_CACHE

Creates a JNFClassInfo struct with desired parameters.

+#define JNF_CLASS_CACHE(cache_symbol, name) \
+JNFClassInfo cache_symbol = {name, NULL}
+
Parameters
cache_symbol

The variable name of the struct.

name

The name of the class that the struct represents.

See Also

JNF_COCOA_ENTER

A macro that indicates the beginning of a JNI method.

+#define JNF_COCOA_ENTER(env)                                     \
+{                                                                \
+   JNFAutoreleasePoolToken* _token = JNFNativeMethodEnter();    \
+   JNF_COCOA_DURING(env)
+
Parameters
env

The JNI environment of the calling thread.

Discussion

This macro sets up an autorelease pool for a JNI method and initiates a try block.

You should include this macro at the beginning of every JNI method.

JNF_COCOA_EXIT

A macro that indicates the end of a JNI method.

+#define JNF_COCOA_EXIT(env)                                     \
+   JNF_COCOA_HANDLE(env)                                       \
+   if (_token) JNFNativeMethodExit(_token);                    \
+}
+
Parameters
env

The JNI environment of the calling thread.

Discussion

This macro cleans up the autorelease pool created by JNF_COCOA_ENTER and throws any exceptions caught during the method to the Java VM.

You should include this macro at the end of every JNI method.

JNF_CTOR_CACHE

Creates a JNFMemberInfo struct for a constructor method with desired parameters.

+#define JNF_CTOR_CACHE(cache_symbol, class_cache_symbol, sig) \
+JNFMemberInfo _ ## cache_symbol = {"<init>", sig, NO, &class_cache_symbol, {NULL}}, *cache_symbol=&_ ## cache_symbol
+
Parameters
cache_symbol

The variable name of the struct.

class_cache_symbol

The JNFClassInfo struct that represents the class that this field or method is a member of.

sig

The signature of the field or method.

See Also

JNF_MEMBER_CACHE

Creates a JNFMemberInfo struct for a non-static field or method with desired parameters.

+#define JNF_MEMBER_CACHE(cache_symbol, class_cache_symbol, name, sig) \
+JNFMemberInfo _ ## cache_symbol = {name, sig, NO, &class_cache_symbol, {NULL}}, *cache_symbol=&_ ## cache_symbol
+
Parameters
cache_symbol

The variable name of the struct.

class_cache_symbol

The JNFClassInfo struct that represents the class that this field or method is a member of.

name

The name of the field or method.

sig

The signature of the field or method.

See Also

JNF_STATIC_MEMBER_CACHE

Creates a JNFMemberInfo struct for a static field or method with desired parameters.

+#define JNF_STATIC_MEMBER_CACHE(cache_symbol, class_cache_symbol, name, sig) \
+JNFMemberInfo _ ## cache_symbol = {name, sig, YES, &class_cache_symbol, {NULL}}, *cache_symbol=&_ ## cache_symbol
+
Parameters
cache_symbol

The variable name of the struct.

class_cache_symbol

The JNFClassInfo struct that represents the class that this field or method is a member of.

name

The name of the field or method.

sig

The signature of the field or method.

See Also

Data Types

JNIEnvBlock

Defines the signature for a block object passed to the JNFPerformEnvBlock function.

+typedef void (^JNIEnvBlock)(JNIEnv *);
+

JNFClassInfo

A struct for caching a Java class reference.

+typedef struct _JNFClassInfo {
+   const char *name;
+   jclass cls;
+} JNFClassInfo;
+
Fields
name

The fully qualified class name, for instance java/lang/String.

cls

The JNI global class reference.

Discussion

This data type should be created with the JNF_CLASS_CACHE macro.

JNFMemberInfo

A struct for caching field or method identification information.

+typedef struct _JNFMemberInfo {
+   const char *name;
+   const char *sig;
+   BOOL isStatic;
+   JNFClassInfo *classInfo;
+   union _j {
+      jfieldID fieldID;
+      jmethodID methodID;
+   } j;
+} JNFMemberInfo;
+
Fields
name

The name of the member.

sig

The signature of the member.

isStatic

YES if the member is static; otherwise, NO.

classInfo

The class that this field or method belongs to.

fieldID

If this is a field, the field ID.

methodID

If this is a method, the field ID.

Discussion

This data type should be created with the JNF_MEMBER_CACHE, JNF_STATIC_MEMBER_CACHE, or JNF_CTOR_CACHE macro.

Constants

JNF Thread Context Flags

Flags for describing the current thread’s context.

+enum {
+   JNFThreadDetachImmediately = (1 << 1),
+   JNFThreadDetachOnThreadDeath = (1 << 2),
+   JNFThreadSetSystemClassLoaderOnAttach = (1 << 3)
+};
+typedef jlong JNFThreadContext;
+
Constants
JNFThreadDetachImmediately

A flag indicating that the thread should detach from the Java VM immediately.

JNFThreadDetachOnThreadDeath

A flag indicating that the thread should automatically detach from the Java VM before it dies.

JNFThreadSetSystemClassLoaderOnAttach

A flag indicating that the thread should set the Java VM’s class loader when it attaches.

+
+ + +
+
+
+
+
+ +
+
+
+
Feedback
+ + + + + + + + + +