OSDN Git Service

gcc/java:
[pf3gnuchains/gcc-fork.git] / libjava / gnu / gcj / runtime / FirstThread.java
1 // FirstThread.java - Implementation of very first thread.
2
3 /* Copyright (C) 1998, 1999, 2000  Free Software Foundation
4
5    This file is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9 details.  */
10
11 package gnu.gcj.runtime;
12
13 import java.util.jar.*;
14
15 /**
16  * @author Tom Tromey <tromey@cygnus.com>
17  * @date August 24, 1998 
18  */
19
20 // This is entirely internal to our implementation.
21
22 final class FirstThread extends Thread
23 {
24   public native void run ();
25
26   public FirstThread (Class k, Object o)
27   {
28     super (null, null, "main");
29     klass = k;
30     klass_name = null;
31     args = o;
32   }
33
34   public FirstThread (String class_name, Object o)
35   {
36     super (null, null, "main");
37     klass = null;
38     klass_name = class_name;
39     args = o;
40   }
41
42   private static void die (String s)
43   {
44     System.err.println(s);
45     System.exit(1);
46   }
47
48   public static void main (String[] args)
49   {
50     try {
51
52       JarFile j = new JarFile (args[0]);
53
54       Attributes a = j.getManifest().getMainAttributes();
55
56       jarMainClassName = a.getValue(Attributes.Name.MAIN_CLASS);
57
58       if (jarMainClassName != null)
59       {
60         jarMainClassName = jarMainClassName.replace('/','.');
61         return;
62       }
63     } catch (Exception e) {
64       // empty
65     }
66
67     System.err.println ("Failed to load Main-Class manifest attribute from\n"
68                         + args[0]);
69   }
70
71   // If interpreter is invoked with -jar, the main class name is recorded
72   // here.
73   public static String jarMainClassName;
74
75   // Private data.
76   private Class klass;
77   private String klass_name;
78   private Object args;
79
80   // If the user links statically then we need to ensure that these
81   // classes are linked in.  Otherwise bootstrapping fails.  These
82   // classes are only referred to via Class.forName(), so we add an
83   // explicit mention of them here.
84   static final Class Kcert = java.security.cert.Certificate.class;
85   static final Class Kfile = gnu.gcj.protocol.file.Handler.class;
86   static final Class Khttp = gnu.gcj.protocol.http.Handler.class;
87   static final Class Kjar  = gnu.gcj.protocol.jar.Handler.class;
88 }