sources.am, [...]: Rebuilt.
* 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. From-SVN: r122553
This commit is contained in:
parent
344189f9ec
commit
f4a2a1deec
@ -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
|
||||
|
@ -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 \
|
||||
|
@ -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
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libjava/classpath/lib/java/lang/VMProcess.class
Normal file
BIN
libjava/classpath/lib/java/lang/VMProcess.class
Normal file
Binary file not shown.
Binary file not shown.
@ -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;
|
||||
|
@ -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$;
|
||||
};
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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>.
|
||||
|
24
libjava/java/lang/VMProcess.h
Normal file
24
libjava/java/lang/VMProcess.h
Normal file
@ -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__
|
@ -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;
|
||||
static native Process nativeExec(String[] cmd, String[] env,
|
||||
File dir, boolean redirect)
|
||||
throws IOException;
|
||||
|
||||
public ProcessBuilder(List<String> command)
|
||||
static Process exec(List<String> cmd, Map<String, String> env,
|
||||
File dir, boolean redirect) throws IOException
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
String[] acmd = (String[]) cmd.toArray(new String[cmd.size()]);
|
||||
String[] aenv = new String[env.size()];
|
||||
|
||||
public ProcessBuilder(String... command)
|
||||
{
|
||||
this.command = Arrays.asList(command);
|
||||
}
|
||||
int i = 0;
|
||||
Iterator iter = env.entrySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Map.Entry entry = (Map.Entry) iter.next();
|
||||
aenv[i++] = entry.getKey() + "=" + entry.getValue();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Process start() 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;
|
||||
return nativeExec(acmd, aenv, dir, redirect);
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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 ();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
34
libjava/java/lang/natVMProcess.cc
Normal file
34
libjava/java/lang/natVMProcess.cc
Normal file
@ -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);
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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 ""
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user