Skip to content
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

Selecting a class from a CAS can yield a classcast exception if the CAS contains subclasses of the type not locally known #384

Open
reckart opened this issue Aug 23, 2024 · 0 comments
Labels
🦟 Bug Something isn't working
Milestone

Comments

@reckart
Copy link
Member

reckart commented Aug 23, 2024

Describe the bug
Let's assume with have a CAS with two types, T and S where S is a subtype of T.

To Reproduce
Now let's assume we are in a PEAR that brings along its own version of the T JCas class (let's call it T_p).

When the code in the PEAR does a for var T : select(T.class) (which actually selects T_p and that select returns an S, that leads to a class cast exception because S cannot be cast to T_p.

Expected behavior
It would probably be a good idea to add a filter to select(class) to ensure that the values it returns are actually compatible with class - which may in the case of selecting inside a PEAR in the scenario outlined above mean that instances of S are actually not returned.

Please complete the following information:

  • Version: 3.5.0

Additional context
Another but similar scenario...

Imagine we have a class outside of the PEAR called H with a field H.x of type X. Now the PEAR brings its own copy of X (i.e. X_p) but not of H. If the pear now calls H.getX() this will return an X instead of an X_p which probably also leads to a class cast exception...

Ok, so the convention is that a PEAR must embed all types it directly uses. Thus, if it wants to call H.getX(), it must embed H which would then be H_p and H_p.getX() would return X_p. So that should be consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦟 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant