You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2005/10/08 06:29:29 UTC

svn commit: r307257 [12/24] - in /incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm: ./ bootJVM/ bootJVM/jni/ bootJVM/jni/src/ bootJVM/jni/src/gnu/ bootJVM/jni/src/gnu/classpath/ bootJVM/jni/src/gnu/classpath/0.16/ bootJVM/jni/src/gnu/classpath...

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classpath.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classpath.c?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classpath.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classpath.c Fri Oct  7 21:27:56 2005
@@ -0,0 +1,668 @@
+/*!
+ * @file classpath.c
+ *
+ * @brief Extract @b CLASSPATH runtime variables from the environment
+ * and/or the command line or other appropriate sources.
+ *
+ * The HEAP_INIT() function must have been called before using
+ * these functions so the environment variables can be stored
+ * into it and not depend on the argument or environment pointers
+ * to always be unchanged.
+ *
+ * The tmparea_init() function must have been called before these
+ * functions so the internal @b CLASSPATH can be set up properly.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/classpath.c $ \$Id: classpath.c 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.
+ *
+ * @section Reference
+ *
+ */
+
+#include "arch.h"
+ARCH_COPYRIGHT_APACHE(classpath, c, "$URL: https://svn.apache.org/path/name/classpath.c $ $Id: classpath.c 0 09/28/2005 dlydick $");
+
+
+#include <string.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+
+#include "jvmcfg.h" 
+#include "cfmacros.h" 
+#include "classfile.h" 
+#include "classpath.h" 
+#include "exit.h" 
+#include "heap.h" 
+#include "linkage.h" 
+#include "jvm.h" 
+#include "nts.h" 
+#include "utf.h" 
+#include "util.h" 
+
+/*!
+ *
+ * @brief Initialize @b CLASSPATH search area of the JVM model.
+ * 
+ * Break @b CLASSPATH apart into its constituent paths.  Run once
+ * during startup to parse @b CLASSPATH.  Heap management must be
+ * started before calling this function via HEAP_INIT().  The
+ * command line must also have been scanned via argv_init().
+ *
+ * The tmparea_init() function must have been called before these
+ * functions so the internal @b CLASSPATH can be set up properly.
+ *
+ *
+ * @param  argc    Number of arguments on command line
+ *
+ * @param  argv    Argument vector from the command line
+ *
+ * @param  envp    Environment pointer from command line environ
+ *
+ *
+ * @returns @link #rvoid rvoid@endlink
+ *
+ *
+ * @todo  Add proper searching for @c @b rt.jar file
+ *        and @c @b Xbootclasspath .
+ *        For the moment, they are defined in
+ *        @link  config.h config.h@endlink as the
+ *        @link #CONFIG_HACKED_RTJARFILE CONFIG_HACKED_RTJARFILE@endlink
+ *        and
+  @link #CONFIG_HACKED_BOOTCLASSPATH CONFIG_HACKED_BOOTCLASSPATH@endlink
+ *        pre-processor symbols and are commented in
+ *        @link jvm/src/jvmcfg.h jvmcfg.h@endlink after this
+ *        fashion.
+ *
+ */
+static rchar **classpath_list    = CHEAT_AND_USE_NULL_TO_INITIALIZE;
+static rint   classpath_list_len = 0;
+
+rvoid classpath_init()
+{
+    /* Initialize only once */
+    if (rnull != classpath_list)
+    {
+        return;
+    }
+
+    rint i;
+    rint pathcount;
+
+    /*
+     * Prepare to concatenate the temp directory area with actual
+     * @b CLASSPATH, followed by potential
+     * CONFIG_HACKED_xxx definitions.
+     */
+    rchar *tmpclasspath;                    /* @b CLASSPATH dlm */
+    rint  tmpcplen = strlen(tmparea_get())   + sizeof(rchar)   +
+                     strlen(pjvm->classpath) + sizeof(rchar);
+
+    /*
+     * Compensate for CONFIG_HACKED_xxx definitions, handy development
+     * hooks for when @b CLASSPATH is in question.
+     */
+#ifdef CONFIG_HACKED_BOOTCLASSPATH
+                                                   /* @b CLASSPATH dlm*/
+    tmpcplen += strlen(CONFIG_HACKED_BOOTCLASSPATH) + sizeof(rchar);
+#endif
+#ifdef CONFIG_HACKED_RTJARFILE
+
+    /* For $JAVA_HOME/$CONFIG_HACKED_RTJARFILE */
+    tmpcplen += strlen(pjvm->java_home);
+    tmpcplen += sizeof(rchar);
+    tmpcplen += strlen(CONFIG_HACKED_RTJARFILE)     + sizeof(rchar);
+#endif
+    tmpcplen += sizeof(rchar);/* NUL byte, possibly 1 more than needed*/
+
+    /*
+     * Allocate space for classpath image with temp area and
+     * possible CONFIG_HACKED_xxx adjustments
+     */
+    tmpclasspath = HEAP_GET_DATA(tmpcplen, rfalse);
+
+    /*
+     * Generate concatenation of
+     *
+     * pjvm->TMPAREA:classpath:
+@link #CONFIG_HACKED_BOOTCLASSPATH CONFIG_HACKED_BOOTCLASSPATH@endlink:
+     * @link #CONFIG_HACKED_RTJARFILE CONFIG_HACKED_RTJARFILE@endlink
+     */
+    strcpy(tmpclasspath, tmparea_get());
+    i = strlen(tmpclasspath);
+    tmpclasspath[i] = CLASSPATH_ITEM_DELIMITER_CHAR;
+    tmpclasspath[i + 1] = '\0';
+
+    strcat(tmpclasspath, pjvm->classpath);
+
+#ifdef CONFIG_HACKED_BOOTCLASSPATH
+     i = strlen(tmpclasspath);
+    tmpclasspath[i] = CLASSPATH_ITEM_DELIMITER_CHAR;
+    tmpclasspath[i + 1] = '\0';
+    strcat(tmpclasspath, CONFIG_HACKED_BOOTCLASSPATH);
+#endif
+#ifdef CONFIG_HACKED_RTJARFILE
+     i = strlen(tmpclasspath);
+    tmpclasspath[i] = CLASSPATH_ITEM_DELIMITER_CHAR;
+    tmpclasspath[i + 1] = '\0';
+    strcat(tmpclasspath, pjvm->java_home);
+
+     i = strlen(tmpclasspath);
+    tmpclasspath[i] = CLASSPATH_ITEM_DELIMITER_CHAR;
+    tmpclasspath[i + 1] = '\0';
+    strcat(tmpclasspath, CONFIG_HACKED_RTJARFILE);
+#endif
+    HEAP_FREE_DATA(pjvm->classpath); /* May or may not be on heap */
+    pjvm->classpath = tmpclasspath;  /* Keep for duration of pgm run */
+    
+
+    /* WARNING!  NON-STANDARD TERMINATION CONDITION <= VERSUS < */
+    for (i = 0, pathcount = 0; i <= strlen(tmpclasspath); i++)
+    {
+        if ((CLASSPATH_ITEM_DELIMITER_CHAR == tmpclasspath[i]) ||
+            (i == strlen(tmpclasspath)))
+        {
+            pathcount++;
+        }
+    }
+
+
+    /* Allocate space for list of @b CLASSPATH entries */
+    classpath_list = HEAP_GET_DATA(pathcount * sizeof(rchar *), rtrue);
+
+    rchar *nextpath;
+    rint  thislen;
+    classpath_list_len = 0;
+
+    /* WARNING!  NON-STANDARD TERMINATION CONDITION <= VERSUS < */
+    for (i = 0, nextpath = tmpclasspath;
+         i <= strlen(tmpclasspath);
+         i++)
+    {
+
+        /* If found item delimiter OR END OF STRING (SEE ABOVE) */
+        if ((CLASSPATH_ITEM_DELIMITER_CHAR == tmpclasspath[i]) ||
+            (i == strlen(tmpclasspath)))
+        {
+            /* calculate length of this @b CLASSPATH entry */
+            thislen = (&tmpclasspath[i]) - nextpath;
+
+            /*
+             * Ignore double-delimiter cases.
+             * It does not hurt any thing for @b classpath_list
+             * to be longer than the pointers slots allocated
+             * in it because @b classpath_list_len limits the
+             * range of usage to those validly allocated.
+             */
+            if (0 == thislen)
+            {
+                /* Pretend it was valid */
+                nextpath = &tmpclasspath[i + 1];
+                continue;
+            }
+
+            /*
+             * Allocate enough space for item, plus final '\0'.
+             * Since we are scanning for a delimiter or EOS,
+             * the current length calculation includes the "1 + x"
+             * for the '\0'.  The string[x] location is set to '\0'.
+             */
+            classpath_list[classpath_list_len] =
+                HEAP_GET_DATA(thislen + sizeof(rchar), rfalse);
+
+            /* Store current @b CLASSPATH item, including final '\0' */
+            memcpy(classpath_list[classpath_list_len],
+                   nextpath, 
+                   thislen);
+            classpath_list[classpath_list_len][thislen] = '\0';
+            classpath_list_len++;
+
+            /* Start looking at next @b CLASSPATH item */
+            nextpath = &tmpclasspath[i + 1];
+
+        } /* if tmpclasspath[i] */
+
+    } /* for i */
+
+    /* Declare this module initialized */
+    jvm_classpath_initialized = rtrue;
+
+    return;
+
+} /* END of classpath_init() */
+
+
+/*!
+ * @brief Determine whether or not a @b CLASSPATH entry is a JAR file
+ * instead of being a directory name.
+ *
+ * A JAR file will be named @c @b /path/name/filename.jar, while a
+ * file name in a directory will be named
+ * @c @b /path/name/ClassName.class .
+ *
+ *
+ * @param  pclasspath  String from @b CLASSPATH list
+ *
+ * @returns @link #rtrue rtrue@endlink if string ends with
+ *          @c @b .jar, @link #rfalse rfalse@endlink otherwise.
+ *
+ */
+rboolean classpath_isjar(rchar *pclasspath)
+{
+    rint len, jarlen;
+
+    /* Lengths of test string and of JAR extension (w/ name.ext dlm)*/
+    len = strlen(pclasspath);
+    jarlen = strlen(JVMCFG_EXTENSION_DELIMITER_STRING) +
+             strlen(CLASSFILE_EXTENSION_JAR);
+
+    /* For VERY short @b CLASSPATH entries, it cannot be a JAR file */
+    if (jarlen >= len)
+    {
+        return(rfalse);
+    }
+
+    /* Check if name.ext delimiter present in test string */
+    if (JVMCFG_EXTENSION_DELIMITER_CHAR != pclasspath[len - jarlen])
+    {
+        return(rfalse);
+    }
+
+    /* Now go test JAR extension since delimiter is present */
+    jarlen--;
+    if (0 == strncmp(&pclasspath[len - jarlen],
+                     CLASSFILE_EXTENSION_JAR,
+                     jarlen))
+    {
+        return(rtrue);
+    }
+    else
+    {
+        return(rfalse);
+    }
+
+} /* END of classpath_isjar() */
+
+
+/*!
+ * @brief Convert class name format external to internal form.
+ 
+ * The external format is @c @b class.name.format , while the
+ * internal format is @c @b class/name/format .
+ * Result is unchanged if it is already in internal format.
+ * When finished with result, call HEAP_FREE_DATA().
+ *
+ *
+ * @param  clsname   Null-terminated string containing class name.
+ *
+ *
+ * @returns Null terminated string in internal format.
+ *          Call HEAP_FREE_DATA() when finished with buffer.
+ *
+ */
+
+rchar *classpath_external2internal_classname(rchar *clsname)
+{
+    rint len = strlen(clsname);
+    rchar *rc = HEAP_GET_DATA(1 + len, rfalse); /* 1 + for NUL byte */
+
+    memcpy(rc, clsname, 1 + len); /* 1 + for NUL byte */
+
+    return(classpath_external2internal_classname_inplace(rc));
+
+} /* END of classpath_external2internal_classname() */
+
+
+/*
+ * In-place version of classpath_externam2internal_classname():
+ * Takes an existing buffer and performs the conversion on it
+ * @e without heap allocation.  Return the input buffer.
+ *
+ *
+ * @param[in,out] inoutbfr  Existing buffer containing text to be
+ *                          translated, also receive output
+ *
+ *
+ * @returns buffer address @b inoutbfr
+ *
+ */
+rchar *classpath_external2internal_classname_inplace(rchar *inoutbfr)
+{
+    rint i;
+    int len = strlen(inoutbfr);
+
+    for (i = 0; i < len; i++)
+    {
+        /*
+         * Substitute internal/external delimiter character
+         * in @b inoutbfr where needed.
+         */
+        if (CLASSNAME_EXTERNAL_DELIMITER_CHAR == inoutbfr[i])
+        {
+            inoutbfr[i] = CLASSNAME_INTERNAL_DELIMITER_CHAR;
+        }
+     }
+
+    return(inoutbfr);
+
+} /* END of classpath_external2internal_classname_inplace() */
+
+
+/*!
+ * @brief Search @b CLASSPATH for a given class name using a prchar.
+ *
+ * Return heap pointer to a buffer containing its location.
+ * If not found, return @link #rnull rnull@endlink.
+ * If a class by this name is stored in more than one location, only
+ * the first location is returned.  When done with result, call
+ * HEAP_FREE_DATA(result) to return buffer to heap area.
+ *
+ * All CLASSNAME_EXTERNAL_DELIMITER (ASCII period) characters
+ * found in the input class name will be unconditionally replaced
+ * with CLASSNAME_INTERNAL_DELIMITER (ASCII slash) characters.
+ * Therefore, the class file extension CLASSFILE_EXTENSION_DEFAULT
+ * may not be appended to the class name.  This constraint permits
+ * both internal and external class names to use the same function
+ * to search for classes.
+ *
+ *
+ * @param  clsname  Name of class, without @c @b .class
+ *                  extension, as either @c @b some.class.name
+ *                  or @c @b some/class/name , that is,
+ *                  the internal form of the class name.  The string
+ *                  may or may not contain class formatting of the
+ *                  form @c @b [[[Lsome/class/name;
+ *
+ *
+ * @returns Heap pointer into @b CLASSPATH of directory or JAR file
+ *          containing class (for a regular .class file).
+ *          For a JAR file, report the name of the .jar file
+ *          as for a .class file, but also call classpath_isjar()
+ *          to distinguish between them.  Thus the usage is,
+ *          Return @link #rnull rnull@endlink if no match.
+ *
+ *         @todo VM Spec section 5.3.1:  Throw 'NoClassDeffoundError'
+ *               if no match.
+ *
+ *         Notice that @b clsname must be specified with package
+ *         designations using INTERNAL (slash) delimiter form of
+ *         the path.  This is what is natively found in the class
+ *         files.  Of course, no package name means the simple
+ *         default package, that is, an unpackaged class having
+ *         no <b><code>package some.package.name</code></b> statement
+ *         in source.
+ *
+ * @verbatim
+               rchar *p = classpath_get_from_prchar(
+                                     "some/package/name/SomeClassName");
+  
+               if (rnull != p)
+               {
+             
+                   if (rtrue == classpath_isjar(p))
+                   {
+                       ** Extract class from JAR file **
+                   }
+                   else
+                   {
+                       ** Read class file directly **
+                   }
+               }
+   @endverbatim
+ *
+ */
+
+rchar *classpath_get_from_prchar(rchar *clsname)
+{
+    rint i;
+    struct stat statbfr;
+    rchar *name;
+    int baselen;
+
+    rchar *class_location = HEAP_GET_DATA(JVMCFG_PATH_MAX, rfalse);
+
+    if (rtrue == nts_prchar_isclassformatted(clsname))
+    {
+        /*
+         * Convert @c @b [[[Lpath/name/ClassName; into
+         * @c @b path/name/ClassName
+         */
+        jvm_array_dim arraydims = nts_get_prchar_arraydims(clsname);
+        name = &clsname[1 + arraydims];
+
+        /* Calc position of end-of-class delimiter */
+        rchar *pdlm = strchr(name, BASETYPE_CHAR_L_TERM);
+        baselen = strlen(name);
+
+        /* Should @e always be @link #rtrue rtrue@endlink */
+        if (rnull != pdlm)
+        {
+            baselen = pdlm - name;
+        }
+    }
+    else
+    {
+        /*
+         * If this class name string contained no formatting,
+         * fake the adjustment above to a formatted class name.
+         * Notice that without formatting, there cannot be any
+         * array dimensions.
+         */
+        name = clsname;
+        baselen = strlen(name);
+    }
+
+    rchar *jarscript = HEAP_GET_DATA(JVMCFG_SCRIPT_MAX, rfalse);
+
+    /*
+     * Search through each entry in @b CLASSPATH for a file by
+     * the proper name.
+     */
+
+    for (i = 0; i < classpath_list_len; i++)
+    {
+        int clen;
+
+        /* Test for JAR files in @b CLASSPATH */
+        if (rtrue == classpath_isjar(classpath_list[i]))
+        {
+            /* Convert input parm to internal form, append suffix */
+            strcpy(class_location, name);
+            clen = strlen(class_location);
+            (rvoid) classpath_external2internal_classname_inplace(
+                                                        class_location);
+            class_location[clen] = JVMCFG_EXTENSION_DELIMITER_CHAR;
+            class_location[clen + 1] = '\0';
+            strcat(class_location, CLASSFILE_EXTENSION_DEFAULT);
+
+            /*!
+             * @internal Build up JAR command using internal class name
+             * with suffix.  Make @e sure all files are writeable
+             * for final <b><code>rm -rf</code></b>.
+             */
+            sprintfLocal(jarscript,
+                         JVMCFG_JARFILE_DATA_EXTRACT_SCRIPT,
+                         tmparea_get(),
+                         pjvm->java_home,
+                         pjvm->java_home,
+                         JVMCFG_PATHNAME_DELIMITER_CHAR,
+                         classpath_list[i],
+                         class_location);
+
+            int rc = system(jarscript);
+
+            if (0 != rc)
+            {
+                sysErrMsg("classpath_get_from_prchar",
+                          "Cannot extract '%s' from JAR file %s",
+                          class_location,
+                          classpath_list[i]);
+                exit_jvm(EXIT_CLASSPATH_JAR);
+/*NOTREACHED*/
+            }
+
+            /* Location of extracted file */
+            sprintfLocal(jarscript,
+                         "%s%c%s",
+                         tmparea_get(),
+                         JVMCFG_PATHNAME_DELIMITER_CHAR,
+                         class_location);
+
+            rc = stat(jarscript, &statbfr);
+
+            /*
+             * If file was extracted, report result
+             * in heap-allocated bfr
+             */
+            if (0 == rc)
+            {
+                HEAP_FREE_DATA(class_location);
+
+                return(jarscript);
+            }
+
+            HEAP_FREE_DATA(jarscript);
+        }
+        else
+        {
+            /* Convert input parm to internal form */
+            sprintfLocal(class_location,
+                         "%s%c\0",
+                         classpath_list[i],
+                         JVMCFG_PATHNAME_DELIMITER_CHAR);
+
+            clen = strlen(class_location);
+
+            strcat(class_location, name);
+
+            /*
+             * Convert input parm to internal format and append
+             * class suffix, but convert @e only the @b name part
+             * just appended, and not if if it is a JAR file.
+             */
+            if (rfalse == classpath_isjar(class_location))
+            {
+                (rvoid) classpath_external2internal_classname_inplace(
+                                                 &class_location[clen]);
+
+
+                class_location[clen + baselen] =
+                                        JVMCFG_EXTENSION_DELIMITER_CHAR;
+                class_location[clen + baselen + 1] = '\0';
+
+                strcat(class_location, CLASSFILE_EXTENSION_DEFAULT);
+            }
+
+            /* Test for existence of valid class file */
+            int rc = stat(class_location, &statbfr);
+
+            /* If match found, report result in heap-allocated bfr */
+            if (0 == rc)
+            {
+                return(class_location);
+            }
+        }
+    } /* for i */
+
+    /* Class not found in @b CLASSPATH */
+    HEAP_FREE_DATA(class_location);
+    return((rchar *) rnull);
+
+} /* END of classpath_get_from_prchar() */
+
+
+/*!
+ * @brief Search @b CLASSPATH for a given class name using
+ * a CONSTANT_Utf8_info.
+ *
+ * Invoke @link #classpath_get_from_prchar()
+   classpath_get_from_prchar@endlink after converting @b clsname
+ * from CONSTANT_Utf8_info to prchar.
+ *
+ * For more information, see @link #classpath_get_from_prchar()
+   classpath_get_from_prchar@endlink.
+ *
+ *
+ * @param  clsname  Name of class, without @c @b .class
+ *                  extension, as either @c @b some.class.name
+ *                  or @c @b some/class/name , that is,
+ *                  the internal form of the class name.  The string
+ *                  may or may not contain class formatting of the
+ *                  form @c @b [[[Lsome/class/name;
+ *
+ *
+ * @returns Heap pointer into @b CLASSPATH of directory or JAR file
+ *          containing class (for a regular .class file).
+ *
+ */
+
+rchar *classpath_get_from_cp_entry_utf(cp_info_dup *clsname)
+{
+    rchar *prchar_clsname = utf_utf2prchar(PTR_THIS_CP_Utf8(clsname));
+
+    rchar *rc = classpath_get_from_prchar(prchar_clsname);
+
+    HEAP_FREE_DATA(prchar_clsname);
+
+    return(rc);
+
+} /* END of classpath_get_from_cp_entry_utf() */
+
+
+/*!
+ * @brief Shut down the @b CLASSPATH search area of the JVM model after
+ * JVM execution.
+ * 
+ * @b Parameters: @link #rvoid rvoid@endlink
+ *
+ *
+ *       @returns @link #rvoid rvoid@endlink
+ *
+ */
+rvoid classpath_shutdown()
+{
+    rint i;
+
+    for (i = 0; i < classpath_list_len; i++)
+    {
+        HEAP_FREE_DATA(classpath_list[i]);
+    }
+    HEAP_FREE_DATA(classpath_list);
+
+    classpath_list = (rchar **) rnull;
+    classpath_list_len = 0;
+
+    /* Declare this module uninitialized */
+    jvm_classpath_initialized = rfalse;
+
+    return;
+
+} /* END of classpath_shutdown() */
+
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classpath.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classpath.h?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classpath.h (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classpath.h Fri Oct  7 21:27:56 2005
@@ -0,0 +1,125 @@
+#ifndef _classpath_h_included_
+#define _classpath_h_included_
+
+/*!
+ * @file classpath.h
+ *
+ * @brief Implementation of the @b CLASSPATH environment heuristic.
+ *
+ * The Java Virtual Machine Specification, version 2,
+ * says absolutely NOTHING about the @b CLASSPATH
+ * item, neither as an environment variable, a JVM command line
+ * parameter, or anything.  Instead, section 5.3.1 states, "The
+ * Java virtual machine searches for a purported representation
+ * of [class] C in a platform-dependent manner.  Note that there
+ * is no guarantee that a purported representation found is valid
+ * or is a representation of C.  Typically, a class or interface
+ * will be represented using a file in a hierarchiacal file system.
+ * The name of the class or interface will usually be encoded in
+ * the pathname of the file."
+ *
+ * This is the industry standard practice, as implemented by use
+ * of the @b CLASSPATH variable.  This header file defines its
+ * characteristics.  The same goes for the JAVA_PATH environment
+ * variable, which has no further definitions that its name and
+ * string content that contains a path name.  Since these variables
+ * are actually a part of standard practice, their names are actually
+ * defined in @link jvm/src/jvmcfg.h jvmcfg.h@endlink instead of
+ * here, but @b CLASSPATH behavior is defined here.
+ *
+ * Conventions for OS file systems (see also
+ * @link jvm/src/jvmcfg.h jvmcfg.h@endlink for
+ * JVMCFG_PATHNAME_xxx and JVMCFG_EXTENSION_xxx definitions).
+ *
+ * @verbatim
+  
+   Unix style:     CLASSPATH="/path/name1:/path/name2/filename.jar"
+  
+   Windows style:  CLASSPATH="c:\path\name1;d:\path\name2\\filename.jar"
+  
+   @endverbatim
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/classpath.h $ \$Id: classpath.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.
+ *
+ * @section Reference
+ *
+ */
+
+ARCH_COPYRIGHT_APACHE(classpath, h, "$URL: https://svn.apache.org/path/name/classpath.h $ $Id: classpath.h 0 09/28/2005 dlydick $");
+
+
+/*!
+ * @brief Delimiter betwen members of @b CLASSPATH string
+ *
+ */
+#ifdef CONFIG_WINDOWS
+#define CLASSPATH_ITEM_DELIMITER_CHAR       ';'
+
+#else
+#define CLASSPATH_ITEM_DELIMITER_CHAR       ':'
+
+#endif
+
+
+/*!
+ * @name File extensions
+ *
+ * @brief Convention for class file names, but not mandatory.
+ *
+ */
+
+/*@{ */
+
+#define CLASSFILE_EXTENSION_DEFAULT "class"
+#define CLASSFILE_EXTENSION_JAR     "jar"
+#define CLASSFILE_EXTENSION_ZIP     "zip"
+
+/*@} */
+
+
+
+/* Prototypes for functions in 'classpath.c' */ 
+extern rvoid classpath_init(rvoid);
+extern rvoid classpath_shutdown(rvoid);
+
+extern rboolean classpath_isjar(rchar *pclasspath);
+
+extern rchar *classpath_external2internal_classname(rchar *clsname);
+
+extern
+  rchar *classpath_external2internal_classname_inplace(rchar *inoutbfr);
+
+extern rchar *classpath_get_from_prchar(rchar *clsname);
+
+extern rchar *classpath_get_from_cp_entry_utf(cp_info_dup *clsname);
+
+
+#endif /* _classpath_h_included_ */
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classutil.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classutil.c?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classutil.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/classutil.c Fri Oct  7 21:27:56 2005
@@ -0,0 +1,59 @@
+/*!
+ * @file classutil.c
+ *
+ * @brief Utility and glue functions for
+ * @link jvm/src/class.c class.c@endlink
+ * and @c @b java.lang.Class
+ *
+ *
+ * @internal Due to the fact that the implementation of the Java class
+ * and the supporting rclass structure is deeply embedded in the core
+ * of the development of this software, this file has contents
+ * that come and go during development.  Some functions get
+ * staged here before deciding where they @e really go; some
+ * are interim functions for debugging, some were glue that eventually
+ * went away.  Be careful to remove prototypes to such functions
+ * from the appropriate header file.
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/classutil.c $ \$Id: classutil.c 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.
+ *
+ * @section Reference
+ *
+ */
+
+#include "arch.h"
+ARCH_COPYRIGHT_APACHE(classutil, c, "$URL: https://svn.apache.org/path/name/classutil.c $ $Id: classutil.c 0 09/28/2005 dlydick $");
+
+
+#include "jvmcfg.h"
+#include "classfile.h"
+#include "jvm.h"
+
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/exit.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/exit.c?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/exit.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/exit.c Fri Oct  7 21:27:56 2005
@@ -0,0 +1,328 @@
+/*!
+ * @file exit.c
+ *
+ * @brief Abort strategy functions for the JVM.
+ *
+ * This implementation uses two invocations of
+ * @c @b setjmp(3)/longjmp(3) to perform non-local returns
+ * from error conditions.
+ *
+ * Normal exit conditions are more likely to use a simple
+ * @c @b return() instead of the error mechanism, but are
+ * not inhibited from it except that returning the normal
+ * @link #EXIT_MAIN_OKAY EXIT_MAIN_OKAY@endlink cannot occur due to the
+ * design of @c @b longjmp(3), which will force
+ * @link #EXIT_LONGJMP_ARGERROR EXIT_LONGJMP_ARGERROR@endlink instead.
+ *
+ * @link #exit_init() exit_init()@endlink must be invoked at a
+ * higher level than where @link #pjvm pjvm@endlink is used to
+ * access anything, namely, @c @b pjvm->xxx since the
+ * main JVM structure cannot be initialized at the same time
+ * it is being protected by a @b jmp_buf hook stored within it.
+ * It typically will be armed at the very entry to the JVM and
+ * will never be re-armed since it is global in its scope of coverage.
+ *
+ * @link #exit_exception_setup() exit_exception_setup()@endlink
+ * has similar requirements.  However, since it is involved more
+ * closely with @link #jvm_init() jvm_init()@endlink, it is typically
+ * invoked at the beginning of that function.  Once initialization
+ * proceeds and more and more facilities become available, it should
+ * be re-armed to a new handler to reflect increased capability.  Once
+ * the virtual execution engine is ready, it should be re-armed to
+ * manually run @link #JVMCLASS_JAVA_LANG_LINKAGEERROR
+ * JVMCLASS_JAVA_LANG_LINKAGEERROR@endlink subclasses through
+ * the virtual execution engine before shutting down the JVM.
+ *
+ * @link #exit_end_thread_setup() exit_end_thread_setup()@endlink
+ * is not so much an error handler as a simplification of the JVM
+ * inner loop execution in @link #opcode_run() opcode_run()@endlink
+ * that eliminates the need for two of the tests needed for continuing
+ * to run Java virtual instruction on this thread.  It is invoked
+ * only once, and that before the inner look @c @b while statement.
+ *  When a member of the Java @b return instruction group is
+ * executed, then if the thread termination conditions have been
+ * met, the @c @b longjmp(3) exits the loop non-locally.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/exit.c $ \$Id: exit.c 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.
+ *
+ * @section Reference
+ *
+ */
+
+#include "arch.h"
+ARCH_COPYRIGHT_APACHE(exit, c, "$URL: https://svn.apache.org/path/name/exit.c $ $Id: exit.c 0 09/28/2005 dlydick $");
+
+
+#include <setjmp.h>
+
+#include "jvmcfg.h"
+#include "classfile.h"
+#include "jvm.h"
+
+/*!
+ * @brief Permit localized usage of @b EXIT_xxx symbols.
+ */
+#define I_AM_EXIT_C
+#include "exit.h"
+
+/*!
+ * @brief Return a descriptive name string for each exit code.
+ *
+ *
+ * @param  code   Exit code @link #exit_code_enum enumeration@endlink
+ *
+ *
+ * @returns Null-terminated string describing the exit code.
+ *
+ */
+rchar *exit_get_name(exit_code_enum code)
+{
+    switch(code)
+    {
+        case EXIT_MAIN_OKAY:        return(EXIT_MAIN_OKAY_DESC);
+        case EXIT_LONGJMP_ARGERROR: return(EXIT_LONGJMP_ARGERROR_DESC);
+        case EXIT_ARGV_HELP:        return(EXIT_ARGV_HELP_DESC);
+        case EXIT_ARGV_VERSION:     return(EXIT_ARGV_VERSION_DESC);
+        case EXIT_ARGV_COPYRIGHT:   return(EXIT_ARGV_COPYRIGHT_DESC);
+        case EXIT_ARGV_LICENSE:     return(EXIT_ARGV_LICENSE_DESC);
+        case EXIT_ARGV_ENVIRONMENT: return(EXIT_ARGV_ENVIRONMENT_DESC);
+        case EXIT_JVM_THREAD:       return(EXIT_JVM_THREAD_DESC);
+        case EXIT_JVM_CLASS:        return(EXIT_JVM_CLASS_DESC);
+        case EXIT_JVM_OBJECT:       return(EXIT_JVM_OBJECT_DESC);
+        case EXIT_JVM_METHOD:       return(EXIT_JVM_METHOD_DESC);
+        case EXIT_JVM_FIELD:        return(EXIT_JVM_FIELD_DESC);
+        case EXIT_JVM_ATTRIBUTE:    return(EXIT_JVM_ATTRIBUTE_DESC);
+        case EXIT_JVM_THROWABLE:    return(EXIT_JVM_THROWABLE_DESC);
+        case EXIT_JVM_SIGNAL:       return(EXIT_JVM_SIGNAL_DESC);
+        case EXIT_JVM_BYTECODE:     return(EXIT_JVM_BYTECODE_DESC);
+        case EXIT_JVM_GC:           return(EXIT_JVM_GC_DESC);
+        case EXIT_JVM_INTERNAL:     return(EXIT_JVM_INTERNAL_DESC);
+        case EXIT_HEAP_ALLOC:       return(EXIT_HEAP_ALLOC_DESC);
+        case EXIT_GC_ALLOC:         return(EXIT_GC_ALLOC_DESC);
+        case EXIT_THREAD_STACK:     return(EXIT_THREAD_STACK_DESC);
+        case EXIT_TIMESLICE_START:  return(EXIT_TIMESLICE_START_DESC);
+        case EXIT_TMPAREA_MKDIR:    return(EXIT_TMPAREA_MKDIR_DESC);
+        case EXIT_TMPAREA_RMDIR:    return(EXIT_TMPAREA_RMDIR_DESC);
+        case EXIT_CLASSPATH_JAR:    return(EXIT_CLASSPATH_JAR_DESC);
+        case EXIT_MANIFEST_JAR:     return(EXIT_MANIFEST_JAR_DESC);
+        default:                    return("unknown");
+    }
+} /* END of exit_get_name() */
+
+
+/*! 
+ * Handler linkage for fatal errors.  Does not need global visibility,
+ * just needs file scope.
+ */
+static jmp_buf exit_general_failure;
+
+
+/*!
+ * Handler linkage for @b LinkageError.  Does not need global
+ * visibility, just needs file scope.
+ */
+static jmp_buf exit_LinkageError;
+
+
+/*!
+ * Class to run on non-local return.  Give global visibility for use
+ * by users of
+ * @link #exit_throw_exception() exit_throw_exception()@endlink.
+ */
+rchar *exit_LinkageError_subclass;
+
+
+/*!
+ * Thread where error occurred.  Give global visibility for use by
+ * users of
+ * @link #exit_throw_exception() exit_throw_exception()@endlink.
+ */
+jvm_thread_index exit_LinkageError_thridx;
+
+
+/*!
+ * @brief Global handler setup for fatal JVM errors-- implements
+ * @c @b setjmp(3).
+ *
+ * @b Parameters: @link #rvoid rvoid@endlink
+ *
+ *
+ * @returns From normal setup, integer @link
+            #EXIT_MAIN_OKAY EXIT_MAIN_OKAY@endlink.  Otherwise,
+ *          return error code from @link #exit_jvm() exit_jvm()@endlink,
+ *          typically using a code found in
+ *          @link jvm/src/exit.h exit.h@endlink
+ */
+
+int exit_init()
+{
+    /* Return point from @c @b longjmp(3) as declared in exit_jvm() */
+    return(setjmp(exit_general_failure));
+
+} /* END of exit_init() */
+
+
+
+/*!
+ * @brief Global handler setup for fatal
+ * @link jvm_init() jvm_init()@endlink errors and other
+ * @c @b java.lang.Throwable events-- implements
+ * @c @b setjmp(3).
+ *
+ *
+ * Use this function to arm handler for throwing
+ * @c @b java.lang.Error and @c @b java.lang.Exception
+ * throwable events.
+ *
+ * @b Parameters: @link #rvoid rvoid@endlink
+ *
+ *
+ * @returns From normal setup, integer
+ *          @link #EXIT_MAIN_OKAY EXIT_MAIN_OKAY@endlink.
+ *          Otherwise, return
+ *          @link #exit_code_enum exit code enumeration@endlink from
+ *          @link #exit_jvm() exit_jvm()@endlink.
+ *
+ */
+
+int exit_exception_setup(rvoid)
+{
+
+    exit_LinkageError_subclass = (rchar *) rnull;
+    exit_LinkageError_thridx   = jvm_thread_index_null;
+
+    /*
+     * Return point from @c @b longjmp(3) as declared
+     * in @link #exit_throw_exception() exit_throw_exception()@endlink
+     */
+    return(setjmp(exit_LinkageError));
+
+} /* END of exit_exception_setup() */
+
+
+/*!
+ * @brief Global handler for initialization linkage errors,
+ * per spec section 2.17.x  -- implements @c @b longjmp(3).
+ *
+ * Use this function to throw @c @b java.lang.Error and
+ * @c @b java.lang.Exception throwable events.
+ *
+ * This is a global handler invocation first for @link #jvm_init()
+   jvm_init()@endlink during startup and then runtime events.
+ * A @e wide variety of runtime conditions may be expressed in
+ * the combination of @b rc and @b preason.  Judicious combinations
+ * of exit codes and error classes will greatly limit the need
+ * for expanding on the number of values for either parameter,
+ * yet can express many different nuances of errors.
+ *
+ * @param  rcenum  Return code to pass back out of failed routine, which
+ *                 must be an
+ *                 @link #exit_code_enum exit code enumeration@endlink
+ *                 other than
+ *                 @link #EXIT_MAIN_OKAY EXIT_MAIN_OKAY@endlink, which
+ *                 will get translated into @link
+                   #EXIT_LONGJMP_ARGERROR EXIT_LONGJMP_ARGERROR@endlink.
+ *
+ * @param  preason Error class, which must be a subclass of
+ *                   @c @b java.lang.LinkageError , namely:
+ *
+ * <ul> <li> @link #JVMCLASS_JAVA_LANG_LINKAGEERROR
+             JVMCLASS_JAVA_LANG_LINKAGEERROR@endlink </li>
+ *      <li> @link #JVMCLASS_JAVA_LANG_CLASSCIRCULARITYERROR
+            JVMCLASS_JAVA_LANG_CLASSCIRCULARITYERROR@endlink </li>
+ *      <li> @link #JVMCLASS_JAVA_LANG_CLASSFORMATERROR
+             JVMCLASS_JAVA_LANG_CLASSFORMATERROR@endlink </li>
+ *      <li> @link #JVMCLASS_JAVA_LANG_EXCEPTIONININITIALIZERERROR
+            JVMCLASS_JAVA_LANG_EXCEPTIONININITIALIZERERROR@endlink </li>
+ *      <li> @link #JVMCLASS_JAVA_LANG_INCOMPATIBLECLASSCHANGEERROR
+           JVMCLASS_JAVA_LANG_INCOMPATIBLECLASSCHANGEERROR@endlink </li>
+ *      <li> @link #JVMCLASS_JAVA_LANG_NOCLASSDEFFOUNDERROR
+             JVMCLASS_JAVA_LANG_NOCLASSDEFFOUNDERROR@endlink </li>
+ *      <li> @link #JVMCLASS_JAVA_LANG_UNSATISFIEDLINKERROR
+             JVMCLASS_JAVA_LANG_UNSATISFIEDLINKERROR@endlink </li>
+ *      <li> @link #JVMCLASS_JAVA_LANG_VERIFYERROR
+             JVMCLASS_JAVA_LANG_VERIFYERROR@endlink </li>
+ * </ul>
+ *
+ * @returns non-local state restoration from setup via @c @b setjmp(3)
+ *          as stored in @link
+            #exit_LinkageError exit_LinkageError@endlink
+ *          buffer by @link #exit_init() exit_init()@endlink
+ *          in @link #jvm_init() jvm_init()@endlink before any of
+ *          these errors could occur. All code invoking this
+ *          function should use the standard @c @b lint(1) comment for
+ *          "code not reached" as shown after the @c @b longjmp(3)
+ *          function call in the source code of this function:
+ *          <b>/</b><b>*NOTREACHED*</b><b>/</b>
+ *
+ */
+
+rvoid exit_throw_exception(exit_code_enum rcenum, rchar *preason)
+{
+    /* Report error class to handler */
+    exit_LinkageError_subclass = preason;
+    exit_LinkageError_thridx   = CURRENT_THREAD;
+
+    /* Returns to @c @b setjmp(3) */
+    int rc = (int) rcenum;
+    longjmp(exit_LinkageError, rc);
+/*NOTREACHED*/
+
+} /* END of exit_throw_exception() */
+
+
+/*!
+ * @brief Global handler invocation for fatal JVM errors-- implements
+ * @c @b longjmp(3)
+ *
+ * @param  rcenum  Return code to pass back out of JVM.
+ *
+ *
+ * @returns non-local state restoration from setup via @c @b setjmp(3)
+ *          above as stored in @link
+            #exit_general_failure exit_general_failure@endlink.
+ *          All code invoking this function should use the
+ *          standard @c @b lint(1) comment for "code not reached" as
+ *          shown after the @c @b longjmp(3) function call in
+ *          the source code of this function:
+ *          <b>/</b><b>*NOTREACHED*</b><b>/</b>
+ */
+
+rvoid exit_jvm(exit_code_enum rcenum)
+{
+    /* Returns to @c @b setjmp(3) as declared in exit_jvm() */
+    int rc = (int) rcenum;
+    longjmp(exit_general_failure, rc);
+/*NOTREACHED*/
+
+} /* END of exit_jvm() */
+
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/exit.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/exit.h?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/exit.h (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/exit.h Fri Oct  7 21:27:56 2005
@@ -0,0 +1,169 @@
+#ifndef _exit_h_defined_
+#define _exit_h_defined_
+
+/*!
+ * @file exit.h
+ *
+ * @brief Exit codes for JVM diagnostics.
+ *
+ * Notice that if a Java program calls @c @b System.exit() ,
+ * then the system call @c @b exit(2) will @e still be made, but
+ * with that requested exit code, having nothing to do with
+ * these codes.  However, Most exit situations are set up
+ * with @c @b fprintf(stderr) immediately before the
+ * @c @b exit(2) call itself, so console output should demonstrate
+ * proper context if there is ever a question.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/exit.h $ \$Id: exit.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.
+ *
+ * @section Reference
+ *
+ */
+
+ARCH_COPYRIGHT_APACHE(exit, h, "$URL: https://svn.apache.org/path/name/exit.h $ $Id: exit.h 0 09/28/2005 dlydick $");
+
+
+/*!
+ * @name Exit code enumeration definitions and name strings.
+ *
+ * @brief Codes and null-terminated strings for constructing
+ * @link #exit_code_enum exit_code_enum enum@endlink and
+ * @link #exit_get_name exit_get_name() switch@endlink, respectively.
+ *
+ * @b NEVER change definition of
+ * @link #EXIT_MAIN_OKAY EXIT_MAIN_OKAY@endlink!  It is
+ * the normal return from @link #exit_init() exit_init()@endlink
+ * function by virtue of @c @b setjmp(3) definition.
+ *
+ * @b NEVER change the definition of
+ * @link #EXIT_LONGJMP_ARGERROR EXIT_LONGJMP_ARGERROR@endlink!
+ * It is defined by @c @b longjmp(3) when an attempt is made to
+ * use @link #EXIT_MAIN_OKAY EXIT_MAIN_OKAY@endlink as
+ * its return code.
+ *
+ */
+
+/*@{ */ /* Begin grouped definitions */
+
+#ifdef I_AM_EXIT_C
+#define EXIT_MAIN_OKAY_DESC        "no error"
+#define EXIT_LONGJMP_ARGERROR_DESC "longjmp(3) argument error"
+
+#define EXIT_ARGV_HELP_DESC        "help request"
+#define EXIT_ARGV_VERSION_DESC     "version request"
+#define EXIT_ARGV_COPYRIGHT_DESC   "copyright request"
+#define EXIT_ARGV_LICENSE_DESC     "license request"
+#define EXIT_ARGV_ENVIRONMENT_DESC "environment request"
+
+#define EXIT_JVM_THREAD_DESC       "thread start error"
+#define EXIT_JVM_CLASS_DESC        "class load error"
+#define EXIT_JVM_OBJECT_DESC       "object load error"
+#define EXIT_JVM_METHOD_DESC       "method invocation error"
+#define EXIT_JVM_FIELD_DESC        "field access error"
+#define EXIT_JVM_ATTRIBUTE_DESC    "attribute access error"
+#define EXIT_JVM_THROWABLE_DESC    "throwable event abort"
+#define EXIT_JVM_SIGNAL_DESC       "OS signal abort trapped"
+#define EXIT_JVM_BYTECODE_DESC     "JVM byte code execution error"
+#define EXIT_JVM_GC_DESC           "Garbage collection error"
+#define EXIT_JVM_INTERNAL_DESC     "Internal JVM logic error"
+
+#define EXIT_HEAP_ALLOC_DESC       "Heap allocation error"
+#define EXIT_GC_ALLOC_DESC         "Garbage collection heap error"
+#define EXIT_THREAD_STACK_DESC     "Stack overflow suppressed"
+#define EXIT_TIMESLICE_START_DESC  "cannot start timer"
+#define EXIT_TMPAREA_MKDIR_DESC    "cannot make temp directory"
+#define EXIT_TMPAREA_RMDIR_DESC    "cannot remove temp directory"
+#define EXIT_CLASSPATH_JAR_DESC    "cannot run jar command"
+#define EXIT_MANIFEST_JAR_DESC     "cannot process jar manifest file"
+#endif
+
+typedef enum
+{
+    EXIT_MAIN_OKAY        = 0, /**< Everything went fine.
+                                    No Java code called
+                                   @c @b java.lang.System.exit() ,
+                                    either. */
+    EXIT_LONGJMP_ARGERROR = 1, /**< @c @b longjmp(3) called with 0 arg*/
+
+/* Command line conditions and errors */
+    EXIT_ARGV_HELP        = 10, /**< @b Help invoked on command line */
+    EXIT_ARGV_VERSION     = 11,/**< @b Version invoked on command line*/
+    EXIT_ARGV_COPYRIGHT   = 12, /**< @b Copyright invoked on cmd line */
+    EXIT_ARGV_LICENSE     = 13, /**< @b Copyright invoked on cmd line */
+    EXIT_ARGV_ENVIRONMENT = 14, /**< Environment variable error */
+
+/* JVM fatal runtime errors */
+    EXIT_JVM_THREAD       = 20, /**< Thread start error */
+    EXIT_JVM_CLASS        = 21, /**< Class load error */
+    EXIT_JVM_OBJECT       = 22, /**< Object load error */
+    EXIT_JVM_METHOD       = 23, /**< Method invocation error */
+    EXIT_JVM_FIELD        = 24, /**< Field access error */
+    EXIT_JVM_ATTRIBUTE    = 25, /**< Attribute access error */
+    EXIT_JVM_THROWABLE    = 26, /**< Throwable event abort */
+    EXIT_JVM_SIGNAL       = 27, /**< OS signal abort trapped */
+    EXIT_JVM_BYTECODE     = 28, /**< JVM byte code execution error */
+    EXIT_JVM_GC           = 29, /**< Garbage collection error */
+    EXIT_JVM_INTERNAL     = 30, /**< Internal JVM logic error */
+
+/* Fatal runtime errors in other modules */
+    EXIT_HEAP_ALLOC       = 31, /**< Heap allocation error */
+    EXIT_GC_ALLOC         = 32, /**< Garbage collection heap error */
+    EXIT_THREAD_STACK     = 33, /**< Stack overflow suppressed */
+    EXIT_TIMESLICE_START  = 34, /**< Cannot start timer */
+    EXIT_TMPAREA_MKDIR    = 35, /**< Cannot make temp directory */
+    EXIT_TMPAREA_RMDIR    = 36, /**< Cannot remove temp directory */
+    EXIT_CLASSPATH_JAR    = 37, /**< Cannot run jar command */
+    EXIT_MANIFEST_JAR     = 38  /**< Cannot process jar manifest file */
+
+} exit_code_enum;
+
+/*@} */ /* End of grouped definitions */
+
+
+/* Prototypes for functions in 'exit.c' */
+extern int exit_init(rvoid);
+
+extern rchar *exit_get_name(exit_code_enum code);
+
+extern rchar *exit_LinkageError_subclass;
+extern jvm_thread_index exit_LinkageError_thridx;
+extern int exit_exception_setup(rvoid);
+
+extern rvoid exit_throw_exception(exit_code_enum rc, rchar *preason);
+
+extern int   exit_end_thread_setup(rvoid);
+extern rvoid exit_end_thread_test(jvm_thread_index thridx);
+
+extern rvoid exit_jvm(exit_code_enum rc);
+
+#endif /* _exit_h_defined_ */
+
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/field.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/field.c?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/field.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/field.c Fri Oct  7 21:27:56 2005
@@ -0,0 +1,767 @@
+/*!
+ * @file field.c
+ *
+ * @brief Manipulate ClassFile fields.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/field.c $ \$Id: field.c 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.
+ *
+ * @section Reference
+ *
+ */
+
+#include "arch.h"
+ARCH_COPYRIGHT_APACHE(field, c, "$URL: https://svn.apache.org/path/name/field.c $ $Id: field.c 0 09/28/2005 dlydick $");
+
+
+#include <strings.h>
+
+#include "jvmcfg.h"
+#include "cfmacros.h"
+#include "classfile.h"
+#include "exit.h"
+#include "jvm.h"
+#include "jvmclass.h"
+#include "linkage.h"
+#include "utf.h"
+
+
+/*!
+ * @brief Locate the field_info index for a field in a class.
+ *
+ * This works both with object instance fields and static class
+ * instance fields.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldname           UTF8 constant_pool entry of name of field
+ *                             in class.
+ *
+ * @param  flddesc           UTF8 constant_pool entry of description of
+ *                             field type.
+ *
+ *
+ * @returns field table index of this field in class or
+ *          @link #jvm_field_index_bad jvm_field_index_bad@endlink
+ *          if not found.
+ *
+ *
+ * @throws nothing.  Let caller throw an error like
+ *         @link #JVMCLASS_JAVA_LANG_NOSUCHFIELDERROR
+           JVMCLASS_JAVA_LANG_NOSUCHFIELDERROR@endlink if it is
+ *         useful at that point.  The purpose of this
+ *         function is simply to locate the field, not
+ *         make a value judgment on the meaning of the
+ *         search result.
+ *
+ */
+jvm_field_index field_find_by_cp_entry(jvm_class_index  clsidx,
+                                       cp_info_dup     *fldname,
+                                       cp_info_dup     *flddesc)
+{
+    /* Prohibit invalid parameter */
+    if (jvm_class_index_null == clsidx)
+    {
+        exit_throw_exception(EXIT_JVM_FIELD,
+                             JVMCLASS_JAVA_LANG_INTERNALERROR);
+    }
+
+    /* Point to class structure, then look for field  */
+    ClassFile *pcfs = CLASS_OBJECT_LINKAGE(clsidx)->pcfs;
+
+    u2 fcount = pcfs->fields_count;
+    jvm_field_index fldidx;
+    for (fldidx = 0; fldidx < fcount; fldidx++)
+    {
+        /* If field name and description match, go run thread */
+        if ((0 == utf_pcfs_strcmp(PTR_THIS_CP_Utf8(fldname),
+                                 pcfs,
+                                 pcfs->fields[fldidx]->name_index))
+            &&
+            (0 == utf_pcfs_strcmp(PTR_THIS_CP_Utf8(flddesc),
+                                 pcfs,
+                                 pcfs
+                                   ->fields[fldidx]
+                                     ->descriptor_index)))
+        {
+            return(fldidx);
+        }
+    }
+
+    /* Not found */
+    return(jvm_field_index_bad);
+
+} /* END of field_find_by_cp_entry() */
+
+
+/*!
+ * @brief Determine if a field index is to a static class instance
+ * field or not.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldidx            Field index in class of field to be located
+ *
+ *
+ * @returns @link #rtrue rtrue@endlink if this field is a class static
+ *          field, otherwise @link #rfalse rfalse@endlink.
+ *
+ *
+ */
+rboolean field_index_is_class_static(jvm_class_index clsidx,
+                                     jvm_field_index fldidx)
+{
+    /* Prohibit invalid parameter */
+    if (jvm_field_index_bad == fldidx)
+    {
+        return(rfalse);
+    }
+
+    jvm_field_lookup_index csflidx;
+    for (csflidx= 0;
+         csflidx < CLASS(clsidx).num_class_static_field_lookups;
+         csflidx++)
+    {
+        /*
+         * Report a match when field index is
+         * found in static class fields table
+         */
+        if (fldidx ==
+            (CLASS(clsidx).class_static_field_lookup)[csflidx])
+        {
+            return(rtrue);
+        }
+    }
+
+    /* Not found */
+    return(rfalse);
+
+} /* END of field_index_is_class_static() */
+
+
+/*!
+ * @brief Determine if a field name/descriptor is a static class
+ * instance field or not.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldname           UTF8 constant_pool entry of name of field
+ *                             in class.
+ *
+ * @param  flddesc           UTF8 constant_pool entry of description of
+ *                             field type.
+ *
+ * @returns @link #rtrue rtrue@endlink if this field is a class static
+ *          field, otherwise @link #rfalse rfalse@endlink.
+ *
+ */
+rboolean field_name_is_class_static(jvm_class_index  clsidx,
+                                    cp_info_dup     *fldname,
+                                    cp_info_dup     *flddesc)
+{
+    return(field_index_is_class_static(
+               clsidx,
+               field_find_by_cp_entry(clsidx, fldname, flddesc)));
+
+} /* END of field_name_is_class_static() */
+
+
+/*!
+ * @brief Determine if a field index is to an object instance field
+ * or not.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldidx            Field index in class of field to be located
+ *
+ *
+ * @returns @link #rtrue rtrue@endlink if this field is an object
+ *          instance field, otherwise @link #rfalse rfalse@endlink.
+ *
+ */
+rboolean field_index_is_object_instance(jvm_class_index clsidx,
+                                        jvm_field_index fldidx)
+{
+    /* Prohibit invalid parameter */
+    if (jvm_field_index_bad == fldidx)
+    {
+        return(rfalse);
+    }
+
+    jvm_field_lookup_index oiflidx;
+    for (oiflidx= 0;
+         oiflidx < CLASS(clsidx).num_object_instance_field_lookups;
+         oiflidx++)
+    {
+        /*
+         * Report a match when field index is
+         * found in static class fields table
+         */
+        if (fldidx ==
+            (CLASS(clsidx).object_instance_field_lookup)[oiflidx])
+        {
+            return(rtrue);
+        }
+    }
+
+    /* Not found */
+    return(rfalse);
+
+} /* END of field_index_is_object_instance() */
+
+
+/*!
+ * @brief Determine if a field name/descriptor is to an object instance
+ * field or not.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldname           UTF8 constant_pool entry of name of field
+ *                             in class.
+ *
+ * @param  flddesc           UTF8 constant_pool entry of description of
+ *                             field type.
+ *
+ *
+ * @returns @link #rtrue rtrue@endlink if this field is an object
+ *          instance field, otherwise @link #rfalse rfalse@endlink.
+ *
+ */
+rboolean field_name_is_object_instance(jvm_class_index   clsidx,
+                                       cp_info_dup     *fldname,
+                                       cp_info_dup     *flddesc)
+{
+    return(field_index_is_object_instance(
+               clsidx,
+               field_find_by_cp_entry(clsidx, fldname, flddesc)));
+
+} /* END of field_name_is_object_instance() */
+
+
+/*!
+ * @brief Retrieve by field index a field lookup index to a static
+ * class instance field.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldidx            Field index in class of field to be located
+ *
+ *
+ * @returns class static field lookup index of located field, otherwise
+ *          @link #jvm_field_index_bad jvm_field_index_bad@endlink.
+ *
+ */
+jvm_field_lookup_index
+    field_index_get_class_static_lookup(jvm_class_index  clsidx,
+                                        jvm_field_index fldidx)
+{
+    /* Prohibit invalid parameter */
+    if (jvm_field_index_bad == fldidx)
+    {
+        return(jvm_field_lookup_index_bad);
+    }
+
+    jvm_field_lookup_index csflidx;
+    for (csflidx= 0;
+         csflidx < CLASS(clsidx).num_class_static_field_lookups;
+         csflidx++)
+    {
+        /*
+         * Report a match when field index is
+         * found in static class fields table
+         */
+        if (fldidx ==
+            (CLASS(clsidx).class_static_field_lookup)[csflidx])
+        {
+            return(fldidx);
+        }
+    }
+
+    /* Not found */
+    return(jvm_field_lookup_index_bad);
+
+} /* END of field_index_get_class_static_lookup() */
+
+
+/*!
+ * @brief Retrieve by name/descriptor a field lookup index to a static
+ * class instance field.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldname           UTF8 constant_pool entry of name of field
+ *                             in class.
+ *
+ * @param  flddesc           UTF8 constant_pool entry of description of
+ *                             field type.
+ *
+ * @returns class static field lookup index of located field, otherwise
+ *          @link #jvm_field_index_bad jvm_field_index_bad@endlink.
+ *
+ */
+jvm_field_lookup_index
+    field_name_get_class_static_lookup(jvm_class_index  clsidx,
+                                       cp_info_dup     *fldname,
+                                       cp_info_dup     *flddesc)
+{
+    return(field_index_get_class_static_lookup(
+               clsidx,
+               field_find_by_cp_entry(clsidx, fldname, flddesc)));
+
+
+} /* END of field_name_get_class_static_lookup() */
+
+
+/*!
+ * @brief Retrieve by field index a field lookup index to an object
+ * instance field.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldidx            Field index in class of field to be located
+ *
+ *
+ * @returns object instance field lookup index of located field,
+ *          otherwise
+ *          @link #jvm_field_index_bad jvm_field_index_bad@endlink.
+ *
+ */
+jvm_field_lookup_index
+    field_index_get_object_instance_lookup(jvm_class_index  clsidx,
+                                           jvm_field_index fldidx)
+{
+    /* Prohibit invalid parameter */
+    if (jvm_field_index_bad == fldidx)
+    {
+        return(rfalse);
+    }
+
+    jvm_field_lookup_index oiflidx;
+    for (oiflidx= 0;
+         oiflidx < CLASS(clsidx).num_object_instance_field_lookups;
+         oiflidx++)
+    {
+        /*
+         * Report a match when field index is
+         * found in static class fields table
+         */
+        if (fldidx ==
+            (CLASS(clsidx).object_instance_field_lookup)[oiflidx])
+        {
+            return(rtrue);
+        }
+    }
+
+    /* Not found */
+    return(rfalse);
+
+} /* END of field_index_get_object_instance_lookup() */
+
+
+/*!
+ * @brief Retrieve by name/descriptor a field lookup index to an object
+ * instance field.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldname           UTF8 constant_pool entry of name of field
+ *                             in class.
+ *
+ * @param  flddesc           UTF8 constant_pool entry of description of
+ *                             field type.
+ *
+ *
+ * @returns object instance field lookup index of located field,
+ *          otherwise 
+ *          @link #jvm_field_index_bad jvm_field_index_bad@endlink.
+ *
+ */
+jvm_field_lookup_index
+    field_name_get_object_instance_lookup(jvm_class_index  clsidx,
+                                          cp_info_dup     *fldname,
+                                          cp_info_dup     *flddesc)
+{
+    return(field_index_get_object_instance_lookup(
+               clsidx,
+               field_find_by_cp_entry(clsidx, fldname, flddesc)));
+
+
+} /* END of field_name_get_object_instance_lookup() */
+
+
+/*!
+ * @brief Retrieve by field index the value of a static class instance
+ * field.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldidx            Field index in class of field to be located
+ *
+ *
+ * @returns pointer to class static field data, otherwise
+ *          @link #rnull rnull@endlink.
+ *
+ */
+jvalue *field_index_get_class_static_pjvalue(jvm_class_index  clsidx,
+                                             jvm_field_index fldidx)
+{
+    /* Prohibit invalid parameter */
+    if (jvm_field_index_bad == fldidx)
+    {
+        return((jvalue *) rnull);
+    }
+
+    jvm_field_lookup_index csflidx;
+    for (csflidx= 0;
+         csflidx < CLASS(clsidx).num_class_static_field_lookups;
+         csflidx++)
+    {
+        /*
+         * Report a match when field index is
+         * found in static class fields table
+         */
+        if (fldidx ==
+            (CLASS(clsidx).class_static_field_lookup)[csflidx])
+        {
+            return(&(CLASS(clsidx).class_static_field_data)[csflidx]);
+        }
+    }
+
+    /* Not found */
+    return((jvalue *) rnull);
+
+} /* END of field_index_get_class_static_pjvalue() */
+
+
+/*!
+ * @brief Retrieve by name the value of a static class instance field.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             located.
+ *
+ * @param  fldname           UTF8 constant_pool entry of name of field
+ *                             in class.
+ *
+ * @param  flddesc           UTF8 constant_pool entry of description of
+ *                             field type.
+ *
+ *
+ * @returns pointer to class static field data, otherwise
+ *          @link #rnull rnull@endlink.
+ *
+ */
+jvalue *field_name_get_class_static_pjvalue(jvm_class_index  clsidx,
+                                            cp_info_dup     *fldname,
+                                            cp_info_dup     *flddesc)
+{
+    return(field_index_get_class_static_pjvalue(
+               clsidx,
+               field_find_by_cp_entry(clsidx, fldname, flddesc)));
+
+
+} /* END of field_name_get_class_static_pjvalue() */
+
+
+/*!
+ * @brief Retrieve by field index the value of an object instance field.
+ *
+ *
+ * @param  objhash           Object hash of object whose field is to be
+ *                             located.
+ *
+ * @param  fldidx            Field index in class of field to be located
+ *
+ *
+ * @returns Pointer to object instance field data, otherwise
+ *          @link #rnull rnull@endlink.
+ *
+ */
+jvalue *field_index_get_object_instance_pjvalue(jvm_object_hash objhash,
+                                                jvm_field_index fldidx)
+{
+    jvm_class_index clsidx = OBJECT_CLASS_LINKAGE(objhash)->clsidx;
+
+    jvm_field_lookup_index oifldidx;
+    for (oifldidx= 0;
+         oifldidx < CLASS(clsidx).num_object_instance_field_lookups;
+         oifldidx++)
+    {
+        /*
+         * Report a match when field index is
+         * found in object instance fields table
+         */
+        if (fldidx ==
+            (CLASS(clsidx).object_instance_field_lookup)[oifldidx])
+        {
+            return(&OBJECT(objhash)
+                        .object_instance_field_data[oifldidx]);
+        }
+    }
+
+    /* Not found */
+    return((jvalue *) rnull);
+
+} /* END of field_index_get_object_instance_pjvalue() */
+
+
+/*!
+ * @brief Retrieve by name the value of an object instance field.
+ *
+ *
+ * @param  objhash           Object hash of object whose field is to be
+ *                             located.
+ *
+ * @param  fldname           UTF8 constant_pool entry of name of field
+ *                             in class.
+ *
+ * @param  flddesc           UTF8 constant_pool entry of description of
+ *                             field type.
+ *
+ *
+ * @returns Pointer to object instance field data, otherwise
+ *          @link #rnull rnull@endlink.
+ *
+ */
+jvalue *field_name_get_object_instance_pjvalue(jvm_object_hash  objhash,
+                                               cp_info_dup     *fldname,
+                                               cp_info_dup     *flddesc)
+{
+    return(field_index_get_object_instance_pjvalue(
+               objhash,
+               field_find_by_cp_entry(
+                   OBJECT_CLASS_LINKAGE(objhash)->clsidx,
+                   fldname,
+                   flddesc)));
+
+} /* END of field_name_get_object_instance_pjvalue() */
+
+
+/*!
+ * @brief Store by field index the value of a static class instance
+ * field.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             stored.
+ *
+ * @param  fldidx            Field index in class of field to be stored.
+ *
+ *
+ * @param  _jvalue           Data to be stored.
+ *
+ *
+ * @returns Field index of field name if this is a valid class static
+ *          field, else
+ *          @link #jvm_field_index_bad jvm_field_index_bad@endlink.
+ *
+ */
+jvm_field_index
+    field_index_put_class_static_pjvalue(jvm_class_index  clsidx,
+                                         jvm_field_index  fldidx,
+                                         jvalue          *_jvalue)
+{
+    /* Prohibit invalid parameter */
+    if (jvm_field_index_bad == fldidx)
+    {
+        return(jvm_field_index_bad);
+    }
+
+    jvm_field_lookup_index csflidx;
+    for (csflidx= 0;
+         csflidx < CLASS(clsidx).num_class_static_field_lookups;
+         csflidx++)
+    {
+        /*
+         * Report a match when field index is
+         * found in static class fields table
+         */
+        if (fldidx ==
+            (CLASS(clsidx).class_static_field_lookup)[csflidx])
+        {
+            memcpy(&CLASS(clsidx).class_static_field_data[csflidx],
+                   _jvalue,
+                   sizeof(jvalue));
+            return(fldidx);
+        }
+    }
+
+    /* Not found */
+    return(jvm_field_index_bad);
+
+} /* END of field_index_put_class_static_pjvalue() */
+
+
+/*!
+ * @brief Store by name/descriptor the value of a static class
+ * instance field.
+ *
+ *
+ * @param  clsidx            Class index of class whose field is to be
+ *                             stored.
+ *
+ * @param  fldname           UTF8 constant_pool entry of name of field
+ *                             in class.
+ *
+ * @param  flddesc           UTF8 constant_pool entry of description of
+ *                             field type.
+ *
+ * @param  _jvalue           Data to be stored.
+ *
+ *
+ * @returns Field index of field name if this is a valid class static
+ *          field, else
+ *          @link #jvm_field_index_bad jvm_field_index_bad@endlink.
+ *
+ */
+jvm_field_index
+    field_name_put_class_static_pjvalue(jvm_class_index  clsidx,
+                                        cp_info_dup     *fldname,
+                                        cp_info_dup     *flddesc,
+                                        jvalue          *_jvalue)
+{
+    return(field_index_put_class_static_pjvalue(
+               clsidx,
+               field_find_by_cp_entry(clsidx,
+                                      fldname,
+                                      flddesc),
+               _jvalue));
+
+} /* END of field_name_put_class_static_pjvalue() */
+
+
+/*!
+ * @brief Store by field index the value of an object instance field.
+ *
+ *
+ * @param  objhash           Object hash of object whose field is to be
+ *                             located.
+ *
+ * @param  fldidx            Field index in class of field to be stored
+ *
+ * @param  _jvalue           Data to be stored.
+ *
+ *
+ * @returns Field index of field name if this is a valid object instance
+ *          field, else
+ *          @link #jvm_field_index_bad jvm_field_index_bad@endlink.
+ *
+ */
+jvm_field_index
+    field_index_put_object_instance_pjvalue(jvm_object_hash  objhash,
+                                            jvm_field_index  fldidx,
+                                            jvalue          *_jvalue)
+{
+    jvm_class_index clsidx = OBJECT_CLASS_LINKAGE(objhash)->clsidx;
+
+    jvm_field_lookup_index oifldidx;
+    for (oifldidx= 0;
+         oifldidx < CLASS(clsidx).num_object_instance_field_lookups;
+         oifldidx++)
+    {
+        /*
+         * Report a match when field index is
+         * found in object instance fields table
+         */
+        if (fldidx ==
+            (CLASS(clsidx).object_instance_field_lookup)[oifldidx])
+        {
+           memcpy(&OBJECT(objhash).object_instance_field_data[oifldidx],
+                   _jvalue,
+                   sizeof(jvalue));
+            return(fldidx);
+        }
+    }
+
+    /* Not found */
+    return(jvm_field_index_bad);
+
+} /* END of field_index_put_object_instance_pjvalue() */
+
+
+/*!
+ * @brief Store by name/descriptor the value of an object
+ * instance field.
+ *
+ *
+ * @param  objhash           Object hash of object whose field is to be
+ *                             located.
+ *
+ * @param  fldname           UTF8 constant_pool entry of name of field
+ *                             in class.
+ *
+ * @param  flddesc           UTF8 constant_pool entry of description of
+ *                             field type.
+ *
+ * @param  _jvalue           Data to be stored.
+ *
+ *
+ * @returns Field index of field name if this is a valid object instance
+ *          field, else
+ *          @link #jvm_field_index_bad jvm_field_index_bad@endlink.
+ *
+ */
+jvm_field_index
+    field_name_put_object_instance_pjvalue(jvm_object_hash  objhash,
+                                           cp_info_dup     *fldname,
+                                           cp_info_dup     *flddesc,
+                                           jvalue          *_jvalue)
+{
+    return(field_index_put_object_instance_pjvalue(
+               objhash,
+               field_find_by_cp_entry(
+                   OBJECT_CLASS_LINKAGE(objhash)->clsidx,
+                   fldname,
+                   flddesc),
+               _jvalue));
+
+} /* END of field_name_put_object_instance_pjvalue() */
+
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/field.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/field.h?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/field.h (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/field.h Fri Oct  7 21:27:56 2005
@@ -0,0 +1,150 @@
+#ifndef _field_h_included_
+#define _field_h_included_
+
+/*!
+ * @file field.h
+ *
+ * @brief Field management functions for the JVM.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/field.h $ \$Id: field.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.
+ *
+ * @section Reference
+ *
+ */
+
+ARCH_COPYRIGHT_APACHE(field, h, "$URL: https://svn.apache.org/path/name/field.h $ $Id: field.h 0 09/28/2005 dlydick $");
+
+
+#include "jvalue.h"
+
+
+/*!
+ * @def FIELD
+ * @brief Access structures of a class' field table at certain index.
+ *
+ * Each class has a table of fields, divided into class static fields
+ * and object instance fields.  This macro references one of
+ * them using the @b clsidx index for the class and @b fldidx for 
+ * the field table entry in that class.
+ *
+ * @param clsidx  Class table index into the global
+ *                @link #rjvm.class rjvm.class[]@endlink array (via
+ *                @link #pjvm pjvm->class[]@endlink).
+ * 
+ * @param fldidx  Index into method table for this class.
+ * 
+ * @returns pointer to a field table entry
+ * 
+ */
+#define FIELD(clsidx, fldidx) \
+    (CLASS_OBJECT_LINKAGE(clsidx)->pcfs->fields[fldidx])
+
+
+/* Prototypes for functions in 'field.h' */
+
+extern jvm_field_index field_find_by_cp_entry(jvm_class_index  clsidx,
+                                              cp_info_dup     *fldname,
+                                              cp_info_dup     *flddesc);
+
+extern rboolean field_index_is_class_static(jvm_class_index clsidx,
+                                            jvm_field_index fldidx);
+
+extern rboolean field_name_is_class_static(jvm_class_index  clsidx,
+                                           cp_info_dup     *fldname,
+                                           cp_info_dup     *flddesc);
+
+extern rboolean field_index_is_object_instance(jvm_class_index clsidx,
+                                               jvm_field_index fldidx);
+
+extern rboolean field_name_is_object_instance(jvm_class_index  clsidx,
+                                              cp_info_dup     *fldname,
+                                              cp_info_dup     *flddesc);
+
+extern jvm_field_lookup_index
+    field_index_get_class_static_lookup(jvm_class_index clsidx,
+                                        jvm_field_index fldidx);
+
+extern jvm_field_lookup_index
+    field_name_get_class_static_lookup(jvm_class_index  clsidx,
+                                       cp_info_dup     *fldname,
+                                       cp_info_dup     *flddesc);
+
+extern jvm_field_lookup_index
+    field_index_get_object_instance_lookup(jvm_class_index clsidx,
+                                           jvm_field_index fldidx);
+
+extern jvm_field_lookup_index
+    field_name_get_object_instance_lookup(jvm_class_index  clsidx,
+                                          cp_info_dup     *fldname,
+                                          cp_info_dup     *flddesc);
+
+extern jvalue *field_index_get_class_static_pjvalue(
+                   jvm_class_index  clsidx,
+                   jvm_field_index fldidx);
+
+extern jvalue *field_name_get_class_static_pjvalue(
+                   jvm_class_index  clsidx,
+                   cp_info_dup     *fldname,
+                   cp_info_dup     *flddesc);
+
+extern jvalue *field_index_get_object_instance_pjvalue(
+                   jvm_object_hash objhash,
+                   jvm_field_index fldidx);
+
+extern jvalue *field_name_get_object_instance_pjvalue(
+                   jvm_object_hash  objhash,
+                   cp_info_dup     *fldname,
+                   cp_info_dup     *flddesc);
+
+extern jvm_field_index field_index_put_class_static_pjvalue(
+                   jvm_class_index  clsidx,
+                   jvm_field_index  fldidx,
+                   jvalue          *_jvalue);
+
+extern jvm_field_index field_name_put_class_static_pjvalue(
+                   jvm_class_index  clsidx,
+                   cp_info_dup     *fldname,
+                   cp_info_dup     *flddesc,
+                   jvalue          *_jvalue);
+
+extern jvm_field_index field_index_put_object_instance_pjvalue(
+                   jvm_object_hash  objhash,
+                   jvm_field_index  fldidx,
+                   jvalue          *_jvalue);
+
+extern jvm_field_index field_name_put_object_instance_pjvalue(
+                   jvm_object_hash  objhash,
+                   cp_info_dup     *fldname,
+                   cp_info_dup     *flddesc,
+                   jvalue          *_jvalue);
+
+#endif /* _field_h_included_ */
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/gc.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/gc.h?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/gc.h (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/gc.h Fri Oct  7 21:27:56 2005
@@ -0,0 +1,153 @@
+#ifndef _gc_h_included_
+#define _gc_h_included_
+
+/*!
+ * @file gc.h
+ *
+ * @brief Garbage collection structures and API
+ *
+ * The logic of these structures and functions is empty, pending
+ * a garbage collection design for the project.
+ *
+ * This common header file @link jvm/src/gc.h gc.h@endlink defines
+ * the prototypes for all garbage collection implementations by way
+ * of the @link #CONFIG_GC_TYPE_STUB CONFIG_GC_TYPE_xxx@endlink
+ * symbol definition.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/gc.h $ \$Id: gc.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.
+ *
+ * @section Reference
+ *
+ */
+
+#include "arch.h"
+ARCH_COPYRIGHT_APACHE(gc, h, "$URL: https://svn.apache.org/path/name/gc.h $ $Id: gc.h 0 09/28/2005 dlydick $");
+
+#ifdef CONFIG_GC_TYPE_STUB
+/*!
+ * @name Stub garbage collection model definitions
+ *
+ * @brief Expand the @b GC_xxx() macros into the simple heap model as
+ * implemented by @link jvm/src/gc_stub.c gc_stub.c@endlink.
+ *
+ * Each garbage collection algorithm will have a section just
+ * like this here in this file so that these macros will expand
+ * to point to the API as implemented by that algoritm.  For
+ * some examples as to how this is done for other modules,
+ * please refer to @link jvm/src/heap.h heap.h@endlink .
+ *
+ */
+
+/*@{ */ /* Begin grouped definitions */
+
+#define GC_INIT gc_init_stub
+#define GC_RUN  gc_run_stub
+
+#define GC_CLASS_NEW                gc_class_new_stub
+#define GC_CLASS_RELOAD             gc_class_reload_stub
+
+#define GC_CLASS_MKREF_FROM_CLASS   gc_class_mkref_from_class_stub
+#define GC_CLASS_MKREF_FROM_OBJECT  gc_class_mkref_from_object_stub
+#define GC_CLASS_RMREF_FROM_CLASS   gc_class_rmref_from_class_stub
+#define GC_CLASS_RMREF_FROM_OBJECT  gc_class_rmref_from_object_stub
+#define GC_CLASS_FIELD_MKREF        gc_class_field_mkref_stub
+#define GC_CLASS_FIELD_RMREF        gc_class_field_rmref_stub
+#define GC_CLASS_DELETE             gc_class_delete_stub
+
+#define GC_OBJECT_NEW               gc_object_new_stub
+#define GC_OBJECT_MKREF_FROM_CLASS  gc_object_mkref_from_class_stub
+#define GC_OBJECT_MKREF_FROM_OBJECT gc_object_mkref_from_object_stub
+#define GC_OBJECT_RMREF_FROM_CLASS  gc_object_rmref_from_class_stub
+#define GC_OBJECT_RMREF_FROM_OBJECT gc_object_rmref_from_object_stub
+#define GC_OBJECT_FIELD_MKREF       gc_object_field_mkref_stub
+#define GC_OBJECT_FIELD_RMREF       gc_object_field_rmref_stub
+#define GC_OBJECT_DELETE            gc_object_delete_stub
+
+#define GC_STACK_NEW                gc_stack_new_stub
+#define GC_STACK_MKREF_FROM_JVM     gc_stack_mkref_from_jvm_stub
+#define GC_STACK_RMREF_FROM_JVM     gc_stack_rmref_from_jvm_stub
+#define GC_STACK_DELETE             gc_stack_delete_stub
+
+/*@} */ /* End of grouped definitions */
+#endif
+
+
+/* Prototypes for functions in 'gc_XXX.c' */
+
+extern rvoid GC_INIT(rvoid);
+extern rvoid GC_RUN(rboolean rmref);
+
+extern rboolean  GC_CLASS_NEW(jvm_class_index clsidxNEW);
+extern rboolean  GC_CLASS_RELOAD(jvm_class_index clsidxOLD,
+                                 jvm_class_index clsidxNEW);
+
+extern rboolean  GC_CLASS_MKREF_FROM_CLASS(jvm_class_index clsidxFROM,
+                                           jvm_class_index clsidxTO);
+extern rboolean  GC_CLASS_MKREF_FROM_OBJECT(jvm_object_hash objhashFROM,
+                                            jvm_class_index clsidxTO);
+extern rboolean  GC_CLASS_RMREF_FROM_CLASS(jvm_class_index clsidxFROM,
+                                           jvm_class_index clsidxTO);
+extern rboolean  GC_CLASS_RMREF_FROM_OBJECT(jvm_object_hash objhashFROM,
+                                            jvm_class_index clsidxTO);
+extern rboolean  GC_CLASS_FIELD_MKREF(jvm_class_index        clsidxTO,
+                                      jvm_field_lookup_index csflidxTO);
+extern rboolean  GC_CLASS_FIELD_RMREF(jvm_class_index        clsidxTO,
+                                      jvm_field_lookup_index csflidxTO);
+extern rboolean  GC_CLASS_DELETE(jvm_class_index clsidxOLD,
+                                 rboolean        delete_class);
+
+extern rboolean  GC_OBJECT_NEW(jvm_object_hash objhashNEW);
+extern rboolean  GC_OBJECT_MKREF_FROM_CLASS(jvm_class_index clsidxFROM,
+                                            jvm_object_hash objhashTO);
+extern rboolean GC_OBJECT_MKREF_FROM_OBJECT(jvm_object_hash objhashFROM,
+                                             jvm_object_hash objhashTO);
+extern rboolean  GC_OBJECT_RMREF_FROM_CLASS(jvm_class_index clsidxFROM,
+                                            jvm_object_hash objhashTO);
+extern rboolean GC_OBJECT_RMREF_FROM_OBJECT(jvm_object_hash objhashFROM,
+                                             jvm_object_hash objhashTO);
+extern rboolean  GC_OBJECT_FIELD_MKREF(jvm_object_hash        objhashTO,
+                                      jvm_field_lookup_index oiflidxTO);
+extern rboolean  GC_OBJECT_FIELD_RMREF(jvm_object_hash        objhashTO,
+                                      jvm_field_lookup_index oiflidxTO);
+extern rboolean  GC_OBJECT_DELETE(jvm_object_hash objhashOLD);
+
+extern rvoid    *GC_STACK_NEW(jvm_thread_index thridxNEW,
+                              rint num_locals);
+extern rboolean  GC_STACK_MKREF_FROM_JVM(jvm_thread_index thridxFROM,
+                                         jint frmidxTO);
+extern rboolean  GC_STACK_RMREF_FROM_JVM(jvm_thread_index thridxFROM,
+                                         jint frmidxTO);
+extern rboolean  GC_STACK_DELETE(jvm_thread_index   thridxOLD,
+                                 rvoid            **ppgcm,
+                                 jint              *plocal_teardown);
+
+#endif /* _gc_h_included_ */
+
+/* EOF */