Imported GNU Classpath 0.90

Imported GNU Classpath 0.90
       * scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.

       * sources.am: Regenerated.
       * gcj/javaprims.h: Regenerated.
       * Makefile.in: Regenerated.
       * gcj/Makefile.in: Regenerated.
       * include/Makefile.in: Regenerated.
       * testsuite/Makefile.in: Regenerated.

       * gnu/java/lang/VMInstrumentationImpl.java: New override.
       * gnu/java/net/local/LocalSocketImpl.java: Likewise.
       * gnu/classpath/jdwp/VMMethod.java: Likewise.
       * gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
       interface.
       * java/lang/Thread.java: Add UncaughtExceptionHandler.
       * java/lang/reflect/Method.java: Implements GenericDeclaration and
       isSynthetic(),
       * java/lang/reflect/Field.java: Likewise.
       * java/lang/reflect/Constructor.java
       * java/lang/Class.java: Implements Type, GenericDeclaration,
       getSimpleName() and getEnclosing*() methods.
       * java/lang/Class.h: Add new public methods.
       * java/lang/Math.java: Add signum(), ulp() and log10().
       * java/lang/natMath.cc (log10): New function.
       * java/security/VMSecureRandom.java: New override.
       * java/util/logging/Logger.java: Updated to latest classpath
       version.
       * java/util/logging/LogManager.java: New override.

From-SVN: r113887
This commit is contained in:
Mark Wielaard 2006-05-18 17:29:21 +00:00
parent eaec4980e1
commit 4f9533c772
1640 changed files with 126485 additions and 104808 deletions

View file

@ -1,11 +1,20 @@
nativelib_LTLIBRARIES = libjavanet.la
nativeexeclib_LTLIBRARIES = libjavanet.la
if ENABLE_LOCAL_SOCKETS
local_sources = gnu_java_net_local_LocalSocketImpl.c \
local.c \
local.h
else
local_sources = gnu_java_net_local_LocalSocketImpl.c
endif
libjavanet_la_SOURCES = javanet.c \
javanet.h \
java_net_VMInetAddress.c \
java_net_VMNetworkInterface.c \
gnu_java_net_VMPlainDatagramSocketImpl.c \
gnu_java_net_VMPlainSocketImpl.c
gnu_java_net_VMPlainSocketImpl.c \
$(local_sources)
libjavanet_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo

View file

