Main Page | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

jlString.h File Reference


Detailed Description

Public interface to native implementation of java.lang.String.

Two parallel sets of definitions are used here, one for internal implementation purposes, the other for the JNI interface. The first uses internal data types (via #ifdef JLSTRING_LOCAL_DEFINED) where the second does not. Instead, it uses <jni.h> data types. Those types must match up for JNI to work, yet by keeping them absolutely separate, application JNI code does not have any dependencies on the core code of this JVM implementation.

Even though there is only apparently one set of definitions, the #ifdef statement controls which set is used.

This file must be included by JNI code along with the java.lang.Class JNI header file. The following example shows how to call one of the local native methods of this class from the JNI environment. Notice that although this is not necessary due to the local implementation shortcut defined in native.c, it is not only possible, but sometimes quite desirable to do so.

   #include <jni.h>
   #include <solaris/jni_md.h>    ... or appropriate platform-specifics
  
   #include "java_lang_String.h"  ... JNI definitions
   #include "jlString.h"          ... this file
  
   JNIEXPORT jstring JNICALL
       Java_java_lang_String_intern(JNIEnv  *env, jobject  thisobj)
   {
       jstring s;

        s = jlString_intern(thisobj); ... call native implementation

        return(s);
   }
   

Attention:
This local native method implementation is defined in native.c and does not make use of the JNIENV pointer in any manner.

Although jvalue is indeed a part of both this implementation and the standard JNI interface through <jni.h> , it is not recommended to use it if at all possible. Due to the fact that both definitions involve unions, along with the slightly differing contents between the two versions, it is almost certain that there will be compilation compatibility problems in the memory layouts from one platform to another, and possibly between the layouts between them on any given platform. Since jvalue is not specificaly a Java type, but instead a JNI construction, this may not be a problem, but this advisory is raised anyway in order to encourage reliable implementation of JNI.

Control

$URL: https://svn.apache.org/path/name/jlString.h $ $Id: jlString.h 0 09/28/2005 dlydick $

Copyright 2005 The Apache Software Foundation or its licensors, as applicable.

Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

Version:
$LastChangedRevision: 0 $
Date:
$LastChangedDate: 09/28/2005 $
Author:
$LastChangedBy: dlydick $ Original code contributed by Daniel Lydick on 09/28/2005.

Reference

Definition in file jlString.h.

#include "jlObject.h"

Go to the source code of this file.

Connection to local native method tables.

These manifest constant code fragments are designed to be inserted directly into locations in native.c without any other modification to that file except a single entry to actually invoke the method.

#define NATIVE_TABLE_JLSTRING   case JLSTRING_NMO_INTERN:
 Complete list of local native method ordinals for java.lang.String.
#define NATIVE_TABLE_JLSTRING_JDOUBLE
 No (jdouble) methods.
#define NATIVE_TABLE_JLSTRING_JFLOAT
 No (jfloat) methods.
#define NATIVE_TABLE_JLSTRING_JINT
 No (jint) methods.
#define NATIVE_TABLE_JLSTRING_JLONG
 No (jlong) methods.
#define NATIVE_TABLE_JLSTRING_JOBJECT   case JLSTRING_NMO_INTERN:
 (jobject) local native method ordinal table for java.lang.String
#define NATIVE_TABLE_JLSTRING_JVOID
 No (jvoid) methods.
#define NATIVE_TABLE_JLSTRING_ORDINALS
 Table of local native methods and their descriptors for java.lang.String.

Unified set of prototypes for functions

JNI table index and external reference to each function that locally implements a JNI native method.

in jlString.c

The JVM native interface ordinal definition base for this class is 30. An enumeration is used so the compiler can help the use to not choose duplicate values.

enum  jlString_nmo_enum { JLSTRING_NMO_INTERN = 30 }
jvm_object_hash jlString_intern (jvm_object_hash objhash)
 JNI hook to intern().


Define Documentation

#define NATIVE_TABLE_JLSTRING   case JLSTRING_NMO_INTERN:
 

Complete list of local native method ordinals for java.lang.String.

Definition at line 169 of file jlString.h.

Referenced by native_verify_ordinal_definition().

#define NATIVE_TABLE_JLSTRING_ORDINALS
 

Value:

{                                                                  \
        { JLSTRING_NMO_INTERN,     "intern",  "()Ljava/lang/String" }, \
                                                                       \
        /* Add other method entries here */                            \
                                                                       \
                                                                       \
        /* End of table marker */                                      \
        { JVMCFG_JLOBJECT_NMO_NULL,                                    \
         CHEAT_AND_USE_NULL_TO_INITIALIZE,                             \
         CHEAT_AND_USE_NULL_TO_INITIALIZE }                            \
    }
Table of local native methods and their descriptors for java.lang.String.

Definition at line 176 of file jlString.h.

#define NATIVE_TABLE_JLSTRING_JVOID
 

No (jvoid) methods.

Definition at line 189 of file jlString.h.

#define NATIVE_TABLE_JLSTRING_JOBJECT   case JLSTRING_NMO_INTERN:
 

(jobject) local native method ordinal table for java.lang.String

Definition at line 195 of file jlString.h.

#define NATIVE_TABLE_JLSTRING_JINT
 

No (jint) methods.

Definition at line 198 of file jlString.h.

#define NATIVE_TABLE_JLSTRING_JFLOAT
 

No (jfloat) methods.

Definition at line 199 of file jlString.h.

#define NATIVE_TABLE_JLSTRING_JLONG
 

No (jlong) methods.

Definition at line 200 of file jlString.h.

#define NATIVE_TABLE_JLSTRING_JDOUBLE
 

No (jdouble) methods.

Definition at line 201 of file jlString.h.


Enumeration Type Documentation

enum jlString_nmo_enum
 

Enumerator:
JLSTRING_NMO_INTERN  Ordinal for intern().

Definition at line 130 of file jlString.h.


Function Documentation

jvm_object_hash jlString_intern jvm_object_hash  objhashthis  ) 
 

JNI hook to intern().

Parameters:
objhashthis Object table hash of this object.
Returns:
Object hash for this java.lang.String (same as input object hash, in this particular implementation)
Todo:
Is this correct?

Definition at line 95 of file jlString.c.

References jvm_object_hash_null.

Referenced by Java_java_lang_String_intern().


Generated on Fri Sep 30 18:59:48 2005 by  doxygen 1.4.4