Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / gnu / java / lang / natMainThread.cc
blob7e8e4223dfece1e6be735ad5b1419f309524ce13
1 // natMainThread.cc - Implementation of MainThread native methods.
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
9 details. */
11 #include <config.h>
13 #include <stdio.h>
14 #include <stdlib.h>
16 #include <gcj/cni.h>
17 #include <jvm.h>
19 #include <gnu/java/lang/MainThread.h>
21 typedef void main_func (jobject);
23 void
24 gnu::java::lang::MainThread::call_main (void)
26 Utf8Const* main_signature = _Jv_makeUtf8Const ("([Ljava.lang.String;)V", 22);
27 Utf8Const* main_name = _Jv_makeUtf8Const ("main", 4);
29 _Jv_Method *meth = _Jv_LookupDeclaredMethod (klass, main_name,
30 main_signature);
32 // Some checks from Java Spec section 12.1.4.
33 const char *msg = NULL;
34 if (meth == NULL)
35 msg = "no suitable method `main' in class";
36 else if (! ::java::lang::reflect::Modifier::isStatic(meth->accflags))
37 msg = "`main' must be static";
38 else if (! ::java::lang::reflect::Modifier::isPublic(meth->accflags))
39 msg = "`main' must be public";
40 if (msg != NULL)
42 fprintf (stderr, "%s\n", msg);
43 ::exit(1);
46 main_func *real_main = (main_func *) meth->ncode;
47 (*real_main) (args);