1 // natFirstThread.cc - Implementation of FirstThread native methods.
3 /* Copyright (C) 1998, 1999 Red Hat, Inc.
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
18 #include <gnu/gcj/runtime/FirstThread.h>
19 #include <java/lang/Class.h>
20 #include <java/lang/String.h>
21 #include <java/lang/System.h>
22 #include <java/lang/reflect/Modifier.h>
23 #include <java/io/PrintStream.h>
25 #define DIE(Message) die (JvNewStringLatin1 (Message))
27 typedef void main_func (jobject);
30 gnu::gcj::runtime::FirstThread::run (void)
32 Utf8Const* main_signature = _Jv_makeUtf8Const ("([Ljava.lang.String;)V", 22);
33 Utf8Const* main_name = _Jv_makeUtf8Const ("main", 4);
37 klass = java::lang::Class::forName (klass_name);
38 if (klass != NULL) _Jv_InitClass (klass);
41 _Jv_Method *meth = _Jv_GetMethodLocal (klass, main_name, main_signature);
43 // Some checks from Java Spec section 12.1.4.
45 DIE ("no suitable method `main' in class");
46 if (! java::lang::reflect::Modifier::isStatic(meth->accflags))
47 DIE ("`main' must be static");
48 if (! java::lang::reflect::Modifier::isPublic(meth->accflags))
49 DIE ("`main' must be public");
51 main_func *real_main = (main_func *) meth->ncode;