harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlyd...@apache.org
Subject svn commit: r565158 - /harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvm.c
Date Sun, 12 Aug 2007 21:32:28 GMT
Author: dlydick
Date: Sun Aug 12 14:32:27 2007
New Revision: 565158

URL: http://svn.apache.org/viewvc?view=rev&rev=565158
Log:
Added 'jvm_argv_initialized'

Conditionally declare 'jvm_tmparea_initialized' and
contitionally invoke tmparea_init() and tmparea_shutdown().

Declared 'jvm_model_initialized' and 'jvm_heap_initialized'
to be static.

Declare jvm_model_init() and jvm_model_shutdown() to be static.

Call HEAP_INIT() with '&jvm_heap_initialized' flag.

Load up starting class by searching CLASSPATH, which may
now include Java archive files, and parse manifest for
starting class where appropriate.

Modified:
    harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvm.c

Modified: harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvm.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvm.c?view=diff&rev=565158&r1=565157&r2=565158
==============================================================================
--- harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvm.c (original)
+++ harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/jvm.c Sun Aug 12 14:32:27 2007
@@ -393,7 +393,7 @@
  *                         All of the <b>section 3.11.x</b> headings
  *                         fall under the category of the inner loop.
  * </li>
- * <li><b>3.12 Class Libraries:</b>  Only minimal support is provied
+ * <li><b>3.12 Class Libraries:</b>  Only minimal support is provided
  *                         for class libraries, and that only enough
  *                         to start the machine.  See especially support
  *                         for the environment variable @b BOOTCLASSPATH
@@ -485,12 +485,17 @@
  *
  * </li>
  * <li><b>main:</b></li>      A simple main() wrapper that links
- *                            @c @b libjvm/lib/libjvm.a and builds
- *                            binary file @c @b main/bin/bootjvm .
+ *                            @c @b libjvm/lib/libjvm.a and builds the
+ *                            JVM binary file @c @b main/bin/bootjvm .
  *                            Source code comes from the @c @b jvm
  *                            directory.
  *
  * </li>
+ * <li><b>jar:</b></li>       A simple main() wrapper that links
+ *                            @c @b libjvm/lib/libjvm.a and builds the
+ *                            JAR binary file @c @b jar/bin/jar .
+ *
+ * </li>
  * <li><b>jni:</b></li>       Source code for a sample JNI shared
  *                            library
  *        <code><b>jni/src/harmony/generic/0.0/lib/bootjvm.so</b></code>
@@ -784,18 +789,6 @@
 
 
 /*!
- * @brief JVM main operational structure.
- *
- * This pointer is initialized by jvm_model_init() and is
- * used @e extensivel throughout the code, both directly
- * and through macros like @link #CLASS() CLASS@endlink and
- * @link #OBJECT() OBJECT()@endlink.
- *
- */
-rjvm *pjvm = CHEAT_AND_USE_NULL_TO_INITIALIZE;
-
-
-/*!
  * @name Roll call globals for JVM initialization and shutdown.
  *
  * @brief Determine if a portion of the JVM has been initialized or not.
@@ -817,10 +810,16 @@
 rboolean jvm_class_initialized      = CHEAT_AND_USE_FALSE_TO_INITIALIZE;
 rboolean jvm_object_initialized     = CHEAT_AND_USE_FALSE_TO_INITIALIZE;
 rboolean jvm_thread_initialized     = CHEAT_AND_USE_FALSE_TO_INITIALIZE;
-rboolean jvm_argv_initialized       = CHEAT_AND_USE_FALSE_TO_INITIALIZE;
 rboolean jvm_classpath_initialized  = CHEAT_AND_USE_FALSE_TO_INITIALIZE;
+static
+rboolean jvm_argv_initialized       = CHEAT_AND_USE_FALSE_TO_INITIALIZE;
+#if JVMCFG_TMPAREA_IN_USE
+static
 rboolean jvm_tmparea_initialized    = CHEAT_AND_USE_FALSE_TO_INITIALIZE;
+#endif
+static
 rboolean jvm_model_initialized      = CHEAT_AND_USE_FALSE_TO_INITIALIZE;
+static
 rboolean jvm_heap_initialized       = CHEAT_AND_USE_FALSE_TO_INITIALIZE;
 
 /*@} */ /* End of grouped definitions */
@@ -832,7 +831,7 @@
  * Wipe structure, set to all zeroes.  Certain of the @b xxx_init()
  * functions depend on a zeroed structure at initialization time.
  * Once cleared, store off command line parameters from main()
- * as passed into jvm_init().
+ * as passed into @link #jvm_init() jvm_init()@endlink.
  *
  * Must run HEAP_INIT() before calling this function.
  *
@@ -846,7 +845,7 @@
  * @returns @link #rvoid rvoid@endlink
  *
  */
