apache / apache/lucene

When running tests on Java 26 disallow modification of final fields

Open
#15,482 3 comments 0 reactions 1 assignee Claimed by @uschindler View on GitHub
module:build-infra type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

### Description

[JEP 500](https://openjdk.org/jeps/500) is moving to making final fields really final. They are currently be allowed to be modified with deep reflection (using `Field#setAccessible(true)`) but as we do not allow `setAccessible` due to forbiddenapis, it is safe to further enforce this, especially to prevent dependencies from doing this. In JDK 26 the default is warn only and in later versions this will change to enforce.

For testing we should pass `--illegal-final-field-mutation=deny` to our test-runner staring with Java 26. We have similar stuff regarding preventing JNI in earlier Java versions, so the code to do this is already there.

I will check what needs to be done. I think we should wait a bit until the RC of JDK 26 comes out to not fail builds with older versions of JDK 26.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.