On 04/02/2014 03:17 PM, roger riggs wrote:
Hi,
On 4/2/2014 6:49 AM, Peter Levart wrote:
On 04/01/2014 09:47 PM, roger riggs wrote:
Hi,
A minor point, but the Enum for LaunchMechanism can be simpler; the
defined enum values (1,2,3)
are never used and can be removed along with the extra constructor.
They are used for the "mode" parameter of forkAndExec() native method.
yes, and could just as easily use the default ordinals (0,1,2).
With the refactoring so far, this seems more complex and harder to
understand.
...
Other alternatives would have been to factor the common code
(Streams handling)
into a utilities class or ProcessImpl and retain the 1st class
subclasses (with different names)
for each platform or merge more up into ProcessImpl.
Maybe it will be clearer with additional refactoring.
As I said, I believe the consolidation of various Input/OutputStream
wrappers could bring the class files number and size further down.
yes, we can't stop yet. The only difference between the inner classes
per platform
is the choice of initializing the streams which could be handled with
a switch instead
of a subclass.
Please continue, Roger
Right,
Here it is:
http://cr.openjdk.java.net/~plevart/jdk9-dev/UNIXProcess/webrev.06/
This one does away with UNIXProcess subclasses. This allowed me to
restore private modifier on all fields and methods that were previously
accessed from subclasses and were changed to package-private to avoid
compiler generating access methods. I also replaced process reaper
thread factory with a lambda. Class files produced by compiling now are:
-rw-rw-r--. 1 peter peter 772 Apr 2 17:45 UNIXProcess$1.class
-rw-rw-r--. 1 peter peter 2155 Apr 2 17:45
UNIXProcess$DeferredCloseInputStream.class
-rw-rw-r--. 1 peter peter 2930 Apr 2 17:45
UNIXProcess$DeferredCloseProcessPipeInputStream.class
-rw-rw-r--. 1 peter peter 1082 Apr 2 17:45
UNIXProcess$LaunchMechanism.class
-rw-rw-r--. 1 peter peter 4762 Apr 2 17:45 UNIXProcess$Platform.class
-rw-rw-r--. 1 peter peter 1711 Apr 2 17:45
UNIXProcess$ProcessPipeInputStream.class
-rw-rw-r--. 1 peter peter 949 Apr 2 17:45
UNIXProcess$ProcessPipeOutputStream.class
-rw-rw-r--. 1 peter peter 9401 Apr 2 17:45 UNIXProcess.class
...8 class files totaling 23.2 KiB.
Getting close to original code.
Regards, Peter