@ -60,15 +60,23 @@ am__vpath_adj = case $$p in \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(nativelibdir)"
nativelibLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(nativelib_LTLIBRARIES)
am__installdirs = "$(DESTDIR)$(nativeexeclibdir)"
nativeexeclibLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(nativeexeclib_LTLIBRARIES)
libjavanet_la_DEPENDENCIES = \
$(top_builddir)/native/jni/classpath/jcl.lo
am__libjavanet_la_SOURCES_DIST = javanet.c javanet.h \
java_net_VMInetAddress.c java_net_VMNetworkInterface.c \
gnu_java_net_VMPlainDatagramSocketImpl.c \
gnu_java_net_VMPlainSocketImpl.c \
gnu_java_net_local_LocalSocketImpl.c local.c local.h
@ENABLE_LOCAL_SOCKETS_FALSE@am__objects_1 = gnu_java_net_local_LocalSocketImpl.lo
@ENABLE_LOCAL_SOCKETS_TRUE@am__objects_1 = gnu_java_net_local_LocalSocketImpl.lo \
@ENABLE_LOCAL_SOCKETS_TRUE@ local.lo
am_libjavanet_la_OBJECTS = javanet.lo java_net_VMInetAddress.lo \
java_net_VMNetworkInterface.lo \
gnu_java_net_VMPlainDatagramSocketImpl.lo \
gnu_java_net_VMPlainSocketImpl.lo
gnu_java_net_VMPlainSocketImpl.lo $(am__objects_1)
libjavanet_la_OBJECTS = $(am_libjavanet_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
depcomp = $(SHELL) $(top_srcdir)/depcomp
@ -82,7 +90,7 @@ CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libjavanet_la_SOURCES)
DIST_SOURCES = $(libjavanet_la_SOURCES)
DIST_SOURCES = $(am__libjavanet_la_SOURCES_DIST)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -101,6 +109,7 @@ CAIRO_LIBS = @CAIRO_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CLASSPATH_CONVENIENCE = @CLASSPATH_CONVENIENCE@
CLASSPATH_INCLUDES = @CLASSPATH_INCLUDES@
CLASSPATH_MODULE = @CLASSPATH_MODULE@
COLLECTIONS_PREFIX = @COLLECTIONS_PREFIX@
@ -140,6 +149,8 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
ECJ = @ECJ@
EGREP = @EGREP@
ENABLE_LOCAL_SOCKETS_FALSE = @ENABLE_LOCAL_SOCKETS_FALSE@
ENABLE_LOCAL_SOCKETS_TRUE = @ENABLE_LOCAL_SOCKETS_TRUE@
ERROR_CFLAGS = @ERROR_CFLAGS@
EXAMPLESDIR = @EXAMPLESDIR@
EXEEXT = @EXEEXT@
@ -160,6 +171,7 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
GJDOC = @GJDOC@
GREP = @GREP@
GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
@ -207,6 +219,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
QT_CFLAGS = @QT_CFLAGS@
@ -225,8 +238,11 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
WARNING_CFLAGS = @WARNING_CFLAGS@
XMKMF = @XMKMF@
XML_CFLAGS = @XML_CFLAGS@
XML_LIBS = @XML_LIBS@
XSLT_CFLAGS = @XSLT_CFLAGS@
@ -238,8 +254,6 @@ X_PRE_LIBS = @X_PRE_LIBS@
ZIP = @ZIP@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
@ -256,7 +270,10 @@ build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
default_toolkit = @default_toolkit@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
glibjdir = @glibjdir@
host = @host@
@ -264,18 +281,22 @@ host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
nativelibdir = @nativelibdir@
nativeexeclibdir = @nativeexeclibdir@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
@ -285,13 +306,19 @@ target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
vm_classes = @vm_classes@
nativelib_LTLIBRARIES = libjavanet.la
nativeexeclib_LTLIBRARIES = libjavanet.la
@ENABLE_LOCAL_SOCKETS_FALSE@local_sources = gnu_java_net_local_LocalSocketImpl.c
@ENABLE_LOCAL_SOCKETS_TRUE@local_sources = gnu_java_net_local_LocalSocketImpl.c \
@ENABLE_LOCAL_SOCKETS_TRUE@ local.c \
@ENABLE_LOCAL_SOCKETS_TRUE@ local.h
libjavanet_la_SOURCES = javanet.c \
javanet.h \
java_net_VMInetAddress.c \
java_net_VMNetworkInterface.c \
gnu_java_net_VMPlainDatagramSocketImpl.c \
gnu_java_net_VMPlainSocketImpl.c
gnu_java_net_VMPlainSocketImpl.c \
$(local_sources)
libjavanet_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo
AM_LDFLAGS = @CLASSPATH_MODULE@
@ -330,35 +357,35 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-nativelibLTLIBRARIES: $(nativelib_LTLIBRARIES)
install-nativeexeclibLTLIBRARIES: $(nativeexeclib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(nativelibdir)" || $(mkdir_p) "$(DESTDIR)$(nativelibdir)"
@list='$(nativelib_LTLIBRARIES)'; for p in $$list; do \
test -z "$(nativeexeclibdir)" || $(mkdir_p) "$(DESTDIR)$(nativeexeclibdir)"
@list='$(nativeexeclib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=install $(nativelibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(nativelibdir)/$$f'"; \
$(LIBTOOL) --mode=install $(nativelibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(nativelibdir)/$$f"; \
echo " $(LIBTOOL) --mode=install $(nativeexeclibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(nativeexeclibdir)/$$f'"; \
$(LIBTOOL) --mode=install $(nativeexeclibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(nativeexeclibdir)/$$f"; \
else :; fi; \
done
uninstall-nativelibLTLIBRARIES:
uninstall-nativeexeclibLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@set -x; list='$(nativelib_LTLIBRARIES)'; for p in $$list; do \
@set -x; list='$(nativeexeclib_LTLIBRARIES)'; for p in $$list; do \
p=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(nativelibdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(nativelibdir)/$$p"; \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(nativeexeclibdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(nativeexeclibdir)/$$p"; \
done
clean-nativelibLTLIBRARIES:
-test -z "$(nativelib_LTLIBRARIES)" || rm -f $(nativelib_LTLIBRARIES)
@list='$(nativelib_LTLIBRARIES)'; for p in $$list; do \
clean-nativeexeclibLTLIBRARIES:
-test -z "$(nativeexeclib_LTLIBRARIES)" || rm -f $(nativeexeclib_LTLIBRARIES)
@list='$(nativeexeclib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libjavanet.la: $(libjavanet_la_OBJECTS) $(libjavanet_la_DEPENDENCIES)
$(LINK) -rpath $(nativelibdir) $(libjavanet_la_LDFLAGS) $(libjavanet_la_OBJECTS) $(libjavanet_la_LIBADD) $(LIBS)
$(LINK) -rpath $(nativeexeclibdir) $(libjavanet_la_LDFLAGS) $(libjavanet_la_OBJECTS) $(libjavanet_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@ -368,9 +395,11 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_net_VMPlainDatagramSocketImpl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_net_VMPlainSocketImpl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_net_local_LocalSocketImpl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_net_VMInetAddress.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_net_VMNetworkInterface.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/javanet.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/local.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@ -482,7 +511,7 @@ check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
for dir in "$(DESTDIR)$(nativelibdir)"; do \
for dir in "$(DESTDIR)$(nativeexeclibdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
@ -511,7 +540,7 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-nativelibLTLIBRARIES \
clean-am: clean-generic clean-libtool clean-nativeexeclibLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
@ -530,9 +559,9 @@ info: info-am
info-am:
install-data-am: install-nativelibLTLIBRARIES
install-data-am:
install-exec-am:
install-exec-am: install-nativeexeclibLTLIBRARIES
install-info: install-info-am
@ -558,20 +587,20 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-nativelibLTLIBRARIES
uninstall-am: uninstall-info-am uninstall-nativeexeclibLTLIBRARIES
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-nativelibLTLIBRARIES ctags distclean \
clean-libtool clean-nativeexeclibLTLIBRARIES ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-nativelibLTLIBRARIES install-strip installcheck \
install-nativeexeclibLTLIBRARIES install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-nativelibLTLIBRARIES
uninstall-nativeexeclibLTLIBRARIES
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

View file

@ -0,0 +1,538 @@
/* gnu_java_net_local_LocalSocketImpl.c -- native local socket implementation.
Copyright (C) 2006 Free Software Foundation, Inc.
This file is a 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 of the License, 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; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, 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. */
#define _GNU_SOURCE
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include <gnu_java_net_local_LocalSocketImpl.h>
#include <stddef.h>
#include "local.h"
#ifdef DEBUG
#define TRACE(msg) fprintf (stderr, "%s(%s:%d) -- %s\n", __FUNCTION__, __FILE__, __LINE__, msg)
#else
#define TRACE(msg)
#endif
static void
_throw (JNIEnv *env, const char *exception, const char *msg)
{
jclass _theclass = (*env)->FindClass (env, exception);
TRACE("begin");
if (!_theclass)
{
(*env)->FatalError (env, "exception class not found");
}
(*env)->ThrowNew (env, _theclass, msg);
TRACE("end");
}
void
Java_gnu_java_net_local_LocalSocketImpl_create (JNIEnv *env, jobject this, jboolean stream)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID socket_fd, created;
jclass clazz;
jint fd = (jint) local_create ((int) stream);
TRACE("begin");
if (fd < 0)
{
_throw (env, "java/io/IOException", local_error ());
return;
}
clazz = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
if (!socket_fd)
{
return;
}
created = (*env)->GetFieldID (env, clazz, "created", "Z");
if (!created)
{
return;
}
(*env)->SetIntField (env, this, socket_fd, fd);
(*env)->SetBooleanField (env, this, created, JNI_TRUE);
TRACE("end");
#else
(void) this;
(void) stream;
_throw (env, "java/lang/Error", "support for local sockets not available");
#endif /* ENABLE_LOCAL_SOCKETS */
}
void
Java_gnu_java_net_local_LocalSocketImpl_listen (JNIEnv *env, jobject this, jint backlog)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID socket_fd;
jclass clazz;
int fd;
TRACE("begin");
clazz = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
if (!socket_fd)
{
return;
}
fd = (int) (*env)->GetIntField (env, this, socket_fd);
if (local_listen (fd, (int) backlog))
{
_throw (env, "java/io/IOException", local_error ());
return;
}
TRACE("end");
#else
(void) this;
(void) backlog;
_throw (env, "java/lang/Error", "support for local sockets not available");
#endif /* ENABLE_LOCAL_SOCKETS */
}
void
Java_gnu_java_net_local_LocalSocketImpl_accept (JNIEnv *env, jobject this, jobject socket)
{
#ifdef ENABLE_LOCAL_SOCKETS
jmethodID addr_init;
jfieldID socket_fd, remote_addr, local_addr;
jclass clazz1, clazz2;
jobject remote, local;
jint fd;
char path[108];
TRACE("begin");
clazz1 = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz1, "socket_fd", "I");
if (!socket_fd)
{
return;
}
fd = (*env)->GetIntField (env, this, socket_fd);
fd = (jint) local_accept ((int) fd, path);
if (fd < 0)
{
_throw (env, "java/io/IOException", local_error ());
return;
}
clazz2 = (*env)->FindClass (env, "gnu/java/net/local/LocalSocketAddress");
if (!clazz2)
{
return;
}
addr_init = (*env)->GetMethodID (env, clazz2, "<init>", "(Ljava/lang/String;)V");
if (!addr_init)
{
return;
}
remote = (*env)->NewObject (env, clazz2, addr_init, (*env)->NewStringUTF (env, path));
remote_addr = (*env)->GetFieldID (env, clazz1, "remote", "Lgnu/java/net/local/LocalSocketAddress;");
if (!remote_addr)
{
return;
}
local_addr = (*env)->GetFieldID (env, clazz1, "local", "Lgnu/java/net/local/LocalSocketAddress;");
if (!local_addr)
{
return;
}
local = (*env)->GetObjectField (env, this, local_addr);
(*env)->SetIntField (env, socket, socket_fd, fd);
(*env)->SetObjectField (env, socket, remote_addr, remote);
(*env)->SetObjectField (env, socket, local_addr, local);
TRACE("end");
#else
(void) this;
(void) socket;
_throw (env, "java/lang/Error", "support for local sockets not available");
#endif /* ENABLE_LOCAL_SOCKETS */
}
jint
Java_gnu_java_net_local_LocalSocketImpl_available (JNIEnv *env, jobject this)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID socket_fd;
jclass clazz;
jint avail;
TRACE("begin");
clazz = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
if (!socket_fd)
{
return 0;
}
avail = (jint) local_available ((int) (*env)->GetIntField (env, this, socket_fd));
if (avail < 0)
{
_throw (env, "java/io/IOException", local_error ());
return 0;
}
TRACE("end");
return avail;
#else
(void) this;
_throw (env, "java/lang/Error", "support for local sockets not available");
return -1;
#endif /* ENABLE_LOCAL_SOCKETS */
}
void
Java_gnu_java_net_local_LocalSocketImpl_close (JNIEnv *env, jobject this)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID socket_fd;
jclass clazz;
int fd;
TRACE("begin");
clazz = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
if (!socket_fd)
{
return;
}
fd = (int) (*env)->GetIntField (env, this, socket_fd);
if (local_close (fd))
{
_throw (env, "java/io/IOException", local_error ());
}
TRACE("end");
#else
(void) this;
_throw (env, "java/lang/Error", "support for local sockets not available");
#endif /* ENABLE_LOCAL_SOCKETS */
}
void
Java_gnu_java_net_local_LocalSocketImpl_unlink (JNIEnv *env, jobject this)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID local;
jmethodID get_path;
jclass clazz1, clazz2;
jobject local_ref, path;
char *addr_path;
TRACE("begin");
clazz1 = (*env)->GetObjectClass (env, this);
local = (*env)->GetFieldID (env, clazz1, "local", "Lgnu/java/net/local/LocalSocketAddress;");
if (!local)
{
return;
}
local_ref = (*env)->GetObjectField (env, this, local);
clazz2 = (*env)->GetObjectClass (env, local_ref);
get_path = (*env)->GetMethodID (env, clazz2, "getPath", "()Ljava/lang/String;");
if (!get_path)
{
return;
}
path = (*env)->CallObjectMethod (env, local_ref, get_path);
addr_path = (char *) (*env)->GetStringUTFChars (env, (jstring) path, NULL);
if (local_unlink (addr_path))
{
_throw (env, "java/io/IOException", local_error ());
}
(*env)->ReleaseStringUTFChars (env, (jstring) path, addr_path);
TRACE("end");
#else
(void) this;
_throw (env, "java/lang/Error", "support for local sockets not available");
#endif /* ENABLE_LOCAL_SOCKETS */
}
void
Java_gnu_java_net_local_LocalSocketImpl_sendUrgentData (JNIEnv *env, jobject this __attribute__((unused)), jint data __attribute__((unused)))
{
/* XXX I don't remember why I have this. Probably should just
remove. */
(*env)->FatalError (env, "Java_gnu_java_net_local_LocalSocketImpl_shutdownInput (JNIEnv *env, jobject) not implemented");
}
void
Java_gnu_java_net_local_LocalSocketImpl_shutdownInput (JNIEnv *env, jobject this)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID socket_fd;
jclass clazz;
int fd;
TRACE("begin");
clazz = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
if (!socket_fd)
{
return;
}
fd = (*env)->GetIntField (env, this, socket_fd);
if (local_shutdown_input (fd))
{
_throw (env, "java/io/IOException", local_error ());
}
TRACE("end");
#else
(void) this;
_throw (env, "java/lang/Error", "support for local sockets not available");
#endif /* ENABLE_LOCAL_SOCKETS */
}
void
Java_gnu_java_net_local_LocalSocketImpl_shutdownOutput (JNIEnv *env, jobject this)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID socket_fd;
jclass clazz;
int fd;
TRACE("begin");
clazz = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
if (!socket_fd)
{
return;
}
fd = (*env)->GetIntField (env, this, socket_fd);
if (local_shutdown_output (fd))
{
_throw (env, "java/io/IOException", local_error ());
}
TRACE("end");
#else
(void) this;
_throw (env, "java/lang/Error", "support for local sockets not available");
#endif /* ENABLE_LOCAL_SOCKETS */
}
void
Java_gnu_java_net_local_LocalSocketImpl_localBind (JNIEnv *env, jobject this, jobject address)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID socket_fd;
jmethodID get_path;
jobject path;
jclass clazz1, clazz2;
const char *addr_path;
int fd;
TRACE("begin");
clazz1 = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz1, "socket_fd", "I");
if (!socket_fd)
{
return;
}
fd = (int) (*env)->GetIntField (env, this, socket_fd);
clazz2 = (*env)->GetObjectClass (env, address);
get_path = (*env)->GetMethodID (env, clazz2, "getPath", "()Ljava/lang/String;");
path = (*env)->CallObjectMethod (env, address, get_path);
addr_path = (*env)->GetStringUTFChars (env, (jstring) path, NULL);
if (local_bind (fd, addr_path))
{
_throw (env, "java/io/IOException", local_error ());
}
(*env)->ReleaseStringUTFChars (env, (jstring) path, addr_path);
TRACE("end");
#else
(void) this;
(void) address;
_throw (env, "java/lang/Error", "support for local sockets not available");
#endif /* ENABLE_LOCAL_SOCKETS */
}
void
Java_gnu_java_net_local_LocalSocketImpl_localConnect (JNIEnv *env, jobject this, jobject address)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID socket_fd;
jmethodID get_path;
jobject path;
jclass clazz1, clazz2;
char *addr_path;
int fd;
TRACE("begin");
clazz1 = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz1, "socket_fd", "I");
if (!socket_fd)
{
return;
}
fd = (int) (*env)->GetIntField (env, this, socket_fd);
clazz2 = (*env)->GetObjectClass (env, address);
get_path = (*env)->GetMethodID (env, clazz2, "getPath", "()Ljava/lang/String;");
path = (*env)->CallObjectMethod (env, address, get_path);
addr_path = (char *) (*env)->GetStringUTFChars (env, (jstring) path, NULL);
if (local_connect (fd, addr_path))
{
_throw (env, "java/io/IOException", local_error ());
}
(*env)->ReleaseStringUTFChars (env, (jstring) path, addr_path);
TRACE("end");
#else
(void) this;
(void) address;
_throw (env, "java/lang/Error", "support for local sockets not available");
#endif /* ENABLE_LOCAL_SOCKETS */
}
jint
Java_gnu_java_net_local_LocalSocketImpl_read (JNIEnv *env, jobject this, jbyteArray buf, jint off, jint len)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID socket_fd;
jclass clazz;
jbyte *buffer;
jint count;
int fd;
TRACE("begin");
if (off < 0 || len < 0 || off + len > (*env)->GetArrayLength (env, buf))
{
_throw (env, "java/lang/ArrayIndexOutOfBoundsException", "");
}
clazz = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
if (!socket_fd)
{
return 0;
}
fd = (int) (*env)->GetIntField (env, this, socket_fd);
buffer = (*env)->GetByteArrayElements (env, buf, NULL);
count = (jint) local_read (fd, (void *) (buffer + off), (int) len);
if (count < 0)
{
_throw (env, "java/io/IOException", local_error ());
}
(*env)->ReleaseByteArrayElements (env, buf, buffer, 0);
TRACE("end");
return count;
#else
(void) this;
(void) buf;
(void) off;
(void) len;
_throw (env, "java/lang/Error", "support for local sockets not available");
return -1;
#endif /* ENABLE_LOCAL_SOCKETS */
}
void
Java_gnu_java_net_local_LocalSocketImpl_write (JNIEnv *env, jobject this, jbyteArray buf, jint off, jint len)
{
#ifdef ENABLE_LOCAL_SOCKETS
jfieldID socket_fd;
jclass clazz;
jbyte *buffer;
int fd;
TRACE("begin");
if (off < 0 || len < 0 || off + len > (*env)->GetArrayLength (env, buf))
{
_throw (env, "java/lang/ArrayIndexOutOfBoundsException", "");
}
clazz = (*env)->GetObjectClass (env, this);
socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
if (!socket_fd)
{
return;
}
fd = (int) (*env)->GetIntField (env, this, socket_fd);
buffer = (*env)->GetByteArrayElements (env, buf, NULL);
if (local_write (fd, (void *) (buffer + off), (int) len) < 0)
{
_throw (env, "java/io/IOException", local_error ());
}
(*env)->ReleaseByteArrayElements (env, buf, buffer, JNI_ABORT);
TRACE("end");
#else
(void) this;
(void) buf;
(void) off;
(void) len;
_throw (env, "java/lang/Error", "support for local sockets not available");
#endif /* ENABLE_LOCAL_SOCKETS */
}

View file

@ -835,6 +835,9 @@ _javanet_accept (JNIEnv * env, jobject this, jobject impl)
}
while (result != TARGET_NATIVE_OK);
/* Reset the inherited timeout. */
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT (newfd, 0, result);
/* Populate instance variables */
_javanet_set_int_field (env, impl, "gnu/java/net/PlainSocketImpl",
"native_fd", newfd);

View file

@ -40,6 +40,7 @@ exception statement from your version. */
#define _JAVANET_LOADED
#include <jni.h>
#include "jcl.h"
/*************************************************************************/
@ -72,19 +73,6 @@ exception statement from your version. */
/*************************************************************************/
/*
* Macros
*/
/* Simple debug macro */
#ifdef DEBUG
#define DBG(x) fprintf(stderr, (x));
#else
#define DBG(x)
#endif
/*************************************************************************/
/*
* Function Prototypes
*/

View file

@ -0,0 +1,193 @@
/* local.c -- implementation of unix-domain sockets.
Copyright (C) 2006 Free Software Foundation, Inc.
This file is a 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 of the License, 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; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, 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. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#ifdef ENABLE_LOCAL_SOCKETS
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include "local.h"
const char *
local_error (void)
{
return strerror (errno);
}
int
local_create (int stream)
{
return socket (PF_UNIX, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
}
static int gcc_sucks = 0;
int
local_bind (int fd, const char *addr)
{
struct sockaddr_un saddr;
/* For some reason, GCC 4.0.1 on Darwin/x86 MODIFIES the `addr'
pointer in the CALLER's STACK FRAME after calling this function,
but if we add this statement below, it doesn't! */
if (gcc_sucks)
fprintf (stderr, "bind %p\n", addr);
if (strlen (addr) > sizeof (saddr.sun_path))
{
errno = ENAMETOOLONG;
return -1;
}
strncpy (saddr.sun_path, addr, sizeof (saddr.sun_path));
saddr.sun_path[sizeof (saddr.sun_path)] = '\0';
saddr.sun_family = AF_LOCAL;
return bind (fd, (struct sockaddr *) &saddr, SUN_LEN (&saddr));
}
int
local_listen (int fd, int backlog)
{
return listen (fd, backlog);
}
int
local_accept (int fd, char *path)
{
int newfd;
struct sockaddr_un addr;
socklen_t sz = SUN_LEN(&addr);
newfd = accept (fd, (struct sockaddr *) &addr, &sz);
if (newfd >= 0)
{
/** sun_path is some crazy statically-sized buffer, and it's
size is different on different OSes. */
int n = sizeof (addr.sun_path);
strncpy (path, addr.sun_path, n);
path[n] = '\0';
}
return newfd;
}
int
local_available (int fd)
{
int val;
if (ioctl (fd, FIONREAD, &val))
{
return -1;
}
return val;
}
int
local_close (int fd)
{
return close (fd);
}
int
local_unlink (char *path)
{
return unlink (path);
}
int
local_shutdown_input (int fd)
{
return shutdown (fd, 0);
}
int
local_shutdown_output (int fd)
{
return shutdown (fd, 1);
}
int
local_connect (int fd, char *path)
{
struct sockaddr_un saddr;
strncpy (saddr.sun_path, path, sizeof (saddr.sun_path));
saddr.sun_path[sizeof (saddr.sun_path) - 1] = '\0';
saddr.sun_family = AF_UNIX;
return connect (fd, (struct sockaddr *) &saddr, SUN_LEN(&saddr));
}
int
local_read (int fd, void *buf, int len)
{
int count = -1;
do
{
count = read (fd, buf, len);
}
while (count == -1 && errno == EINTR);
return count;
}
int
local_write (int fd, void *buf, int len)
{
int count = -1;
do
{
count = write (fd, buf, len);
}
while (count == -1 && errno == EINTR);
return count;
}
#endif /* ENABLE_LOCAL_SOCKETS */

View file

@ -0,0 +1,28 @@
#ifndef __LOCAL_H__
#define __LOCAL_H__
#ifdef __cplusplus
extern "C"
{
#endif
#define __EMACSEN__ }
extern const char *local_error (void);
extern int local_create (int);
extern int local_bind (int, const char *);
extern int local_listen (int, int);
extern int local_accept (int, char *);
extern int local_available (int);
extern int local_close (int);
extern int local_shutdown_input (int);
extern int local_shutdown_output (int);
extern int local_connect (int, char *);
extern int local_unlink (char *);
extern int local_read (int, void *, int);
extern int local_write (int, void *, int);
#ifdef __cplusplus
}
#endif
#endif /* __LOCAL_H__ */