Unable to understand need to make Process.java abstract
Process
is abstract because it is likely to have a different implementation on each operating system. Application developers don't implement this abstract class; it's implemented as part of the Java runtime.
Since all methods are abstract, it could have been declared as an interface, but that would make the class unable to evolve in the future. For example, new methods should not be added to an interface once it's been declared in a public API, because then any existing implementations will be incompatible. In contrast, a new (concrete) method can be easily added to an abstract class.
Instances of Process
are created by the runtime, either through the Runtime
class methods, or from a ProcessBuilder
instance. Applications generally wouldn't use the new
operator to create an instance (of the concrete subclass) directly.
I suspect the critical difference arises from the fact that you can implement
as many interface
s as you wish but you can only extend
one class
, be it abstract or otherwise.
Making Process
abstract therefore ensures that if you actually decide to create one from scratch (i.e. not from a system-supplied factory, which is the normal route) you would not be able to put functionality in a parent class of it. How that helps I'm not sure.
Maybe it's a security thing since processes are supposed to be created and owned by the operating system. It is doing it's best to discourage you from making them yourself.
Added
Deep down I think the reason it's not an interface is historical. Remember Process
has been in java.lang
since the year dot and back then an interface was something you implement, not a definition of a facet of an object's personality. That concept grew up much later.
Notice that Process
has been around since JDK 1.0 while many of the more useful interfaces arrived much later, the CharSequence
interface for example did not appear until JDK 1.4. I think there was a paradigm shift from objects being primary and interfaces being really useful to interfaces being the be all and end all while objects merely implement.
Process
would therefore be one of the old classes that were created at the time when a Process
was a real object and probably drove an Audi Quattro, not some vague notional namby-pamby miasmic thing that has some methods in it and looks a bit like this.