Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

The codebase targets Java 17 but wasn't fully utilizing its language features. Applied pattern matching for instanceof (JEP 394) to eliminate redundant casts.

Changes

  • 4 files updated to use pattern matching for instanceof:
    • Configuration.java and TreeProperties.java: String key checks in stringPropertyNames()
    • RemoteTools.java: SocketException cause check in exception handler
    • SubMonitor.java: SubMonitor type check in convert() optimization path

Example

Before:

if (key instanceof String) {
    keys.add((String) key);
}

After:

if (key instanceof final String stringKey) {
    keys.add(stringKey);
}

Other Java 17 Features Evaluated

  • Sealed classes: Not applicable - public library APIs require extensibility
  • Records: No candidates - existing data classes are mutable or extend other types
  • Switch expressions: Single switch statement unsuitable (side effects, complex logic)
  • Text blocks: No multi-line string literals present

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.puppycrawl.com
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/com.bitctrl/.codeql-scratch/dbs/java/working/files-to-index8986416209424227427.list --sourceArchiveDir=/home/REDACTED/work/com.bitctrl/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/com.bitctrl/.codeql-scratch/dbs/java/trap/java (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Aktualisiere den Code auf Java 17 Level und verwende Java 17 Sprachfeatures


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: ChristianHoesel <4498707+ChristianHoesel@users.noreply.github.com>
Copilot AI changed the title [WIP] Update code to Java 17 and use language features Apply pattern matching for instanceof across codebase Nov 18, 2025
Copy link
Member

@upeuker upeuker left a comment

Choose a reason for hiding this comment

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

Dafür hätte es nun wirklich keine KI gebraucht :)

@ChristianHoesel ChristianHoesel marked this pull request as ready for review November 18, 2025 18:18
@ChristianHoesel ChristianHoesel merged commit d34b911 into master Nov 18, 2025
4 checks passed
@ChristianHoesel ChristianHoesel deleted the copilot/update-code-to-java-17 branch November 18, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants