Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

JAnnotationArrayMember.annotations() is causing ClassCastException #884

Open
glassfishrobot opened this issue Feb 24, 2012 · 7 comments
Open

Comments

@glassfishrobot
Copy link
Contributor

JAnnotationArrayMember adds to values field annotations, which are not of type JAnnotationUse. Hence model causes ClassCastException when attempt is made to iterate this collection via JAnnotationArrayMember.annotations():

// ann represents @XmlType class-level annotation. // ClassCastException here: for (JAnnotationUse ann : ((JAnnotationArrayMember) annotation.getAnnotationMembers().get("propOrder")).annotations()) {
	...
}

Affected Versions

[2.2.5]

@glassfishrobot
Copy link
Contributor Author

Reported by dma_k

@glassfishrobot
Copy link
Contributor Author

Was assigned to yaroska

@glassfishrobot
Copy link
Contributor Author

snajper said:
Hi, thanks. Would you please add some more reproduction code here or the full exception trace to ease the fix/debugging? Thanks in advance.

@glassfishrobot
Copy link
Contributor Author

dma_k said:
I have caught this bug while working on code of jabx-xew plugin. In that line I refer #784, but the method code tries to overcome both of them.

As I mentioned in issue description, JAnnotationArrayMember violates the casting by using explicitly @SuppressWarnings("unchecked"). For example JAnnotationStringValue which is added in line 76 is not of type JAnnotationUse.

@glassfishrobot
Copy link
Contributor Author

snajper said:
Either downgrade or mark metro2_3-exclude as this is not relevant to jaxb or metro - or perhaps easy to fix?

@glassfishrobot
Copy link
Contributor Author

dma_k said:
If xjc code model is part of JAXB, then why do you say it is not relevant?

The issue can be fixed by changing the return type from Collection to Collection in JAnnotationArrayMember#annotations().

@glassfishrobot
Copy link
Contributor Author

This issue was imported from java.net JIRA JAXB-884

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant