Source Code Migration to Java 17

XMLWordPrintable

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Minor
    • Component/s: trilead-api-plugin
    • None
    • Environment:
      RHEL 9.5
      Jenkins 2.492.2 LTS
      OpenJDK 17
      SSH Build Agents Plugin 3.1031.v72c6b_883b_869
      SSH Credentials Plugin 355.v9b_e5b_cde5003

      Development Environment:
      Mac OS 15.3.2
      Temurin JDK 21
      IntelliJ Idea 2024.3.3

      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.

            Assignee:
            Ivan Fernandez Calvo
            Reporter:
            Steven
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: