On Sat, 19 Oct 2019 at 11:32, Neil C Smith <[email protected]> wrote:
> Searching that system property surprised to see it's quite old -
> https://blogs.oracle.com/thejavatutorials/jdk-7u25:-solutions-to-issues-caused-by-changes-to-runtimeexec
>
> I've opened a linked issue for 11.3 to track fixing it properly
> https://issues.apache.org/jira/browse/NETBEANS-3254

I have had a bit of a play with this and might have made some
progress. However, in the NB source there are at comments relating to
fixing at least 6 different bugs going back a decade so it's obviously
a bit of a hairy patch of code.

In the linked article above it gives the 'Golden Rule' as creating a
process builder with the first 2 string args being "cmd" and "/c",
then folding the actual thing you want to call into the third
argument, taking care to quote it properly.

But it seems to me that with changes to the JDK's command line
argument validation it is impossible to tiptoe around the tighter
checks with this technique, and furthermore a better approach is to
keep all the parts of the arguments separated out, and let Java take
care of the escaping. More like you'd do on Linux, in fact.

I've had a go at implementing this here:
https://github.com/pedro-w/netbeans/tree/NETBEANS-3254
It works for me with JDK11 on Windows and Linux but I only tested
simple projects. I'm not a Maven expert* and I don't know what kind of
crazy parameters people will use to invoke mvn.cmd with. So, if anyone
could have a go and see where they get to I would be grateful. In my
branch there is also a commit which just cleans up some warnings in
the code, I didn't go all-in on this (e.g. using lambdas where
suggested) but I thought if we were changing the file we might as well
clear up a few things.

Pete
 .* see what I _didn't_ do there!

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Reply via email to