1 // FirstThread.java - Implementation of very first thread.
3 /* Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11 package gnu.gcj.runtime;
13 import java.util.jar.*;
16 * @author Tom Tromey <tromey@cygnus.com>
17 * @date August 24, 1998
20 final class FirstThread extends Thread
22 public FirstThread (Class k, String[] args)
24 super (null, null, "main");
29 public FirstThread (String class_name, String[] args, boolean is_jar)
31 super (null, null, "main");
32 klass_name = class_name;
40 klass_name = getMain(klass_name);
46 klass = Class.forName(klass_name);
48 catch (ClassNotFoundException x)
50 throw new NoClassDefFoundError(klass_name);
57 private String getMain (String name)
59 String mainName = null;
62 JarFile j = new JarFile(name);
63 Attributes a = j.getManifest().getMainAttributes();
64 mainName = a.getValue(Attributes.Name.MAIN_CLASS);
73 System.err.println("Failed to load Main-Class manifest attribute from "
80 private native void call_main ();
84 private String klass_name;
86 private boolean is_jar;
88 // If the user links statically then we need to ensure that these
89 // classes are linked in. Otherwise bootstrapping fails. These
90 // classes are only referred to via Class.forName(), so we add an
91 // explicit mention of them here.
92 static final Class Kcert = java.security.cert.Certificate.class;
93 static final Class Kfile = gnu.gcj.protocol.file.Handler.class;
94 static final Class Khttp = gnu.gcj.protocol.http.Handler.class;
95 static final Class Kjar = gnu.gcj.protocol.jar.Handler.class;