KNI Specification

K Native Interface (KNI)
1.0

December, 2002

 
Contents Previous Next

Contents


Preface

1. Background

1.1 Some History

1.2 Why KNI?

2. KNI Goals

3. KNI Scope

3.1 Version Information

3.2 Class and Interface Operations

3.3 Exceptions

3.4 Object Operations

3.5 Instance Field Access

3.6 Static Field Access

3.7 String Operations

3.8 Array Operations

3.9 Parameter (Operand Stack) Access

3.10 Handle Operations

4. KNI Data Types

4.1 Primitive and Reference Types

4.1.1 Primitive Types

4.1.2 Reference Types

4.1.3 Return Types

4.2 Field IDs

4.3 String Formats

4.3.1 UTF-8 Strings

4.3.2 Class Descriptors

4.3.3 Field Descriptors

4.4 Constants

5. KNI Functions

5.1 Version Information

5.1.1 KNI_GetVersion

5.2 Class and Interface Operations

5.2.1 KNI_FindClass

5.2.2 KNI_GetSuperClass

5.2.3 KNI_IsAssignableFrom

5.3 Exceptions

5.3.1 KNI_ThrowNew

5.3.2 KNI_FatalError

5.4 Object Operations

5.4.1 KNI_GetObjectClass

5.4.2 KNI_IsInstanceOf

5.5 Instance Field Access

5.5.1 KNI_GetFieldID

5.5.2 KNI_Get<Type>Field

5.5.3 KNI_Set<Type>Field

5.5.4 KNI_GetObjectField

5.5.5 KNI_SetObjectField

5.6 Static Field Access

5.6.1 KNI_GetStaticFieldID

5.6.2 KNI_GetStatic<Type>Field

5.6.3 KNI_SetStatic<Type>Field

5.6.4 KNI_GetStaticObjectField

5.6.5 KNI_SetStaticObjectField

5.7 String Operations

5.7.1 KNI_GetStringLength

5.7.2 KNI_GetStringRegion

5.7.3 KNI_NewString

5.7.4 KNI_NewStringUTF

5.8 Array Operations

5.8.1 KNI_GetArrayLength

5.8.2 KNI_Get<Type>ArrayElement

5.8.3 KNI_Set<Type>ArrayElement

5.8.4 KNI_GetObjectArrayElement

5.8.5 KNI_SetObjectArrayElement

5.8.6 KNI_GetRawArrayRegion

5.8.7 KNI_SetRawArrayRegion

5.9 Parameter (Operand Stack) Access

5.9.1 KNI_GetParameterAs<Type>

5.9.2 KNI_GetParameterAsObject

5.9.3 KNI_GetThisPointer

5.9.4 KNI_GetClassPointer

5.9.5 KNI_ReturnVoid

5.9.6 KNI_Return<Type>

5.10 Handle Operations

5.10.1 KNI_StartHandles

5.10.2 KNI_DeclareHandle

5.10.3 KNI_IsNullHandle

5.10.4 KNI_IsSameObject

5.10.5 KNI_ReleaseHandle

5.10.6 KNI_EndHandles

5.10.7 KNI_EndHandlesAndReturnObject

6. KNI Programming Overview

6.1 The ‘kni.h’ Include File

6.2 Sample KNI Application

6.2.1 Java Code

6.2.2 The Corresponding Native Code

6.2.3 Compiling and Running the Sample Application in the KVM

7. Examples

7.1 Parameter Passing

7.2 Returning Values from Native Functions

7.2.1 Returning Primitive Values

7.2.2 Returning Object References

7.2.3 Returning Null Object References

7.3 Accessing Fields

7.3.1 General Procedure for Accessing Fields

7.3.2 Accessing Instance Fields

7.3.3 Accessing Static Fields

7.4 Accessing Arrays

7.5 Accessing Strings

 


Contents Previous Next