summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-05 15:57:13 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-05 15:57:13 +0000
commit3dbf7319f6bfc98d7cfc1318538554278e42648a (patch)
treeade62852d2118479bf46fcdfc3db7466a4d05e58
parentbce94ab50a172995b7fe80591b207cf1cf33a8e3 (diff)
downloadgcc-3dbf7319f6bfc98d7cfc1318538554278e42648a.tar.gz
* sources.am, Makefile.in: Rebuilt.
* scripts/makemake.tcl (emit_package_rule): Don't omit VMProcess.java. * Makefile.am (nat_source_files): Added natVMProcess.cc. (inner_nat_headers): Added ImmediateEOFInputStream.h. * gcj/javaprims.h: Regenerated. * java/lang/System.java (EnvironmentMap): Now package-private. (EnvironmentMap(Map)): New constructor. (EnvironmentMap.put): New method. * java/lang/natWin32Process.cc (startProcess): Update. * java/lang/Win32Process.java (Win32Process): Added 'redirect' argument. (startProcess): Likewise. * java/lang/EcosProcess.java (EcosProcess): Added 'redirect' argument. * java/lang/natPosixProcess.cc (nativeSpawn): Handle redirection. * java/lang/PosixProcess.java (redirect): New field. (PosixProcess): Added 'redirect' argument. * java/lang/natRuntime.cc (execInternal): Added 'redirect' argument to Process creation. * java/lang/natVMProcess.cc: New file. * java/lang/ProcessBuilder.java: Removed. * java/lang/VMProcess.java: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122553 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libjava/ChangeLog26
-rw-r--r--libjava/Makefile.am2
-rw-r--r--libjava/Makefile.in22
-rw-r--r--libjava/classpath/lib/java/lang/EcosProcess.classbin1047 -> 1073 bytes
-rw-r--r--libjava/classpath/lib/java/lang/PosixProcess$EOFInputStream.classbin567 -> 567 bytes
-rw-r--r--libjava/classpath/lib/java/lang/PosixProcess.classbin4143 -> 4197 bytes
-rw-r--r--libjava/classpath/lib/java/lang/ProcessBuilder.classbin2592 -> 2812 bytes
-rw-r--r--libjava/classpath/lib/java/lang/System$EnvironmentMap.classbin2592 -> 3407 bytes
-rw-r--r--libjava/classpath/lib/java/lang/System$EnvironmentSet.classbin1021 -> 1021 bytes
-rw-r--r--libjava/classpath/lib/java/lang/System.classbin5896 -> 5896 bytes
-rw-r--r--libjava/classpath/lib/java/lang/VMProcess.classbin0 -> 1926 bytes
-rw-r--r--libjava/classpath/lib/java/lang/Win32Process.classbin1711 -> 1739 bytes
-rw-r--r--libjava/gcj/javaprims.h3
-rw-r--r--libjava/java/lang/EcosProcess.h2
-rw-r--r--libjava/java/lang/EcosProcess.java7
-rw-r--r--libjava/java/lang/PosixProcess.h3
-rw-r--r--libjava/java/lang/PosixProcess.java8
-rw-r--r--libjava/java/lang/System$EnvironmentMap.h3
-rw-r--r--libjava/java/lang/System.java44
-rw-r--r--libjava/java/lang/VMProcess.h24
-rw-r--r--libjava/java/lang/VMProcess.java (renamed from libjava/java/lang/ProcessBuilder.java)92
-rw-r--r--libjava/java/lang/Win32Process.h4
-rw-r--r--libjava/java/lang/Win32Process.java14
-rw-r--r--libjava/java/lang/natPosixProcess.cc58
-rw-r--r--libjava/java/lang/natRuntime.cc4
-rw-r--r--libjava/java/lang/natVMProcess.cc34
-rw-r--r--libjava/java/lang/natWin32Process.cc7
-rwxr-xr-xlibjava/scripts/makemake.tcl2
-rw-r--r--libjava/sources.am5
29 files changed, 235 insertions, 129 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index c595a229d71..3f940e242ef 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,29 @@
+2007-03-05 Tom Tromey <tromey@redhat.com>
+
+ * sources.am, Makefile.in: Rebuilt.
+ * scripts/makemake.tcl (emit_package_rule): Don't omit
+ VMProcess.java.
+ * Makefile.am (nat_source_files): Added natVMProcess.cc.
+ (inner_nat_headers): Added ImmediateEOFInputStream.h.
+ * gcj/javaprims.h: Regenerated.
+ * java/lang/System.java (EnvironmentMap): Now package-private.
+ (EnvironmentMap(Map)): New constructor.
+ (EnvironmentMap.put): New method.
+ * java/lang/natWin32Process.cc (startProcess): Update.
+ * java/lang/Win32Process.java (Win32Process): Added 'redirect'
+ argument.
+ (startProcess): Likewise.
+ * java/lang/EcosProcess.java (EcosProcess): Added 'redirect'
+ argument.
+ * java/lang/natPosixProcess.cc (nativeSpawn): Handle redirection.
+ * java/lang/PosixProcess.java (redirect): New field.
+ (PosixProcess): Added 'redirect' argument.
+ * java/lang/natRuntime.cc (execInternal): Added 'redirect'
+ argument to Process creation.
+ * java/lang/natVMProcess.cc: New file.
+ * java/lang/ProcessBuilder.java: Removed.
+ * java/lang/VMProcess.java: New file.
+
2007-03-03 Andrew Haley <aph@redhat.com>
* java/lang/natClass.cc (parseAnnotationElement): Correct long
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index 9b87324e65a..3151444ccdf 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -406,6 +406,7 @@ inner_nat_headers = java/io/ObjectOutputStream$$PutField.h \
java/nio/DirectByteBufferImpl$$ReadWrite.h \
java/nio/channels/Pipe$$SinkChannel.h \
java/nio/channels/Pipe$$SourceChannel.h \
+ java/lang/VMProcess$ImmediateEOFInputStream.h \
java/lang/reflect/Proxy$$ProxyData.h \
java/lang/reflect/Proxy$$ProxyType.h \
gnu/java/net/PlainSocketImpl$$SocketInputStream.h \
@@ -883,6 +884,7 @@ java/lang/natSystem.cc \
java/lang/natThread.cc \
java/lang/natThreadLocal.cc \
java/lang/natVMClassLoader.cc \
+java/lang/natVMProcess.cc \
java/lang/natVMThrowable.cc \
java/lang/ref/natReference.cc \
java/lang/reflect/natArray.cc \
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index 99433510638..04d19c327ad 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -331,8 +331,9 @@ am__libgcj_la_SOURCES_DIST = prims.cc jni.cc jvmti.cc exception.cc \
java/lang/natString.cc java/lang/natStringBuffer.cc \
java/lang/natStringBuilder.cc java/lang/natSystem.cc \
java/lang/natThread.cc java/lang/natThreadLocal.cc \
- java/lang/natVMClassLoader.cc java/lang/natVMThrowable.cc \
- java/lang/ref/natReference.cc java/lang/reflect/natArray.cc \
+ java/lang/natVMClassLoader.cc java/lang/natVMProcess.cc \
+ java/lang/natVMThrowable.cc java/lang/ref/natReference.cc \
+ java/lang/reflect/natArray.cc \
java/lang/reflect/natConstructor.cc \
java/lang/reflect/natField.cc java/lang/reflect/natMethod.cc \
java/lang/reflect/natVMProxy.cc java/net/natVMInetAddress.cc \
@@ -393,8 +394,9 @@ am__objects_2 = gnu/classpath/jdwp/natVMFrame.lo \
java/lang/natString.lo java/lang/natStringBuffer.lo \
java/lang/natStringBuilder.lo java/lang/natSystem.lo \
java/lang/natThread.lo java/lang/natThreadLocal.lo \
- java/lang/natVMClassLoader.lo java/lang/natVMThrowable.lo \
- java/lang/ref/natReference.lo java/lang/reflect/natArray.lo \
+ java/lang/natVMClassLoader.lo java/lang/natVMProcess.lo \
+ java/lang/natVMThrowable.lo java/lang/ref/natReference.lo \
+ java/lang/reflect/natArray.lo \
java/lang/reflect/natConstructor.lo \
java/lang/reflect/natField.lo java/lang/reflect/natMethod.lo \
java/lang/reflect/natVMProxy.lo java/net/natVMInetAddress.lo \
@@ -4270,7 +4272,7 @@ classpath/java/lang/Override.java \
classpath/java/lang/Package.java \
java/lang/PosixProcess.java \
classpath/java/lang/Process.java \
-java/lang/ProcessBuilder.java \
+classpath/java/lang/ProcessBuilder.java \
classpath/java/lang/Readable.java \
classpath/java/lang/Runnable.java \
java/lang/Runtime.java \
@@ -4302,6 +4304,7 @@ java/lang/VMClassLoader.java \
java/lang/VMCompiler.java \
java/lang/VMDouble.java \
java/lang/VMFloat.java \
+java/lang/VMProcess.java \
java/lang/VMThrowable.java \
classpath/java/lang/VerifyError.java \
classpath/java/lang/VirtualMachineError.java \
@@ -7777,6 +7780,7 @@ inner_nat_headers = java/io/ObjectOutputStream$$PutField.h \
java/nio/DirectByteBufferImpl$$ReadWrite.h \
java/nio/channels/Pipe$$SinkChannel.h \
java/nio/channels/Pipe$$SourceChannel.h \
+ java/lang/VMProcess$ImmediateEOFInputStream.h \
java/lang/reflect/Proxy$$ProxyData.h \
java/lang/reflect/Proxy$$ProxyType.h \
gnu/java/net/PlainSocketImpl$$SocketInputStream.h \
@@ -7992,6 +7996,7 @@ java/lang/natSystem.cc \
java/lang/natThread.cc \
java/lang/natThreadLocal.cc \
java/lang/natVMClassLoader.cc \
+java/lang/natVMProcess.cc \
java/lang/natVMThrowable.cc \
java/lang/ref/natReference.cc \
java/lang/reflect/natArray.cc \
@@ -8503,6 +8508,8 @@ java/lang/natThreadLocal.lo: java/lang/$(am__dirstamp) \
java/lang/$(DEPDIR)/$(am__dirstamp)
java/lang/natVMClassLoader.lo: java/lang/$(am__dirstamp) \
java/lang/$(DEPDIR)/$(am__dirstamp)
+java/lang/natVMProcess.lo: java/lang/$(am__dirstamp) \
+ java/lang/$(DEPDIR)/$(am__dirstamp)
java/lang/natVMThrowable.lo: java/lang/$(am__dirstamp) \
java/lang/$(DEPDIR)/$(am__dirstamp)
java/lang/ref/$(am__dirstamp):
@@ -8950,6 +8957,8 @@ mostlyclean-compile:
-rm -f java/lang/natVMDouble.lo
-rm -f java/lang/natVMFloat.$(OBJEXT)
-rm -f java/lang/natVMFloat.lo
+ -rm -f java/lang/natVMProcess.$(OBJEXT)
+ -rm -f java/lang/natVMProcess.lo
-rm -f java/lang/natVMThrowable.$(OBJEXT)
-rm -f java/lang/natVMThrowable.lo
-rm -f java/lang/ref/natReference.$(OBJEXT)
@@ -9102,6 +9111,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@java/lang/$(DEPDIR)/natVMClassLoader.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@java/lang/$(DEPDIR)/natVMDouble.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@java/lang/$(DEPDIR)/natVMFloat.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@java/lang/$(DEPDIR)/natVMProcess.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@java/lang/$(DEPDIR)/natVMThrowable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@java/lang/ref/$(DEPDIR)/natReference.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@java/lang/reflect/$(DEPDIR)/natArray.Plo@am__quote@
@@ -11057,7 +11067,7 @@ java/io.list: $(java_io_source_files)
java/lang.list: $(java_lang_source_files)
@$(mkinstalldirs) $(dir $@)
- echo $(srcdir)/classpath/lib/java/lang/*.class | tr ' ' '\n' | fgrep -v Object.class | fgrep -v Class.class | grep -v '[^/]Process' > java/lang.list
+ echo $(srcdir)/classpath/lib/java/lang/*.class | tr ' ' '\n' | fgrep -v Object.class | fgrep -v Class.class | egrep -v '(Ecos|Posix|Win32)Process' > java/lang.list
-include java/lang.deps
diff --git a/libjava/classpath/lib/java/lang/EcosProcess.class b/libjava/classpath/lib/java/lang/EcosProcess.class
index f306e4c87af..84ef1599bf9 100644
--- a/libjava/classpath/lib/java/lang/EcosProcess.class
+++ b/libjava/classpath/lib/java/lang/EcosProcess.class
Binary files differ
diff --git a/libjava/classpath/lib/java/lang/PosixProcess$EOFInputStream.class b/libjava/classpath/lib/java/lang/PosixProcess$EOFInputStream.class
index 951dbfa9872..a7103f81a1c 100644
--- a/libjava/classpath/lib/java/lang/PosixProcess$EOFInputStream.class
+++ b/libjava/classpath/lib/java/lang/PosixProcess$EOFInputStream.class
Binary files differ
diff --git a/libjava/classpath/lib/java/lang/PosixProcess.class b/libjava/classpath/lib/java/lang/PosixProcess.class
index dc237fc1149..0227add131e 100644
--- a/libjava/classpath/lib/java/lang/PosixProcess.class
+++ b/libjava/classpath/lib/java/lang/PosixProcess.class
Binary files differ
diff --git a/libjava/classpath/lib/java/lang/ProcessBuilder.class b/libjava/classpath/lib/java/lang/ProcessBuilder.class
index 10bbc8183bd..d83d708d82e 100644
--- a/libjava/classpath/lib/java/lang/ProcessBuilder.class
+++ b/libjava/classpath/lib/java/lang/ProcessBuilder.class
Binary files differ
diff --git a/libjava/classpath/lib/java/lang/System$EnvironmentMap.class b/libjava/classpath/lib/java/lang/System$EnvironmentMap.class
index cb2f72235d9..04ee59d5597 100644
--- a/libjava/classpath/lib/java/lang/System$EnvironmentMap.class
+++ b/libjava/classpath/lib/java/lang/System$EnvironmentMap.class
Binary files differ
diff --git a/libjava/classpath/lib/java/lang/System$EnvironmentSet.class b/libjava/classpath/lib/java/lang/System$EnvironmentSet.class
index e5f8effefc8..32427879c13 100644
--- a/libjava/classpath/lib/java/lang/System$EnvironmentSet.class
+++ b/libjava/classpath/lib/java/lang/System$EnvironmentSet.class
Binary files differ
diff --git a/libjava/classpath/lib/java/lang/System.class b/libjava/classpath/lib/java/lang/System.class
index b2525559531..b3702178368 100644
--- a/libjava/classpath/lib/java/lang/System.class
+++ b/libjava/classpath/lib/java/lang/System.class
Binary files differ
diff --git a/libjava/classpath/lib/java/lang/VMProcess.class b/libjava/classpath/lib/java/lang/VMProcess.class
new file mode 100644
index 00000000000..5a13c775378
--- /dev/null
+++ b/libjava/classpath/lib/java/lang/VMProcess.class
Binary files differ
diff --git a/libjava/classpath/lib/java/lang/Win32Process.class b/libjava/classpath/lib/java/lang/Win32Process.class
index 4ee8415b917..ef70db74131 100644
--- a/libjava/classpath/lib/java/lang/Win32Process.class
+++ b/libjava/classpath/lib/java/lang/Win32Process.class
Binary files differ
diff --git a/libjava/gcj/javaprims.h b/libjava/gcj/javaprims.h
index 1e4e9488b59..715a96e026a 100644
--- a/libjava/gcj/javaprims.h
+++ b/libjava/gcj/javaprims.h
@@ -1,7 +1,7 @@
// javaprims.h - Main external header file for libgcj. -*- c++ -*-
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation
This file is part of libgcj.
@@ -248,6 +248,7 @@ extern "Java"
class VMCompiler;
class VMDouble;
class VMFloat;
+ class VMProcess;
class VMThrowable;
class VerifyError;
class VirtualMachineError;
diff --git a/libjava/java/lang/EcosProcess.h b/libjava/java/lang/EcosProcess.h
index 30fd067e034..a0173c30a1a 100644
--- a/libjava/java/lang/EcosProcess.h
+++ b/libjava/java/lang/EcosProcess.h
@@ -20,7 +20,7 @@ public:
::java::io::InputStream * getInputStream();
::java::io::OutputStream * getOutputStream();
jint waitFor();
- EcosProcess(JArray< ::java::lang::String * > *, JArray< ::java::lang::String * > *, ::java::io::File *);
+ EcosProcess(JArray< ::java::lang::String * > *, JArray< ::java::lang::String * > *, ::java::io::File *, jboolean);
static ::java::lang::Class class$;
};
diff --git a/libjava/java/lang/EcosProcess.java b/libjava/java/lang/EcosProcess.java
index 30c8253e67d..79c2f12a55a 100644
--- a/libjava/java/lang/EcosProcess.java
+++ b/libjava/java/lang/EcosProcess.java
@@ -1,6 +1,6 @@
// EcosProcess.java - Subclass of Process for eCos systems.
-/* Copyright (C) 1998, 1999, 2006 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2006, 2007 Free Software Foundation
This file is part of libgcj.
@@ -51,9 +51,8 @@ final class EcosProcess extends Process
return 0;
}
- public EcosProcess (String[] progarray,
- String[] envp,
- File dir)
+ public EcosProcess (String[] progarray, String[] envp, File dir,
+ boolean redirect)
throws IOException
{
throw new IOException ("eCos processes unimplemented");
diff --git a/libjava/java/lang/PosixProcess.h b/libjava/java/lang/PosixProcess.h
index 62539ceb2ac..a43fa0739d5 100644
--- a/libjava/java/lang/PosixProcess.h
+++ b/libjava/java/lang/PosixProcess.h
@@ -31,7 +31,7 @@ public: // actually package-private
private:
void nativeSpawn();
public: // actually package-private
- PosixProcess(JArray< ::java::lang::String * > *, JArray< ::java::lang::String * > *, ::java::io::File *);
+ PosixProcess(JArray< ::java::lang::String * > *, JArray< ::java::lang::String * > *, ::java::io::File *, jboolean);
static jlong access$0(::java::lang::PosixProcess *);
static ::java::lang::Object * access$1();
static void access$2(::java::lang::PosixProcess$ProcessManager *);
@@ -39,6 +39,7 @@ private:
JArray< ::java::lang::String * > * __attribute__((aligned(__alignof__( ::java::lang::Process)))) progarray;
JArray< ::java::lang::String * > * envp;
::java::io::File * dir;
+ jboolean redirect;
::java::lang::Throwable * exception;
jlong pid;
public: // actually package-private
diff --git a/libjava/java/lang/PosixProcess.java b/libjava/java/lang/PosixProcess.java
index 517e6f33f92..6b1496426dd 100644
--- a/libjava/java/lang/PosixProcess.java
+++ b/libjava/java/lang/PosixProcess.java
@@ -1,5 +1,5 @@
// PosixProcess.java - Subclass of Process for POSIX systems.
-/* Copyright (C) 1998, 1999, 2004, 2006 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2004, 2006, 2007 Free Software Foundation
This file is part of libgcj.
@@ -354,8 +354,8 @@ final class PosixProcess extends Process
*/
private native void nativeSpawn();
- PosixProcess(String[] progarray, String[] envp, File dir)
- throws IOException
+ PosixProcess(String[] progarray, String[] envp, File dir, boolean redirect)
+ throws IOException
{
// Check to ensure there is something to run, and avoid
// dereferencing null pointers in native code.
@@ -365,6 +365,7 @@ final class PosixProcess extends Process
this.progarray = progarray;
this.envp = envp;
this.dir = dir;
+ this.redirect = redirect;
// Start a ProcessManager if there is not one already running.
synchronized (queueLock)
@@ -419,6 +420,7 @@ final class PosixProcess extends Process
private String[] progarray;
private String[] envp;
private File dir;
+ private boolean redirect;
/** Set by the ProcessManager on problems starting. */
private Throwable exception;
diff --git a/libjava/java/lang/System$EnvironmentMap.h b/libjava/java/lang/System$EnvironmentMap.h
index ee4582b43fb..1220f57e28f 100644
--- a/libjava/java/lang/System$EnvironmentMap.h
+++ b/libjava/java/lang/System$EnvironmentMap.h
@@ -13,16 +13,19 @@ class java::lang::System$EnvironmentMap : public ::java::util::HashMap
public: // actually package-private
System$EnvironmentMap();
+ System$EnvironmentMap(::java::util::Map *);
public:
virtual jboolean containsKey(::java::lang::Object *);
virtual jboolean containsValue(::java::lang::Object *);
virtual ::java::util::Set * entrySet();
virtual ::java::lang::String * target$get(::java::lang::Object *);
virtual ::java::util::Set * keySet();
+ virtual ::java::lang::String * target$put(::java::lang::String *, ::java::lang::String *);
virtual ::java::lang::String * target$remove(::java::lang::Object *);
virtual ::java::util::Collection * values();
virtual ::java::lang::Object * get(::java::lang::Object *);
virtual ::java::lang::Object * remove(::java::lang::Object *);
+ virtual ::java::lang::Object * put(::java::lang::Object *, ::java::lang::Object *);
private:
::java::util::Set * __attribute__((aligned(__alignof__( ::java::util::HashMap)))) entries;
::java::util::Set * keys;
diff --git a/libjava/java/lang/System.java b/libjava/java/lang/System.java
index 76a39f0d3f2..b516a513e75 100644
--- a/libjava/java/lang/System.java
+++ b/libjava/java/lang/System.java
@@ -828,7 +828,7 @@ public final class System
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
*/
- private static class EnvironmentMap
+ static class EnvironmentMap
extends HashMap<String,String>
{
@@ -854,7 +854,20 @@ public final class System
{
super();
}
-
+
+ /**
+ * Constructs a new <code>EnvironmentMap</code> containing
+ * the contents of the specified map.
+ *
+ * @param m the map to be added to this.
+ * @throws NullPointerException if a key or value is null.
+ * @throws ClassCastException if a key or value is not a String.
+ */
+ EnvironmentMap(Map<String,String> m)
+ {
+ super(m);
+ }
+
/**
* Blocks queries containing a null key or one which is not
* of type <code>String</code>. All other queries
@@ -939,7 +952,32 @@ public final class System
keys = new EnvironmentSet(super.keySet());
return keys;
}
-
+
+ /**
+ * Associates the given key to the given value. If the
+ * map already contains the key, its value is replaced.
+ * The map does not accept null keys or values, or keys
+ * and values not of type {@link String}.
+ *
+ * @param key the key to map.
+ * @param value the value to be mapped.
+ * @return the previous value of the key, or null if there was no mapping
+ * @throws NullPointerException if a key or value is null.
+ * @throws ClassCastException if a key or value is not a String.
+ */
+ public String put(String key, String value)
+ {
+ if (key == null)
+ throw new NullPointerException("A new key is null.");
+ if (value == null)
+ throw new NullPointerException("A new value is null.");
+ if (!(key instanceof String))
+ throw new ClassCastException("A new key is not a String.");
+ if (!(value instanceof String))
+ throw new ClassCastException("A new value is not a String.");
+ return super.put(key, value);
+ }
+
/**
* Removes a key-value pair from the map. The queried key may not
* be null or of a type other than a <code>String</code>.
diff --git a/libjava/java/lang/VMProcess.h b/libjava/java/lang/VMProcess.h
new file mode 100644
index 00000000000..c0912e5c21e
--- /dev/null
+++ b/libjava/java/lang/VMProcess.h
@@ -0,0 +1,24 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_lang_VMProcess__
+#define __java_lang_VMProcess__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+
+class java::lang::VMProcess : public ::java::lang::Object
+{
+
+public: // actually package-private
+ VMProcess();
+ static ::java::lang::Process * nativeExec(JArray< ::java::lang::String * > *, JArray< ::java::lang::String * > *, ::java::io::File *, jboolean);
+ static ::java::lang::Process * exec(::java::util::List *, ::java::util::Map *, ::java::io::File *, jboolean);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_lang_VMProcess__
diff --git a/libjava/java/lang/ProcessBuilder.java b/libjava/java/lang/VMProcess.java
index 440e5e0b48d..c0c7bebc10c 100644
--- a/libjava/java/lang/ProcessBuilder.java
+++ b/libjava/java/lang/VMProcess.java
@@ -1,5 +1,5 @@
-/* ProcessBuilder.java - Represent spawned system process
- Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* java.lang.VMProcess -- VM implementation of java.lang.ProcessBuilder
+ Copyright (C) 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,84 +35,34 @@ 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. */
-
package java.lang;
import java.io.File;
import java.io.IOException;
-import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
-public final class ProcessBuilder
+final class VMProcess
{
- private File directory = new File(System.getProperty("user.dir"));
- private List<String> command;
- // FIXME: make a copy.
- private Map<String, String> environment = System.getenv();
- private boolean redirect = false;
-
- public ProcessBuilder(List<String> command)
- {
- this.command = command;
- }
-
- public ProcessBuilder(String... command)
- {
- this.command = Arrays.asList(command);
- }
-
- public List<String> command()
- {
- return command;
- }
-
- public ProcessBuilder command(List<String> command)
- {
- this.command = command;
- return this;
- }
-
- public ProcessBuilder command(String... command)
- {
- this.command = Arrays.asList(command);
- return this;
- }
-
- public File directory()
- {
- return directory;
- }
-
- public ProcessBuilder directory(File directory)
- {
- this.directory = directory;
- return this;
- }
-
- public Map<String, String> environment()
- {
- return environment;
- }
-
- public boolean redirectErrorStream()
- {
- return redirect;
- }
-
- public ProcessBuilder redirectErrorStream(boolean redirect)
- {
- this.redirect = redirect;
- return this;
- }
+ static native Process nativeExec(String[] cmd, String[] env,
+ File dir, boolean redirect)
+ throws IOException;
- public Process start() throws IOException
+ static Process exec(List<String> cmd, Map<String, String> env,
+ File dir, boolean redirect) throws IOException
{
- SecurityManager sm = SecurityManager.current; // Be thread-safe!
- if (sm != null)
- sm.checkExec(command.get(0));
- // return VMProcess.exec(command, environment, directory, redirect);
- // FIXME
- return null;
+ String[] acmd = (String[]) cmd.toArray(new String[cmd.size()]);
+ String[] aenv = new String[env.size()];
+
+ int i = 0;
+ Iterator iter = env.entrySet().iterator();
+ while (iter.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) iter.next();
+ aenv[i++] = entry.getKey() + "=" + entry.getValue();
+ }
+
+ return nativeExec(acmd, aenv, dir, redirect);
}
}
diff --git a/libjava/java/lang/Win32Process.h b/libjava/java/lang/Win32Process.h
index 0b49c6e9c33..5e22934a990 100644
--- a/libjava/java/lang/Win32Process.h
+++ b/libjava/java/lang/Win32Process.h
@@ -20,10 +20,10 @@ public:
::java::io::InputStream * getInputStream();
::java::io::OutputStream * getOutputStream();
jint waitFor();
- Win32Process(JArray< ::java::lang::String * > *, JArray< ::java::lang::String * > *, ::java::io::File *);
+ Win32Process(JArray< ::java::lang::String * > *, JArray< ::java::lang::String * > *, ::java::io::File *, jboolean);
private:
jboolean hasExited();
- void startProcess(JArray< ::java::lang::String * > *, JArray< ::java::lang::String * > *, ::java::io::File *);
+ void startProcess(JArray< ::java::lang::String * > *, JArray< ::java::lang::String * > *, ::java::io::File *, jboolean);
void cleanup();
::java::io::OutputStream * __attribute__((aligned(__alignof__( ::java::lang::Process)))) outputStream;
::java::io::InputStream * inputStream;
diff --git a/libjava/java/lang/Win32Process.java b/libjava/java/lang/Win32Process.java
index 7d9e40fce4a..e817a0c9090 100644
--- a/libjava/java/lang/Win32Process.java
+++ b/libjava/java/lang/Win32Process.java
@@ -1,6 +1,6 @@
// Win32Process.java - Subclass of Process for Win32 systems.
-/* Copyright (C) 2002, 2003, 2006 Free Software Foundation
+/* Copyright (C) 2002, 2003, 2006, 2007 Free Software Foundation
This file is part of libgcj.
@@ -51,9 +51,8 @@ final class Win32Process extends Process
public native int waitFor () throws InterruptedException;
- public Win32Process (String[] progarray,
- String[] envp,
- File dir)
+ public Win32Process (String[] progarray, String[] envp, File dir,
+ boolean redirect)
throws IOException
{
for (int i = 0; i < progarray.length; i++)
@@ -64,7 +63,7 @@ final class Win32Process extends Process
progarray[i] = "\"" + s + "\"";
}
- startProcess (progarray, envp, dir);
+ startProcess (progarray, envp, dir, redirect);
}
// The standard streams (stdin, stdout and stderr, respectively)
@@ -81,8 +80,9 @@ final class Win32Process extends Process
private native boolean hasExited ();
private native void startProcess (String[] progarray,
- String[] envp,
- File dir)
+ String[] envp,
+ File dir,
+ boolean redirect)
throws IOException;
private native void cleanup ();
}
diff --git a/libjava/java/lang/natPosixProcess.cc b/libjava/java/lang/natPosixProcess.cc
index 498647036c5..149b5d8ba34 100644
--- a/libjava/java/lang/natPosixProcess.cc
+++ b/libjava/java/lang/natPosixProcess.cc
@@ -1,6 +1,6 @@
// natPosixProcess.cc - Native side of POSIX process code.
-/* Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation
This file is part of libgcj.
@@ -41,6 +41,7 @@ details. */
#include <java/io/FileOutputStream.h>
#include <java/io/IOException.h>
#include <java/lang/OutOfMemoryError.h>
+#include <java/lang/PosixProcess$EOFInputStream.h>
using gnu::java::nio::channels::FileChannelImpl;
@@ -231,7 +232,7 @@ java::lang::PosixProcess::nativeSpawn ()
try
{
// Transform arrays to native form.
- args = (char **) _Jv_Malloc ((progarray->length + 1) * sizeof (char *));
+ args = (char **) _Jv_Malloc ((progarray->length + 1) * sizeof (char *));
// Initialize so we can gracefully recover.
jstring *elts = elements (progarray);
@@ -262,23 +263,30 @@ java::lang::PosixProcess::nativeSpawn ()
path = new_string (dir->getPath ());
// Create pipes for I/O. MSGP is for communicating exec()
- // status.
- if (pipe (inp) || pipe (outp) || pipe (errp) || pipe (msgp)
+ // status. If redirecting stderr to stdout, we don't need to
+ // create the ERRP pipe.
+ if (pipe (inp) || pipe (outp) || pipe (msgp)
|| fcntl (msgp[1], F_SETFD, FD_CLOEXEC))
- throw new IOException (JvNewStringUTF (strerror (errno)));
+ throw new IOException (JvNewStringUTF (strerror (errno)));
+ if (! redirect && pipe (errp))
+ throw new IOException (JvNewStringUTF (strerror (errno)));
// We create the streams before forking. Otherwise if we had an
// error while creating the streams we would have run the child
// with no way to communicate with it.
- errorStream =
- new FileInputStream (new
- FileChannelImpl (errp[0], FileChannelImpl::READ));
- inputStream =
- new FileInputStream (new
- FileChannelImpl (inp[0], FileChannelImpl::READ));
- outputStream =
- new FileOutputStream (new FileChannelImpl (outp[1],
- FileChannelImpl::WRITE));
+ if (redirect)
+ errorStream = PosixProcess$EOFInputStream::instance;
+ else
+ errorStream =
+ new FileInputStream (new
+ FileChannelImpl (errp[0],
+ FileChannelImpl::READ));
+ inputStream =
+ new FileInputStream (new
+ FileChannelImpl (inp[0], FileChannelImpl::READ));
+ outputStream =
+ new FileOutputStream (new FileChannelImpl (outp[1],
+ FileChannelImpl::WRITE));
// We don't use vfork() because that would cause the local
// environment to be set by the child.
@@ -319,14 +327,17 @@ java::lang::PosixProcess::nativeSpawn ()
// We ignore errors from dup2 because they should never occur.
dup2 (outp[0], 0);
dup2 (inp[1], 1);
- dup2 (errp[1], 2);
+ dup2 (redirect ? inp[1] : errp[1], 2);
// Use close and not myclose -- we're in the child, and we
// aren't worried about the possible race condition.
close (inp[0]);
close (inp[1]);
- close (errp[0]);
- close (errp[1]);
+ if (! redirect)
+ {
+ close (errp[0]);
+ close (errp[1]);
+ }
close (outp[0]);
close (outp[1]);
close (msgp[0]);
@@ -362,7 +373,8 @@ java::lang::PosixProcess::nativeSpawn ()
myclose (outp[0]);
myclose (inp[1]);
- myclose (errp[1]);
+ if (! redirect)
+ myclose (errp[1]);
myclose (msgp[1]);
char c;
@@ -406,7 +418,7 @@ java::lang::PosixProcess::nativeSpawn ()
{
if (errorStream != NULL)
errorStream->close ();
- else
+ else if (! redirect)
myclose (errp[0]);
}
catch (java::lang::Throwable *ignore)
@@ -417,10 +429,11 @@ java::lang::PosixProcess::nativeSpawn ()
// the use of myclose.
myclose (outp[0]);
myclose (inp[1]);
- myclose (errp[1]);
+ if (! redirect)
+ myclose (errp[1]);
myclose (msgp[1]);
- exception = thrown;
+ exception = thrown;
}
myclose (msgp[0]);
@@ -430,6 +443,7 @@ java::lang::PosixProcess::nativeSpawn ()
{
fcntl (outp[1], F_SETFD, FD_CLOEXEC);
fcntl (inp[0], F_SETFD, FD_CLOEXEC);
- fcntl (errp[0], F_SETFD, FD_CLOEXEC);
+ if (! redirect)
+ fcntl (errp[0], F_SETFD, FD_CLOEXEC);
}
}
diff --git a/libjava/java/lang/natRuntime.cc b/libjava/java/lang/natRuntime.cc
index 64c8fbb3f90..02842b1dfda 100644
--- a/libjava/java/lang/natRuntime.cc
+++ b/libjava/java/lang/natRuntime.cc
@@ -1,6 +1,6 @@
// natRuntime.cc - Implementation of native side of Runtime class.
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation
This file is part of libgcj.
@@ -297,7 +297,7 @@ java::lang::Runtime::execInternal (jstringArray cmd,
jstringArray env,
java::io::File *dir)
{
- return new _Jv_platform_process (cmd, env, dir);
+ return new _Jv_platform_process (cmd, env, dir, false);
}
jint
diff --git a/libjava/java/lang/natVMProcess.cc b/libjava/java/lang/natVMProcess.cc
new file mode 100644
index 00000000000..0a14465c4bb
--- /dev/null
+++ b/libjava/java/lang/natVMProcess.cc
@@ -0,0 +1,34 @@
+// natVMProcess.cc - native code for ProcessBuilder
+
+/* Copyright (C) 2007 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 <config.h>
+
+#include <gcj/cni.h>
+#include <jvm.h>
+
+#include <platform.h>
+
+#include <java/lang/VMProcess.h>
+#include <java/lang/Process.h>
+#include <java/io/File.h>
+
+// It is convenient and safe to simply include all of these.
+#include <java/lang/Win32Process.h>
+#include <java/lang/EcosProcess.h>
+#include <java/lang/PosixProcess.h>
+
+::java::lang::Process *
+java::lang::VMProcess::nativeExec (jstringArray cmd,
+ jstringArray env,
+ ::java::io::File *dir,
+ jboolean redirect)
+{
+ return new _Jv_platform_process (cmd, env, dir, redirect);
+}
diff --git a/libjava/java/lang/natWin32Process.cc b/libjava/java/lang/natWin32Process.cc
index d07f501366b..c836b5630f5 100644
--- a/libjava/java/lang/natWin32Process.cc
+++ b/libjava/java/lang/natWin32Process.cc
@@ -1,6 +1,6 @@
// natWin32Process.cc - Native side of Win32 process code.
-/* Copyright (C) 2003, 2006 Free Software Foundation
+/* Copyright (C) 2003, 2006, 2007 Free Software Foundation
This file is part of libgcj.
@@ -210,8 +210,9 @@ HANDLE ChildProcessPipe::getChildHandle()
void
java::lang::Win32Process::startProcess (jstringArray progarray,
- jstringArray envp,
- java::io::File *dir)
+ jstringArray envp,
+ java::io::File *dir,
+ jboolean redirect)
{
using namespace java::io;
diff --git a/libjava/scripts/makemake.tcl b/libjava/scripts/makemake.tcl
index 59a5915a5fe..4ac29a5fa30 100755
--- a/libjava/scripts/makemake.tcl
+++ b/libjava/scripts/makemake.tcl
@@ -304,7 +304,7 @@ proc emit_package_rule {package} {
# Object and Class are special cases due to an apparent compiler
# bug. Process is a special case because we don't build all
# concrete implementations of Process on all platforms.
- set omit "| tr ' ' '\\n' | fgrep -v Object.class | fgrep -v Class.class | grep -v '\[^/\]Process' "
+ set omit "| tr ' ' '\\n' | fgrep -v Object.class | fgrep -v Class.class | egrep -v '\(Ecos\|Posix\|Win32\)Process' "
} else {
set omit ""
}
diff --git a/libjava/sources.am b/libjava/sources.am
index e9adc2178f7..4bf9956f161 100644
--- a/libjava/sources.am
+++ b/libjava/sources.am
@@ -4721,7 +4721,7 @@ classpath/java/lang/Override.java \
classpath/java/lang/Package.java \
java/lang/PosixProcess.java \
classpath/java/lang/Process.java \
-java/lang/ProcessBuilder.java \
+classpath/java/lang/ProcessBuilder.java \
classpath/java/lang/Readable.java \
classpath/java/lang/Runnable.java \
java/lang/Runtime.java \
@@ -4753,6 +4753,7 @@ java/lang/VMClassLoader.java \
java/lang/VMCompiler.java \
java/lang/VMDouble.java \
java/lang/VMFloat.java \
+java/lang/VMProcess.java \
java/lang/VMThrowable.java \
classpath/java/lang/VerifyError.java \
classpath/java/lang/VirtualMachineError.java \
@@ -4763,7 +4764,7 @@ java_lang_header_files = $(filter-out java/lang/Object.h java/lang/Class.h,$(pat
java/lang.list: $(java_lang_source_files)
@$(mkinstalldirs) $(dir $@)
- echo $(srcdir)/classpath/lib/java/lang/*.class | tr ' ' '\n' | fgrep -v Object.class | fgrep -v Class.class | grep -v '[^/]Process' > java/lang.list
+ echo $(srcdir)/classpath/lib/java/lang/*.class | tr ' ' '\n' | fgrep -v Object.class | fgrep -v Class.class | egrep -v '(Ecos|Posix|Win32)Process' > java/lang.list
-include java/lang.deps