Skip to content

JarUrlClassLoader rejects valid class names since #52271 - #52284

Merged
philwebb merged 2 commits into
spring-projects:mainfrom
janwaleed09:loadable-names-jvm-class-names
Oct 18, 2026
Merged

philwebb merged 2 commits into
spring-projects:mainfrom
janwaleed09:loadable-names-jvm-class-names

Conversation

@janwaleed09

Copy link
Copy Markdown
Contributor

Since #52271 the loader only accepts class names that are Java identifiers, but the JVM allows more than that (JVMS 4.2.2). In an executable jar, OkHttp now fails with NoClassDefFoundError: okio/internal/-ByteStringNonJs, kotlinx-serialization and Micrometer's Atlas registry fail the same way, and package annotations are gone. I changed the check to only reject what the JVM never allows (an empty name part, ; or [), which also covers the package-info case from #52283.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. label Oct 18, 2026
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. labels Oct 18, 2026
@philwebb philwebb added this to the 4.2.0-RC1 milestone Oct 18, 2026
@philwebb philwebb self-assigned this Oct 18, 2026
@philwebb

Copy link
Copy Markdown
Member

We've decided to revert #52271 for now since it's too risky. Whatever we do, we'll test out in 4.2 before considering a backport.

@philwebb philwebb mentioned this pull request Oct 18, 2026
janwaleed09 and others added 2 commits October 18, 2026 15:17
Update `LoadableNames` logic to validate class name against rules
defined by the "Java Virtual Machine Specification" rather than
the "Java Langage Specification".

Prior to this commit, restrictions would prevent valid JVM bytecode
from running, for example if a `package-info` class was loaded.

Signed-off-by: Jan Mohr <jan.mohr.1@web.de>

See spring-projectsgh-52284
Add more tests and implement package/module name restrictions.

This commit also removes all resource name restrictions which
could be risky to enforce.

See spring-projectsgh-52284
@philwebb
philwebb force-pushed the loadable-names-jvm-class-names branch from 79af7c1 to 868bba7 Compare October 18, 2026 22:24
Comment on lines +11 to +25
name: Read Version
runs-on: 'ubuntu-latest'
steps:
- name: Check Out Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Read Version From gradle.properties
id: read-version
shell: bash
run: |
version=$(sed -n 's/version=\(.*\)/\1/p' gradle.properties)
echo "Version is $version"
echo "version=$version" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.read-version.outputs.version }}
publish-gradle-plugin:
Comment on lines +26 to +42
name: Publish Gradle Plugin
if: ${{ !vars.COMMERCIAL }}
needs:
- read-version
runs-on: 'ubuntu-latest'
steps:
- name: Check Out Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Publish
uses: ./.github/actions/publish-gradle-plugin
with:
build-number: '2026.4'
gradle-plugin-publish-key: ${{ secrets.GRADLE_PLUGIN_PUBLISH_KEY }}
gradle-plugin-publish-secret: ${{ secrets.GRADLE_PLUGIN_PUBLISH_SECRET }}
jfrog-cli-config-token: ${{ secrets.JF_ARTIFACTORY_SPRING }}
plugin-version: ${{ needs.read-version.outputs.version }}
trigger-docs-build:
Comment on lines +55 to +70
name: Create GitHub Release
needs:
- read-version
- publish-gradle-plugin
- trigger-docs-build
runs-on: 'ubuntu-latest'
steps:
- name: Check Out Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Create GitHub Release
uses: ./.github/actions/create-github-release
with:
commercial: ${{ vars.COMMERCIAL }}
pre-release: true
milestone: ${{ needs.read-version.outputs.version }}
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} No newline at end of file
@philwebb
philwebb changed the base branch from 4.0.x to main October 18, 2026 22:25
@philwebb
philwebb merged commit 1434d21 into spring-projects:main Oct 18, 2026
3 of 4 checks passed
@philwebb

Copy link
Copy Markdown
Member

Thanks @janwaleed09! I've attempted to implement package/module name restrictions as well and also included < and > since those chars are only valid for method names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants