2006-06-20 21:25:32 +02:00
|
|
|
// 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 <gcj/cni.h>
|
|
|
|
#include <gcj/javaprims.h>
|
|
|
|
#include <java-assert.h>
|
|
|
|
#include <jvm.h>
|
|
|
|
#include <jni.h>
|
|
|
|
|
|
|
|
using namespace gcj;
|
|
|
|
|
|
|
|
// Forward declarations.
|
Import GNU Classpath (libgcj-import-20070727).
libjava/
2007-08-04 Matthias Klose <doko@ubuntu.com>
Import GNU Classpath (libgcj-import-20070727).
* Regenerate class and header files.
* Regenerate auto* files.
* include/jvm.h:
* jni-libjvm.cc (Jv_JNI_InvokeFunctions): Rename type.
* jni.cc (_Jv_JNIFunctions, _Jv_JNI_InvokeFunctions): Likewise.
* jni.cc (_Jv_JNI_CallAnyMethodA, _Jv_JNI_CallAnyVoidMethodA,
_Jv_JNI_CallMethodA, _Jv_JNI_CallVoidMethodA,
_Jv_JNI_CallStaticMethodA, _Jv_JNI_CallStaticVoidMethodA,
_Jv_JNI_NewObjectA, _Jv_JNI_SetPrimitiveArrayRegion): Constify
jvalue parameter.
* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Likewise.
* java/lang/VMFloat.java (toString, parseFloat): New.
* gnu/awt/xlib/XToolkit.java (setAlwaysOnTop, isModalityTypeSupported,
isModalExclusionTypeSupported): New (stub only).
* gnu/awt/xlib/XCanvasPeer.java (requestFocus): Likewise.
* gnu/awt/xlib/XFramePeer.java (updateMinimumSize, updateIconImages,
updateFocusableWindowState, setModalBlocked, getBoundsPrivate,
setAlwaysOnTop): Likewise.
* gnu/awt/xlib/XFontPeer.java (canDisplay): Update signature.
* scripts/makemake.tcl: Ignore gnu/javax/sound/sampled/gstreamer,
ignore javax.sound.sampled.spi.MixerProvider, ignore .in files.
* HACKING: Mention --enable-gstreamer-peer, removal of generated files.
libjava/classpath/
2007-08-04 Matthias Klose <doko@ubuntu.com>
* java/util/EnumMap.java (clone): Add cast.
From-SVN: r127204
2007-08-04 12:53:49 +02:00
|
|
|
extern struct JNIInvokeInterface_ _Jv_JNI_InvokeFunctions;
|
2006-06-20 21:25:32 +02:00
|
|
|
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<JavaVMInitArgs *> (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<JvVMInitArgs *> (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;
|
|
|
|
}
|