OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [gnu/] [java/] [lang/] [natMainThread.cc] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
// natMainThread.cc - Implementation of MainThread native methods.
2
 
3
/* Copyright (C) 1998, 1999, 2000, 2001, 2003, 2006  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
#include <config.h>
12
 
13
#include <stdio.h>
14
#include <stdlib.h>
15
 
16
#include <gcj/cni.h>
17
#include <jvm.h>
18
#include <java-threads.h>
19
 
20
#include <gnu/java/lang/MainThread.h>
21
#include <java/lang/Runtime.h>
22
#include <java/lang/ThreadGroup.h>
23
 
24
typedef void main_func (jobject);
25
 
26
void
27
gnu::java::lang::MainThread::call_main (void)
28
{
29
  Utf8Const* main_signature = _Jv_makeUtf8Const ("([Ljava.lang.String;)V", 22);
30
  Utf8Const* main_name = _Jv_makeUtf8Const ("main", 4);
31
 
32
  _Jv_Method *meth = _Jv_LookupDeclaredMethod (klass, main_name,
33
                                               main_signature);
34
 
35
  // Some checks from Java Spec section 12.1.4.
36
  const char *msg = NULL;
37
  if (meth == NULL)
38
    msg = "no suitable method `main' in class";
39
  else if (! ::java::lang::reflect::Modifier::isStatic(meth->accflags))
40
    msg = "`main' must be static";
41
  else if (! ::java::lang::reflect::Modifier::isPublic(meth->accflags))
42
    msg =  "`main' must be public";
43
  if (msg != NULL)
44
    {
45
      fprintf (stderr, "%s\n", msg);
46
      ::exit(1);
47
    }
48
 
49
  main_func *real_main = (main_func *) meth->ncode;
50
  (*real_main) (args);
51
 
52
  // Note that we do thread cleanup here.  We have to do this here and
53
  // not in _Jv_RunMain; if we do if after the main thread has exited,
54
  // our ThreadGroup will be null, and if Runtime.exit tries to create
55
  // a new Thread (which it does when running shutdown hooks), it will
56
  // eventually NPE due to this.
57
  _Jv_ThreadWait ();
58
 
59
  int status = (int) ::java::lang::ThreadGroup::had_uncaught_exception;
60
  ::java::lang::Runtime::exitNoChecksAccessor (status);
61
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.