Skip to content

LDEV-6226 fix cross-classloader method resolution and type conversion#2773

Merged
michaeloffner merged 1 commit intolucee:7.0from
zspitzer:LDEV-6226-v7
Apr 12, 2026
Merged

LDEV-6226 fix cross-classloader method resolution and type conversion#2773
michaeloffner merged 1 commit intolucee:7.0from
zspitzer:LDEV-6226-v7

Conversation

@zspitzer
Copy link
Copy Markdown
Member

@zspitzer zspitzer commented Apr 8, 2026

Summary

Port of #2772 (6.2) to 7.0.

Fixes intermittent NoSuchMethodException when calling Java methods from CFML after a classloader swap. Affects both OSGi bundle refreshes and JavaSettings classloader flushes (reinit, idle eviction, systemCacheClear).

Root Cause

When a Java object is persisted in a long-lived scope (e.g. variables.sfnClient) and its classloader is replaced, the persisted object's class is from the old classloader while newly created arguments come from the new classloader. Same class name, different classloader = strict class identity checks fail.

Two code paths affected:

  1. Clazz.getMethod() / getConstructor() Phase 1 - uses Class.isAssignableFrom() for type matching, fails cross-classloader
  2. Reflector.like() - used by _convert() in Phase 2 method resolution, delegates to isInstaneOf(src, trg, true) which also does strict identity. With overloaded methods this silently picks the wrong overload (e.g. Object instead of the typed parameter).

Fix

Clazz.java: Phase 1 - try isAssignableFrom first, fall back to Reflector.isInstaneOf(argClass, paramClass, false) for name-based comparison.

Reflector.java: like() - try identity, then isAssignableFrom, then isInstaneOf(src, trg, false) for cross-classloader name-based matching.

Test plan

  • LDEV6226.cfc - 6 tests, all passing

@michaeloffner michaeloffner merged commit 359905f into lucee:7.0 Apr 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants