aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/native
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/native')
-rw-r--r--libjava/classpath/native/jni/classpath/jcl.c128
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.c2
-rw-r--r--libjava/classpath/native/jni/gtk-peer/GtkDragSourceContextPeer.c9
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c4
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c14
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c11
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c3
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c4
-rw-r--r--libjava/classpath/native/jni/java-io/Makefile.am3
-rw-r--r--libjava/classpath/native/jni/java-io/Makefile.in6
-rw-r--r--libjava/classpath/native/jni/java-io/java_io_VMConsole.c90
-rw-r--r--libjava/classpath/native/jni/java-lang/java_lang_VMSystem.c52
-rw-r--r--libjava/classpath/native/jni/java-net/java_net_VMInetAddress.c2
-rw-r--r--libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c7
-rw-r--r--libjava/classpath/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c16
15 files changed, 273 insertions, 78 deletions
diff --git a/libjava/classpath/native/jni/classpath/jcl.c b/libjava/classpath/native/jni/classpath/jcl.c
index 0180ab9..0970965 100644
--- a/libjava/classpath/native/jni/classpath/jcl.c
+++ b/libjava/classpath/native/jni/classpath/jcl.c
@@ -1,5 +1,5 @@
/* jcl.c
- Copyright (C) 1998, 2005, 2006, 2008 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2005, 2006, 2008, 2010 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -42,12 +42,24 @@ exception statement from your version. */
#include <stdio.h>
#include <jcl.h>
-#ifndef __GNUC__
- #ifndef __attribute__
- #define __attribute__(x) /* nothing */
- #endif
+#if !defined(__GNUC__) && !defined(__attribute__)
+# define __attribute__(x) /* nothing */
#endif
+#if SIZEOF_VOID_P == 8
+# define JCL_POINTER_CLASSNAME "gnu/classpath/Pointer64"
+# define JCL_POINTER_DATASIGN "J"
+# define JCL_POINTER_INTTYPE jlong
+# define JCL_POINTER_GETFIELD GetLongField
+#elif SIZEOF_VOID_P == 4
+# define JCL_POINTER_CLASSNAME "gnu/classpath/Pointer32"
+# define JCL_POINTER_DATASIGN "I"
+# define JCL_POINTER_INTTYPE jint
+# define JCL_POINTER_GETFIELD GetIntField
+#else
+# error "Pointer size is not supported."
+#endif /* SIZEOF_VOID_P */
+
/*
* Cached Pointer class info.
*/
@@ -55,6 +67,12 @@ static jclass rawDataClass = NULL;
static jfieldID rawData_fid = NULL;
static jmethodID rawData_mid = NULL;
+/* Define JCL_NO_JNIONLOAD to build JCL without JNI_OnLoad exported.
+ * (rawDataClass and friends are initialized lazily in that case.)
+ */
+
+#ifndef JCL_NO_JNIONLOAD
+
/*
* JNI OnLoad constructor.
*/
@@ -69,35 +87,23 @@ JNI_OnLoad (JavaVM *vm, void *reserved __attribute__((unused)))
return JNI_VERSION_1_4;
}
env = (JNIEnv *) envp;
-#if SIZEOF_VOID_P == 8
- rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer64");
- if (rawDataClass != NULL)
- rawDataClass = (*env)->NewGlobalRef (env, rawDataClass);
- if (rawDataClass != NULL)
- {
- rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "J");
- rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(J)V");
- }
-#else
-#if SIZEOF_VOID_P == 4
- rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer32");
+ rawDataClass = (*env)->FindClass (env, JCL_POINTER_CLASSNAME);
if (rawDataClass != NULL)
rawDataClass = (*env)->NewGlobalRef (env, rawDataClass);
if (rawDataClass != NULL)
{
- rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "I");
- rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(I)V");
+ rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data",
+ JCL_POINTER_DATASIGN);
+ rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>",
+ "(" JCL_POINTER_DATASIGN ")V");
}
-#else
-#error "Pointer size is not supported."
-#endif /* SIZEOF_VOID_P == 4 */
-#endif /* SIZEOF_VOID_P == 8 */
return JNI_VERSION_1_4;
}
+#endif /* !JCL_NO_JNIONLOAD */
JNIEXPORT void JNICALL
JCL_ThrowException (JNIEnv * env, const char *className, const char *errMsg)
@@ -127,9 +133,10 @@ JCL_ThrowException (JNIEnv * env, const char *className, const char *errMsg)
}
/* Removed this (more comprehensive) error string to avoid the need for
* a static variable or allocation of a buffer for this message in this
- * (unlikely) error case. --Fridi.
+ * (unlikely) error case. --Fridi.
*
- * sprintf(errstr,"JCL: Failed to throw exception %s with message %s: could not find exception class.", className, errMsg);
+ * sprintf(errstr,"JCL: Failed to throw exception %s with message %s:"
+ * " could not find exception class.", className, errMsg);
*/
(*env)->ThrowNew (env, errExcClass, className);
}
@@ -154,12 +161,12 @@ JCL_realloc (JNIEnv * env, void *ptr, size_t size)
{
void *orig_ptr = ptr;
ptr = realloc (ptr, size);
- if (ptr == 0)
+ if (ptr == NULL)
{
- free (orig_ptr);
+ if (orig_ptr != NULL)
+ free (orig_ptr);
JCL_ThrowException (env, "java/lang/OutOfMemoryError",
"malloc() failed.");
- return NULL;
}
return (ptr);
}
@@ -238,37 +245,76 @@ JCL_FindClass (JNIEnv * env, const char *className)
/*
* Build a Pointer object.
*/
-
JNIEXPORT jobject JNICALL
JCL_NewRawDataObject (JNIEnv * env, void *data)
{
+#ifdef JCL_NO_JNIONLOAD
+ jclass aclass = rawDataClass;
+ jmethodID mid;
+ if (aclass == NULL)
+ {
+ aclass = (*env)->FindClass (env, JCL_POINTER_CLASSNAME);
+ if (aclass == NULL ||
+ (aclass = (*env)->NewGlobalRef (env, aclass)) == NULL)
+ {
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "Pointer class not found");
+ return NULL;
+ }
+ rawDataClass = aclass;
+ }
+ if ((mid = rawData_mid) == NULL)
+ {
+ if ((mid = (*env)->GetMethodID (env, aclass, "<init>",
+ "(" JCL_POINTER_DATASIGN ")V")) == NULL)
+ {
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "Pointer class constructor not found");
+ return NULL;
+ }
+ rawData_mid = mid;
+ }
+ return (*env)->NewObject (env, aclass, mid, (JCL_POINTER_INTTYPE) data);
+#else
if (rawDataClass == NULL || rawData_mid == NULL)
{
JCL_ThrowException (env, "java/lang/InternalError",
"Pointer class was not properly initialized");
return NULL;
}
-
-#if SIZEOF_VOID_P == 8
- return (*env)->NewObject (env, rawDataClass, rawData_mid, (jlong) data);
-#else
- return (*env)->NewObject (env, rawDataClass, rawData_mid, (jint) data);
+ return (*env)->NewObject (env, rawDataClass, rawData_mid,
+ (JCL_POINTER_INTTYPE) data);
#endif
}
JNIEXPORT void * JNICALL
JCL_GetRawData (JNIEnv * env, jobject rawdata)
{
+#ifdef JCL_NO_JNIONLOAD
+ jclass aclass;
+ jfieldID fid = rawData_fid;
+ if (fid == NULL)
+ {
+ aclass = rawDataClass;
+ if ((aclass == NULL && (aclass = (*env)->FindClass (env,
+ JCL_POINTER_CLASSNAME)) == NULL) ||
+ (fid = (*env)->GetFieldID (env, aclass, "data",
+ JCL_POINTER_DATASIGN)) == NULL)
+ {
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "Pointer class was not properly initialized");
+ return NULL;
+ }
+ rawData_fid = fid;
+ }
+ return (void *) (*env)->JCL_POINTER_GETFIELD (env, rawdata, fid);
+#else
if (rawData_fid == NULL)
{
JCL_ThrowException (env, "java/lang/InternalError",
"Pointer class was not properly initialized");
return NULL;
}
-
-#if SIZEOF_VOID_P == 8
- return (void *) (*env)->GetLongField (env, rawdata, rawData_fid);
-#else
- return (void *) (*env)->GetIntField (env, rawdata, rawData_fid);
-#endif
+ return (void *) (*env)->JCL_POINTER_GETFIELD (env, rawdata, rawData_fid);
+#endif
}
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.c b/libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.c
index 80c6795..224622a 100644
--- a/libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.c
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.c
@@ -163,14 +163,12 @@ static void
gst_classpath_src_class_init (GstClasspathSrcClass *klass)
{
GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
GstBaseSrcClass *gstbasesrc_class;
GstPushSrcClass *gstpushsrc_class;
GParamSpec *pspec;
gobject_class = G_OBJECT_CLASS (klass);
- gstelement_class = GST_ELEMENT_CLASS (klass);
gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
gstpushsrc_class = GST_PUSH_SRC_CLASS (klass);
diff --git a/libjava/classpath/native/jni/gtk-peer/GtkDragSourceContextPeer.c b/libjava/classpath/native/jni/gtk-peer/GtkDragSourceContextPeer.c
index aee61bd..b8f1ba5 100644
--- a/libjava/classpath/native/jni/gtk-peer/GtkDragSourceContextPeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/GtkDragSourceContextPeer.c
@@ -99,9 +99,8 @@ Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_create
JNIEXPORT void JNICALL
Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_nativeSetCursor
- (JNIEnv *env, jobject obj, jint type)
+ (JNIEnv *env __attribute__((unused)), jobject obj, jint type)
{
- void *ptr;
GdkWindow *win;
GdkCursorType gdk_cursor_type;
GdkCursor *gdk_cursor;
@@ -109,7 +108,6 @@ Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_nativeSetCursor
gdk_threads_enter ();
javaObj = obj;
- ptr = gtkpeer_get_global_ref (env, obj);
switch (type)
{
@@ -230,10 +228,9 @@ Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_connectSignals
}
static void
-connect_signals_for_widget (GtkWidget *w)
+connect_signals_for_widget (GtkWidget *w __attribute__((unused)))
{
/* FIXME: Not implemented. */
- w = NULL;
}
JNIEXPORT void JNICALL
@@ -257,7 +254,6 @@ Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_nativeStartDrag
(JNIEnv *env, jobject obj, jobject img, jint x, jint y, jint act,
jstring target)
{
- void *ptr;
const gchar *data;
GtkTargetEntry tar[1];
GdkEvent *event;
@@ -268,7 +264,6 @@ Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_nativeStartDrag
gdk_threads_enter ();
javaObj = obj;
- ptr = gtkpeer_get_global_ref (env, obj);
data = (*env)->GetStringUTFChars (env, target, NULL);
tar[0].target = (gchar *) data;
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
index 3364640..31bab77 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
@@ -121,7 +121,6 @@ Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState
{
GdkDrawable *drawable;
GtkWidget *widget;
- int width, height;
cairo_t *cr;
void *ptr;
@@ -136,9 +135,6 @@ Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState
drawable = widget->window;
g_assert (drawable != NULL);
- width = widget->allocation.width;
- height = widget->allocation.height;
-
cr = gdk_cairo_create(drawable);
g_assert(cr != NULL);
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c
index 4240f11..ea9c1d6 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c
@@ -120,6 +120,8 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseMove
result = XTestFakeMotionEvent (xdisplay,
-1,
x, y, CurrentTime);
+ if (result)
+ g_warning("XTestFakeMotionEvent returned %d\n", result);
XFlush (xdisplay);
@@ -153,6 +155,8 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mousePress
result = XTestFakeButtonEvent (xdisplay,
awt_button_mask_to_num (buttons),
True, CurrentTime);
+ if (result)
+ g_warning("XTestFakeButtonEvent returned %d\n", result);
XFlush (xdisplay);
@@ -185,6 +189,8 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseRelease
result = XTestFakeButtonEvent (xdisplay,
awt_button_mask_to_num (buttons),
False, CurrentTime);
+ if (result)
+ g_warning("XTestFakeButtonEvent returned %d\n", result);
XFlush (xdisplay);
@@ -275,7 +281,7 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyPress
&n_keys))
{
/* No matching keymap entry was found. */
- g_printerr ("No matching keymap entries were found\n");
+ g_message ("No matching keymap entries were found\n");
gdk_threads_leave ();
return;
}
@@ -287,6 +293,8 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyPress
result = XTestFakeKeyEvent (xdisplay,
keymap_keys[0].keycode,
True, CurrentTime);
+ if (result)
+ g_warning("XTestFakeKeyEvent returned %d\n", result);
g_free (keymap_keys);
@@ -330,7 +338,7 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyRelease
&n_keys))
{
/* No matching keymap entry was found. */
- g_printerr ("No matching keymap entries were found\n");
+ g_message ("No matching keymap entries were found\n");
gdk_threads_leave ();
return;
}
@@ -342,6 +350,8 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyRelease
result = XTestFakeKeyEvent (xdisplay,
keymap_keys[0].keycode,
False, CurrentTime);
+ if (result)
+ g_warning("XTestFakeKeyEvent returned %d\n", result);
g_free (keymap_keys);
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c
index b7b1c33..0511c05 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c
@@ -83,20 +83,25 @@ Java_gnu_java_awt_peer_gtk_GtkPopupMenuPeer_show
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkPopupMenuPeer_setupAccelGroup
- (JNIEnv *env, jobject obj, jobject parent)
+ (JNIEnv *env, jobject obj, jobject parent __attribute__((unused)))
{
- void *ptr1, *ptr2;
+ void *ptr1;
GtkMenu *menu;
+#if 0
+ void *ptr2;
+#endif
gdk_threads_enter ();
ptr1 = gtkpeer_get_widget (env, obj);
- ptr2 = gtkpeer_get_widget (env, parent);
menu = GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu);
gtk_menu_set_accel_group (menu, gtk_accel_group_new ());
/* FIXME: update this to use GTK-2.4 GtkActions. */
+ // FIXME: _gtk_accel_group_attach is a GTK-private function, so
+ // we'll need a different approach here
#if 0
+ ptr2 = gtkpeer_get_widget (env, parent);
_gtk_accel_group_attach (gtk_menu_get_accel_group (menu),
G_OBJECT (gtk_widget_get_toplevel (ptr2)));
#endif
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
index b209797..ad99664 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
@@ -1,6 +1,6 @@
/* gtktoolkit.c -- Native portion of GtkToolkit
- Copyright (C) 1998, 1999, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2005, 2007, 2010 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -216,6 +216,7 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env,
init_dpi_conversion_factor ();
gtktoolkit = (*env)->FindClass(env, "gnu/java/awt/peer/gtk/GtkMainThread");
+ gtktoolkit = (*env)->NewGlobalRef(env, gtktoolkit); /* bug fix #40889 */
setRunningID = (*env)->GetStaticMethodID (env, gtktoolkit,
"setRunning", "(Z)V");
}
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
index 50197ca..af0868cc 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
@@ -110,7 +110,7 @@ Java_gnu_java_awt_peer_gtk_GtkVolatileImage_nativeGetPixels
GdkPixmap *pixmap;
GdkPixbuf *pixbuf;
jintArray jpixels;
- int width, height, depth, size;
+ int width, height, size;
jclass cls;
jfieldID field;
guchar *pixels;
@@ -129,8 +129,6 @@ Java_gnu_java_awt_peer_gtk_GtkVolatileImage_nativeGetPixels
gdk_threads_enter();
- /* get depth in bytes */
- depth = gdk_drawable_get_depth( pixmap ) >> 3;
size = width * height;
jpixels = (*env)->NewIntArray ( env, size );
jpixdata = (*env)->GetIntArrayElements (env, jpixels, NULL);
diff --git a/libjava/classpath/native/jni/java-io/Makefile.am b/libjava/classpath/native/jni/java-io/Makefile.am
index 58bd973..80edb32 100644
--- a/libjava/classpath/native/jni/java-io/Makefile.am
+++ b/libjava/classpath/native/jni/java-io/Makefile.am
@@ -1,6 +1,7 @@
nativeexeclib_LTLIBRARIES = libjavaio.la
-libjavaio_la_SOURCES = java_io_VMFile.c \
+libjavaio_la_SOURCES = java_io_VMConsole.c \
+ java_io_VMFile.c \
java_io_VMObjectInputStream.c \
java_io_VMObjectStreamClass.c
diff --git a/libjava/classpath/native/jni/java-io/Makefile.in b/libjava/classpath/native/jni/java-io/Makefile.in
index 0052aee..b9c68ad 100644
--- a/libjava/classpath/native/jni/java-io/Makefile.in
+++ b/libjava/classpath/native/jni/java-io/Makefile.in
@@ -94,7 +94,7 @@ LTLIBRARIES = $(nativeexeclib_LTLIBRARIES)
libjavaio_la_DEPENDENCIES = \
$(top_builddir)/native/jni/classpath/jcl.lo \
$(top_builddir)/native/jni/native-lib/libclasspathnative.la
-am_libjavaio_la_OBJECTS = java_io_VMFile.lo \
+am_libjavaio_la_OBJECTS = java_io_VMConsole.lo java_io_VMFile.lo \
java_io_VMObjectInputStream.lo java_io_VMObjectStreamClass.lo
libjavaio_la_OBJECTS = $(am_libjavaio_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
@@ -326,7 +326,8 @@ top_srcdir = @top_srcdir@
uudecode = @uudecode@
vm_classes = @vm_classes@
nativeexeclib_LTLIBRARIES = libjavaio.la
-libjavaio_la_SOURCES = java_io_VMFile.c \
+libjavaio_la_SOURCES = java_io_VMConsole.c \
+ java_io_VMFile.c \
java_io_VMObjectInputStream.c \
java_io_VMObjectStreamClass.c
@@ -412,6 +413,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_io_VMConsole.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_io_VMFile.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_io_VMObjectInputStream.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_io_VMObjectStreamClass.Plo@am__quote@
diff --git a/libjava/classpath/native/jni/java-io/java_io_VMConsole.c b/libjava/classpath/native/jni/java-io/java_io_VMConsole.c
new file mode 100644
index 0000000..2883f5f
--- /dev/null
+++ b/libjava/classpath/native/jni/java-io/java_io_VMConsole.c
@@ -0,0 +1,90 @@
+/* java_io_VMConsole.c - Native methods for java.io.Console class
+ Copyright (C) 2012 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+/* do not move; needed here because of some macro definitions */
+#include <config.h>
+
+#include <termios.h>
+#include <unistd.h>
+
+#include <jni.h>
+
+#include "java_io_VMConsole.h"
+
+/*************************************************************************/
+
+#define TERMIOS_ECHO_IFLAGS (IUCLC|IXON|IXOFF|IXANY)
+#define TERMIOS_ECHO_LFLAGS (ECHO|ECHOE|ECHOK|ECHONL|TOSTOP)
+
+/*
+ * Class: java_io_VMConsole
+ * Method: echo
+ * Signature: (Z)Z
+ */
+JNIEXPORT jstring JNICALL
+Java_java_io_VMConsole_readPassword (JNIEnv * env,
+ jclass clazz
+ __attribute__ ((__unused__)),
+ jobject con)
+{
+ struct termios old, new;
+ jmethodID readLineID;
+ jstring result;
+
+ readLineID =
+ (*env)->GetMethodID (env, (*env)->GetObjectClass (env, con), "readLine",
+ "()Ljava/lang/String;");
+ if (!readLineID)
+ {
+ return NULL;
+ }
+
+ tcgetattr (STDIN_FILENO, &old);
+
+ tcgetattr (STDIN_FILENO, &new);
+
+ new.c_iflag &= ~TERMIOS_ECHO_IFLAGS;
+ new.c_lflag &= ~TERMIOS_ECHO_LFLAGS;
+
+ tcsetattr (STDIN_FILENO, TCSANOW, &new);
+
+ result = (*env)->CallObjectMethod (env, con, readLineID);
+
+ tcsetattr (STDIN_FILENO, TCSANOW, &old);
+
+ return result;
+}
diff --git a/libjava/classpath/native/jni/java-lang/java_lang_VMSystem.c b/libjava/classpath/native/jni/java-lang/java_lang_VMSystem.c
index d203227..f623857 100644
--- a/libjava/classpath/native/jni/java-lang/java_lang_VMSystem.c
+++ b/libjava/classpath/native/jni/java-lang/java_lang_VMSystem.c
@@ -39,8 +39,12 @@ exception statement from your version. */
#include <jcl.h>
+#include <time.h>
#include <sys/time.h>
#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
/*
* Class: java_lang_VMSystem
@@ -111,6 +115,22 @@ Java_java_lang_VMSystem_setErr (JNIEnv * env,
(*env)->SetStaticObjectField (env, cls, field, obj);
}
+static jlong currentTimeMicros(JNIEnv * env)
+{
+ /* Note: this implementation copied directly from Japhar's, by Chris Toshok. */
+ jlong result;
+ struct timeval tp;
+
+ if (gettimeofday (&tp, NULL) == -1)
+ (*env)->FatalError (env, "gettimeofday call failed.");
+
+ result = (jlong) tp.tv_sec;
+ result *= (jlong)1000000L;
+ result += (jlong)tp.tv_usec;
+
+ return result;
+}
+
/*
* Class: java_lang_VMSystem
* Method: nanoTime
@@ -118,22 +138,38 @@ Java_java_lang_VMSystem_setErr (JNIEnv * env,
*/
JNIEXPORT jlong JNICALL
Java_java_lang_VMSystem_nanoTime
- (JNIEnv * env __attribute__ ((__unused__)),
+ (JNIEnv * env,
jclass thisClass __attribute__ ((__unused__)))
{
- /* Note: this implementation copied directly from Japhar's, by Chris Toshok. */
+#if defined(HAVE_CLOCK_GETTIME) && defined(_POSIX_MONOTONIC_CLOCK)
jlong result;
- struct timeval tp;
+ struct timespec tp;
- if (gettimeofday (&tp, NULL) == -1)
- (*env)->FatalError (env, "gettimeofday call failed.");
+ if (clock_gettime (CLOCK_MONOTONIC, &tp) == -1) {
+ return currentTimeMicros(env) * (jlong)1000;
+ }
result = (jlong) tp.tv_sec;
- result *= (jlong)1000000L;
- result += (jlong)tp.tv_usec;
- result *= (jlong)1000;
+ result *= (jlong)1000000000L;
+ result += (jlong)tp.tv_nsec;
return result;
+#else
+ return currentTimeMicros(env) * (jlong)1000;
+#endif
+}
+
+/*
+ * Class: java_lang_VMSystem
+ * Method: currentTimeMillis
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL
+Java_java_lang_VMSystem_currentTimeMillis
+ (JNIEnv * env,
+ jclass thisClass __attribute__ ((__unused__)))
+{
+ return currentTimeMicros(env) / (jlong)1000L;
}
JNIEXPORT jstring JNICALL
diff --git a/libjava/classpath/native/jni/java-net/java_net_VMInetAddress.c b/libjava/classpath/native/jni/java-net/java_net_VMInetAddress.c
index 6ee7773..4de63cf 100644
--- a/libjava/classpath/native/jni/java-net/java_net_VMInetAddress.c
+++ b/libjava/classpath/native/jni/java-net/java_net_VMInetAddress.c
@@ -180,6 +180,7 @@ Java_java_net_VMInetAddress_getHostByAddr (JNIEnv * env,
/* Resolve the address and return the name */
result = cpnet_getHostByAddr (env, addr, hostname, sizeof (hostname));
+ cpnet_freeAddress (env, addr);
if (result != CPNATIVE_OK)
{
JCL_ThrowException (env, UNKNOWN_HOST_EXCEPTION,
@@ -330,6 +331,7 @@ Java_java_net_VMInetAddress_aton (JNIEnv *env,
}
result = cpnet_aton (env, hostname, &address);
+ (*env)->ReleaseStringUTFChars (env, host, hostname);
if (result != CPNATIVE_OK)
{
JCL_ThrowException (env, UNKNOWN_HOST_EXCEPTION, "Internal Error");
diff --git a/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c b/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c
index bfee7e9..7325c5b 100644
--- a/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c
+++ b/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c
@@ -51,6 +51,13 @@ Java_java_nio_VMDirectByteBuffer_allocate
{
void *buffer;
+ if (capacity < 0)
+ {
+ JCL_ThrowException (env, "java/lang/IllegalArgumentException",
+ "negative capacity");
+ return 0;
+ }
+
buffer = malloc (capacity);
if (buffer == NULL)
diff --git a/libjava/classpath/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c b/libjava/classpath/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c
index d3e4f2b..5916eb2 100644
--- a/libjava/classpath/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c
+++ b/libjava/classpath/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c
@@ -1,5 +1,5 @@
/* gnu_javax_sound_midi_alsa_AlsaPortDevice.c - Native support
- Copyright (C) 2005, 2010
+ Copyright (C) 2005, 2010, 2011
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ exception statement from your version. */
#include <gnu_javax_sound_midi_alsa_AlsaPortDevice.h>
#include <unistd.h>
+#include <jcl.h>
#include <alsa/asoundlib.h>
JNIEXPORT void JNICALL
@@ -48,6 +49,7 @@ Java_gnu_javax_sound_midi_alsa_AlsaPortDevice_run_1receiver_1thread_1
(JNIEnv *env, jobject this __attribute__((unused)),
jlong client, jlong port, jobject receiver)
{
+ int rc;
snd_seq_port_info_t *pinfo, *sinfo;
snd_seq_port_subscribe_t *subs;
snd_seq_addr_t sender, dest;
@@ -57,12 +59,16 @@ Java_gnu_javax_sound_midi_alsa_AlsaPortDevice_run_1receiver_1thread_1
snd_seq_port_info_alloca (&sinfo);
snd_seq_port_subscribe_alloca (&subs);
- snd_seq_open (&seq, "default", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK);
+ rc = snd_seq_open (&seq, "default", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK);
+ if (rc < 0)
+ JCL_ThrowException (env, "java/lang/InternalError", snd_strerror (rc));
snd_seq_port_info_set_capability (pinfo, SND_SEQ_PORT_CAP_WRITE);
snd_seq_port_info_set_type (pinfo, SND_SEQ_PORT_TYPE_MIDI_GENERIC);
- snd_seq_create_port (seq, pinfo);
+ rc = snd_seq_create_port (seq, pinfo);
+ if (rc < 0)
+ JCL_ThrowException (env, "java/lang/InternalError", snd_strerror (rc));
sender.client = (int) client;
sender.port = (int) port;
@@ -71,7 +77,9 @@ Java_gnu_javax_sound_midi_alsa_AlsaPortDevice_run_1receiver_1thread_1
snd_seq_port_subscribe_set_sender (subs, &sender);
snd_seq_port_subscribe_set_dest (subs, &dest);
- snd_seq_subscribe_port(seq, subs);
+ rc = snd_seq_subscribe_port(seq, subs);
+ if (rc < 0)
+ JCL_ThrowException (env, "java/lang/InternalError", snd_strerror (rc));
{
int npfd;