Skip to content

[GR-65541] Polyglot version check fails during checking when using Version.getComponent. #11444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -1758,15 +1758,14 @@ private static AbstractPolyglotImpl loadAndValidateProviders(Iterator<? extends
}
impls.add(found);
}
Collections.sort(impls, Comparator.comparing(AbstractPolyglotImpl::getPriority));
Version polyglotVersion = Boolean.getBoolean("polyglotimpl.DisableVersionChecks") ? null : getPolyglotVersion();
AbstractPolyglotImpl prev = null;
for (AbstractPolyglotImpl impl : impls) {
if (impl.getPriority() == Integer.MIN_VALUE) {
// disabled
continue;
}
if (polyglotVersion != null) {
/*
* Verifies the Polyglot and Truffle API versions before sorting polyglot implementations.
* This is necessary because AbstractPolyglotImpl#getPriority, which is used during sorting,
* may already depend on compatible API versions and could trigger incompatibility issues.
*/
if (!Boolean.getBoolean("polyglotimpl.DisableVersionChecks")) {
Version polyglotVersion = getPolyglotVersion();
for (AbstractPolyglotImpl impl : impls) {
String truffleVersionString = impl.getTruffleVersion();
Version truffleVersion = truffleVersionString != null ? Version.parse(truffleVersionString) : Version.create(23, 1, 1);
if (!polyglotVersion.equals(truffleVersion)) {
Expand Down Expand Up @@ -1794,6 +1793,14 @@ private static AbstractPolyglotImpl loadAndValidateProviders(Iterator<? extends
throw new IllegalStateException(errorMessage.toString());
}
}
}
Collections.sort(impls, Comparator.comparing(AbstractPolyglotImpl::getPriority));
AbstractPolyglotImpl prev = null;
for (AbstractPolyglotImpl impl : impls) {
if (impl.getPriority() == Integer.MIN_VALUE) {
// disabled
continue;
}
impl.setNext(prev);
try {
impl.setConstructors(APIAccessImpl.INSTANCE);
Expand Down