Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #384 where select(SuperType.class) in a PEAR context can trigger ClassCastException when the CAS contains subtype FSes whose JCas wrappers are not locally (PEAR) compatible due to classloader isolation.
Changes:
- Adjust PEAR generator selection to wrap subtype FSes using the nearest PEAR-overridden ancestor wrapper, avoiding incompatible subtype wrappers.
- Update the PEAR integration scenario 3 to assert successful processing and verify the subtype FS remains in the CAS.
- Add a core regression test for PEAR-classloader
select(Class)behavior.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
uimaj-it-pear-with-typesystem/src/test/java/org/apache/uima/it/pear_with_typesystem/PearIT.java |
Updates scenario 3 test to expect successful processing (no ClassCastException) and verify the subtype FS persists. |
uimaj-it-pear-with-typesystem/src/main/java/org/apache/uima/it/pear_with_typesystem/Scenario3TestAnnotator.java |
Strengthens in-PEAR assertions to verify returned wrapper type and underlying UIMA type for the subtype FS. |
uimaj-core/src/test/java/org/apache/uima/cas/test/SelectByClassInPearContextTest.java |
Adds a core-level regression test exercising PEAR classloader selection behavior. |
uimaj-core/src/main/java/org/apache/uima/cas/impl/FSClassRegistry.java |
Implements the PEAR-specific ancestor-wrapper fallback to prevent classloader-incompatible subtype wrappers from causing ClassCastException. |
.gitignore |
Normalizes ignoring of VS Code folder to .vscode/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ion if the CAS contains subclasses of the type not locally known - Added reproducer test
…ion if the CAS contains subclasses of the type not locally known - Fix `select(SuperType.class)` in PEAR contexts so subtype FSes whose JCas wrapper was loaded by the parent classloader get re-wrapped using the PEAR's override of the nearest ancestor type instead of being returned as parent-classloader instances (which would `ClassCastException` at the caller). - In `FSClassRegistry.getGeneratorsForTypeAndSubtypes`, when in PEAR mode and the resolved `JCasClassInfo` is not actually a PEAR override, walk further up the type hierarchy for an ancestor whose JCas class *is* PEAR-overridden, and use that ancestor's generator.
…ion if the CAS contains subclasses of the type not locally known - Update PEAR integration test `testScenario3` to reflect the corrected behavior: PEAR processing must succeed instead of throwing a `ClassCastException`, with the sub-type FS remaining in the CAS after the PEAR exits. - In `Scenario3TestAnnotator`, replace the comment describing the old broken behavior and add assertions that the FS returned by `select(ComplexAnnotation.class)` is a PEAR-local `ComplexAnnotation` instance while its UIMA type is still `ComplexAnnotationSubtype`. - Drop now-unused imports of `assertThatExceptionOfType` and `AnalysisEngineProcessException` in `PearIT`.
…ion if the CAS contains subclasses of the type not locally known - FSClassRegistry: update `getGeneratorsForClassLoader` Javadoc to document ancestor-wrapper fallback for non-overridden PEAR sub-types - SelectByClassInPearContextTest: update class-level Javadoc to clarify sub-type FSes are wrapped (not filtered) with nearest PEAR-overridden ancestor - SelectByClassInPearContextTest: rename test method to `thatSelectByClassWrapsIncompatibleSubtypeWithNearestPearAncestor` - SelectByClassInPearContextTest: strengthen test assertions to verify result size and that returned FS retains UIMA type Level_2
reckart
force-pushed
the
bugfix/384-Selecting-a-class-from-a-CAS-can-yield-a-classcast-exception-if-the-CAS-contains-subclasses-of-the-type-not-locally-known
branch
from
June 17, 2026 15:00
561a0bd to
eff0255
Compare
reckart
deleted the
bugfix/384-Selecting-a-class-from-a-CAS-can-yield-a-classcast-exception-if-the-CAS-contains-subclasses-of-the-type-not-locally-known
branch
June 17, 2026 15:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's in the PR
How to test manually
Automatic testing
Documentation
Organizational
Only dependencies under approved licenses are allowed. LICENSE and NOTICE files in the respective modules where dependencies have been added as well as in the project root have been updated.