This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[ecj] Patch: FYI: change how Process is built
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 10 Oct 2006 20:41:35 -0600
- Subject: [ecj] Patch: FYI: change how Process is built
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcj-eclipse branch.
This is a step toward checking in .class and .h files. This removes
the one instance of a certain kind of conditional compilation of a
.java file in our tree. Now all our .class files should be platform
independent.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* gcj/javaprims.h: Updated.
* sources.am, Makefile.in: Rebuilt.
* standard.omit.in: Removed process source files.
* scripts/makemake.tcl: Removed ConcreteProcess special case.
(emit_package_rule): Also special-case Process.
(emit_process_package_rule): New proc.
* Makefile.am (inner_nat_headers): Removed
PLATFORM_INNER_NAT_HDRS.
* configure: Rebuilt.
* configure.ac (PLATFORM_INNER_NAT_HDRS): Removed subst.
Don't create ConcreteProcess.java link.
(PLATFORM): New subst.
* java/lang/natWin32Process.cc: Updated.
* java/lang/natPosixProcess.cc: Updated.
* java/lang/natEcosProcess.cc: Updated.
* java/lang/Win32Process.java (Win32Process): Renamed from
ConcreteProcess.
* java/lang/EcosProcess.java (EcosProcess): Renamed from
ConcreteProcess.
* java/lang/PosixProcess.java (PosixProcess): Renamed from
ConcreteProcess.
* include/win32.h (_Jv_platform_process): New define.
* java/lang/natRuntime.cc (execInternal): Use
_Jv_platform_process.
* include/posix.h (_Jv_platform_process): New define.
Index: scripts/makemake.tcl
===================================================================
--- scripts/makemake.tcl (revision 117511)
+++ scripts/makemake.tcl (working copy)
@@ -271,9 +271,11 @@
set lname $base.list
set dname $base.deps
- # A special case due to an apparent compiler bug.
if {$pkgname == "java/lang"} {
- set omit "| tr ' ' '\\n' | fgrep -v Object.class | fgrep -v Class.class "
+ # 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' "
} else {
set omit ""
}
@@ -293,6 +295,22 @@
}
}
+# Emit a package-like rule for a platform-specific Process
+# implementation.
+proc emit_process_package_rule {platform} {
+ set base "java/process-$platform"
+ set lname $base.list
+ set dname $base.deps
+
+ puts "$lname: java/lang/${platform}Process.java"
+ puts "\t@\$(mkinstalldirs) \$(dir \$@)"
+ puts "\techo classpath/lib/java/lang/${platform}Process*.class > $lname"
+ puts ""
+ puts "-include $dname"
+ puts ""
+ puts ""
+}
+
# Emit a source file variable for a package, and corresponding header
# file variable, if needed.
proc emit_source_var {package} {
@@ -379,7 +397,6 @@
# when scanning classpath.
scan_packages .
# Files created by the build.
-classify_source_file . java/lang/ConcreteProcess.java
classify_source_file classpath gnu/java/locale/LocaleData.java
classify_source_file classpath gnu/classpath/Configuration.java
@@ -408,6 +425,10 @@
}
}
+emit_process_package_rule Ecos
+emit_process_package_rule Win32
+emit_process_package_rule Posix
+
pp_var all_packages_source_files $package_files
pp_var ordinary_header_files $header_vars "\$(" ")"
pp_var bc_objects $bc_objects
Index: gcj/javaprims.h
===================================================================
--- gcj/javaprims.h (revision 117511)
+++ gcj/javaprims.h (working copy)
@@ -162,11 +162,9 @@
class Cloneable;
class Comparable;
class Compiler;
- class ConcreteProcess;
- class ConcreteProcess$EOFInputStream;
- class ConcreteProcess$ProcessManager;
class Deprecated;
class Double;
+ class EcosProcess;
class Enum;
class EnumConstantNotPresentException;
class Error;
@@ -204,6 +202,9 @@
class OutOfMemoryError;
class Override;
class Package;
+ class PosixProcess;
+ class PosixProcess$EOFInputStream;
+ class PosixProcess$ProcessManager;
class Process;
class ProcessBuilder;
class Readable;
@@ -250,6 +251,7 @@
class VerifyError;
class VirtualMachineError;
class Void;
+ class Win32Process;
namespace annotation
{
class Annotation;
Index: configure.ac
===================================================================
--- configure.ac (revision 117511)
+++ configure.ac (working copy)
@@ -612,7 +612,6 @@
TARGET_ECOS="$with_ecos"
)
-PLATFORM_INNER_NAT_HDRS=
case "$TARGET_ECOS" in
no) case "$host" in
*mingw*)
@@ -625,7 +624,6 @@
PLATFORM=Posix
PLATFORMNET=Posix
PLATFORMH=posix.h
- PLATFORM_INNER_NAT_HDRS='java/lang/ConcreteProcess$$ProcessManager.h'
;;
esac
;;
@@ -636,7 +634,7 @@
PLATFORMH=posix.h
;;
esac
-AC_SUBST(PLATFORM_INNER_NAT_HDRS)
+AC_SUBST(PLATFORM)
AC_CONFIG_LINKS(include/platform.h:include/$PLATFORMH)
AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1,
@@ -671,9 +669,8 @@
test -d gnu || mkdir gnu
AC_CONFIG_LINKS(java/io/natFile.cc:java/io/natFile${FILE-${PLATFORM}}.cc)
-# Likewise for ConcreteProcess.java and natConcreteProcess.cc.
+# Likewise for natConcreteProcess.cc.
test -d java/lang || mkdir java/lang
-AC_CONFIG_LINKS(java/lang/ConcreteProcess.java:java/lang/${PLATFORM}Process.java)
AC_CONFIG_LINKS(java/lang/natConcreteProcess.cc:java/lang/nat${PLATFORM}Process.cc)
# Likewise for natInetAddress.cc and natVMNetworkInterface.cc.
Index: java/lang/natEcosProcess.cc
===================================================================
--- java/lang/natEcosProcess.cc (revision 117511)
+++ java/lang/natEcosProcess.cc (working copy)
@@ -1,6 +1,6 @@
// natEcosProcess.cc - Native side of eCos processes.
-/* Copyright (C) 1998, 1999 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2006 Free Software Foundation
This file is part of libgcj.
@@ -17,9 +17,9 @@
#include <gcj/cni.h>
#include <jvm.h>
-#include <java/lang/ConcreteProcess.h>
+#include <java/lang/EcosProcess.h>
void
-java::lang::ConcreteProcess::destroy (void)
+java::lang::EcosProcess::destroy (void)
{
}
Index: java/lang/EcosProcess.java
===================================================================
--- java/lang/EcosProcess.java (revision 117511)
+++ java/lang/EcosProcess.java (working copy)
@@ -1,6 +1,6 @@
// EcosProcess.java - Subclass of Process for eCos systems.
-/* Copyright (C) 1998, 1999 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2006 Free Software Foundation
This file is part of libgcj.
@@ -22,9 +22,7 @@
// This is entirely internal to our implementation.
-// This file is copied to `ConcreteProcess.java' before compilation.
-// Hence the class name apparently does not match the file name.
-final class ConcreteProcess extends Process
+final class EcosProcess extends Process
{
// See natEcosProcess.cc to understand why this is native.
public native void destroy ();
@@ -53,7 +51,7 @@
return 0;
}
- public ConcreteProcess (String[] progarray,
+ public EcosProcess (String[] progarray,
String[] envp,
File dir)
throws IOException
Index: java/lang/natRuntime.cc
===================================================================
--- java/lang/natRuntime.cc (revision 117511)
+++ java/lang/natRuntime.cc (working copy)
@@ -26,9 +26,13 @@
#include <java/util/TimeZone.h>
#include <java/lang/StringBuffer.h>
#include <java/lang/Process.h>
-#include <java/lang/ConcreteProcess.h>
#include <java/lang/ClassLoader.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>
+
#include <jni.h>
#ifdef HAVE_PWD_H
@@ -286,7 +290,7 @@
jstringArray env,
java::io::File *dir)
{
- return new java::lang::ConcreteProcess (cmd, env, dir);
+ return new _Jv_platform_process (cmd, env, dir);
}
jint
Index: java/lang/Win32Process.java
===================================================================
--- java/lang/Win32Process.java (revision 117511)
+++ java/lang/Win32Process.java (working copy)
@@ -1,6 +1,6 @@
// Win32Process.java - Subclass of Process for Win32 systems.
-/* Copyright (C) 2002, 2003 Free Software Foundation
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation
This file is part of libgcj.
@@ -22,9 +22,7 @@
// This is entirely internal to our implementation.
-// This file is copied to `ConcreteProcess.java' before compilation.
-// Hence the class name apparently does not match the file name.
-final class ConcreteProcess extends Process
+final class Win32Process extends Process
{
public native void destroy ();
@@ -53,7 +51,7 @@
public native int waitFor () throws InterruptedException;
- public ConcreteProcess (String[] progarray,
+ public Win32Process (String[] progarray,
String[] envp,
File dir)
throws IOException
Index: java/lang/PosixProcess.java
===================================================================
--- java/lang/PosixProcess.java (revision 117511)
+++ java/lang/PosixProcess.java (working copy)
@@ -1,5 +1,5 @@
// PosixProcess.java - Subclass of Process for POSIX systems.
-/* Copyright (C) 1998, 1999, 2004 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2004, 2006 Free Software Foundation
This file is part of libgcj.
@@ -25,19 +25,15 @@
* @author David Daney <ddaney@avtrex.com> Rewrote using
* ProcessManager
*/
-
-// This is entirely internal to our implementation.
-// This file is copied to `ConcreteProcess.java' before compilation.
-// Hence the class name apparently does not match the file name.
-final class ConcreteProcess extends Process
+final class PosixProcess extends Process
{
static class ProcessManager extends Thread
{
/**
- * A list of {@link ConcreteProcess ConcreteProcesses} to be
+ * A list of {@link PosixProcess PosixProcesses} to be
* started. The queueLock object is used as the lock Object
* for all process related operations. To avoid dead lock
- * ensure queueLock is obtained before ConcreteProcess.
+ * ensure queueLock is obtained before PosixProcess.
*/
List queue = new LinkedList();
private Map pidToProcess = new HashMap();
@@ -52,37 +48,37 @@
}
/**
- * Get the ConcreteProcess object with the given pid and
+ * Get the PosixProcess object with the given pid and
* remove it from the map. This method is called from the
* native code for {@link #reap()). The mapping is removed so
- * the ConcreteProcesses can be GCed after they terminate.
+ * the PosixProcesses can be GCed after they terminate.
*
* @param p The pid of the process.
*/
- private ConcreteProcess removeProcessFromMap(long p)
+ private PosixProcess removeProcessFromMap(long p)
{
- return (ConcreteProcess) pidToProcess.remove(new Long(p));
+ return (PosixProcess) pidToProcess.remove(new Long(p));
}
/**
- * Put the given ConcreteProcess in the map using the Long
+ * Put the given PosixProcess in the map using the Long
* value of its pid as the key.
*
- * @param p The ConcreteProcess.
+ * @param p The PosixProcess.
*/
- void addProcessToMap(ConcreteProcess p)
+ void addProcessToMap(PosixProcess p)
{
pidToProcess.put(new Long(p.pid), p);
}
/**
- * Queue up the ConcreteProcess and awake the ProcessManager.
- * The ProcessManager will start the ConcreteProcess from its
+ * Queue up the PosixProcess and awake the ProcessManager.
+ * The ProcessManager will start the PosixProcess from its
* thread so it can be reaped when it terminates.
*
- * @param p The ConcreteProcess.
+ * @param p The PosixProcess.
*/
- void startExecuting(ConcreteProcess p)
+ void startExecuting(PosixProcess p)
{
synchronized (queueLock)
{
@@ -154,7 +150,7 @@
}
while (queue.size() > 0)
{
- ConcreteProcess p = (ConcreteProcess) queue.remove(0);
+ PosixProcess p = (PosixProcess) queue.remove(0);
p.spawn(this);
}
}
@@ -353,10 +349,7 @@
*/
private native void nativeSpawn();
- // This file is copied to `ConcreteProcess.java' before
- // compilation. Hence the constructor name apparently does not
- // match the file name.
- ConcreteProcess(String[] progarray, String[] envp, File dir)
+ PosixProcess(String[] progarray, String[] envp, File dir)
throws IOException
{
// Check to ensure there is something to run, and avoid
@@ -378,7 +371,7 @@
processManager.waitUntilReady();
}
- // Queue this ConcreteProcess for starting by the ProcessManager.
+ // Queue this PosixProcess for starting by the ProcessManager.
processManager.startExecuting(this);
}
@@ -428,8 +421,8 @@
/** The process id. This is cast to a pid_t on the native side. */
private long pid;
- // FIXME: Why doesn't the friend declaration in ConcreteProcess.h
- // allow ConcreteProcess$ProcessManager native code access these
+ // FIXME: Why doesn't the friend declaration in PosixProcess.h
+ // allow PosixProcess$ProcessManager native code access these
// when they are private?
/** Before the process is forked. */
Index: java/lang/natPosixProcess.cc
===================================================================
--- java/lang/natPosixProcess.cc (revision 117511)
+++ java/lang/natPosixProcess.cc (working copy)
@@ -27,8 +27,8 @@
#include <gcj/cni.h>
#include <jvm.h>
-#include <java/lang/ConcreteProcess$ProcessManager.h>
-#include <java/lang/ConcreteProcess.h>
+#include <java/lang/PosixProcess$ProcessManager.h>
+#include <java/lang/PosixProcess.h>
#include <java/lang/IllegalThreadStateException.h>
#include <java/lang/InternalError.h>
#include <java/lang/InterruptedException.h>
@@ -98,7 +98,7 @@
// Get ready to enter the main reaper thread loop.
void
-java::lang::ConcreteProcess$ProcessManager::init ()
+java::lang::PosixProcess$ProcessManager::init ()
{
using namespace java::lang;
// Remenber our PID so other threads can kill us.
@@ -124,7 +124,7 @@
}
void
-java::lang::ConcreteProcess$ProcessManager::waitForSignal ()
+java::lang::PosixProcess$ProcessManager::waitForSignal ()
{
// Wait for SIGCHLD
sigset_t mask;
@@ -145,7 +145,7 @@
return;
}
-jboolean java::lang::ConcreteProcess$ProcessManager::reap ()
+jboolean java::lang::PosixProcess$ProcessManager::reap ()
{
using namespace java::lang;
@@ -168,7 +168,7 @@
return true; // No children to wait for.
// Look up the process in our pid map.
- ConcreteProcess * process = removeProcessFromMap ((jlong) pid);
+ PosixProcess * process = removeProcessFromMap ((jlong) pid);
// Note that if process==NULL, then we have an unknown child.
// This is not common, but can happen, and isn't an error.
@@ -176,7 +176,7 @@
{
JvSynchronize sync (process);
process->status = WIFEXITED (status) ? WEXITSTATUS (status) : -1;
- process->state = ConcreteProcess::STATE_TERMINATED;
+ process->state = PosixProcess::STATE_TERMINATED;
process->processTerminationCleanup();
process->notifyAll ();
}
@@ -187,7 +187,7 @@
}
void
-java::lang::ConcreteProcess$ProcessManager::signalReaper ()
+java::lang::PosixProcess$ProcessManager::signalReaper ()
{
int c = pthread_kill ((pthread_t) reaperPID, SIGCHLD);
if (c == 0)
@@ -197,7 +197,7 @@
}
void
-java::lang::ConcreteProcess::nativeDestroy ()
+java::lang::PosixProcess::nativeDestroy ()
{
int c = kill ((pid_t) pid, SIGKILL);
if (c == 0)
@@ -207,7 +207,7 @@
}
void
-java::lang::ConcreteProcess::nativeSpawn ()
+java::lang::PosixProcess::nativeSpawn ()
{
using namespace java::io;
Index: java/lang/natWin32Process.cc
===================================================================
--- java/lang/natWin32Process.cc (revision 117511)
+++ java/lang/natWin32Process.cc (working copy)
@@ -1,6 +1,6 @@
// natWin32Process.cc - Native side of Win32 process code.
-/* Copyright (C) 2003 Free Software Foundation
+/* Copyright (C) 2003, 2006 Free Software Foundation
This file is part of libgcj.
@@ -14,7 +14,7 @@
// Conflicts with the definition in "java/lang/reflect/Modifier.h"
#undef STRICT
-#include <java/lang/ConcreteProcess.h>
+#include <java/lang/Win32Process.h>
#include <java/lang/IllegalThreadStateException.h>
#include <java/lang/InterruptedException.h>
#include <java/lang/NullPointerException.h>
@@ -30,7 +30,7 @@
using gnu::java::nio::channels::FileChannelImpl;
void
-java::lang::ConcreteProcess::cleanup (void)
+java::lang::Win32Process::cleanup (void)
{
// FIXME:
// We used to close the input, output and
@@ -42,7 +42,7 @@
// to the POSIX approach.
//
// What I wanted to do is have private nested
- // classes in ConcreteProcess which extend FileInputStream
+ // classes in Win32Process which extend FileInputStream
// and FileOutputStream, respectively, but override
// close() to permit multiple calls to close(). This
// led to class header and platform configury issues
@@ -63,7 +63,7 @@
}
void
-java::lang::ConcreteProcess::destroy (void)
+java::lang::Win32Process::destroy (void)
{
if (! hasExited ())
{
@@ -76,7 +76,7 @@
}
jboolean
-java::lang::ConcreteProcess::hasExited (void)
+java::lang::Win32Process::hasExited (void)
{
DWORD exitStatus;
@@ -100,7 +100,7 @@
}
jint
-java::lang::ConcreteProcess::waitFor (void)
+java::lang::Win32Process::waitFor (void)
{
if (! hasExited ())
{
@@ -209,7 +209,7 @@
}
void
-java::lang::ConcreteProcess::startProcess (jstringArray progarray,
+java::lang::Win32Process::startProcess (jstringArray progarray,
jstringArray envp,
java::io::File *dir)
{
Index: include/posix.h
===================================================================
--- include/posix.h (revision 117511)
+++ include/posix.h (working copy)
@@ -69,6 +69,13 @@
#define O_DSYNC O_SYNC
#endif
+// Name of the Process implementation.
+#ifdef ECOS
+#define _Jv_platform_process ::java::lang::EcosProcess
+#else
+#define _Jv_platform_process ::java::lang::PosixProcess
+#endif
+
// Separator for file name components.
#define _Jv_platform_file_separator ((jchar) '/')
// Separator for path components.
Index: include/win32.h
===================================================================
--- include/win32.h (revision 117511)
+++ include/win32.h (working copy)
@@ -76,6 +76,9 @@
#define _Jv_platform_solib_prefix ""
#define _Jv_platform_solib_suffix ".dll"
+// Name of the Process implementation.
+#define _Jv_platform_process ::java::lang::PosixProcess
+
// Separator for file name components.
#define _Jv_platform_file_separator ((jchar) '\\')
// Separator for path components.
Index: Makefile.am
===================================================================
--- Makefile.am (revision 117521)
+++ Makefile.am (working copy)
@@ -232,11 +232,15 @@
classpath/native/fdlibm/libfdlibm.la \
java/lang/Object.lo \
java/lang/Class.lo \
+ java/process-$(PLATFORM).lo \
$(all_packages_source_files:.list=.lo) \
$(bc_objects) \
$(propertyo_files) \
$(LIBMAGIC) $(LIBFFI) $(ZLIBS) $(GCLIBS)
libgcj_la_DEPENDENCIES = libgcj-$(gcc_version).jar \
+ java/lang/Object.lo \
+ java/lang/Class.lo \
+ java/process-$(PLATFORM).lo \
$(all_packages_source_files:.list=.lo) \
$(LIBLTDL) $(libgcj_la_LIBADD)
libgcj_la_LINK = $(LIBLINK)
@@ -398,8 +402,7 @@
gnu/java/net/PlainSocketImpl$$SocketInputStream.h \
gnu/java/net/PlainSocketImpl$$SocketOutputStream.h \
gnu/java/nio/PipeImpl$$SinkChannelImpl.h \
- gnu/java/nio/PipeImpl$$SourceChannelImpl.h \
- $(PLATFORM_INNER_NAT_HDRS)
+ gnu/java/nio/PipeImpl$$SourceChannelImpl.h
nat_headers = $(ordinary_header_files) $(inner_nat_headers)
nat_headers_install = $(ordinary_header_files)
Index: standard.omit.in
===================================================================
--- standard.omit.in (revision 117511)
+++ standard.omit.in (working copy)
@@ -1,6 +1,3 @@
-java/lang/EcosProcess.java
-java/lang/Win32Process.java
-java/lang/PosixProcess.java
gnu/java/nio/charset/iconv
java/util/zip/DeflaterConstants.java
java/util/zip/DeflaterEngine.java