Skip to content

feat(jdk): add getJavaVersion() and improve Javadocs#11160

Closed
miracneroid wants to merge 3 commits intojenkinsci:masterfrom
miracneroid:hacktoberfest-fix
Closed

feat(jdk): add getJavaVersion() and improve Javadocs#11160
miracneroid wants to merge 3 commits intojenkinsci:masterfrom
miracneroid:hacktoberfest-fix

Conversation

@miracneroid
Copy link

@miracneroid miracneroid commented Oct 5, 2025

See JENKINS-XXXXX.

Testing done

Proposed changelog entries

  • human-readable text

Proposed changelog category

/label

Proposed upgrade guidelines

N/A

Submitter checklist

  • The Jira issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • New or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

  • There are at least two (2) approvals for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

Summary

This PR enhances the JDK class in Jenkins by:

  1. Adding a new method getJavaVersion() to detect the installed JDK version.
  2. Improving Javadoc for all public methods to help developers understand usage.
  3. Adding warning logs when the Java executable is missing or version detection fails.

Motivation

Provides a useful utility method for developers and improves code readability and maintainability.

Notes

  • Backward-compatible: no existing functionality is broken.
  • Documentation-only improvements and small feature addition.

Summary

This PR enhances the JDK class in Jenkins by:

  1. Adding a new method getJavaVersion() to detect the installed JDK version.
  2. Improving Javadoc for all public methods to help developers understand usage.
  3. Adding warning logs when the Java executable is missing or version detection fails.
  4. Adding a unit test for getJavaVersion() to ensure it works correctly.

Motivation

Provides a useful utility method for developers and improves code readability and maintainability.

@welcome
Copy link

welcome bot commented Oct 5, 2025

Yay, your first pull request towards Jenkins core was created successfully! Thank you so much!

A contributor will provide feedback soon. Meanwhile, you can join the chats and community forums to connect with other Jenkins users, developers, and maintainers.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2025

Missing required label for changelog. Requires at least 1 of: bug, developer, dependencies, internal, localization, major-bug, major-rfe, rfe, regression-fix, removed, skip-changelog. Found: .

You can add the required label by adding a comment with the following text: /label <category>

Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please assure that your code changes successfully compile and pass tests before submitting a pull request. Refer to the contributing guide for guidance to compile and test Jenkins core.

Please complete the pull request template when submitting a pull request. It wastes the time of maintainers to review pull requests that do not complete the pull request template.

If you are choosing to use the title format of conventional commits, please use them accurately. In this case, you added a test but used the conventional commit text that indicates this is a feature. New automated tests are not features.

I will close this pull request on the assumption that if you decide to fix the code so that it compiles and passes tests, you can reopen it.

@@ -0,0 +1,32 @@
package hudson.model;

import org.junit.Test;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use JUnit 5 for tests instead of JUnit 4.

Suggested change
import org.junit.Test;
import org.junit.jupiter.api.Test;

@MarkEWaite MarkEWaite closed this Oct 5, 2025
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* copies, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change the license of existing source files.

Suggested change
* subject to the following conditions:
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:

@MarkEWaite
Copy link
Contributor

We strongly prefer that new API's are not added to Jenkins core unless there are also consumers of the API.

@NotMyFault NotMyFault added the spam This pull request is not a valid change proposal (e.g. vandalism, empty changes) label Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spam This pull request is not a valid change proposal (e.g. vandalism, empty changes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants