Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Ant Problem(XSD2Java generates faulty Java Code)
Ant Problem [message #684334] Wed, 15 June 2011 12:39 Go to next message
Kai B. Heinz is currently offline Kai B. HeinzFriend
Messages: 17
Registered: March 2011
Location: Germany
Junior Member
Hi there,
As I described here: http://www.eclipse.org/forums/index.php/mv/msg/210348/675052/#msg_675052 The XSD2Java Ant Task is a bit buggy. During my try to get a workaround by myself I found out that also wrong code is generated. Using the genmodel manually will result in:
public FeatureMap getAny() {
    return (FeatureMap)getMixed().<FeatureMap.Entry>list(MyPackage.eINSTANCE.getData_Any());
}

whereas XSD2Java generates:
public FeatureMap getAny() {
    return (FeatureMap)getMixed().list(MyPackage.eINSTANCE.getData_Any());
}

with the result that Eclipse says: "Cannnot cast from EList<Object> to FeatureMap". In my whole model this happens just once, but it seems, that XSD2Java is not as reliable as the EMF UI. Not very useful for a nightly build Sad I hope development of the ANT Tasks will go on as they can be very useful!

regards
Kai
Re: Ant Problem [message #687206 is a reply to message #684334] Wed, 15 June 2011 13:32 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30439
Registered: July 2009
Senior Member
Kai,

Is your genmodel's compliance level set to 5.0? The difference you show
depends (getting the first result) on this being true:

<%final boolean isJDK50 = genModel.getComplianceLevel().getValue() >=
GenJDKLevel.JDK50;%>

Hopefully you're not generating a new *.genmodel each time but rather
reusing the same one you use in the IDE.


Kai B. Heinz wrote:
> Hi there,
> As I described here:
> http://www.eclipse.org/forums/index.php/mv/msg/210348/675052/#msg_675052
> The XSD2Java Ant Task is a bit buggy. During my try to get a
> workaround by myself I found out that also wrong code is generated.
> Using the genmodel manually will result in:
> public FeatureMap getAny() {
> return
> (FeatureMap)getMixed().<FeatureMap.Entry>list(MyPackage.eINSTANCE.getData_Any());
>
> }
> whereas XSD2Java generates:
> public FeatureMap getAny() {
> return (FeatureMap)getMixed().list(MyPackage.eINSTANCE.getData_Any());
> }
> with the result that Eclipse says: "Cannnot cast from EList<Object> to
> FeatureMap". In my whole model this happens just once, but it seems,
> that XSD2Java is not as reliable as the EMF UI. Not very useful for a
> nightly build :( I hope development of the ANT Tasks will go on as
> they can be very useful!
>
> regards
> Kai
Previous Topic:(no subject)
Next Topic:(no subject)
Goto Forum:
  


Current Time: Sun Sep 15 07:28:20 GMT 2019

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

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

Back to the top