[JENKINS-69647] Eliminate reflection from WinProcess
#71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
See JENKINS-69647. Stopping a build on Java 17 results in:
Evaluation
The use of reflection is unnecessary as of Java 9+, which natively supports getting the process ID through
Process#pid
. Furthermore, the use of reflection is actively harmful on Java 17, causing the above error.Solution
Eliminate reflection in favor of native Java Platform functionality.
Implementation
This PR does the following:
Jenkinsfile
for the Java (not native) portions of the build.This PR explicitly does not cover any of the following:
Native#getProcessId(long)
, recompile the native binaries, and re-sign them.The reason for explicitly marking these tasks out of scope is that I am not interested in doing them at the present time. I am not against somebody else doing them, but they are not necessary in the short to medium term and I am explicitly not volunteering to do them myself. Once approved, I plan to merge this PR and do a release to the Jenkins Artifactory server, with the release notes mentioning that this release (a) requires Java 11 or newer and (b) is now published on
repo.jenkins-ci.org
rather than Maven Central. Note that we have been following the same process for other libraries adopted from Kohsuke, includinglib-mock-javamail
andlib-file-leak-detector
, and while in some cases users have asked for Maven Central releases, so far nobody from the community has stepped up to perform releases on Maven Central. Similarly, I do not intend to maintain a Java 8 support branch for users outside of the Jenkins project who want to continue to use Java 8. As above, I am not against somebody stepping up to do this, but I am explicitly not volunteering to do it myself.Testing done
build.cmd cleanbuild
passes on Windows.