Hi,
On Mon, 2006-08-14 at 14:33 -0700, Casey Marshall wrote:
> Guilhem Lavaux wrote:
> > Here is a patch to merge NATIVE-LAYER branch to HEAD. I expect that the
> > new code will have some troubles to compile on some random OS different
> > from linux but hopefully it is sufficiently flexible to be
I fixed some issue with it that I found. Now it compiles cleanly for me.
It also fixes some small bugs I found.
2006-08-20 Mark Wielaard <[EMAIL PROTECTED]>
* doc/tools.texinfo: Add file from trunk.
* native/jni/Makefile.am (DIST_SUBDIRS): Add native-lib.
* native/jni/java-io/java_io_VMFile.c: Include lstat and readlink
headers.
* native/jni/java-lang/java_lang_VMProcess.c
(Java_java_lang_VMProcess_nativeSpawn): Remove redirect argument.
* native/jni/java-net/java_net_VMInetAddress.c
(Java_java_net_VMInetAddress_getHostByName): Remove unused variable.
* native/jni/native-lib/Makefile.am: Remove empty and nonexisting
files.
* native/jni/native-lib/cpio.c (cpio_setFileReadonly): Use correct
mask.
* native/jni/native-lib/cpnet.c (cpnet_connect): Removed unused
theaddr.
* native/jni/native-lib/cpnet.h (cpnet_freeAddresses): Moved from
cpnet.h.
* native/jni/native-lib/cpnet.h (cpnet_freeAddresses): Declare,
don't implement.
* vm/reference/java/lang/VMProcess.java: Removed unused redirect
argument.
* include/java_lang_VMProcess.h: Regenerated.
With this patch I can do a warning free compile and distcheck.
> > autoconfiscated. I have checked there is one less regression on my
> > system (I have not tested the AWT part because this system is a bit out
> > of date and I could not compile the peers but I have not touched
> > anything in that part so there should not be any regression).
Checked all of mauve and with the attached patch I see an improvement in
DatagramSocketTest2, but also a few rmi/corba regressions:
FAIL: org.omg.CORBA.ORB.parallelRunTest
FAIL: org.omg.CORBA.ORB.DirectTest
FAIL: org.omg.CORBA_2_3.ORB.ValueTypeTest
FAIL: org.omg.PortableServer.POAOperations.poa_POA_test
FAIL: org.omg.PortableInterceptor.Interceptor.testInterceptors
These seem all related to socket timeouts. I need to carefully read that
code to understand how this should work now. But I know Casey is
rewriting this part. So maybe we should just go with this merge for now
and then improve the socket timeout code later.
> At the
> > moment the ChangeLog is not yet merged. The branch changelog is still
> > held in ChangeLog.native (Mark what to do with this ?). I would like
> > some of you test this on a linux workstation and see if it works ok. I
> > will leave for (real !) vacations tomorrow so I may not be joinable.
> > Casey can you take this in charge if I am not responsive ? You told me
> > you can help...
I will add the ChangeLog entries from ChangeLog.native (except the merge
messages) to the main ChangeLog file when adding it to the trunk.
> I've been hacking on our NIO stuff a bit, and I will need to modify our
> java.net code, too. I'd like to do those modifications after this goes in.
>
> In general I'll say that the approach looks pretty good. I'd prefer that
> we stick closer to a POSIX API, and make the cp* functions just simple
> wrappers where they need to be (as in: blocking syscalls). I don't have
> a Linux machine to test this on right now, though.
>
> It is probably OK to commit this now, then fix the issues on darwin (et
> al) in CVS.
Since this finally cleans up the target layer stuff I would like this to
go in now and then we build on this for your further improvements to NIO
and the socket timeouts. OK?
I have committed the attached patch to the NATIVE-LAYER branch.
Cheers,
Mark
Index: native/jni/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/Makefile.am,v
retrieving revision 1.16.2.2
diff -u -r1.16.2.2 Makefile.am
--- native/jni/Makefile.am 9 Jul 2006 16:59:23 -0000 1.16.2.2
+++ native/jni/Makefile.am 21 Aug 2006 00:35:28 -0000
@@ -32,7 +32,8 @@
$(ALSADIR) $(DSSIDIR) $(GTKDIR) $(CLASSPATH_QT_PEER_DIR) $(XMLJDIR) \
$(CLASSPATH_GCONF_PEER_DIR)
DIST_SUBDIRS = classpath java-io java-lang java-net java-nio java-util \
- gtk-peer gconf-peer qt-peer xmlj midi-alsa midi-dssi
+ gtk-peer gconf-peer qt-peer xmlj midi-alsa midi-dssi \
+ native-lib
all-local:
cd $(top_srcdir) && $(SHELL) ./scripts/check_jni_methods.sh
Index: native/jni/java-io/java_io_VMFile.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-io/java_io_VMFile.c,v
retrieving revision 1.10.2.4
diff -u -r1.10.2.4 java_io_VMFile.c
--- native/jni/java-io/java_io_VMFile.c 9 Jul 2006 16:59:24 -0000 1.10.2.4
+++ native/jni/java-io/java_io_VMFile.c 21 Aug 2006 00:35:28 -0000
@@ -42,6 +42,12 @@
#include <stdio.h>
#include <stdlib.h>
+#if defined (HAVE_LSTAT) && defined (HAVE_READLINK)
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#endif
+
#include <jni.h>
#include <jcl.h>
#include "cpio.h"
Index: native/jni/java-lang/java_lang_VMProcess.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-lang/java_lang_VMProcess.c,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 java_lang_VMProcess.c
--- native/jni/java-lang/java_lang_VMProcess.c 6 Jun 2006 20:30:29 -0000 1.7.2.2
+++ native/jni/java-lang/java_lang_VMProcess.c 21 Aug 2006 00:35:28 -0000
@@ -123,8 +123,7 @@
JNIEXPORT void JNICALL
Java_java_lang_VMProcess_nativeSpawn (JNIEnv * env, jobject this,
jobjectArray cmdArray,
- jobjectArray envArray, jobject dirFile,
- jboolean redirect)
+ jobjectArray envArray, jobject dirFile)
{
int fds[CPIO_EXEC_NUM_PIPES];
jobject streams[CPIO_EXEC_NUM_PIPES] = { NULL, NULL, NULL };
Index: native/jni/java-net/java_net_VMInetAddress.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-net/java_net_VMInetAddress.c,v
retrieving revision 1.7.2.3
diff -u -r1.7.2.3 java_net_VMInetAddress.c
--- native/jni/java-net/java_net_VMInetAddress.c 16 Jun 2006 18:07:47 -0000 1.7.2.3
+++ native/jni/java-net/java_net_VMInetAddress.c 21 Aug 2006 00:35:28 -0000
@@ -208,7 +208,7 @@
int result;
jclass arr_class;
jobjectArray addrs;
- jint i, j;
+ jint i;
jbyte *octets;
jarray ret_octets;
Index: native/jni/native-lib/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/native-lib/Attic/Makefile.am,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 Makefile.am
--- native/jni/native-lib/Makefile.am 25 Mar 2006 17:08:50 -0000 1.1.2.2
+++ native/jni/native-lib/Makefile.am 21 Aug 2006 00:35:28 -0000
@@ -3,9 +3,7 @@
cpnet.h \
cpio.c \
cpio.h \
- cpnative.c \
cpnative.h \
- cpmath.h \
cpproc.h \
cpproc.c
Index: native/jni/native-lib/cpio.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/native-lib/Attic/cpio.c,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 cpio.c
--- native/jni/native-lib/cpio.c 16 Jun 2006 18:07:47 -0000 1.1.2.5
+++ native/jni/native-lib/cpio.c 21 Aug 2006 00:35:28 -0000
@@ -334,7 +334,7 @@
if (stat(filename, &statbuf) < 0)
return errno;
- if (chmod(filename, statbuf.st_mode & ~(S_IRUSR | S_IRGRP | S_IROTH)) < 0)
+ if (chmod(filename, statbuf.st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH)) < 0)
return errno;
return 0;
Index: native/jni/native-lib/cpnet.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/native-lib/Attic/cpnet.c,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 cpnet.c
--- native/jni/native-lib/cpnet.c 16 Jun 2006 18:07:47 -0000 1.1.2.6
+++ native/jni/native-lib/cpnet.c 21 Aug 2006 00:35:28 -0000
@@ -180,8 +180,6 @@
int ret;
/* TODO: implement socket time out */
- struct sockaddr_in *theaddr = (struct sockaddr_in *)addr->data;
-
ret = connect(fd, (struct sockaddr *)addr->data, addr->len);
if (ret != 0)
return errno;
@@ -697,3 +695,11 @@
return 0;
}
+
+void cpnet_freeAddresses(JNIEnv * env, cpnet_address **addr, jint addresses_count)
+{
+ jint i;
+
+ for (i = 0; i < addresses_count; i++)
+ cpnet_freeAddress(env, addr[i]);
+}
Index: native/jni/native-lib/cpnet.h
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/native-lib/Attic/cpnet.h,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 cpnet.h
--- native/jni/native-lib/cpnet.h 16 Jun 2006 18:07:47 -0000 1.1.2.7
+++ native/jni/native-lib/cpnet.h 21 Aug 2006 00:35:28 -0000
@@ -94,6 +94,7 @@
JNIEXPORT jint cpnet_getHostname (JNIEnv *env, char *hostname, jint hostname_len);
JNIEXPORT jint cpnet_getHostByName (JNIEnv *env, const char *hostname, cpnet_address ***adresses, jint *addresses_count);
JNIEXPORT jint cpnet_getHostByAddr (JNIEnv *env, cpnet_address *addr, char *hostname, jint hostname_len);
+JNIEXPORT void cpnet_freeAddresses(JNIEnv * env, cpnet_address **addr, jint addresses_count);
static inline cpnet_address *cpnet_newIPV4Address(JNIEnv * env)
{
@@ -130,14 +131,6 @@
JCL_free(env, addr);
}
-static void cpnet_freeAddresses(JNIEnv * env, cpnet_address **addr, jint addresses_count)
-{
- jint i;
-
- for (i = 0; i < addresses_count; i++)
- cpnet_freeAddress(env, addr[i]);
-}
-
static inline void cpnet_addressSetPort(cpnet_address *addr, jint port)
{
struct sockaddr_in *ipaddr = (struct sockaddr_in *)&(addr->data[0]);
Index: vm/reference/java/lang/VMProcess.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/VMProcess.java,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 VMProcess.java
--- vm/reference/java/lang/VMProcess.java 6 Jun 2006 20:30:38 -0000 1.7.2.2
+++ vm/reference/java/lang/VMProcess.java 21 Aug 2006 00:35:28 -0000
@@ -95,7 +95,6 @@
InputStream stdout; // process output stream
InputStream stderr; // process error stream
int exitValue; // process exit value
- boolean redirect; // redirect stderr -> stdout
//
// Dedicated thread that does all the fork()'ing and wait()'ing
@@ -200,8 +199,7 @@
{
try
{
- process.nativeSpawn(process.cmd, process.env, process.dir,
- process.redirect);
+ process.nativeSpawn(process.cmd, process.env, process.dir);
process.state = RUNNING;
activeMap.put(new Long(process.pid), process);
}
@@ -220,7 +218,7 @@
}
// Constructor
- private VMProcess(String[] cmd, String[] env, File dir, boolean redirect)
+ private VMProcess(String[] cmd, String[] env, File dir)
throws IOException
{
@@ -229,7 +227,6 @@
this.cmd = cmd;
this.env = env;
this.dir = dir;
- this.redirect = redirect;
// Add process to the new process work list and wakeup processThread
synchronized (workList)
@@ -304,11 +301,10 @@
*/
static Process exec(String[] cmd, String[] env, File dir) throws IOException
{
- return new VMProcess(cmd, env, dir, false);
+ return new VMProcess(cmd, env, dir);
}
- static Process exec(List cmd, Map env,
- File dir, boolean redirect) throws IOException
+ static Process exec(List cmd, Map env, File dir) throws IOException
{
String[] acmd = (String[]) cmd.toArray(new String[cmd.size()]);
String[] aenv = new String[env.size()];
@@ -321,7 +317,7 @@
aenv[i++] = entry.getKey() + "=" + entry.getValue();
}
- return new VMProcess(acmd, aenv, dir, redirect);
+ return new VMProcess(acmd, aenv, dir);
}
public OutputStream getOutputStream()
@@ -380,8 +376,7 @@
*
* @throws IOException if the O/S process could not be created.
*/
- native void nativeSpawn(String[] cmd, String[] env, File dir,
- boolean redirect)
+ native void nativeSpawn(String[] cmd, String[] env, File dir)
throws IOException;
/**