Skip to content

[JENKINS-75490] Source Code Migration to Java 17 #300

@jenkins-infra-bot

Description

@jenkins-infra-bot

Update trilead ssh api plugin (/jenkinsci/trilead-ssh2 library) source code to Java 17.

This should make it easier for this very old library to be maintained by developers, as the current one is difficult to maintain / enhance features. 

Since the new JVM recommendation for Jenkins is 17/21, I believe updating the source compatibility to Java 17 is reasonable and enables some new language features which help the developer experience. 

The following changes will be implemented:

  • pom.xml: Source and Target set to 17 (currently unset) PR-226
  • Generic types parameterized to the best of the ability (I came across one that I am not sure on how to proceed, but the code builds and current tests still pass, so I left it alone) PR-226
  • Use lamda-style sytnax for classes such as Java Runnable
  • Improve for loops to safer (X element : collection) from (for int x=0; x < collection.length; x++) syntax where possible
  • Use new improve switch-statement syntax
  • Add @​Deprectated annotations to deprecated methods
  • Add @​Override annotations to implementations for interface methods PR-226
  • Add @​Serial annotation to serialVersionUIDs
  • Use try-with-resources blocks for closeable resources
  • Make private class methods final
  • Make private unchanging variables final where necessary
  • Remove unnecessary type-casts PR-226
  • Use static-method reference in streams, where appropriate
  • Use class references instead of "strings" of class names (looking specifically at com.trilead.ssh2.crypto.cipher.BlockCipherFactory ciphers list) PR-226
  • Instantiate classes with getDeclaredConstructor().newInstance() instead of the deprecated newInstance() method PR-226
  • Remove unnecessary methods from child classes that have the same exact values / content as parent classes (com.trilead.ssh2.crypto.cipherDES getBlockSize() is an example) PR-226
  • Fix case in Long variables (lowercase "l" -> uppercase "L") PR-226
  • Use https where possible for XML files and for git clone (in the Dockerfile)

I have already done the changes above and am opening this ticket so I can submit a PR.

 

The original PR for this was.... very large, so I am breaking up the work into PRs, from most important to least.


Originally reported by speedythesnail, imported from: Source Code Migration to Java 17
  • assignee: ifernandezcalvo
  • status: Open
  • priority: Minor
  • component(s): trilead-api-plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 3
  • imported: 20251216-225446
Raw content of original issue

Update trilead ssh api plugin (/jenkinsci/trilead-ssh2 library) source code to Java 17.

This should make it easier for this very old library to be maintained by developers, as the current one is difficult to maintain / enhance features. 

Since the new JVM recommendation for Jenkins is 17/21, I believe updating the source compatibility to Java 17 is reasonable and enables some new language features which help the developer experience. 

The following changes will be implemented:

  • pom.xml: Source and Target set to 17 (currently unset) PR-226
  • Generic types parameterized to the best of the ability (I came across one that I am not sure on how to proceed, but the code builds and current tests still pass, so I left it alone) PR-226
  • Use lamda-style sytnax for classes such as Java Runnable
  • Improve for loops to safer (X element : collection) from (for int x=0; x < collection.length; x++) syntax where possible
  • Use new improve switch-statement syntax
  • Add @Deprectated annotations to deprecated methods
  • Add @Override annotations to implementations for interface methods PR-226
  • Add @Serial annotation to serialVersionUIDs
  • Use try-with-resources blocks for closeable resources
  • Make private class methods final
  • Make private unchanging variables final where necessary
  • Remove unnecessary type-casts PR-226
  • Use static-method reference in streams, where appropriate
  • Use class references instead of "strings" of class names (looking specifically at com.trilead.ssh2.crypto.cipher.BlockCipherFactory ciphers list) PR-226
  • Instantiate classes with getDeclaredConstructor().newInstance() instead of the deprecated newInstance() method PR-226
  • Remove unnecessary methods from child classes that have the same exact values / content as parent classes (com.trilead.ssh2.crypto.cipherDES getBlockSize() is an example) PR-226
  • Fix case in Long variables (lowercase "l" -> uppercase "L") PR-226
  • Use https where possible for XML files and for git clone (in the Dockerfile)

I have already done the changes above and am opening this ticket so I can submit a PR.

 

The original PR for this was.... very large, so I am breaking up the work into PRs, from most important to least.

environment
RHEL 9.5<br/>
Jenkins 2.492.2 LTS<br/>
OpenJDK 17<br/>
SSH Build Agents Plugin 3.1031.v72c6b_883b_869<br/>
SSH Credentials Plugin 355.v9b_e5b_cde5003<br/>
Development Environment: <br/>
Mac OS 15.3.2<br/>
Temurin JDK 21<br/>
IntelliJ Idea 2024.3.3

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions