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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [jni-libjvm.cc] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 753 jeremybenn
// jni-libjvm.cc - an implementation of the JNI invocation API.
2
 
3
/* Copyright (C) 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 <gcj/cni.h>
12
#include <gcj/javaprims.h>
13
#include <java-assert.h>
14
#include <jvm.h>
15
#include <jni.h>
16
 
17
using namespace gcj;
18
 
19
// Forward declarations.
20
extern struct JNIInvokeInterface_ _Jv_JNI_InvokeFunctions;
21
extern jint JNICALL _Jv_JNI_AttachCurrentThread (JavaVM *vm,
22
                                                 void **penv, void *args);
23
extern JavaVM *_Jv_the_vm;
24
 
25
jint JNICALL
26
JNI_GetDefaultJavaVMInitArgs (void *args)
27
{
28
  jint version = * (jint *) args;
29
  // Here we only support 1.2 and 1.4.
30
  if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4)
31
    return JNI_EVERSION;
32
 
33
  JavaVMInitArgs *ia = reinterpret_cast<JavaVMInitArgs *> (args);
34
  ia->version = JNI_VERSION_1_4;
35
  ia->nOptions = 0;
36
  ia->options = NULL;
37
  ia->ignoreUnrecognized = true;
38
 
39
  return 0;
40
}
41
 
42
jint JNICALL
43
JNI_CreateJavaVM (JavaVM **vm, void **penv, void *args)
44
{
45
  JvAssert (! _Jv_the_vm);
46
 
47
  jint version = * (jint *) args;
48
  // We only support 1.2 and 1.4.
49
  if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4)
50
    return JNI_EVERSION;
51
 
52
  JvVMInitArgs* vm_args = reinterpret_cast<JvVMInitArgs *> (args);
53
 
54
  jint result = _Jv_CreateJavaVM (vm_args);
55
  if (result)
56
    return result;
57
 
58
  // FIXME: synchronize
59
  JavaVM *nvm = (JavaVM *) _Jv_MallocUnchecked (sizeof (JavaVM));
60
  if (nvm == NULL)
61
    return JNI_ERR;
62
  nvm->functions = &_Jv_JNI_InvokeFunctions;
63
 
64
  jint r =_Jv_JNI_AttachCurrentThread (nvm, penv, NULL);
65
  if (r < 0)
66
    return r;
67
 
68
  _Jv_the_vm = nvm;
69
  *vm = _Jv_the_vm;
70
 
71
  return 0;
72
}
73
 
74
jint JNICALL
75
JNI_GetCreatedJavaVMs (JavaVM **vm_buffer, jsize buf_len, jsize *n_vms)
76
{
77
  if (buf_len <= 0)
78
    return JNI_ERR;
79
 
80
  // We only support a single VM.
81
  if (_Jv_the_vm != NULL)
82
    {
83
      vm_buffer[0] = _Jv_the_vm;
84
      *n_vms = 1;
85
    }
86
  else
87
    *n_vms = 0;
88
  return 0;
89
}

powered by: WebSVN 2.1.0

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