1 // jni-libjvm.cc - an implementation of the JNI invocation API.
3 /* Copyright (C) 2006 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
12 #include <gcj/javaprims.h>
13 #include <java-assert.h>
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
;
26 JNI_GetDefaultJavaVMInitArgs (void *args
)
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
)
33 JavaVMInitArgs
*ia
= reinterpret_cast<JavaVMInitArgs
*> (args
);
34 ia
->version
= JNI_VERSION_1_4
;
37 ia
->ignoreUnrecognized
= true;
43 JNI_CreateJavaVM (JavaVM
**vm
, void **penv
, void *args
)
45 JvAssert (! _Jv_the_vm
);
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
)
52 JvVMInitArgs
* vm_args
= reinterpret_cast<JvVMInitArgs
*> (args
);
54 jint result
= _Jv_CreateJavaVM (vm_args
);
59 JavaVM
*nvm
= (JavaVM
*) _Jv_MallocUnchecked (sizeof (JavaVM
));
62 nvm
->functions
= &_Jv_JNI_InvokeFunctions
;
64 jint r
=_Jv_JNI_AttachCurrentThread (nvm
, penv
, NULL
);
75 JNI_GetCreatedJavaVMs (JavaVM
**vm_buffer
, jsize buf_len
, jsize
*n_vms
)
80 // We only support a single VM.
81 if (_Jv_the_vm
!= NULL
)
83 vm_buffer
[0] = _Jv_the_vm
;