You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by dl...@apache.org on 2007/08/13 00:15:38 UTC
svn commit: r565175 -
/harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/linkage.c
Author: dlydick
Date: Sun Aug 12 15:15:36 2007
New Revision: 565175
URL: http://svn.apache.org/viewvc?view=rev&rev=565175
Log:
Fill in linkage_resolve_class() with lots of missing pieces
for parsing of constant_pool entries.
Modified:
harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/linkage.c
Modified: harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/linkage.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/linkage.c?view=diff&rev=565175&r1=565174&r2=565175
==============================================================================
--- harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/linkage.c (original)
+++ harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/linkage.c Sun Aug 12 15:15:36 2007
@@ -70,7 +70,13 @@
/*!
* @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
+ * @link #class_static_new() class_static_new()@endlink .
+ *
+ * This function implements the lookups of JVM spec section 5.4.3 .
+ * The errors thrown as a result of failure are initiated by the calling
+ * function when a class (section 5.4.3.1), field (section 5.4.3.2),
+ * method (sectino 5.4.3.3), or interface method (sectino 5.4.3.4)
+ * should have been resolved herein but was not.
*
*
* @param clsidx Class table index to class to resolve against
@@ -138,6 +144,8 @@
ClassFile *pcfs = CLASS_OBJECT_LINKAGE(clsidx)->pcfs;
jvm_constant_pool_index cpidx;
+ u2 ifidx;
+ rboolean ifallfound;
for (cpidx = CONSTANT_CP_START_INDEX;
cpidx < pcfs->constant_pool_count + CONSTANT_CP_START_INDEX -1;
cpidx++)
@@ -159,640 +167,1011 @@
cp_info_mem_align *clsname;
- switch (CP_TAG(pcfs, cpidx))
- {
- case CONSTANT_Class:
+/*******************************************/
+/* */
+/* Begin large switch statement. */
+/* Due to the depth of nested blocks, */
+/* indentation has been reset until the */
+/* end of the switch. */
+/* */
+/*******************************************/
+switch (CP_TAG(pcfs, cpidx))
+{
+case CONSTANT_Class:
- pcpma_Class = PTR_THIS_CP_Class(pcpma);
+ pcpma_Class = PTR_THIS_CP_Class(pcpma);
- /* Only resolve this CP slot if it is not yet done. */
- if (jvm_class_index_null ==
- pcpma_Class->LOCAL_Class_binding.clsidxJVM)
- {
- clsname =
- pcfs->constant_pool[pcpma_Class->name_index];
+ /* Only resolve this CP slot if it is not yet done. */
+ if (jvm_class_index_null ==
+ pcpma_Class->LOCAL_Class_binding.clsidxJVM)
+ {
+ clsname = pcfs->constant_pool[pcpma_Class->name_index];
- clsidxFIND = class_find_by_cp_entry(clsname);
+ 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(pcpma)
- ->LOCAL_Class_binding.clsidxJVM = clsidxFIND;
+ if (jvm_class_index_null == clsidxFIND)
+ {
+ /* Class not yet loaded in memory */
+ class_fully_linked = rfalse;
+ }
+ else
+ {
+ PTR_THIS_CP_Class(pcpma)
+ ->LOCAL_Class_binding.clsidxJVM = clsidxFIND;
- /* Add reference unless it references itself */
- if (clsidx != clsidxFIND)
- {
- (rvoid) GC_CLASS_MKREF_FROM_CLASS(
- clsidx,
- clsidxFIND);
- }
- }
- }
- break;
+ /* Add reference unless it references itself */
+ if (clsidx != clsidxFIND)
+ {
+ (rvoid) GC_CLASS_MKREF_FROM_CLASS( clsidx, clsidxFIND);
+ }
+ }
+ }
+ break;
- case CONSTANT_Fieldref:
+case CONSTANT_Fieldref:
- pcpma_Fieldref = PTR_THIS_CP_Fieldref(pcpma);
+ pcpma_Fieldref = PTR_THIS_CP_Fieldref(pcpma);
- /* Only resolve this CP slot if it is not yet done. */
- if (jvm_class_index_null ==
- pcpma_Fieldref->LOCAL_Fieldref_binding.clsidxJVM)
- {
- pcpma_Class =
- PTR_THIS_CP_Class(pcfs->constant_pool
- [pcpma_Fieldref->class_index]);
+ /* Only resolve this CP slot if it is not yet done. */
+ if (jvm_class_index_null ==
+ pcpma_Fieldref->LOCAL_Fieldref_binding.clsidxJVM)
+ {
+ pcpma_Class =
+ PTR_THIS_CP_Class(pcfs->constant_pool
+ [pcpma_Fieldref->class_index]);
+
+ clsname = pcfs->constant_pool[pcpma_Class->name_index];
- clsname =
- pcfs->constant_pool[pcpma_Class->name_index];
+ clsidxFIND = class_find_by_cp_entry(clsname);
- clsidxFIND = class_find_by_cp_entry(clsname);
+ if (jvm_class_index_null == clsidxFIND)
+ {
+ /* Class not yet loaded in memory */
+ class_fully_linked = rfalse;
+ }
+ else
+ {
+ pcpma_NameAndType =
+ PTR_THIS_CP_NameAndType(
+ pcfs->constant_pool
+ [pcpma_Fieldref ->name_and_type_index]);
+
+ fldidxFIND =
+ field_find_by_cp_entry(
+ clsidxFIND,
+
+ pcfs->constant_pool[pcpma_NameAndType->name_index],
+
+ pcfs->constant_pool[pcpma_NameAndType
+ ->descriptor_index]);
+
+ /* Done if field located in class itself */
+ if (jvm_field_index_bad != fldidxFIND)
+ {
+ pcpma_Fieldref->LOCAL_Fieldref_binding.clsidxJVM =
+ clsidxFIND;
+ }
+ else
+ {
+#warning Need to test Fieldref superinterface field search algorithm:
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-10 Need to test the
+ * Fieldref superinterface field search
+ * algorithm.
+ */
- pcpma_Fieldref
- ->LOCAL_Fieldref_binding.clsidxJVM = clsidxFIND;
+ /*
+ * Otherwise search superinterfaces
+ */
+ for (ifidx = 0; ifidx < pcfs->interfaces_count; ifidx++)
+ {
+ clsidxFIND =
+ class_find_by_cp_entry(
+ pcfs->constant_pool
+ [pcfs->interfaces[ifidx]]);
if (jvm_class_index_null == clsidxFIND)
{
- /* Class not yet loaded in memory */
class_fully_linked = rfalse;
}
else
{
- /*!
- * @todo HARMONY-6-jvm-linkage.c-3 The
- * @c @b while() loop that scans for
- * the field in a superclass needs
- * unit testing w/ real data.
+ /*
+ * Class found, locate field in it
+ * or in its superclasses
*/
- while(rtrue)
+ while(jvm_class_index_null != clsidxFIND)
{
- pcpma_NameAndType =
- PTR_THIS_CP_NameAndType(
- pcfs->constant_pool
- [pcpma_Fieldref
- ->name_and_type_index]);
-
fldidxFIND =
field_find_by_cp_entry(
clsidxFIND,
+
pcfs->constant_pool
- [pcpma_NameAndType
- ->name_index],
+ [pcpma_NameAndType->name_index],
+
pcfs->constant_pool
- [pcpma_NameAndType
- ->descriptor_index]);
+ [pcpma_NameAndType->descriptor_index]);
+
- /* Done if field located */
+ /*
+ * Done if field has been located
+ */
if (jvm_field_index_bad != fldidxFIND)
{
+ pcpma_Fieldref
+ ->LOCAL_Fieldref_binding
+ .clsidxJVM =
+ clsidxFIND;
+
break;
}
/*
- * Otherwise search superclass
- * (which is java.lang.Object for arrays)
- */
- /*!
- * @todo HARMONY-6-jvm-linkage.c-6 The array
- * test branch needs unit testing with
- * real data.
+ * Look to next higher
+ * superclass
*/
+#warning Confusing jvm_constant_pool_index_null and jvm_class_index_null
clsidxFIND =
-#if 0 /* Explicitly allow resolution of lower-dimension array types */
- (CLASS(clsidxFIND).status &
- CLASS_STATUS_ARRAY)
- ? class_java_lang_Object
- :
-#endif
- CLASS_OBJECT_LINKAGE(clsidxFIND)
- ->pcfs
- ->super_class;
+ CLASS_OBJECT_LINKAGE(clsidxFIND)
+ ->pcfs
+ ->super_class;
- pcpma_Fieldref
- ->LOCAL_Fieldref_binding.clsidxJVM =
- clsidxFIND;
+ } /* while clsidxFIND */
- /* Quit if no more superclasses */
- if (jvm_class_index_null == clsidxFIND)
- {
- break;
- }
+ /* Done if field has been located */
+ if (jvm_field_index_bad != fldidxFIND)
+ {
+ break;
}
- 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
- pcpma_Fieldref
- ->LOCAL_Fieldref_binding.fluidxJVM =
- jvm_field_lookup_index_bad;
+ } /* if clsidxFIND else */
- pcpma_Fieldref
- ->LOCAL_Fieldref_binding.oiflagJVM =
- rneither_true_nor_false;
+ /* Done if field located */
+ if (jvm_field_index_bad != fldidxFIND)
+ {
+ break;
+ }
+ } /* for ifidx */
+
+
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-3 The @c @b while()
+ * loop that scans for the field in a superclass
+ * needs unit testing w/ real data.
+ */
+
+ /* Search superclasses if field not yet found */
+ if (jvm_field_index_bad == fldidxFIND)
+ {
+
+ /* Search until no more superclasses */
+ while (jvm_class_index_null != clsidxFIND)
+ {
+ fldidxFIND =
+ field_find_by_cp_entry(
+ clsidxFIND,
+
+ pcfs->constant_pool
+ [pcpma_NameAndType->name_index],
+
+ pcfs->constant_pool
+ [pcpma_NameAndType->descriptor_index]);
+
+ /* Done if field located */
+ if (jvm_field_index_bad != fldidxFIND)
+ {
pcpma_Fieldref
- ->LOCAL_Fieldref_binding.jvaluetypeJVM =
- LOCAL_BASETYPE_ERROR;
+ ->LOCAL_Fieldref_binding
+ .clsidxJVM =
+ clsidxFIND;
- /* No point processing ACC_STATIC bit */
- continue;
-#endif
+ break;
}
/*
- * Now check if ACC_STATIC or not and store
- * the proper type of field lookup index.
+ * Otherwise search superclass
+ * (which is java.lang.Object for arrays)
*/
- 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);
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-6
+ * The array test branch needs
+ * unit testing with real data
+ */
+ clsidxFIND =
+#if 0 /* Explicitly allow resolution of lower-dimension array types */
+ (CLASS(clsidxFIND).status &
+ CLASS_STATUS_ARRAY)
+ ? pjvm->class_java_lang_Object
+ :
+#endif
- }
+#warning Confusing jvm_constant_pool_index_null and jvm_class_index_null
+ CLASS_OBJECT_LINKAGE(clsidxFIND)
+ ->pcfs
+ ->super_class;
- pcpma_Fieldref
- ->LOCAL_Fieldref_binding.fluidxJVM =
- fluidxFIND;
+ } /* while clsidxFIND */
- if (jvm_field_lookup_index_bad == fluidxFIND)
- {
- /* Field not found in class-- fatal error */
- exit_throw_exception(EXIT_JVM_CLASS,
+ } /* if clsidxFIND */
+
+ } /* if fldidxFIND else */
+
+ if (jvm_field_index_bad == fldidxFIND)
+ {
+ /* Field not found anywhere-- fatal error */
+ exit_throw_exception(EXIT_JVM_CLASS,
JVMCLASS_JAVA_LANG_NOSUCHFIELDERROR);
/*NOTREACHED*/
#if 0
- pcpma_Fieldref
- ->LOCAL_Fieldref_binding.oiflagJVM =
+ /* The alternative to throwing an exception is: */
+
+ pcpma_Fieldref
+ ->LOCAL_Fieldref_binding.fluidxJVM =
+ jvm_field_lookup_index_bad;
+
+ pcpma_Fieldref
+ ->LOCAL_Fieldref_binding.oiflagJVM =
rneither_true_nor_false;
- pcpma_Fieldref
- ->LOCAL_Fieldref_binding.jvaluetypeJVM =
+ pcpma_Fieldref
+ ->LOCAL_Fieldref_binding.jvaluetypeJVM =
LOCAL_BASETYPE_ERROR;
- /*
- * Don't have valid @b oiflagJVM or
- * @b jvaluetypeJVM result
- */
- continue;
+ /* 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);
+
+ }
+
+ 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*/
+#if 0
+ /* The alternative to throwing an exception is: */
- pcpma_Fieldref
- ->LOCAL_Fieldref_binding.oiflagJVM =
- (FIELD(clsidxFIND, fldidxFIND)
- ->access_flags & ACC_STATIC)
- ? rfalse
- : rtrue;
-
- cp_info_mem_align *pfldesc_mem_align =
- CLASS_OBJECT_LINKAGE(clsidxFIND)
- ->pcfs
- ->constant_pool
- [FIELD(clsidxFIND, fldidxFIND)
- ->descriptor_index];
+ pcpma_Fieldref
+ ->LOCAL_Fieldref_binding.oiflagJVM =
+ rneither_true_nor_false;
+
+ pcpma_Fieldref
+ ->LOCAL_Fieldref_binding.jvaluetypeJVM =
+ LOCAL_BASETYPE_ERROR;
- CONSTANT_Utf8_info *pfldesc =
- PTR_THIS_CP_Utf8(pfldesc_mem_align);
+ /*
+ * Don't have valid @b oiflagJVM or
+ * @b jvaluetypeJVM result
+ */
+ continue;
+#endif
+ }
- /*!
- * @todo HARMONY-6-jvm-linkage.c-1 What needs
- * to happen when base type is
- * BASETYPE_ARRAY or BASETYPE_ERROR
- * or BASETYPE_VOID?
- */
- pcpma_Fieldref
- ->LOCAL_Fieldref_binding.jvaluetypeJVM =
- pfldesc->bytes[0];
+ pcpma_Fieldref
+ ->LOCAL_Fieldref_binding.fluidxJVM = fluidxFIND;
- /* Add reference unless it references itself */
- if (clsidx != clsidxFIND)
- {
- (rvoid) GC_CLASS_MKREF_FROM_CLASS(
- clsidx,
- clsidxFIND);
- }
- }
- }
- break;
+ pcpma_Fieldref->LOCAL_Fieldref_binding.oiflagJVM =
+ (FIELD(clsidxFIND, fldidxFIND)->access_flags & ACC_STATIC)
+ ? rfalse
+ : rtrue;
+
+ cp_info_mem_align *pfldesc_mem_align =
+ CLASS_OBJECT_LINKAGE(clsidxFIND)
+ ->pcfs
+ ->constant_pool
+ [FIELD(clsidxFIND, fldidxFIND)->descriptor_index];
+
+ CONSTANT_Utf8_info *pfldesc =
+ PTR_THIS_CP_Utf8(pfldesc_mem_align);
+
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-1 What needs to happen
+ * when base type is BASETYPE_ARRAY or BASETYPE_ERROR
+ * or BASETYPE_VOID?
+ */
+ pcpma_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:
+
+ pcpma_Methodref = PTR_THIS_CP_Methodref(pcpma);
+
+ /* Only resolve this CP slot if it is not yet done. */
+ if (jvm_class_index_null ==
+ pcpma_Methodref->LOCAL_Methodref_binding.clsidxJVM)
+ {
+ pcpma_Class =
+ PTR_THIS_CP_Class(
+ pcfs->constant_pool[pcpma_Methodref->class_index]);
+
+ clsname = pcfs->constant_pool[pcpma_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
+ {
+ /* The requested class must NOT be an interface */
+ if (ACC_INTERFACE &
+ CLASS_OBJECT_LINKAGE(clsidxFIND)->pcfs->access_flags)
+ {
+ exit_throw_exception(EXIT_JVM_CLASS,
+ JVMCLASS_JAVA_LANG_INCOMPATIBLECLASSCHANGEERROR);
+/*NOTREACHED*/
+ }
+
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-4 The @c @b while() loop
+ * that scans for the method in a superclass needs
+ * unit testing w/ real data.
+ */
+
+ pcpma_NameAndType =
+ PTR_THIS_CP_NameAndType(
+ pcfs
+ ->constant_pool
+ [pcpma_Methodref->name_and_type_index]);
+
+ /* Search until no more superclasses */
+ while (jvm_class_index_null != clsidxFIND)
+ {
+ mthidxFIND =
+ method_find_by_cp_entry(
+ clsidxFIND,
- case CONSTANT_Methodref:
+ pcfs->constant_pool
+ [pcpma_NameAndType->name_index],
- pcpma_Methodref = PTR_THIS_CP_Methodref(pcpma);
+ pcfs->constant_pool
+ [pcpma_NameAndType->descriptor_index]);
- /* Only resolve this CP slot if it is not yet done. */
- if (jvm_class_index_null ==
- pcpma_Methodref->LOCAL_Methodref_binding.clsidxJVM)
+ /* Done if method located */
+ if (jvm_method_index_bad != mthidxFIND)
{
- pcpma_Class =
- PTR_THIS_CP_Class(
- pcfs
- ->constant_pool
- [pcpma_Methodref->class_index]);
+ pcpma_Methodref->LOCAL_Methodref_binding.clsidxJVM =
+ clsidxFIND;
- clsname =
- pcfs->constant_pool[pcpma_Class->name_index];
+ pcpma_Methodref->LOCAL_Methodref_binding.mthidxJVM =
+ mthidxFIND;
- clsidxFIND = class_find_by_cp_entry(clsname);
+ break;
+ }
- pcpma_Methodref
- ->LOCAL_Methodref_binding.clsidxJVM = clsidxFIND;
+ /*
+ * Otherwise search superclass
+ * (which is java.lang.Object for arrays)
+ */
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-7 The array
+ * test branch needs unit testing with
+ * real data.
+ */
+ clsidxFIND =
+#if 0 /* Explicitly allow resolution of lower-dimension array types */
+ (CLASS(clsidxFIND).status &
+ CLASS_STATUS_ARRAY)
+ ? pjvm->class_java_lang_Object
+ :
+#endif
+
+#warning Confusing jvm_constant_pool_index_null and jvm_class_index_null
+ CLASS_OBJECT_LINKAGE(clsidxFIND)->pcfs->super_class;
+
+ } /* while clsidxFIND */
+
+
+ if (jvm_method_index_bad == mthidxFIND)
+ {
+#warning Need to test Methodref superinterface method search algorithm:
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-11 Need to test the
+ * Methodref superinterface field search
+ * algorithm.
+ */
+
+ /*
+ * Otherwise search superinterfaces
+ */
+ for (ifidx = 0; ifidx < pcfs->interfaces_count; ifidx++)
+ {
+ clsidxFIND =
+ class_find_by_cp_entry(
+ pcfs->constant_pool[pcfs->interfaces[ifidx]]);
if (jvm_class_index_null == clsidxFIND)
{
- /* Class not yet loaded in memory */
class_fully_linked = rfalse;
}
else
{
- /*!
- * @todo HARMONY-6-jvm-linkage.c-4 The
- * @c @b while() loop that scans for
- * the method in a superclass needs
- * unit testing w/ real data.
+ /*
+ * Class found, locate method in it
+ * or in its superclasses
*/
- while(rtrue)
+ while(jvm_class_index_null != clsidxFIND)
{
- pcpma_NameAndType =
- PTR_THIS_CP_NameAndType(
- pcfs
- ->constant_pool
- [pcpma_Methodref
- ->name_and_type_index]);
-
mthidxFIND =
method_find_by_cp_entry(
clsidxFIND,
- pcfs
- ->constant_pool
+
+ pcfs->constant_pool
[pcpma_NameAndType->name_index],
- pcfs
- ->constant_pool
- [pcpma_NameAndType
- ->descriptor_index]);
-
- pcpma_Methodref
- ->LOCAL_Methodref_binding.mthidxJVM =
- mthidxFIND;
- /* Done if method located */
+ pcfs->constant_pool
+ [pcpma_NameAndType->descriptor_index]);
+
+
+ /*
+ * Done if interface method has been located
+ */
if (jvm_method_index_bad != mthidxFIND)
{
+ pcpma_Methodref
+ ->LOCAL_Methodref_binding
+ .clsidxJVM =
+ clsidxFIND;
+
+ pcpma_Methodref
+ ->LOCAL_Methodref_binding
+ .mthidxJVM =
+ mthidxFIND;
+
break;
}
/*
- * Otherwise search superclass
- * (which is java.lang.Object for arrays)
- */
- /*!
- * @todo HARMONY-6-jvm-linkage.c-7 The array
- * test branch needs unit testing with
- * real data.
+ * Look to next higher superclass
*/
+#warning Confusing jvm_constant_pool_index_null and jvm_class_index_null
clsidxFIND =
-#if 0 /* Explicitly allow resolution of lower-dimension array types */
- (CLASS(clsidxFIND).status &
- CLASS_STATUS_ARRAY)
- ? class_java_lang_Object
- :
-#endif
- CLASS_OBJECT_LINKAGE(clsidxFIND)
- ->pcfs
- ->super_class;
-
- pcpma_Methodref
- ->LOCAL_Methodref_binding.clsidxJVM =
- clsidxFIND;
+ CLASS_OBJECT_LINKAGE(clsidxFIND)
+ ->pcfs
+ ->super_class;
- /* Quit if no more superclasses */
- if (jvm_class_index_null == clsidxFIND)
- {
- break;
- }
- }
+ } /* while clsidxFIND */
- if (jvm_method_index_bad == mthidxFIND)
+ /*
+ * Done if method has been located
+ */
+ if (jvm_method_index_bad != mthidxFIND)
{
- /* Method not found in class-- fatal error*/
- exit_throw_exception(EXIT_JVM_CLASS,
+ break;
+ }
+
+ } /* if clsidxFIND else */
+
+ /* Done if method located */
+ if (jvm_method_index_bad != mthidxFIND)
+ {
+ break;
+ }
+ } /* for ifidx */
+ }
+
+ 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.
+ * Otherwise, check if abstract, then check
+ * for code itself if not abstract.
+ */
+
+ if(ACC_NATIVE & METHOD(clsidxFIND,mthidxFIND)->access_flags)
+ {
+ atridxFIND = jvm_attribute_index_native;
+
+ pcpma_Methodref->LOCAL_Methodref_binding.nmordJVM =
+ native_locate_local_method(
+ pcfs,
+ pcpma_Class->name_index,
+ pcpma_NameAndType->name_index,
+ pcpma_NameAndType->descriptor_index,
+ find_registerNatives);
+ }
+ else
+ {
+ if (ACC_ABSTRACT &
+ METHOD(clsidxFIND,mthidxFIND)->access_flags)
+ {
+ if (ACC_ABSTRACT &
+ CLASS_OBJECT_LINKAGE(clsidxFIND)
+ ->pcfs->access_flags)
+ {
/*
- * Now check if Code_attribute is present
- * and store its index. First check if native
- * and insert native method ordinal if so.
+ * Concrete class but abstract method--
+ * fatal error
*/
+#if 0 /* Do NOT throw exception here-- throw it at method invocation */
+ exit_throw_exception(EXIT_JVM_CLASS,
+ JVMCLASS_JAVA_LANG_ABSTRACTMETHODERROR);
+/*NOTREACHED*/
+#endif
+ }
- if (ACC_NATIVE &
- METHOD(clsidxFIND,mthidxFIND)->access_flags)
- {
- atridxFIND = jvm_attribute_index_native;
-
- pcpma_Methodref
- ->LOCAL_Methodref_binding
- .nmordJVM =
- native_locate_local_method(
- pcfs,
- pcpma_Class->name_index,
- pcpma_NameAndType->name_index,
- pcpma_NameAndType
- ->descriptor_index,
- find_registerNatives);
- }
- else
- {
- atridxFIND =
- attribute_find_in_method_by_enum(
- clsidxFIND,
- mthidxFIND,
- LOCAL_CODE_ATTRIBUTE);
- }
+ atridxFIND = jvm_attribute_index_abstract;
+ }
+ else
+ {
+ atridxFIND =
+ attribute_find_in_method_by_enum(
+ clsidxFIND,
+ mthidxFIND,
+ LOCAL_CODE_ATTRIBUTE);
+ }
+ }
- pcpma_Methodref
- ->LOCAL_Methodref_binding.codeatridxJVM =
- atridxFIND;
+ pcpma_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,
+ if (jvm_attribute_index_bad == atridxFIND)
+ {
+ /* Code not found in method-- fatal error */
+ exit_throw_exception(EXIT_JVM_ATTRIBUTE,
JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
/*NOTREACHED*/
- }
+ }
+ else
+ if (jvm_attribute_index_abstract == atridxFIND)
+ {
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-8 Abstract methods
+ * do @e not have exceptions blocks, do they,
+ * since they do not have code blocks?
+ */
+ atridxFIND = jvm_attribute_index_bad;
+ }
+ else
+ {
+ /*
+ * Now check if Exceptions attribute is
+ * present and store its index.
+ */
- /*
- * Now check if Exceptions attribute is
- * present and store its index.
- */
+ atridxFIND = attribute_find_in_method_by_enum(
+ clsidxFIND,
+ mthidxFIND,
+ LOCAL_EXCEPTIONS_ATTRIBUTE);
+ }
+
+ pcpma_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;
- atridxFIND =
- attribute_find_in_method_by_enum(
- clsidxFIND,
- mthidxFIND,
- LOCAL_EXCEPTIONS_ATTRIBUTE);
+case CONSTANT_InterfaceMethodref:
- pcpma_Methodref
- ->LOCAL_Methodref_binding.excpatridxJVM =
- atridxFIND;
+ pcpma_InterfaceMethodref = PTR_THIS_CP_InterfaceMethodref(pcpma);
- 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;
+ /* Only resolve this CP slot if it is not yet done. */
+ if (jvm_class_index_null ==
+ pcpma_InterfaceMethodref
+ ->LOCAL_InterfaceMethodref_binding
+ .clsidxJVM)
+ {
+ pcpma_Class =
+ PTR_THIS_CP_Class(pcfs->constant_pool
+ [pcpma_InterfaceMethodref->class_index]);
- case CONSTANT_InterfaceMethodref:
+ clsname = pcfs->constant_pool[pcpma_Class->name_index];
- pcpma_InterfaceMethodref =
- PTR_THIS_CP_InterfaceMethodref(pcpma);
+ clsidxFIND = class_find_by_cp_entry(clsname);
- /* Only resolve this CP slot if it is not yet done. */
- if (jvm_class_index_null ==
- pcpma_InterfaceMethodref
- ->LOCAL_InterfaceMethodref_binding.clsidxJVM)
- {
- pcpma_Class =
- PTR_THIS_CP_Class(pcfs->constant_pool
- [pcpma_InterfaceMethodref->class_index]);
- clsname =
- pcfs->constant_pool[pcpma_Class->name_index];
-
- clsidxFIND = class_find_by_cp_entry(clsname);
-
- pcpma_InterfaceMethodref
- ->LOCAL_InterfaceMethodref_binding.clsidxJVM =
- clsidxFIND;
+ if (jvm_class_index_null == clsidxFIND)
+ {
+ /* Class not yet loaded in memory */
+ class_fully_linked = rfalse;
+ }
+ else
+ {
+ /* The requested class must be an interface */
+ if (!(ACC_INTERFACE &
+ CLASS_OBJECT_LINKAGE(clsidxFIND)->pcfs->access_flags))
+ {
+ exit_throw_exception(EXIT_JVM_CLASS,
+ JVMCLASS_JAVA_LANG_INCOMPATIBLECLASSCHANGEERROR);
+/*NOTREACHED*/
+ }
+
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-5 The
+ * @c @b while() loop that scans for the
+ * interface method in a superinterface
+ * needs unit testing w/ real data.
+ */
+ pcpma_NameAndType =
+ PTR_THIS_CP_NameAndType(
+ pcfs->constant_pool[pcpma_InterfaceMethodref
+ ->name_and_type_index]);
+
+ mthidxFIND =
+ method_find_by_cp_entry(
+ clsidxFIND,
+
+ pcfs
+ ->constant_pool[pcpma_NameAndType->name_index],
+
+ pcfs
+ ->constant_pool
+ [pcpma_NameAndType->descriptor_index]);
+
+ /*
+ * Done if interface method located
+ * in current class
+ */
+ if (jvm_method_index_bad != mthidxFIND)
+ {
+ pcpma_InterfaceMethodref
+ ->LOCAL_InterfaceMethodref_binding
+ .clsidxJVM =
+ clsidxFIND;
+
+ pcpma_InterfaceMethodref
+ ->LOCAL_InterfaceMethodref_binding
+ .mthidxJVM =
+ mthidxFIND;
- if (jvm_class_index_null == clsidxFIND)
- {
- /* Class not yet loaded in memory */
- class_fully_linked = rfalse;
- }
- else
- {
- /*!
- * @todo HARMONY-6-jvm-linkage.c-5 The
- * @c @b while() loop that scans for
- * the interface method in a superclass
- * needs unit testing w/ real data.
- */
- while(rtrue)
- {
- pcpma_NameAndType =
- PTR_THIS_CP_NameAndType(
- pcfs
- ->constant_pool
- [pcpma_InterfaceMethodref
- ->name_and_type_index]);
+ break;
+ }
- mthidxFIND =
- method_find_by_cp_entry(
- clsidxFIND,
- pcfs
- ->constant_pool
- [pcpma_NameAndType->name_index],
- pcfs
- ->constant_pool
- [pcpma_NameAndType
- ->descriptor_index]);
+#warning Need to test IntfcMthrf superinterface method search algorithm:
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-12 Need to test the
+ * InterfaceMethodref superinterface field search
+ * algorithm.
+ */
+
+ /*
+ * Otherwise search superinterfaces,
+ * then finally java.lang.Object
+ */
+ ifallfound = rtrue;
+ for (ifidx = 0; ifidx < pcfs->interfaces_count; ifidx++)
+ {
+ clsidxFIND =
+ class_find_by_cp_entry(
+ pcfs->constant_pool[pcfs->interfaces[ifidx]]);
- pcpma_InterfaceMethodref
- ->LOCAL_InterfaceMethodref_binding
- .mthidxJVM =
- mthidxFIND;
+ if (jvm_class_index_null == clsidxFIND)
+ {
+ class_fully_linked = rfalse;
- /* Done if interface method located */
- if (jvm_method_index_bad != mthidxFIND)
- {
- break;
- }
+ /*
+ * Keep searching interfaces, but do not
+ * do not search java.lang.Object
+ */
+ ifallfound = rfalse;
+ }
+ else
+ {
+ /*
+ * Class found, locate method in it
+ * or in its superclasses
+ */
+ while(jvm_class_index_null !=clsidxFIND)
+ {
+ mthidxFIND =
+ method_find_by_cp_entry(
+ clsidxFIND,
+
+ pcfs
+ ->constant_pool
+ [pcpma_NameAndType->name_index],
+
+ pcfs
+ ->constant_pool
+ [pcpma_NameAndType->descriptor_index]);
+
+ pcpma_InterfaceMethodref
+ ->LOCAL_InterfaceMethodref_binding
+ .mthidxJVM =
+ mthidxFIND;
- /*
- * Otherwise search superclass
- * (which is java.lang.Object for arrays)
- */
- /*!
- * @todo HARMONY-6-jvm-linkage.c-8 The array
- * test branch needs unit testing with
- * real data.
- */
- clsidxFIND =
-#if 0 /* Explicitly allow resolution of lower-dimension array types */
- (CLASS(clsidxFIND).status &
- CLASS_STATUS_ARRAY)
- ? class_java_lang_Object
- :
-#endif
- CLASS_OBJECT_LINKAGE(clsidxFIND)
- ->pcfs
- ->super_class;
+ /* Done if interface method located */
+ if (jvm_method_index_bad != mthidxFIND)
+ {
pcpma_InterfaceMethodref
->LOCAL_InterfaceMethodref_binding
.clsidxJVM =
- clsidxFIND;
-
- /* Quit if no more superclasses */
- if (jvm_class_index_null == clsidxFIND)
- {
- break;
- }
+ clsidxFIND;
+ break;
}
- if (jvm_method_index_bad == mthidxFIND)
- {
- /* Method not found in class-- fatal error*/
- exit_throw_exception(EXIT_JVM_CLASS,
- JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
-/*NOTREACHED*/
- }
+ /* Look to next higher superclass */
+#warning Confusing jvm_constant_pool_index_null and jvm_class_index_null
+ clsidxFIND =
+ CLASS_OBJECT_LINKAGE(clsidxFIND)
+ ->pcfs
+ ->super_class;
- /*
- * Now check if Code_attribute is present
- * and store its index. First check if native
- * and insert native method ordinal if so.
- */
+ } /* while clsidxFIND */
- if (ACC_NATIVE &
- METHOD(clsidxFIND,mthidxFIND)->access_flags)
- {
- atridxFIND = jvm_attribute_index_native;
+ /* Done if interface method located */
+ if (jvm_method_index_bad != mthidxFIND)
+ {
+ break;
+ }
- /*!
- * @todo HARMONY-6-jvm-linkage.c-2 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?
- */
- pcpma_InterfaceMethodref
- ->LOCAL_InterfaceMethodref_binding
- .nmordJVM =
- native_locate_local_method(
- pcfs,
- pcpma_Class->name_index,
- pcpma_NameAndType->name_index,
- pcpma_NameAndType
- ->descriptor_index,
- find_registerNatives);
- }
- else
- {
- atridxFIND =
- attribute_find_in_method_by_enum(
- clsidxFIND,
- mthidxFIND,
- LOCAL_CODE_ATTRIBUTE);
- }
+ } /* if clsidxFIND else */
- pcpma_InterfaceMethodref
- ->LOCAL_InterfaceMethodref_binding
- .codeatridxJVM =
- atridxFIND;
+ /* Done if interface method located */
+ if (jvm_method_index_bad != mthidxFIND)
+ {
+ break;
+ }
+ } /* for ifidx */
- if (jvm_attribute_index_bad == atridxFIND)
- {
- /* Code not found in method-- fatal error */
- exit_throw_exception(EXIT_JVM_ATTRIBUTE,
- JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
+ /*
+ * Finally search java.lang.Object, but only
+ * if all superinterfaces have previously
+ * been loaded so they have all been searched.
+ */
+ if ((jvm_method_index_bad == mthidxFIND) &&
+ (rtrue == ifallfound))
+ {
+ /*
+ * Will always succeed since interfaces
+ * will never be loaded before this class,
+ * which is always loaded first.
+ */
+ clsidxFIND =
+ /* class_find_by_prchar(JVMCLASS_JAVA_LANG_OBJECT); */
+ pjvm->class_java_lang_Object;
+
+ /* Will never happen, but keep consistent algorithm */
+ if (jvm_class_index_null == clsidxFIND)
+ {
/*NOTREACHED*/
- }
+ class_fully_linked = rfalse;
+ }
+ else
+ {
+ /*
+ * Method must be here if no
+ * more superclasses
+ */
+ mthidxFIND =
+ method_find_by_cp_entry(
+ clsidxFIND,
- /*
- * Now check if Exceptions attribute is
- * present and store its index.
- */
+ pcfs
+ ->constant_pool
+ [pcpma_NameAndType->name_index],
- atridxFIND =
- attribute_find_in_method_by_enum(
- clsidxFIND,
- mthidxFIND,
- LOCAL_EXCEPTIONS_ATTRIBUTE);
+ pcfs
+ ->constant_pool
+ [pcpma_NameAndType->descriptor_index]);
+ /*
+ * Done if interface method located.
+ * Otherwise lookup failure.
+ */
+ if (jvm_method_index_bad != mthidxFIND)
+ {
pcpma_InterfaceMethodref
->LOCAL_InterfaceMethodref_binding
- .excpatridxJVM =
- atridxFIND;
-
- if (jvm_attribute_index_bad == atridxFIND)
- {
- /* It is OKAY to not have exceptions */
- }
+ .clsidxJVM =
+ clsidxFIND;
- /* Add reference unless it references itself */
- if (clsidx != clsidxFIND)
- {
- (rvoid) GC_CLASS_MKREF_FROM_CLASS(
- clsidx,
- clsidxFIND);
- }
+ pcpma_InterfaceMethodref
+ ->LOCAL_InterfaceMethodref_binding
+ .mthidxJVM =
+ mthidxFIND;
}
}
- break;
- case CONSTANT_String:
+ /*
+ * All possible locations searched,
+ * but method was still not found
+ * in class-- fatal error
+ */
+ if (jvm_method_index_bad == mthidxFIND)
+ {
+ exit_throw_exception(EXIT_JVM_CLASS,
+ JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR);
+/*NOTREACHED*/
+ }
+ }
- case CONSTANT_Integer:
+ /*
+ * Now check if Code_attribute is present
+ * and store its index. First check if native
+ * and insert native method ordinal if so.
+ * Otherwise, check if abstract, then check
+ * for code itself if not abstract.
+ */
+
+ if (ACC_NATIVE &
+ METHOD(clsidxFIND,mthidxFIND)->access_flags)
+ {
+ atridxFIND = jvm_attribute_index_native;
+
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-2 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?
+ */
+ pcpma_InterfaceMethodref
+ ->LOCAL_InterfaceMethodref_binding
+ .nmordJVM =
+ native_locate_local_method(
+ pcfs,
+ pcpma_Class->name_index,
+ pcpma_NameAndType->name_index,
+ pcpma_NameAndType->descriptor_index,
+ find_registerNatives);
+ }
+ else
+ {
+ if (ACC_ABSTRACT &
+ METHOD(clsidxFIND, mthidxFIND)->access_flags)
+ {
+ atridxFIND = jvm_attribute_index_abstract;
+ }
+ else
+ {
+ atridxFIND =
+ attribute_find_in_method_by_enum(
+ clsidxFIND,
+ mthidxFIND,
+ LOCAL_CODE_ATTRIBUTE);
+ }
+ }
+
+ pcpma_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*/
+ }
+ else
+ if (jvm_attribute_index_abstract == atridxFIND)
+ {
+ /*!
+ * @todo HARMONY-6-jvm-linkage.c-9 Abstract methods
+ * do @e not have exceptions blocks, do they,
+ * since they do not have code blocks?
+ */
+ atridxFIND = jvm_attribute_index_bad;
+ }
+ else
+ {
+ /*
+ * Now check if Exceptions attribute is
+ * present and store its index.
+ */
- case CONSTANT_Float:
+ atridxFIND =
+ attribute_find_in_method_by_enum(
+ clsidxFIND,
+ mthidxFIND,
+ LOCAL_EXCEPTIONS_ATTRIBUTE);
+ }
+
+ pcpma_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_Long:
+case CONSTANT_String:
- case CONSTANT_Double:
+case CONSTANT_Integer:
- case CONSTANT_NameAndType:
+case CONSTANT_Float:
- case CONSTANT_Utf8:
+case CONSTANT_Long:
- /*
- * There is no late binding associated
- * directly with these tags.
- */
+case CONSTANT_Double:
- break;
+case CONSTANT_NameAndType:
+
+case CONSTANT_Utf8:
+
+ /*
+ * There is no late binding associated
+ * directly with these tags.
+ */
- default:
- GENERIC_FAILURE1_VALUE(rtrue,
- DMLNORM,
- arch_function_name,
- "Invalid CP tag %d",
- CP_TAG(pcfs, cpidx),
- rfalse,
- rnull,
- rnull);
+ break;
- } /* switch ... */
+default:
+ GENERIC_FAILURE1_VALUE(rtrue,
+ DMLNORM,
+ arch_function_name,
+ "Invalid CP tag %d",
+ CP_TAG(pcfs, cpidx),
+ rfalse,
+ rnull,
+ rnull);
+
+} /* switch CP_TAG() */
+/*******************************************/
+/* */
+/* End of large switch statement. */
+/* Indentation reset to normal. */
+/* */
+/*******************************************/
} /* for (cpidx) */
@@ -802,7 +1181,7 @@
CLASS(clsidx).status |= CLASS_STATUS_LINKED;
}
- cfmsgs_show_constant_pool(CLASS_OBJECT_LINKAGE(clsidx)->pcfs);
+ /* cfmsgs_show_constant_pool(CLASS_OBJECT_LINKAGE(clsidx)->pcfs); */
return(class_fully_linked);