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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [gnu/] [java/] [lang/] [natMainThread.cc] - Blame information for rev 756

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 756 jeremybenn
// 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
  // This is one of the few places where we might have access to an
33
  // unlinked class.
34
  _Jv_Linker::wait_for_state (klass, JV_STATE_LOADING);
35
 
36
  _Jv_Method *meth = _Jv_LookupDeclaredMethod (klass, main_name,
37
                                               main_signature);
38
 
39
  // Some checks from Java Spec section 12.1.4.
40
  const char *msg = NULL;
41
  if (meth == NULL)
42
    msg = "no suitable method `main' in class";
43
  else if (! ::java::lang::reflect::Modifier::isStatic(meth->accflags))
44
    msg = "`main' must be static";
45
  else if (! ::java::lang::reflect::Modifier::isPublic(meth->accflags))
46
    msg =  "`main' must be public";
47
  if (msg != NULL)
48
    {
49
      fprintf (stderr, "%s\n", msg);
50
      ::exit(1);
51
    }
52
 
53
  main_func *real_main = (main_func *) meth->ncode;
54
  (*real_main) (args);
55
 
56
  // Note that we do thread cleanup here.  We have to do this here and
57
  // not in _Jv_RunMain; if we do if after the main thread has exited,
58
  // our ThreadGroup will be null, and if Runtime.exit tries to create
59
  // a new Thread (which it does when running shutdown hooks), it will
60
  // eventually NPE due to this.
61
  _Jv_ThreadWait ();
62
 
63
  int status = (int) ::java::lang::ThreadGroup::had_uncaught_exception;
64
  ::java::lang::Runtime::exitNoChecksAccessor (status);
65
}

powered by: WebSVN 2.1.0

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