-rvoid jvm_model_init()
+static rvoid jvm_model_init()
 {
     ARCH_FUNCTION_NAME(jvm_model_init);
 
@@ -874,7 +873,7 @@
  * @returns @link #rvoid rvoid@endlink
  *
  */
-rvoid jvm_model_shutdown()
+static rvoid jvm_model_shutdown()
 {
     ARCH_FUNCTION_NAME(jvm_model_shutdown);
 
@@ -1203,9 +1202,11 @@
     jvm_class_initialized      = rfalse;
     jvm_object_initialized     = rfalse;
     jvm_thread_initialized     = rfalse;
-    jvm_argv_initialized       = rfalse;
     jvm_classpath_initialized  = rfalse;
+    jvm_argv_initialized       = rfalse;
+#if JVMCFG_TMPAREA_IN_USE
     jvm_tmparea_initialized    = rfalse;
+#endif
     jvm_model_initialized      = rfalse;
     jvm_heap_initialized       = rfalse;
 
@@ -1229,7 +1230,8 @@
             exit_LinkageError_subclass = "unknown";
         }
 
-        fprintfLocalStderr("jvm_init:  Error %d (%s): %s\n",
+        fprintfLocalStderr("%s:  Error %d (%s): %s\n",
+                           arch_function_name,
                            nonlocal_rc,
                            exit_get_name(nonlocal_rc),
                            exit_LinkageError_subclass);
@@ -1240,7 +1242,7 @@
 
     /********** Initialize heap management ***********/
 
-    HEAP_INIT();
+    HEAP_INIT(&jvm_heap_initialized);
 
 
     /********** Initialize entire JVM area ***********/
@@ -1251,14 +1253,21 @@
 
     jvmutil_set_dml(DMLDEFAULT);
 
-    /********** Initialize temp area *****************/
+    HEAP_INIT_REPORT(&jvm_heap_initialized);
 
-    tmparea_init(argv);
 
+#if JVMCFG_TMPAREA_IN_USE
+    /********** Initialize temp area *****************/
+
+    tmparea_init(argv,
+                 HEAP_GET_DATA,
+                 HEAP_FREE_DATA,
+                 &jvm_tmparea_initialized);
+#endif
 
     /********** Parse command line, environment,etc. */
 
-    argv_init(argc, argv, envp);
+    jvmargv_init(argc, argv, envp, &jvm_argv_initialized);
 
 
     /********** Initialize the @b CLASSPATH **********/
@@ -1345,21 +1354,32 @@
                                   jvm_thread_index_null,
                                   rtrue,
                                   rtrue);
+#if 0
+    /* Enable for diagnostics when desired */
     cfmsgs_show_constant_pool(CLASS_OBJECT_LINKAGE(clsidxOBJECT)->pcfs);
+#endif
 
     jvm_class_index clsidxCLASS =
         class_load_resolve_clinit(JVMCLASS_JAVA_LANG_CLASS,
                                   jvm_thread_index_null,
                                   rtrue,
                                   rtrue);
+#if 0
+    /* Enable for diagnostics when desired */
     cfmsgs_show_constant_pool(CLASS_OBJECT_LINKAGE(clsidxCLASS)->pcfs);
+#endif
 
     jvm_class_index clsidxSTRING =
         class_load_resolve_clinit(JVMCLASS_JAVA_LANG_STRING,
                                   jvm_thread_index_null,
                                   rtrue,
                                   rtrue);
+#if 0
+    /* Enable for diagnostics when desired */
     cfmsgs_show_constant_pool(CLASS_OBJECT_LINKAGE(clsidxSTRING)->pcfs);
+#endif
+
+    HEAP_REPORT(&jvm_heap_initialized);
 
     /*!
      * @todo HARMONY-6-jvm-jvm.c-7 Locate the 'value' and 'length'
@@ -1380,7 +1400,12 @@
                                   jvm_thread_index_null,
                                   rtrue,
                                   rtrue);
+#if 0
+    /* Enable for diagnostics when desired */
     cfmsgs_show_constant_pool(CLASS_OBJECT_LINKAGE(clsidxTHREAD)->pcfs);
+#endif
+
+    HEAP_REPORT(&jvm_heap_initialized);
 
     /********** Load java.lang.String[] (1 dim array) */
 
@@ -1425,6 +1450,8 @@
                                        rtrue,
                                        rfalse);
 
+    HEAP_REPORT(&jvm_heap_initialized);
+
 
     /******* Re-arm java.lang.LinkageError handler ***/
 
@@ -1449,7 +1476,8 @@
             exit_LinkageError_subclass = "unknown";
         }
 
