Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Type cast error in generated code
Type cast error in generated code [message #417303] Tue, 04 March 2008 22:05 Go to next message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
I get an error in generated EMF code that I can't figure out. This is an
Ecore model that was created from XSD. It was originally created in RSM
7.0.0.2 (using whatever EMF version bundled there). Now I get type cast
errors in the source when opened in the new release RSM 7.0.5 that is using
EMF 2.3.1. I tried regenerating the model sources, but this error is still
present.

The generated code looks like this. I have a compilation error "Cannot cast
from EList<Object> to FeatureMap". Any ideas?

public FeatureMap getBasicMarkupGroup() {
return
(FeatureMap)getMixed().list(MifPackage.Literals.BASIC_MARKUP __BASIC_MARKUP_GROUP);
}

The method signature in FeatureMap looks like this:

<T> EList<T> list(EStructuralFeature feature);
Re: Type cast error in generated code [message #417306 is a reply to message #417303] Tue, 04 March 2008 22:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Dave,

You can set your source compatibility to 1.4 to make the error go away,
or you can change the Gen Model's JDK Level to 5.0 and regenerate to
produce code that works for 5.0 source compatibility; I think this will
add (EList<?>) to the right of the (FeatureMap) cast. The problem is
that a FeatureMap is EList<FeatureMap.Entry> and the result of the list
call is EList<Object>, and you can never cast EList<A> to EList<B> no
matter how A and B are related. Of course when the types are erased,
they're both just EList and Java is happy.


Dave Carlson wrote:
> I get an error in generated EMF code that I can't figure out. This is an
> Ecore model that was created from XSD. It was originally created in RSM
> 7.0.0.2 (using whatever EMF version bundled there). Now I get type cast
> errors in the source when opened in the new release RSM 7.0.5 that is using
> EMF 2.3.1. I tried regenerating the model sources, but this error is still
> present.
>
> The generated code looks like this. I have a compilation error "Cannot cast
> from EList<Object> to FeatureMap". Any ideas?
>
> public FeatureMap getBasicMarkupGroup() {
> return
> (FeatureMap)getMixed().list(MifPackage.Literals.BASIC_MARKUP __BASIC_MARKUP_GROUP);
> }
>
> The method signature in FeatureMap looks like this:
>
> <T> EList<T> list(EStructuralFeature feature);
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Type cast error in generated code [message #417307 is a reply to message #417306] Tue, 04 March 2008 22:53 Go to previous message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
Ed,
Thanks for the quick reply. I had to set the compiler to 1.4 compatible
because these plugins need to run in older RSA installations. It works now!

Dave

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:fqkhmt$cvk$1@build.eclipse.org...
> Dave,
>
> You can set your source compatibility to 1.4 to make the error go away, or
> you can change the Gen Model's JDK Level to 5.0 and regenerate to produce
> code that works for 5.0 source compatibility; I think this will add
> (EList<?>) to the right of the (FeatureMap) cast. The problem is that a
> FeatureMap is EList<FeatureMap.Entry> and the result of the list call is
> EList<Object>, and you can never cast EList<A> to EList<B> no matter how A
> and B are related. Of course when the types are erased, they're both just
> EList and Java is happy.
Previous Topic:MultiDocument Example
Next Topic:ItemproviderAdapter#factorRemoveCommand
Goto Forum:
  


Current Time: Fri Apr 26 09:58:31 GMT 2024

Powered by FUDForum. Page generated in 0.02902 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top