From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- libjava/jni-libjvm.cc | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 libjava/jni-libjvm.cc (limited to 'libjava/jni-libjvm.cc') diff --git a/libjava/jni-libjvm.cc b/libjava/jni-libjvm.cc new file mode 100644 index 000000000..1833eb7f3 --- /dev/null +++ b/libjava/jni-libjvm.cc @@ -0,0 +1,89 @@ +// jni-libjvm.cc - an implementation of the JNI invocation API. + +/* Copyright (C) 2006 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +#include +#include +#include +#include +#include + +using namespace gcj; + +// Forward declarations. +extern struct JNIInvokeInterface_ _Jv_JNI_InvokeFunctions; +extern jint JNICALL _Jv_JNI_AttachCurrentThread (JavaVM *vm, + void **penv, void *args); +extern JavaVM *_Jv_the_vm; + +jint JNICALL +JNI_GetDefaultJavaVMInitArgs (void *args) +{ + jint version = * (jint *) args; + // Here we only support 1.2 and 1.4. + if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4) + return JNI_EVERSION; + + JavaVMInitArgs *ia = reinterpret_cast (args); + ia->version = JNI_VERSION_1_4; + ia->nOptions = 0; + ia->options = NULL; + ia->ignoreUnrecognized = true; + + return 0; +} + +jint JNICALL +JNI_CreateJavaVM (JavaVM **vm, void **penv, void *args) +{ + JvAssert (! _Jv_the_vm); + + jint version = * (jint *) args; + // We only support 1.2 and 1.4. + if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4) + return JNI_EVERSION; + + JvVMInitArgs* vm_args = reinterpret_cast (args); + + jint result = _Jv_CreateJavaVM (vm_args); + if (result) + return result; + + // FIXME: synchronize + JavaVM *nvm = (JavaVM *) _Jv_MallocUnchecked (sizeof (JavaVM)); + if (nvm == NULL) + return JNI_ERR; + nvm->functions = &_Jv_JNI_InvokeFunctions; + + jint r =_Jv_JNI_AttachCurrentThread (nvm, penv, NULL); + if (r < 0) + return r; + + _Jv_the_vm = nvm; + *vm = _Jv_the_vm; + + return 0; +} + +jint JNICALL +JNI_GetCreatedJavaVMs (JavaVM **vm_buffer, jsize buf_len, jsize *n_vms) +{ + if (buf_len <= 0) + return JNI_ERR; + + // We only support a single VM. + if (_Jv_the_vm != NULL) + { + vm_buffer[0] = _Jv_the_vm; + *n_vms = 1; + } + else + *n_vms = 0; + return 0; +} -- cgit v1.2.3