Skip to content

Fix Groovy substitutions for Apache Groovy /5.x compatibility#12986

Draft
lissam1 wants to merge 1 commit intooracle:masterfrom
lissam1:fix-GroovySubstitutions
Draft

Fix Groovy substitutions for Apache Groovy /5.x compatibility#12986
lissam1 wants to merge 1 commit intooracle:masterfrom
lissam1:fix-GroovySubstitutions

Conversation

@lissam1
Copy link
Member

@lissam1 lissam1 commented Feb 16, 2026

Problem

Native Image builds fail when Apache Groovy 5.x is present on the classpath with the following error during the initialization phase:

Error: Could not find target method: protected static void 
com.oracle.svm.polyglot.groovy.Target_org_codehaus_groovy_vmplugin_v7_IndyInterface_invalidateSwitchPoints.invalidateSwitchPoints()

This affects projects using:

  • Apache Groovy 5.x (org.apache.groovy:groovy)
  • Micronaut

Reported in issue #10200.

Investigation & Root Cause

Through investigation of the Groovy source code and GraalVM substitution mechanism, we identified the following:

1. Architecture Change in Groovy 4.x/5.x

Groovy changes:

Old Groovy (2.x/3.x):

  • org.codehaus.groovy.vmplugin.v7.IndyInterface contains invalidateSwitchPoints() method

New Groovy (4.x/5.x):

  • org.codehaus.groovy.vmplugin.v8.IndyInterface is the primary interface (contains invalidateSwitchPoints())
  • org.codehaus.groovy.vmplugin.v7.IndyInterface exists only as a deprecated bridge class for backward compatibility
  • v7 no longer contains invalidateSwitchPoints() - it only delegates to v8

Evidence from Groovy source code:

v7/IndyInterface (Groovy 5.x):

@Deprecated
public class IndyInterface {
    // All methods delegate to v8:
    public static CallSite bootstrap(...) {
        return org.codehaus.groovy.vmplugin.v8.IndyInterface.bootstrap(...);
    }
    
    // NO invalidateSwitchPoints() method!
}

v8/IndyInterface (Groovy 5.x):

public class IndyInterface {
    protected static void invalidateSwitchPoints() {  // ← Method is HERE now
        if (LOG_ENABLED) {
            LOG.info("invalidating switch point");
        }
        synchronized (IndyInterface.class) {
            SwitchPoint old = switchPoint;
            switchPoint = new SwitchPoint();
            SwitchPoint.invalidateAll(new SwitchPoint[]{old});
        }
    }
}

2. Current GraalVM Substitution Issue

The existing GroovyIndyInterfaceFeature has :

Only targets v7

@Override
public boolean isInConfiguration(IsInConfigurationAccess access) {
    return access.findClassByName("org.codehaus.groovy.vmplugin.v7.IndyInterface") != null;
}
  • Doesn't check for v8 at all
  • Assumes the method exists in v7

Solution

This PR updates the Groovy substitutions to handle both v7 and v8:

Changes Made

  • Updated isInConfiguration() to detect both v7 and v8 IndyInterface classes

Related Issues

Fixes #10200

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GR-60622][Native Image] Compiling Native Image with Groovy 5.0.0 throws an exception Could not find target method

1 participant