Hi there —

I was looking for a way to get the process ID of a process that gets started by 
the DefaultExecutor. From looking at the javadoc, there’s no built-in way to do 
it.

Google recommends that I create a subclass of DefaultExecutor that overrides 
the launch() method, such that the Process it returns is interrogated for the 
PID. DefaultExecutor isn’t final and launch() is protected, so in principle 
this can be done.

However:

The only public constructor for DefaultExecutor is deprecated. The 
non-deprecated method to instantiate a DefaultExecutor is to use the 
DefaultExecutor builder, but AFAICT there’s no way to get this builder to 
return a DefaultExecutor subclass. I could subclass the DefaultExecutor 
builder, but the DefaultExecutor builder uses a package-private DefaultExecutor 
constructor, so my subclass of DefaultExecutor builder can’t use that 
constructor.

In a pinch, I could imagine giving my subclass its own constructor that 
emulates the package-private one in DefaultExecutor. Unfortunately, this also 
won’t work: all the instance variables are private and there are no protected 
setters for them.

It seems like the intent is there to allow users to subclass DefaultExecutor, 
but in practice the only way to do it appears to be the deprecated public 
constructor. Am I missing something?

Is there an easier way to get the PID from a DefaultExecutor?

Thanks,
-PT

Reply via email to