Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XSD generated switch method exceeds 65k size
XSD generated switch method exceeds 65k size [message #1754925] Fri, 24 February 2017 07:45 Go to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I have an ecore model generated from an existing XSD.
The generated model Switch contains a really huge method that delegates to concrete case methods... The compiler comlains about that method to exceed 65k size.
I have never used Switch and I am not sure what this is good for. Is there a way to tell EMF to automatically split that method? Or even prevent its generation if not needed (as all case methods by default return null)?
Re: XSD generated switch method exceeds 65k size [message #1754933 is a reply to message #1754925] Fri, 24 February 2017 08:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
The switch is also used in the adapter factory and that's used by the generated item providers. If you don't need any of these things, you could delete them. Sorry, there is no switch to turn off generating those two things.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD generated switch method exceeds 65k size [message #1754940 is a reply to message #1754933] Fri, 24 February 2017 09:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You can switch off/change the Switch generation by providing a variant such as org.eclipse.qvtd.compiler/templates/model/SwitchClass.javajet that fixes an @NonNull annotation bug. Not a pleasant or recommended approach but if you want to be able to regenerate automatically without manual editing it may be your best bet. Of course you easiest approach may be to make your metamodel smaller. Can you split it into subpackages each with a separate Ecore metamodel, and so separate Switch? The Switches can be extensible across packages if you take care.

The autogenerated Switch provides a powerful Visitor-like capability to add algorithms to models without adding code to every model class. Many of Ecore's mechanisms are widely used so you may be in trouble if you don't have a working Switch.

The org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/xtend/GenerateVisitorsXtend.xtend and associated files autogenerate a family of true Visitor classes that are faster than Switch and do not incur the size limitation. It might well be possible to implement a much simpler Switch that delegates to a Visitor. However trying to make two different method override opportunities co-exist could be difficult.

Regards

Ed Willink
Re: XSD generated switch method exceeds 65k size [message #1754958 is a reply to message #1754933] Fri, 24 February 2017 14:13 Go to previous message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Thanks, Ed.
I left two empty classes (the adapter factory and the model switch) and marked them "@generator NOT", so I do not have to delete them each time the model code is generated.

Ed Merks wrote on Fri, 24 February 2017 09:59
The switch is also used in the adapter factory and that's used by the generated item providers. If you don't need any of these things, you could delete them. Sorry, there is no switch to turn off generating those two things.

Previous Topic:CDO: Standalone Setup for programming with the API
Next Topic:deleted
Goto Forum:
  


Current Time: Fri Mar 29 04:56:50 GMT 2024

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

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

Back to the top