source: trunk/gcc/libjava/gnu/gcj/runtime/natFirstThread.cc

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.2 KB
Line 
1// natFirstThread.cc - Implementation of FirstThread native methods.
2
3/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
4
5 This file is part of libgcj.
6
7This software is copyrighted work licensed under the terms of the
8Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9details. */
10
11#include <config.h>
12
13#include <stdio.h>
14#include <stdlib.h>
15
16#include <gcj/cni.h>
17#include <jvm.h>
18
19#include <gnu/gcj/runtime/FirstThread.h>
20
21typedef void main_func (jobject);
22
23void
24gnu::gcj::runtime::FirstThread::call_main (void)
25{
26 Utf8Const* main_signature = _Jv_makeUtf8Const ("([Ljava.lang.String;)V", 22);
27 Utf8Const* main_name = _Jv_makeUtf8Const ("main", 4);
28
29 _Jv_Method *meth = _Jv_GetMethodLocal (klass, main_name, main_signature);
30
31 // Some checks from Java Spec section 12.1.4.
32 const char *msg = NULL;
33 if (meth == NULL)
34 msg = "no suitable method `main' in class";
35 else if (! java::lang::reflect::Modifier::isStatic(meth->accflags))
36 msg = "`main' must be static";
37 else if (! java::lang::reflect::Modifier::isPublic(meth->accflags))
38 msg = "`main' must be public";
39 if (msg != NULL)
40 {
41 fprintf (stderr, "%s\n", msg);
42 ::exit(1);
43 }
44
45 main_func *real_main = (main_func *) meth->ncode;
46 (*real_main) (args);
47}
Note: See TracBrowser for help on using the repository browser.