Skip to content

Conversation

@MarkEWaite
Copy link
Contributor

@MarkEWaite MarkEWaite commented Oct 25, 2025

Support Java 25

Don't add String.getChars(int, int, char[], int) or AbstractStringBuilder.getChars(int, int, char[], int) to the generic whitelist when running on Java 25 because those methods are now inherited from CharSequence.getChars(int, int, char[]. int)

Java 25 adds a new method CharSequence.getChars(int, int, char[], int) that is then used in the String class and the AbstractStringBuilder class.

Java 25 CharSequence javadoc:

Java 21 CharSequence javadoc:

Switches to only test Java 25 and Java 21 because we've found no issues that were specific to the Java 17 compiler.

Testing done

  • Confirmed that test fails on Java 25 without this change
  • Confirmed that tests pass on Java 25 with this change
  • Confirmed that tests pass on Java 21 with this change
  • Confirmed that tests pass on Java 17 with this change

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

Don't add `String.getChars(int, int, char[], int)` or
`AbstractStringBuilder.getChars(int, int, char[], int)` to the generic
whitelist when running on Java 25 because those methods are now inherited
from `CharSequence.getChars(int, int, char[]. int)`

Java 25 adds a new method CharSequence.getChars(int, int, char[], int)
that is then used in the String class and the AbstractStringBuilder class.

Java 25 CharSequence javadoc:

* https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/CharSequence.html

Java 21 CharSequence javadoc:

* https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/CharSequence.html

Switches to only test Java 25 and Java 21 because we've found no issues
that were specific to the Java 17 compiler.

Testing done:

* Confirmed that test fails on Java 25 without this change
* Confirmed that tests pass on Java 25 with this change
* Confirmed that tests pass on Java 21 with this change
* Confirmed that tests pass on Java 17 with this change
@MarkEWaite MarkEWaite requested a review from a team as a code owner October 25, 2025 16:24
@MarkEWaite
Copy link
Contributor Author

I would appreciate a review from either @jglick or @dwnusbaum since they are most familiar with this code.

@dwnusbaum
Copy link
Member

@MarkEWaite unless this case is unique, normally when adapting to these kinds of changes we just add the new signatures to generic-whitelist, and then adjust StaticWhitelistTest to ignore the signatures which are only available in some Java versions. Compare with #394 and #453.

Follows the same pattern as pull requests:

* jenkinsci#394
* jenkinsci#453

Testing done:

* Confirmed that tests pass on Java 21 and Java 25
@MarkEWaite
Copy link
Contributor Author

add the new signatures to generic-whitelist

Thanks! I've done that in 2408872 . Much appreciated!

@dwnusbaum
Copy link
Member

dwnusbaum commented Oct 27, 2025

Looks like StaticWhitelistTest.KNOWN_GOOD_SIGNATURES will need to be updated to ignore the old signature that no longer exists in Java 25+:

java.lang.AssertionError: method java.lang.AbstractStringBuilder getChars int int char[] int does not exist (or is an override)
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelistTest.sanity(StaticWhitelistTest.java:106)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.GenericWhitelistTest.sanity(GenericWhitelistTest.java:39)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)

@jglick jglick added the bug label Oct 27, 2025
@MarkEWaite
Copy link
Contributor Author

I'm disappearing for two weeks, so won't be able to make the necessary final change before I leave. Others are welcome to make the change or it can wait until I return.

@dwnusbaum
Copy link
Member

Tests should be fixed by e23e24f, or at least I checked that GenericWhitelistTest passes against java 21 and 25 with that commit.

@dwnusbaum dwnusbaum enabled auto-merge October 27, 2025 18:18
@dwnusbaum dwnusbaum merged commit 7d2d9ec into jenkinsci:master Oct 27, 2025
16 of 17 checks passed
@MarkEWaite MarkEWaite deleted the support-java-25 branch December 15, 2025 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants