Skip to content

Commit a3f946c

Browse files
committed
Polyglot version check fails during checking when using Version.getComponent.
1 parent e546906 commit a3f946c

File tree

1 file changed

+16
-9
lines changed
  • sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot

1 file changed

+16
-9
lines changed

sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/Engine.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,15 +1758,14 @@ private static AbstractPolyglotImpl loadAndValidateProviders(Iterator<? extends
17581758
}
17591759
impls.add(found);
17601760
}
1761-
Collections.sort(impls, Comparator.comparing(AbstractPolyglotImpl::getPriority));
1762-
Version polyglotVersion = Boolean.getBoolean("polyglotimpl.DisableVersionChecks") ? null : getPolyglotVersion();
1763-
AbstractPolyglotImpl prev = null;
1764-
for (AbstractPolyglotImpl impl : impls) {
1765-
if (impl.getPriority() == Integer.MIN_VALUE) {
1766-
// disabled
1767-
continue;
1768-
}
1769-
if (polyglotVersion != null) {
1761+
/*
1762+
* Verifies the Polyglot and Truffle API versions before sorting polyglot implementations.
1763+
* This is necessary because AbstractPolyglotImpl#getPriority, which is used during sorting,
1764+
* may already depend on compatible API versions and could trigger incompatibility issues.
1765+
*/
1766+
if (!Boolean.getBoolean("polyglotimpl.DisableVersionChecks")) {
1767+
Version polyglotVersion = getPolyglotVersion();
1768+
for (AbstractPolyglotImpl impl : impls) {
17701769
String truffleVersionString = impl.getTruffleVersion();
17711770
Version truffleVersion = truffleVersionString != null ? Version.parse(truffleVersionString) : Version.create(23, 1, 1);
17721771
if (!polyglotVersion.equals(truffleVersion)) {
@@ -1794,6 +1793,14 @@ private static AbstractPolyglotImpl loadAndValidateProviders(Iterator<? extends
17941793
throw new IllegalStateException(errorMessage.toString());
17951794
}
17961795
}
1796+
}
1797+
Collections.sort(impls, Comparator.comparing(AbstractPolyglotImpl::getPriority));
1798+
AbstractPolyglotImpl prev = null;
1799+
for (AbstractPolyglotImpl impl : impls) {
1800+
if (impl.getPriority() == Integer.MIN_VALUE) {
1801+
// disabled
1802+
continue;
1803+
}
17971804
impl.setNext(prev);
17981805
try {
17991806
impl.setConstructors(APIAccessImpl.INSTANCE);

0 commit comments

Comments
 (0)