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 [17/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/linkage.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/linkage.c?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/linkage.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/linkage.c Fri Oct  7 21:27:56 2005
@@ -0,0 +1,894 @@
+/*!
+ * @file linkage.c
+ *
+ * @brief Late binding linkages between classes.
+ *
+ * This logic should be called each and every time a class is
+ * loaded or unloaded.  When a new class is loaded, existing
+ * classes may have unresolved linkages to them that need to
+ * be filled in to point to the new class.  Likewise, when a
+ * class is unloaded, the remaining classes need to have the
+ * linkages removed.  In this manner, the class linkage status
+ * will stay current.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/linkage.c $ \$Id: linkage.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(linkage, c, "$URL: https://svn.apache.org/path/name/linkage.c $ $Id: linkage.c 0 09/28/2005 dlydick $");
+
+#include "jvmcfg.h"
+#include "cfmacros.h"
+#include "classfile.h"
+#include "attribute.h"
+#include "exit.h"
+#include "field.h"
+#include "gc.h" 
+#include "jvm.h"
+#include "jvmclass.h"
+#include "linkage.h"
+#include "method.h"
+#include "native.h"
+#include "util.h"
+
+
+/*!
+ * @brief Resolve class table and object table linkages for a class
+ * file, typically one just loaded by
+ * @link #class_static_new() class_static_new()@endlink
+ *
+ *
+ * @param  clsidx   Class table index to class to resolve against
+ *                  all loaded classes.
+ *
+ * @param find_registerNatives When @link #rtrue rtrue@endlink, will
+ *                  return the ordinal for
+ *                  @link #JVMCFG_JLOBJECT_NMO_REGISTER 
+                    JVMCFG_JLOBJECT_NMO_REGISTER@endlink and
+ *                  @link #JVMCFG_JLOBJECT_NMO_UNREGISTER 
+                    JVMCFG_JLOBJECT_NMO_UNREGISTER@endlink
+ *                  as well as the other ordinals.  Once JVM
+ *                  initialization is complete, this should always
+ *                  be @link #rfalse rfalse@endlink because all
+ *                  future classes should @e never have local ordinals.
+ *
+ *
+ * @returns @link #rtrue rtrue@endlink if class was completely
+ *          resolved, @link #rfalse rfalse@endlink otherwise.
+ *
+ */
+
+rboolean linkage_resolve_class(jvm_class_index clsidx,
+                               rboolean        find_registerNatives)
+{
+    if (jvm_class_index_null == clsidx)
+    {
+        /*!
+         * @link #rtrue rtrue@endlink/@link #rfalse rfalse@endlink
+         * irrelevant here
+         */
+        return(rfalse);
+    }
+
+    /* If class is not present, cannot resolve linkages */
+    if (!(CLASS_STATUS_INUSE & CLASS(clsidx).status))
+    {
+        return(rfalse);
+    }
+
+    /* If class is fully linked, there is no need to do it again */
+    if (CLASS_STATUS_LINKED & CLASS(clsidx).status)
+    {
+        return(rtrue);
+    }
+
+    /*
+     * Try to find @e one instance of a class not yet loaded.  If found,
+     * then this class cannot be linked to it, so set
+     * @link #rfalse rfalse@endlink.  This result will be stored in the
+     * </b><code>CLASS(clsidx)->status</code></b>
+     * as the @link #CLASS_STATUS_LINKED CLASS_STATUS_LINKED@endlink
+     * bit, either @link #rtrue rtrue@endlink or
+     * @link #rfalse rfalse@endlink.
+     */
+    rboolean class_fully_linked = rtrue;
+
+    /*
+     * Scan through constant_pool, resolving any missing items
+     * that might now be available.
+     */
+
+    ClassFile *pcfs = CLASS_OBJECT_LINKAGE(clsidx)->pcfs;
+
+    jvm_constant_pool_index cpidx;
+    for (cpidx = CONSTANT_CP_START_INDEX;
+         cpidx < pcfs->constant_pool_count + CONSTANT_CP_START_INDEX -1;
+         cpidx++)
+    {
+        jvm_class_index        clsidxFIND;
+        jvm_field_index        fldidxFIND;
+        jvm_field_lookup_index fluidxFIND;
+
+        jvm_method_index       mthidxFIND;
+        jvm_attribute_index    atridxFIND;
+
+        cp_info_dup *pcpd = pcfs->constant_pool[cpidx];
+
+        CONSTANT_Class_info              *pcpd_Class;
+        CONSTANT_Fieldref_info           *pcpd_Fieldref;
+        CONSTANT_Methodref_info          *pcpd_Methodref;
+        CONSTANT_InterfaceMethodref_info *pcpd_InterfaceMethodref;
+        CONSTANT_NameAndType_info        *pcpd_NameAndType;
+
+        cp_info_dup *clsname;
+
+        switch (CP_TAG(pcfs, cpidx))
+        {
+            case CONSTANT_Class:
+
+                pcpd_Class = PTR_THIS_CP_Class(pcpd);
+
+                /* Only resolve this CP slot if it is not yet done. */
+                if (jvm_class_index_null ==
+                    pcpd_Class->LOCAL_Class_binding.clsidxJVM)
+                {
+                    clsname =
+                        pcfs->constant_pool[pcpd_Class->name_index];
+
+                    clsidxFIND = class_find_by_cp_entry(clsname);
+
+                    if (jvm_class_index_null == clsidxFIND)
+                    {
+                        /* Class not yet loaded in memory */
+                        class_fully_linked = rfalse;
+                    }
+                    else
+                    {
+                        PTR_THIS_CP_Class(pcpd)
+                           ->LOCAL_Class_binding.clsidxJVM = clsidxFIND;
+
+                        /* Add reference unless it references itself */
+                        if (clsidx != clsidxFIND)
+                        {
+                            (rvoid) GC_CLASS_MKREF_FROM_CLASS(
+                                        clsidx,
+                                        clsidxFIND);
+                        }
+                    }
+                }
+                break;
+
+            case CONSTANT_Fieldref:
+
+                pcpd_Fieldref = PTR_THIS_CP_Fieldref(pcpd);
+
+                /* Only resolve this CP slot if it is not yet done. */
+                if (jvm_class_index_null ==
+                    pcpd_Fieldref->LOCAL_Fieldref_binding.clsidxJVM)
+                {
+                    pcpd_Class =
+                        PTR_THIS_CP_Class(pcfs->constant_pool
+                                         [pcpd_Fieldref->class_index]);
+
+                    clsname =
+                        pcfs->constant_pool[pcpd_Class->name_index];
+
+                    clsidxFIND = class_find_by_cp_entry(clsname);
+
+                    pcpd_Fieldref
+                        ->LOCAL_Fieldref_binding.clsidxJVM = clsidxFIND;
+
+                    if (jvm_class_index_null == clsidxFIND)
+                    {
+                        /* Class not yet loaded in memory */
+                        class_fully_linked = rfalse;
+                    }
+                    else
+                    {
+                        pcpd_NameAndType =
+                            PTR_THIS_CP_NameAndType(
+                                pcfs->constant_pool
+                                  [pcpd_Fieldref->name_and_type_index]);
+
+                        fldidxFIND =
+                            field_find_by_cp_entry(
+                                clsidxFIND,
+                                pcfs->constant_pool
+                                    [pcpd_NameAndType->name_index],
+                                pcfs->constant_pool
+                                  [pcpd_NameAndType->descriptor_index]);
+
+                        if (jvm_field_index_bad == fldidxFIND)
+                        {
+                            /* Field not found in class-- fatal error */
+                            exit_throw_exception(EXIT_JVM_CLASS,
+                                   JVMCLASS_JAVA_LANG_NOSUCHFIELDERROR);
+/*NOTREACHED*/
+#if 0
+                            pcpd_Fieldref
+                                ->LOCAL_Fieldref_binding.fluidxJVM =
+                                    jvm_field_lookup_index_bad;
+
+                            pcpd_Fieldref
+                                ->LOCAL_Fieldref_binding.oiflagJVM =
+                                    rneither_true_nor_false;
+
+                            pcpd_Fieldref
+                                ->LOCAL_Fieldref_binding.jvaluetypeJVM =
+                                    LOCAL_BASETYPE_ERROR;
+
+                            /* No point processing ACC_STATIC bit */
+                            continue;
+#endif
+                        }
+
+                        /*
+                         * Now check if ACC_STATIC or not and store
+                         * the proper type of field lookup index.
+                         */
+                        if (FIELD(clsidxFIND, fldidxFIND)
+                              ->access_flags & ACC_STATIC)
+                        {
+                            fluidxFIND =
+            field_index_get_class_static_lookup(clsidxFIND, fldidxFIND);
+
+                        }
+                        else
+                        {
+                            fluidxFIND =
+         field_index_get_object_instance_lookup(clsidxFIND, fldidxFIND);
+
+                        }
+
+                        pcpd_Fieldref
+                            ->LOCAL_Fieldref_binding.fluidxJVM =
+                                fluidxFIND;
+
+                        if (jvm_field_lookup_index_bad == fluidxFIND)
+                        {
+                            /* Field not found in class-- fatal error */
+                            exit_throw_exception(EXIT_JVM_CLASS,
+                                   JVMCLASS_JAVA_LANG_NOSUCHFIELDERROR);
+/*NOTREACHED*/
+
+                            pcpd_Fieldref
+                                ->LOCAL_Fieldref_binding.oiflagJVM =
+                                    rneither_true_nor_false;
+
+                            pcpd_Fieldref
+                                ->LOCAL_Fieldref_binding.jvaluetypeJVM =
+                                    LOCAL_BASETYPE_ERROR;
+
+                            /*
+                             * Don't have valid @b oiflagJVM or
+                             * @b jvaluetypeJVM result
+                             */
+                            continue;
+                        }
+
+                        pcpd_Fieldref
+                            ->LOCAL_Fieldref_binding.oiflagJVM =
+                                (FIELD(clsidxFIND, fldidxFIND)
+                                   ->access_flags & ACC_STATIC)
+                                ? rfalse
+                                : rtrue;
+
+                        cp_info_dup *pfldesc_dup =
+                           CLASS_OBJECT_LINKAGE(clsidxFIND)
+                             ->pcfs
+                               ->constant_pool
+                                 [FIELD(clsidxFIND, fldidxFIND)
+                                    ->descriptor_index];
+
+                        CONSTANT_Utf8_info *pfldesc =
+                                          PTR_THIS_CP_Utf8(pfldesc_dup);
+
+                        /*!
+                         * @todo What needs to happen when base type
+                         *       is BASETYPE_ARRAY or BASETYPE_ERROR
+                         *       or BASETYPE_VOID?
+                         */
+                        pcpd_Fieldref
+                            ->LOCAL_Fieldref_binding.jvaluetypeJVM =
+
+                                pfldesc->bytes[0];
+
+                        /* Add reference unless it references itself */
+                        if (clsidx != clsidxFIND)
+                        {
+                            (rvoid) GC_CLASS_MKREF_FROM_CLASS(
+                                        clsidx,
+                                        clsidxFIND);
+                        }
+                    }
+                }
+                break;
+
+            case CONSTANT_Methodref:
+
+                pcpd_Methodref = PTR_THIS_CP_Methodref(pcpd);
+
+                /* Only resolve this CP slot if it is not yet done. */
+                if (jvm_class_index_null ==
+                    pcpd_Methodref->LOCAL_Methodref_binding.clsidxJVM)
+                {
+                    pcpd_Class =
+                        PTR_THIS_CP_Class(pcfs->constant_pool
+                                         [pcpd_Methodref->class_index]);
+
+                    clsname =
+                        pcfs->constant_pool[pcpd_Class->name_index];
+
+                    clsidxFIND = class_find_by_cp_entry(clsname);
+
+                    pcpd_Methodref
+                        ->LOCAL_Methodref_binding.clsidxJVM =clsidxFIND;
+
+                    if (jvm_class_index_null == clsidxFIND)
+                    {
+                        /* Class not yet loaded in memory */
+                        class_fully_linked = rfalse;
+                    }
+                    else
+                    {
+                        pcpd_NameAndType =
+                            PTR_THIS_CP_NameAndType(
+                                pcfs->constant_pool
+                                 [pcpd_Methodref->name_and_type_index]);
+
+                        mthidxFIND =
+                            method_find_by_cp_entry(
+                                clsidxFIND,
+                                pcfs->constant_pool
+                                    [pcpd_NameAndType->name_index],
+                                pcfs->constant_pool
+                                  [pcpd_NameAndType->descriptor_index]);
+
+                        pcpd_Methodref
+                            ->LOCAL_Methodref_binding.mthidxJVM =
+                                mthidxFIND;
+
+                        if (jvm_method_index_bad == mthidxFIND)
+                        {
+                            /* Method not found in class-- fatal error*/
+                            exit_throw_exception(EXIT_JVM_CLASS,
+                                  JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
+/*NOTREACHED*/
+                        }
+
+                        /*
+                         * Now check if Code_attribute is present
+                         * and store its index.  First check if native
+                         * and insert native method ordinal if so.
+                         */
+
+                        if (ACC_NATIVE &
+                            METHOD(clsidxFIND,mthidxFIND)->access_flags)
+                        {
+                            atridxFIND = jvm_attribute_index_native;
+
+                            pcpd_Methodref
+                              ->LOCAL_Methodref_binding
+                                  .nmordJVM =
+                                native_locate_local_method(
+                                        pcfs,
+                                        pcpd_Class->name_index,
+                                        pcpd_NameAndType->name_index,
+                                        pcpd_NameAndType
+                                          ->descriptor_index,
+                                        find_registerNatives);
+                        }
+                        else
+                        {
+                            atridxFIND =
+                                attribute_find_in_method_by_enum(
+                                    clsidxFIND,
+                                    mthidxFIND,
+                                    LOCAL_CODE_ATTRIBUTE);
+                        }
+
+                        pcpd_Methodref
+                            ->LOCAL_Methodref_binding.codeatridxJVM =
+                                atridxFIND;
+
+                        if (jvm_attribute_index_bad == atridxFIND)
+                        {
+                            /* Code not found in method-- fatal error */
+                            exit_throw_exception(EXIT_JVM_ATTRIBUTE,
+                                  JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
+/*NOTREACHED*/
+                        }
+
+                        /*
+                         * Now check if Exceptions attribute is
+                         * present and store its index.
+                         */
+
+                        atridxFIND =
+                            attribute_find_in_method_by_enum(
+                                clsidxFIND,
+                                mthidxFIND,
+                                LOCAL_EXCEPTIONS_ATTRIBUTE);
+
+                        pcpd_Methodref
+                            ->LOCAL_Methodref_binding.excpatridxJVM =
+                                atridxFIND;
+
+                        if (jvm_attribute_index_bad == atridxFIND)
+                        {
+                            /* It is OKAY to not have exceptions */
+                        }
+ 
+                        /* Add reference unless it references itself */
+                        if (clsidx != clsidxFIND)
+                        {
+                            (rvoid) GC_CLASS_MKREF_FROM_CLASS(
+                                        clsidx,
+                                        clsidxFIND);
+                        }
+                    }
+                }
+                break;
+
+            case CONSTANT_InterfaceMethodref:
+
+                pcpd_InterfaceMethodref =
+                    PTR_THIS_CP_InterfaceMethodref(pcpd);
+
+                /* Only resolve this CP slot if it is not yet done. */
+                if (jvm_class_index_null ==
+                    pcpd_InterfaceMethodref
+                        ->LOCAL_InterfaceMethodref_binding.clsidxJVM)
+                {
+                    pcpd_Class =
+                        PTR_THIS_CP_Class(pcfs->constant_pool
+                                [pcpd_InterfaceMethodref->class_index]);
+                    clsname =
+                        pcfs->constant_pool[pcpd_Class->name_index];
+
+                    clsidxFIND = class_find_by_cp_entry(clsname);
+
+                    pcpd_InterfaceMethodref
+                        ->LOCAL_InterfaceMethodref_binding.clsidxJVM =
+                            clsidxFIND;
+
+                    if (jvm_class_index_null == clsidxFIND)
+                    {
+                        /* Class not yet loaded in memory */
+                        class_fully_linked = rfalse;
+                    }
+                    else
+                    {
+                        pcpd_NameAndType =
+                            PTR_THIS_CP_NameAndType(
+                                pcfs->constant_pool
+                                [pcpd_InterfaceMethodref
+                                  ->name_and_type_index]);
+
+                        mthidxFIND =
+                            method_find_by_cp_entry(
+                                clsidxFIND,
+                                pcfs->constant_pool
+                                    [pcpd_NameAndType->name_index],
+                                pcfs->constant_pool
+                                  [pcpd_NameAndType->descriptor_index]);
+
+                        pcpd_InterfaceMethodref
+                            ->LOCAL_InterfaceMethodref_binding
+                              .mthidxJVM =
+                                  mthidxFIND;
+
+                        if (jvm_method_index_bad == mthidxFIND)
+                        {
+                            /* Method not found in class-- fatal error*/
+                            exit_throw_exception(EXIT_JVM_CLASS,
+                                  JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
+/*NOTREACHED*/
+                        }
+
+                        /*
+                         * Now check if Code_attribute is present
+                         * and store its index.  First check if native
+                         * and insert native method ordinal if so.
+                         */
+
+                        if (ACC_NATIVE &
+                            METHOD(clsidxFIND,mthidxFIND)->access_flags)
+                        {
+                            atridxFIND = jvm_attribute_index_native;
+
+                            /*!
+                             * @todo Should this instance permit
+                             *       use of @b find_registerNatives
+                             *       since interaces are not a part
+                             *       of the JVM startup, just a few
+                             *       foundational classes?  Should
+                             *       it just be
+                             *       @link #rfalse rfalse@endlink
+                             *       instead?
+                             */
+                            pcpd_InterfaceMethodref
+                              ->LOCAL_InterfaceMethodref_binding
+                                  .nmordJVM =
+                                native_locate_local_method(
+                                        pcfs,
+                                        pcpd_Class->name_index,
+                                        pcpd_NameAndType->name_index,
+                                        pcpd_NameAndType
+                                          ->descriptor_index,
+                                        find_registerNatives);
+                        }
+                        else
+                        {
+                            atridxFIND =
+                                attribute_find_in_method_by_enum(
+                                    clsidxFIND,
+                                    mthidxFIND,
+                                    LOCAL_CODE_ATTRIBUTE);
+                        }
+
+                        pcpd_InterfaceMethodref
+                            ->LOCAL_InterfaceMethodref_binding
+                              .codeatridxJVM =
+                                  atridxFIND;
+
+                        if (jvm_attribute_index_bad == atridxFIND)
+                        {
+                            /* Code not found in method-- fatal error */
+                            exit_throw_exception(EXIT_JVM_ATTRIBUTE,
+                                  JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
+/*NOTREACHED*/
+                        }
+
+                        /*
+                         * Now check if Exceptions attribute is
+                         * present and store its index.
+                         */
+
+                        atridxFIND =
+                            attribute_find_in_method_by_enum(
+                                clsidxFIND,
+                                mthidxFIND,
+                                LOCAL_EXCEPTIONS_ATTRIBUTE);
+
+                        pcpd_InterfaceMethodref
+                            ->LOCAL_InterfaceMethodref_binding
+                              .excpatridxJVM =
+                                  atridxFIND;
+
+                        if (jvm_attribute_index_bad == atridxFIND)
+                        {
+                            /* It is OKAY to not have exceptions */
+                        }
+
+                        /* Add reference unless it references itself */
+                        if (clsidx != clsidxFIND)
+                        {
+                            (rvoid) GC_CLASS_MKREF_FROM_CLASS(
+                                        clsidx,
+                                        clsidxFIND);
+                        }
+                    }
+                }
+                break;
+
+            case CONSTANT_String:
+
+            case CONSTANT_Integer:
+
+            case CONSTANT_Float:
+
+            case CONSTANT_Long:
+
+            case CONSTANT_Double:
+
+            case CONSTANT_NameAndType:
+
+            case CONSTANT_Utf8:
+
+                /*
+                 * There is no late binding associated
+                 * directly with these tags.
+                 */
+
+                break;
+
+            default:
+                GENERIC_FAILURE1_VALUE(rtrue,
+                                       DMLNORM,
+                                       "linkage_resolve_class",
+                                       "Invalid CP tag %d",
+                                       CP_TAG(pcfs, cpidx),
+                                       rfalse,
+                                       rnull,
+                                       rnull);
+
+        } /* switch ... */
+
+    } /* for (cpidx) */
+
+    /* If this class linked to existing classes, it is fully linked */
+    if (rtrue == class_fully_linked)
+    {
+        CLASS(clsidx).status |= CLASS_STATUS_LINKED;
+    } 
+
+    cfmsgs_show_constant_pool(CLASS_OBJECT_LINKAGE(clsidx)->pcfs);
+
+    return(class_fully_linked);
+
+} /* END of linkage_resolve_class() */
+
+
+/*!
+ * @brief Unresolve class table and object table linkages for a
+ * class file that is getting ready to be unloaded.
+ *
+ *
+ * @param  clsidx   Class table index to class to unresolve against
+ *                  all loaded classes.
+ *
+ *
+ * @returns @link #rtrue rtrue@endlink if class linkages were
+ *          unresolved, @link #rfalse rfalse@endlink otherwise.
+ *
+ */
+
+rboolean linkage_unresolve_class(jvm_class_index clsidx)
+{
+    if (jvm_class_index_null == clsidx)
+    {
+        /*
+         * @link #rtrue rtrue@endlink/@link #rfalse rfalse@endlink
+         * irrelevant here
+         */
+        return(rfalse);
+    }
+
+    /* If class is not present, cannot unresolve linkages */
+    if (!(CLASS_STATUS_INUSE & CLASS(clsidx).status))
+    {
+        return(rfalse);
+    }
+
+
+    ClassFile *pcfs = CLASS_OBJECT_LINKAGE(clsidx)->pcfs;
+
+    /*
+     * Scan through constant_pool, resolving any missing items
+     * that might now be available.
+     */
+    jvm_constant_pool_index cpidx;
+    for (cpidx = CONSTANT_CP_START_INDEX;
+         cpidx < pcfs->constant_pool_count + CONSTANT_CP_START_INDEX -1;
+         cpidx++)
+    {
+        cp_info_dup *pcpd = pcfs->constant_pool[cpidx];
+
+        CONSTANT_Class_info              *pcpd_Class;
+        CONSTANT_Fieldref_info           *pcpd_Fieldref;
+        CONSTANT_Methodref_info          *pcpd_Methodref;
+        CONSTANT_InterfaceMethodref_info *pcpd_InterfaceMethodref;
+
+        switch (CP_TAG(pcfs, cpidx))
+        {
+            case CONSTANT_Class:
+
+                pcpd_Class = PTR_THIS_CP_Class(pcpd);
+
+                /* Only unresolve this CP slot if it was resolved */
+                if (jvm_class_index_null !=
+                    pcpd_Class->LOCAL_Class_binding.clsidxJVM)
+                {
+                    /* Remove reference unless it references itself */
+                    if (clsidx !=
+                        pcpd_Class->LOCAL_Class_binding.clsidxJVM)
+                    {
+                        (rvoid) GC_CLASS_RMREF_FROM_CLASS(
+                                    clsidx,
+                                    pcpd_Class
+                                      ->LOCAL_Class_binding
+                                        .clsidxJVM);
+                    }
+
+                    pcpd_Class->LOCAL_Class_binding.clsidxJVM =
+                        jvm_class_index_null;
+                }
+                break;
+
+            case CONSTANT_Fieldref:
+
+                pcpd_Fieldref = PTR_THIS_CP_Fieldref(pcpd);
+
+                /* Only unresolve this CP slot if it was resolved */
+                if (jvm_class_index_null !=
+                    pcpd_Fieldref->LOCAL_Fieldref_binding.clsidxJVM)
+                {
+                    /* Remove reference unless it references itself */
+                    if (clsidx != 
+                        pcpd_Fieldref->LOCAL_Fieldref_binding.clsidxJVM)
+                    {
+                        (rvoid) GC_CLASS_RMREF_FROM_CLASS(
+                                    clsidx,
+                                    pcpd_Fieldref
+                                      ->LOCAL_Fieldref_binding
+                                        .clsidxJVM);
+                    }
+
+                    pcpd_Fieldref
+                        ->LOCAL_Fieldref_binding.clsidxJVM =
+                            jvm_class_index_null;
+
+                    pcpd_Fieldref
+                        ->LOCAL_Fieldref_binding.fluidxJVM =
+                            jvm_field_lookup_index_bad;
+
+                    pcpd_Fieldref
+                        ->LOCAL_Fieldref_binding.oiflagJVM =
+                            rneither_true_nor_false;
+
+                    pcpd_Fieldref
+                        ->LOCAL_Fieldref_binding.jvaluetypeJVM =
+                            LOCAL_BASETYPE_ERROR;
+                }
+                break;
+
+            case CONSTANT_Methodref:
+
+                pcpd_Methodref = PTR_THIS_CP_Methodref(pcpd);
+
+                /* Only unresolve this CP slot if it was resolved */
+                if (jvm_class_index_null !=
+                    pcpd_Methodref->LOCAL_Methodref_binding.clsidxJVM)
+                {
+                    /* Remove reference unless it references itself */
+                    if (clsidx != 
+                      pcpd_Methodref->LOCAL_Methodref_binding.clsidxJVM)
+                    {
+                        (rvoid) GC_CLASS_RMREF_FROM_CLASS(
+                                    clsidx,
+                                    pcpd_Methodref
+                                      ->LOCAL_Methodref_binding
+                                        .clsidxJVM);
+                    }
+
+                    pcpd_Methodref
+                        ->LOCAL_Methodref_binding.clsidxJVM =
+                            jvm_class_index_null;
+
+                    pcpd_Methodref
+                        ->LOCAL_Methodref_binding.mthidxJVM =
+                            jvm_method_index_bad;
+
+                    pcpd_Methodref
+                        ->LOCAL_Methodref_binding.codeatridxJVM =
+                            jvm_attribute_index_bad;
+
+                    pcpd_Methodref
+                        ->LOCAL_Methodref_binding.excpatridxJVM =
+                            jvm_attribute_index_bad;
+
+                    pcpd_Methodref
+                        ->LOCAL_Methodref_binding.nmordJVM =
+                            jvm_native_method_ordinal_null;
+                }
+                break;
+
+            case CONSTANT_InterfaceMethodref:
+
+                pcpd_InterfaceMethodref =
+                    PTR_THIS_CP_InterfaceMethodref(pcpd);
+
+                /* Only unresolve this CP slot if it was resolved */
+                if (jvm_class_index_null !=
+                    pcpd_InterfaceMethodref
+                        ->LOCAL_InterfaceMethodref_binding.clsidxJVM)
+                {
+                    /* Remove reference unless it references itself */
+                    if (clsidx != 
+                        pcpd_InterfaceMethodref
+                          ->LOCAL_InterfaceMethodref_binding.clsidxJVM)
+                    {
+                        (rvoid) GC_CLASS_RMREF_FROM_CLASS(
+                                    clsidx,
+                                    pcpd_InterfaceMethodref
+                                      ->LOCAL_InterfaceMethodref_binding
+                                        .clsidxJVM);
+                    }
+
+                    pcpd_InterfaceMethodref
+                        ->LOCAL_InterfaceMethodref_binding.clsidxJVM =
+                            jvm_class_index_null;
+
+                    pcpd_InterfaceMethodref
+                        ->LOCAL_InterfaceMethodref_binding.mthidxJVM =
+                            jvm_method_index_bad;
+
+                    pcpd_InterfaceMethodref
+                       ->LOCAL_InterfaceMethodref_binding.codeatridxJVM=
+                            jvm_attribute_index_bad;
+
+                    pcpd_InterfaceMethodref
+                       ->LOCAL_InterfaceMethodref_binding.excpatridxJVM=
+                            jvm_attribute_index_bad;
+
+                    pcpd_InterfaceMethodref
+                       ->LOCAL_InterfaceMethodref_binding.nmordJVM=
+                            jvm_native_method_ordinal_null;
+                }
+                break;
+
+            case CONSTANT_String:
+
+            case CONSTANT_Integer:
+
+            case CONSTANT_Float:
+
+            case CONSTANT_Long:
+
+            case CONSTANT_Double:
+
+            case CONSTANT_NameAndType:
+
+            case CONSTANT_Utf8:
+
+                /*
+                 * There is no late binding associated
+                 * directly with these tags.
+                 */
+
+                break;
+
+            default:
+                GENERIC_FAILURE1_VALUE(rtrue,
+                                       DMLNORM,
+                                       "linkage_rmresolve_class",
+                                       "Invalid CP tag %d",
+                                       CP_TAG(pcfs, cpidx),
+                                       rfalse,
+                                       rnull,
+                                       rnull);
+
+        } /* switch ... */
+
+    } /* for (cpidx) */
+
+    /* This class is no longer fully linked */
+    CLASS(clsidx).status &= ~CLASS_STATUS_LINKED;
+
+    return(rtrue);
+
+} /* END of linkage_unresolve_class() */
+
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/linkage.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/linkage.h?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/linkage.h (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/linkage.h Fri Oct  7 21:27:56 2005
@@ -0,0 +1,242 @@
+#ifndef _linkage_h_included_
+#define _linkage_h_included_
+
+/*!
+ * @file linkage.h
+ *
+ * @brief Runtime linkages between major data structures.
+ *
+ * Of particular interest are the linkages between thread, class,
+ * and object areas.
+ *
+ * Several useful macros are defined here.  They are used to associate
+ * an object instance with its ClassFile structure, its class
+ * definition, and its thread definition, where applicable.
+ *
+ * The macro CLASS_OBJECT_LINKAGE() associates a class definition with
+ * its object instance.  The macro OBJECT_CLASS_LINKAGE() associates
+ * an object instance with its class definition.
+ *
+ * The macro THREAD_OBJECT_LINKAGE() associates a thread definition with
+ * its object instance.  The macro OBJECT_THREAD_LINKAGE() associates
+ * an object instance with its thread definition.  This functionality
+ * is @e only meaningful when the object is a
+ * <b><code>java.lang.Thread</code></b>.
+ *
+ * The information stored in that object table entry points to both
+ * the ClassFile storage for that class and to the class table entry
+ * for that class.
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/linkage.h $ \$Id: linkage.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(linkage, h, "$URL: https://svn.apache.org/path/name/linkage.h $ $Id: linkage.h 0 09/28/2005 dlydick $");
+
+
+/*!
+ * @def CLASS_OBJECT_LINKAGE()
+ *
+ * @brief Retrieve class information about a class from its
+ * class object.
+ *
+ * @param  clsidx     Class table index of class definition for which
+ *                    to locate its class definition
+ *                   @link #jvm_table_linkage jvm_table_linkage@endlink.
+ *
+ *
+ * @returns (jvm_table_linkage *) to object table class linkage entry
+ *
+ */
+#define CLASS_OBJECT_LINKAGE(clsidx) \
+                (&OBJECT(CLASS(clsidx).class_objhash).table_linkage)
+
+/*!
+ * @def OBJECT_CLASS_LINKAGE()
+ *
+ * @brief Retrieve class information about an object from its
+ * class.
+ *
+ * @param  objhash    Object hash of object for which to locate its
+ *                    class table entry.
+ *
+ * @returns (jvm_table_linkage *) to object table class linkage entry
+ *
+ */
+
+#define OBJECT_CLASS_LINKAGE(objhash) (&OBJECT(objhash).table_linkage)
+
+
+/* Now the thread definitions: */
+
+/*!
+ * @def VERIFY_THREAD_LINKAGE()
+ *
+ * @brief Verify that a thread slot is in use, is not a null thread,
+ * and contains a valid, non-null, thread object hash that is
+ * definitely marked as a thread object
+ *
+ * @param  thridx     Thread table index of thread to verify its
+ *                    thread table entry.
+ *
+ *
+ * @returns @link #rtrue rtrue@endlink if this thread index indicates
+ * a valid thread table slot, otherwise @link #rfalse rfalse@endlink.
+ *
+ */
+#define VERIFY_THREAD_LINKAGE(thridx)                            \
+   (((thridx != jvm_thread_index_null) &&                        \
+     (THREAD(thridx).status & THREAD_STATUS_INUSE) &&            \
+     (!(THREAD(thridx).status & THREAD_STATUS_NULL)) &&          \
+     (THREAD(thridx).thread_objhash != jvm_object_hash_null)&&   \
+     (OBJECT(THREAD(thridx).thread_objhash).status &             \
+                                        OBJECT_STATUS_INUSE) &&  \
+     (!(OBJECT(THREAD(thridx).thread_objhash).status &           \
+                                        OBJECT_STATUS_NULL)) &&  \
+     (OBJECT(THREAD(thridx).thread_objhash).status &             \
+                                        OBJECT_STATUS_THREAD))   \
+    ? rtrue                                                      \
+    : rfalse)
+
+
+/*!
+ * @def THREAD_OBJECT_LINKAGE()
+ *
+ * @brief Retrieve object information about a thread from its
+ * thread object instance.
+ *
+ * @param  thridx     Thread table index of thread definition for which
+ *                    to locate its class definition
+ *                   @link #jvm_table_linkage jvm_table_linkage@endlink.
+ *
+ *
+ * @returns (jvm_table_linkage *) to object table class linkage entry
+ *
+ *
+ * @note  This macro will return @link #rnull rnull@endlink if
+ *        the object hash in this slot is a
+ *        @link #jvm_thread_index_null jvm_thread_index_null@endlink
+ *        reference.
+ *        
+ */
+#define THREAD_OBJECT_LINKAGE(thridx)                         \
+    ((THREAD(thridx).thread_objhash != jvm_object_hash_null)  \
+     ? (&OBJECT(THREAD(thridx).thread_objhash).table_linkage) \
+     : (jvm_table_linkage *) rnull)
+
+
+/*!
+ * @def OBJECT_THREAD_LINKAGE()
+ *
+ * @brief Retrieve thread information about an object from its
+ * thread entry.
+ *
+ *
+ * @param  objhash    Object hash of object for which to locate its
+ *                    thread table entry.
+ *
+ *
+ * @returns (jvm_table_linkage *) to object table class linkage entry of
+ *                               <b><code>java.lang.Thread</code></b>
+ *                               class object.
+ *
+ * @note  This macro will return @link #rnull rnull@endlink if the
+ * object in this slot is not a <b><code>java.lang.Thread</code></b>
+ * object and one which indexes a valid thread.
+ *
+ */
+#define OBJECT_THREAD_LINKAGE(objhash)                                 \
+    (((OBJECT(objhash).status & OBJECT_STATUS_INUSE) &&                \
+      (OBJECT(objhash).status & OBJECT_STATUS_THREAD) &&               \
+      (jvm_thread_index_null != OBJECT(objhash).table_linkage.thridx)) \
+     ? (&OBJECT(objhash).table_linkage)                                \
+     : ((jvm_table_linkage *) rnull))
+
+
+/*!
+ * @def VERIFY_OBJECT_THREAD_LINKAGE()
+ *
+ * @brief Verify that a thread slot is in use, is not a null thread,
+ * and contains a valid thread object hash.
+ *
+ * @param  objhash    Object hash of object for which to verify its
+ *                    thread linkage and its thread table entry.
+ *
+ *
+ * @returns @link #rtrue rtrue@endlink if this object hash indicates
+ * a valid thread linkage and a thread table slot, otherwise
+ * @link #rfalse rfalse@endlink.
+ *
+ */
+#define VERIFY_OBJECT_THREAD_LINKAGE(objhash)   \
+   ((rnull != (OBJECT_THREAD_LINKAGE(objhash))) \
+    ? rtrue                                     \
+    : rfalse)
+
+
+/* Finally the object self-referential definitions: */
+
+/*!
+ * @def OBJECT_OBJECT_LINKAGE()
+ *
+ * @brief Retrieve object information about an object from itself.
+ *
+ * @param  objhash    Object hash of object for which
+ *                    to locate its class definition
+ *                   @link #jvm_table_linkage jvm_table_linkage@endlink.
+ *
+ *
+ * @returns (jvm_table_linkage *) to object table class linkage entry
+ *
+ *
+ * @note  This macro will return @link #rnull rnull@endlink if the
+ *        object hash in this slot is a
+ *        @link #jvm_object_hash_null jvm_object_hash_null@endlink
+ *        reference.
+ *
+ */
+
+#define OBJECT_OBJECT_LINKAGE(objhash)             \
+    ((OBJECT(objhash).status & OBJECT_STATUS_INUSE) \
+     ? (&OBJECT(objhash).table_linkage)             \
+     : (jvm_table_linkage *) rnull)
+
+
+/* Prototypes for functions in 'linkage.c' */
+extern rboolean linkage_resolve_class(jvm_class_index clsidx,
+                                      rboolean    find_registerNatives);
+
+extern rboolean linkage_unresolve_class(jvm_class_index clsidx);
+
+#endif /* _linkage_h_included_ */
+
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/main.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/main.c?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/main.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/main.c Fri Oct  7 21:27:56 2005
@@ -0,0 +1,84 @@
+/*!
+ * @file jvm/src/main.c
+ *
+ * @brief Entry point for bootstrap Java Virtual Machine
+ *
+ * The normal invocation of the JVM is very simple: just pass
+ * the main() parameters into the JVM entry point, then call
+ * @c @b exit(2) with the return code from it.  That's all there
+ * is to it from the top level.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/main.c $ \$Id: main.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(main, c, "$URL: https://svn.apache.org/path/name/main.c $ $Id: main.c 0 09/28/2005 dlydick $");
+
+
+#include <stdlib.h>
+
+#include "jvmcfg.h"
+#include "classfile.h"
+#include "jvm.h"
+
+
+/*!
+ * @brief Example of invoking the main JVM entry point
+ *
+ * The arguments to @link #jvm() jvm()@endlink are identical in
+ * format and presentation to those used to enter a 'C' main program.
+ *
+ *
+ * @param argc  Number of parameters being passed in @b argv
+ *
+ * @param argv  Array of null-terminated strings, @b argv[0] being the
+ *              program name, @b argv[1] being the first argument, etc.
+ *
+ * @param envp  Environment pointer
+ *
+ *
+ * @returns exit code from @link #jvm() jvm()@endlink
+ *
+ */
+int main(int argc, char **argv, char **envp)
+{
+    /* Run the JVM and retrieve its return code */
+    int rc = jvm(argc, argv, envp);
+
+    /* Report the return code to the OS shell */
+    exit(rc);
+
+} /* END of main() */
+
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/manifest.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/manifest.c?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/manifest.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/manifest.c Fri Oct  7 21:27:56 2005
@@ -0,0 +1,189 @@
+/*!
+ * @file manifest.c
+ *
+ * @brief Read JAR manifest file.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/manifest.c $ \$Id: manifest.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(manifest, c, "$URL: https://svn.apache.org/path/name/manifest.c $ $Id: manifest.c 0 09/28/2005 dlydick $");
+
+
+#include <stdio.h>
+#include <ctype.h>
+#include <strings.h>
+
+#include "jvmcfg.h"
+#include "heap.h" 
+#include "exit.h"
+#include "util.h"
+
+/*!
+ * @brief Search a JAR manifest file for a main class attribute.
+ *
+ * This attribute MUST be all on one line and without any
+ * line continuations breaking up the class name.  Look for
+ * a line of text like this, where @b | indicates that the
+ * following character is the first one on the line:
+ *
+ * @verbatim
+      |
+      |Main-Class: name.of.start.class\n
+      |
+  
+   WITHOUT any line continuations,
+  
+      |
+      |Main-Class: name.of.sta\n
+      | rt.class\n
+      |
+  
+   @endverbatim
+ *
+ * @todo  Although such a continuation is supported by the JAR file,
+ * this implementation does not support it (yet).  With this
+ * restriction, the if only one single space separates the name of
+ * the attribute and the class name, then since a line may be up
+ * to 72 characters long (that is JVMCFG_JARFILE_MANIFEST_LINE_MAX
+ * characters), then the class name may be 61 characters long.
+ *
+ *
+ * @param  mnfname   JAR manifest file name, /absolute/path/name
+ *         
+ *
+ * @returns Heap pointer to null-terminated class name, or
+ *          @link #rnull rnull@endlink if not found.
+ *          Call HEAP_FREE_DATA() when done.
+ *
+ */
+rchar *manifest_get_main(rchar *mnfname)
+{
+    FILE *mf = fopen(mnfname, "r");
+
+    if (rnull == mf)
+    {
+        return((rchar *) rnull);
+    }
+
+    rchar *mnfdata = HEAP_GET_DATA(JVMCFG_STDIO_BFR, rfalse);
+
+    int mclen =  strlen(JVMCFG_JARFILE_MANIFEST_MAIN_CLASS);
+
+    /* Read until end of file or match located */
+    while (mnfdata == (rchar *) fgets(mnfdata, JVMCFG_STDIO_BFR, mf))
+    {
+        /*
+         * Scan for ^Main-Class: attribute name (text starting
+         * at beginnin of line)
+         */
+        if (0 != strncmp(mnfdata,
+                         JVMCFG_JARFILE_MANIFEST_MAIN_CLASS,
+                         mclen))
+        {
+            continue;
+        }
+
+        /*
+         * Attribute name found.
+         *
+         * Scan for first non-white character after attribute name.
+         * This will be the start of the class name.
+         */
+        rint i;
+        for (i = mclen; i < strlen(mnfdata); i++)
+        {
+            /* if <b>white space</b> is rfalse */
+            if (0 == isspace((int) mnfdata[i]))
+            {
+                break; /* Found first non-white-space character */
+            }
+        }
+        /* If nothing else, the \n at end of line is white space */
+
+        /*
+         * Class name found.
+         *
+         * Scan for first white character after class name.
+         * This will be the end of the class name.
+         */
+        rint j;
+        for (j = i; j < strlen(mnfdata); j++)
+        {
+            /* if <b>white space</b> is @link #rtrue rtrue@endlink */
+            if (0 != isspace((int) mnfdata[j]))
+            {
+                break;  /* Found first white-space character */
+            }
+        }
+        /* If nothing else, the \n at end of line is white space */
+
+        fclose(mf);
+
+        /* Allocate space for non-empty class name plus NUL byte */
+        rchar *mnfresult;
+        if (i != j)
+        { 
+            mnfresult = HEAP_GET_DATA(j - i + sizeof(rchar), rfalse);
+
+            /* If failure above, HEAP_FREE_DATA(mnfdata) is never run */
+        }
+        else
+        {
+            /* Do not process empty class name, declare error instead */
+            HEAP_FREE_DATA(mnfdata);
+
+            sysErrMsg("manifest_get_main",
+                      "Missing class name in manifest file %s",
+                      mnfname);
+            exit_jvm(EXIT_MANIFEST_JAR);
+/*NOTREACHED*/
+        }
+
+        memcpy(mnfresult, &mnfdata[i], j - i);
+        mnfresult[j - i] = '\0';
+
+        HEAP_FREE_DATA(mnfdata);
+        return(mnfresult);
+    }
+
+    fclose(mf);
+
+    HEAP_FREE_DATA(mnfdata);
+
+    return((rchar *) rnull);
+
+} /* END of manifest_get_main() */
+
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/method.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/method.c?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/method.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/method.c Fri Oct  7 21:27:56 2005
@@ -0,0 +1,237 @@
+/*!
+ * @file method.c
+ *
+ * @brief Manipulate ClassFile methods.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/method.c $ \$Id: method.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(method, c, "$URL: https://svn.apache.org/path/name/method.c $ $Id: method.c 0 09/28/2005 dlydick $");
+
+
+#include <stdlib.h>
+#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 "nts.h"
+#include "utf.h"
+
+
+/*!
+ * @brief Locate the method_info index for a normal method in a class
+ * using a constant_pool entry to the name and description of
+ * the method.
+ *
+ *
+ * @param  clsidx            Class index of class whose method is to be
+ *                             located.
+ *
+ * @param  mthname           UTF8 constant_pool entry of name of method
+ *                             in class.
+ *
+ * @param  mthdesc           UTF8 constant_pool entry of description of
+ *                             method parameters and return type.
+ *
+ *
+ * @returns method table index of this method in class or
+ *          @link #jvm_method_index_bad jvm_method_index_bad@endlink
+ *          if not found.
+ *
+ *
+ * Throws: nothing.  Let caller throw an error like
+ *         JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR if it is
+ *         useful at that point.  The purpose of this
+ *         function is simply to locate the method, not
+ *         make a value judgment on the meaning of the
+ *         search result.
+ *
+ */
+jvm_method_index method_find_by_cp_entry(jvm_class_index  clsidx,
+                                         cp_info_dup     *mthname,
+                                         cp_info_dup     *mthdesc)
+{
+    /* Prohibit invalid parameter */
+    if (jvm_class_index_null == clsidx)
+    {
+        exit_throw_exception(EXIT_JVM_METHOD,
+                             JVMCLASS_JAVA_LANG_INTERNALERROR);
+    }
+
+    /* Prohibit non-UTF8 CP entries from being parsed */
+    CONSTANT_Utf8_info *pmthdata = PTR_THIS_CP_Utf8(mthname);
+    if (CONSTANT_Utf8 != pmthdata->tag)
+    {
+        return(jvm_method_index_bad);
+    }
+
+    pmthdata = PTR_THIS_CP_Utf8(mthdesc);
+    if (CONSTANT_Utf8 != pmthdata->tag)
+    {
+        return(jvm_method_index_bad);
+    }
+
+    /* Point to class structure, then look for method  */
+    ClassFile *pcfs = CLASS_OBJECT_LINKAGE(clsidx)->pcfs;
+
+    u2 mcount = pcfs->methods_count;
+    jvm_method_index mthidx;
+    for (mthidx = 0; mthidx < mcount; mthidx++)
+    {
+        /* Report a match of method name and description when found */
+        if ((0 == utf_pcfs_strcmp(PTR_THIS_CP_Utf8(mthname),
+                                  pcfs,
+                                  pcfs->methods[mthidx]->name_index))
+            &&
+            (0 == utf_pcfs_strcmp(PTR_THIS_CP_Utf8(mthdesc),
+                                  pcfs,
+                                  pcfs
+                                    ->methods[mthidx]
+                                      ->descriptor_index)))
+        {
+            return(mthidx);
+        }
+    }
+
+    /* Not found */
+    return(jvm_method_index_bad);
+
+} /* END of method_find_by_cp_entry() */
+
+
+/*!
+ * @brief Retrieve by <b><code>(rchar *)</code></b> name a method
+ * index to a method in a class.
+ *
+ *
+ * @param  clsidx            Class index of class whose method is to be
+ *                             located.
+ *
+ * @param  mthname           Null-terminated string of name of method
+ *                             in class.
+ *
+ * @param  mthdesc           Null-terminated string of description of
+ *                             method parameters and return type.
+ *
+ *
+ * @returns method index of located method in class, otherwise
+ *          @link #jvm_method_index_bad jvm_method_index_bad@endlink.
+ *
+ */
+jvm_method_index
+    method_find_by_prchar(jvm_class_index  clsidx,
+                          rchar           *mthname,
+                          rchar           *mthdesc)
+{
+    cp_info_dup *pcip_mthname = nts_prchar2utf(mthname);
+    cp_info_dup *pcip_mthdesc = nts_prchar2utf(mthdesc);
+
+    jvm_method_index rc =
+        method_find_by_cp_entry(clsidx, pcip_mthname, pcip_mthdesc);
+
+    HEAP_FREE_DATA(pcip_mthname);
+    HEAP_FREE_DATA(pcip_mthdesc);
+
+    return(rc);
+
+} /* END of method_find_by_prchar() */
+
+/*!
+ * @brief Extract method return type from descriptor
+ *
+ *
+ * @param clsidx      Class table index of method to examine.
+ *
+ * @param mthdescidx  Class file constant_pool index of method
+ *                    descriptor to examine.  This entry must be a
+ *                    CONSTANT_Utf8_info string containing the
+ *                    descriptor of an unqualified method name.
+ *
+ *
+ * @returns Primative base type of method return value or
+ *          @link #LOCAL_BASETYPE_ERROR LOCAL_BASETYPE_ERROR@endlink
+ *          if not found.
+ *
+ */
+jvm_basetype method_return_type(jvm_class_index         clsidx,
+                                jvm_constant_pool_index mthdescidx)
+{
+    cp_info_dup        *pcpd;
+    CONSTANT_Utf8_info *pcpd_Utf8;
+
+    pcpd =CLASS_OBJECT_LINKAGE(clsidx)->pcfs->constant_pool[mthdescidx];
+    pcpd_Utf8 = PTR_THIS_CP_Utf8(pcpd);
+
+    u2 idx;
+           /* Last char will be result:/ - 1/ except 'Lsome/class;' */
+    for(idx = 0; idx < pcpd_Utf8->length - 1; idx++)
+    {
+        /* Scan for parm list closure, next char is return type */
+        if (METHOD_CHAR_CLOSE_PARM == pcpd_Utf8->bytes[idx])
+        {
+            switch (pcpd_Utf8->bytes[idx + 1])
+            {
+                case BASETYPE_CHAR_B:
+                case BASETYPE_CHAR_C:
+                case BASETYPE_CHAR_D:
+                case BASETYPE_CHAR_F:
+                case BASETYPE_CHAR_I:
+                case BASETYPE_CHAR_J:
+                case BASETYPE_CHAR_L:
+                case BASETYPE_CHAR_S:
+                case BASETYPE_CHAR_Z:
+                case BASETYPE_CHAR_ARRAY:
+                case METHOD_CHAR_VOID:
+                    return((jvm_basetype) pcpd_Utf8->bytes[idx + 1]);
+            }
+        }
+    }
+
+    /*!
+     * @todo  Should this throw a @b VerifyError instead?
+     *        Is it better to let caller do this?
+     */
+
+    /* Error, something else found */
+    return((jvm_basetype) LOCAL_BASETYPE_ERROR);
+
+} /* END of method_return_type() */
+
+
+/* EOF */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/method.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/method.h?rev=307257&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/method.h (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/method.h Fri Oct  7 21:27:56 2005
@@ -0,0 +1,86 @@
+#ifndef _method_h_included_
+#define _method_h_included_
+
+/*!
+ * @file method.h
+ *
+ * @brief Method management functions for the JVM.
+ *
+ *
+ * @section Control
+ *
+ * \$URL: https://svn.apache.org/path/name/method.h $ \$Id: method.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(method, h, "$URL: https://svn.apache.org/path/name/method.h $ $Id: method.h 0 09/28/2005 dlydick $");
+
+
+/*!
+ * @def METHOD
+ * @brief Access structures of a class' method table at certain index.
+ *
+ * Each class has a table of methods, divided into virtual methods
+ * @e within the Java code and native methods referenced @e from the
+ * Java code and implemented in some outside object library.
+ * They may be distinquished by the @link #ACC_NATIVE ACC_NATIVE@endlink
+ * status bit in @link #rclass.status rclass.status@endlink
+ * This macro references one of them using the @p @b clsidx index for
+ * the class and @p @b mthidx for the method 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 mthidx  Index into method table for this class.
+ * 
+ * @returns pointer to a method table entry
+ * 
+ */
+#define METHOD(clsidx, mthidx) \
+    (CLASS_OBJECT_LINKAGE(clsidx)->pcfs->methods[mthidx])
+
+
+/* Prototypes for functions in 'method.c' */
+
+extern
+    jvm_method_index method_find_by_cp_entry(jvm_class_index  clsidx,
+                                             cp_info_dup    *mthname,
+                                             cp_info_dup    *mthdesc);
+
+extern jvm_method_index method_find_by_prchar(jvm_class_index  clsidx,
+                                              rchar           *mthname,
+                                              rchar           *mthdesc);
+
+extern jvm_basetype method_return_type(jvm_class_index      clsidx,
+                                    jvm_constant_pool_index mthdescidx);
+
+#endif /* _method_h_included_ */
+
+/* EOF */