-        fprintfLocalStderr("jvm_init:  Error %d (%s): %s\n",
+        fprintfLocalStderr("%s:  Error %d (%s): %s\n",
+                           arch_function_name,
                            nonlocal_rc,
                            exit_get_name(nonlocal_rc),
                            exit_LinkageError_subclass);
@@ -1507,7 +1535,70 @@
      * from the @c @b argv[] list (Translation:  "Be nice to
      * the runtime environment!")
      */
-    if (rnull == pjvm->startjar)
+    if (rnull != pjvm->startjar)
+    {
+        jar_state *pjs =
+            jarutil_find_member(pjvm->startjar,
+                                JVMCFG_JARFILE_MANIFEST_FILENAME,
+                                HEAP_GET_DATA,
+                                HEAP_FREE_DATA);
+
+        if (rnull == pjs)
+        {
+            sysErrMsg(arch_function_name,
+                      "Invalid startup JAR file name");
+            exit_jvm(EXIT_JVM_CLASS);
+/*NOTREACHED*/
+        }
+
+        if (JAR_OKAY != pjs->jar_code)
+        {
+            portable_close(pjs->fd);
+
+            if (pjs->jar_msg)
+            {
+            sysErrMsg(arch_function_name,
+                     "Invalid or missing startup JAR manifest file: %s",
+                      pjs->jar_msg);
+            }
+            else
+            {
+            sysErrMsg(arch_function_name,
+                      "Invalid or missing startup JAR manifest file");
+            }
+            HEAP_FREE_DATA(pjs);
+
+            exit_jvm(EXIT_JVM_CLASS);
+/*NOTREACHED*/
+        }
+
+        /* JAR file manifest contains class name for main() entry */
+        jarutil_read_current_member(pjs);
+
+        /* Extract startup class from manifest */
+        startup = manifest_get_main_from_bfr(pjs->bfr,
+                                pjs->directory_entry.uncompressed_size);
+
+        portable_close(pjs->fd);
+        HEAP_FREE_DATA(pjs);
+
+        if (rnull == startup)
+        {
+            sysErrMsg(arch_function_name,
+                      "Startup class not found in JAR manifest file");
+            exit_jvm(EXIT_MANIFEST_JAR);
+/*NOTREACHED*/
+        }
+
+        /*!
+         * @internal If startup class was found in '-jar filename' parm,
+         *           then when it comes time to load that class below,
+         *           it will be found at the very beginning of
+         *           @b CLASSPATH since 'filename' was inserted there
+         *           during classpath_init() name insertions.
+         */
+    }
+    else
     {
         startup = classpath_external2internal_classname(startup);
     }
@@ -1595,7 +1686,8 @@
                 exit_jvm(EXIT_JVM_OBJECT);
 /*NOTREACHED*/
             }
-             */
+
+            /* Add reference to command line parameter string */
             (rvoid) GC_OBJECT_MKREF_FROM_OBJECT(jvm_object_hash_null,
                                                 pjargv[i]);
         }
@@ -1681,6 +1773,8 @@
     /********** Declare the JVM completely set up ****/
     jvm_completely_initialized = rtrue;
 
+    HEAP_REPORT(&jvm_heap_initialized);
+
     return;
 
 } /* END of jvm_init() */
@@ -1963,7 +2057,8 @@
             exit_LinkageError_subclass = "unknown";
         }
 
-        fprintfLocalStderr("jvm_shutdown:  Error %d (%s): %s\n",
+        fprintfLocalStderr("%s:  Error %d (%s): %s\n",
+                           arch_function_name,
                            nonlocal_rc,
                            exit_get_name(nonlocal_rc),
                            exit_LinkageError_subclass);
@@ -1975,6 +2070,9 @@
     /*
      * Clean up thread stack areas, ClassFile storage, etc.
      * This process is effectively the reverse of jvm_init().
+     * Notice, however, that jvmargv_shutdown() and
+     * classpath_shutdown() are reversed from this
+     * normal order.
      */
 
     jvm_completely_initialized = rfalse;
@@ -2006,7 +2104,7 @@
 
     if (rtrue == jvm_argv_initialized)
     {
-        argv_shutdown();
+        jvmargv_shutdown(&jvm_argv_initialized);
     }
 
     if (rtrue == jvm_classpath_initialized)
@@ -2014,10 +2112,14 @@
         classpath_shutdown();
     }
 
+#if JVMCFG_TMPAREA_IN_USE
     if (rtrue == jvm_tmparea_initialized)
     {
-        tmparea_shutdown();
+        tmparea_shutdown(HEAP_GET_DATA,
+                         HEAP_FREE_DATA,
+                        &jvm_tmparea_initialized);
     }
+#endif
 
     if (rtrue == jvm_model_initialized)
     {
@@ -2026,7 +2128,7 @@
 
     if (rtrue == jvm_heap_initialized)
     {
-        HEAP_SHUTDOWN();
+        HEAP_SHUTDOWN(&jvm_heap_initialized);
     }
 
     return;
@@ -2090,7 +2192,7 @@
 
     /*
      * Protect JVM shutdown and heap free mechanism
-     * with non-local error return.  (When setting
+     * with non-local error return.  When setting
      * it up, @link #EXIT_INIT() EXIT_INIT()@endlink returns @link
        #EXIT_MAIN_OKAY exit code enumeration EXIT_MAIN_OKAY@endlink,
      * but when invoking @link #exit_jvm() exit_jvm(EXIT_xxx)@endlink,



Mime
View raw message