Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [xcore] Error in the generated code, when a type with generics is wrapped and used as argument
[xcore] Error in the generated code, when a type with generics is wrapped and used as argument [message #1776433] Thu, 16 November 2017 12:31 Go to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Error in the generated code, when a type with generics is wrapped an used an argument

Here minimal example that produce compile errors:
@GenModel(
    bundleManifest="false",
    modelDirectory="xcore-maven-example/src/main/java-gen",
    complianceLevel="8.0"
)
package simple.model

interface MyMap wraps java.util.Map<String, String> {}

class Author {
    String name
    op String operationA(MyMap tmp) {
        "Hello " + this.name
    }
}


I get these errors (java compilation errros):
| Description                                                     | Resource              | Path                       | Location | Type         |
+-----------------------------------------------------------------+-----------------------+----------------------------+----------+--------------+
| Syntax error on token "(", Expression expected after this token | ModelPackage.java     | /src-gen/sample/model      | line 234 | Java Problem |
| Syntax error on token "(", Expression expected after this token | ModelPackageImpl.java | /src-gen/sample/model/impl | line 213 | Java Problem |
| Syntax error on token ">", delete this token                    | ModelPackage.java     | /src-gen/sample/model      | line 123 | Java Problem |
| Syntax error on token ">", delete this token                    | ModelPackage.java     | /src-gen/sample/model      | line 175 | Java Problem |
| Syntax error on token ">", delete this token                    | ModelPackage.java     | /src-gen/sample/model      | line 234 | Java Problem |
| Syntax error on token ">", delete this token                    | ModelPackageImpl.java | /src-gen/sample/model/impl | line 136 | Java Problem |
| Syntax error on token ">", Expression expected after this token | AuthorImpl.java       | /src-gen/sample/model/impl | line 172 | Java Problem |
| Syntax error on token ">", Expression expected after this token | ModelPackageImpl.java | /src-gen/sample/model/impl | line 172 | Java Problem |
| Void methods cannot return a value                              | ModelPackageImpl.java | /src-gen/sample/model/impl | line 137 | Java Problem | 


When I look at the generated code, it is really broken. Example in ModelPackage:
EOperation getAuthor__OperationA__String>();


This is really due to generics, because if you change the wrapped type to a type without generics, everything works well:
@GenModel(
    bundleManifest="false",
    modelDirectory="xcore-maven-example/src/main/java-gen",
    complianceLevel="8.0"
)
package simple.model

interface MyFile wraps java.io.File {}

class Author {
    String name
    op String operationA(MyFile tmp) {
        "Hello " + this.name
    }
} 


Another fact: usage as Argument Type is relevant, because for return Types, it is OK:
@GenModel(
    bundleManifest="false",
    modelDirectory="xcore-maven-example/src/main/java-gen",
    complianceLevel="8.0"
)
package simple.model

interface MyMap wraps java.util.Map<String, String> {}

class Author {
    String name
    op MyMap operationR() {
        emptyMap
    }
}

[Updated on: Thu, 16 November 2017 12:33]

Report message to a moderator

Re: [xcore] Error in the generated code, when a type with generics is wrapped and used as argument [message #1776454 is a reply to message #1776433] Thu, 16 November 2017 14:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Yes, something appears to be wrong with how operation accessors are computed. Perhaps @GenModel(operationReflection="false") will avoid the problem, but please open a Bugzilla.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [xcore] Error in the generated code, when a type with generics is wrapped and used as argument [message #1776483 is a reply to message #1776454] Thu, 16 November 2017 21:01 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Thank you a lot for your answer.

Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=527368

Your idea with @GenModel(operationReflection="false") seems to work for this simple example.
Any pointer on what 'operationReflection' is modifying?
Re: [xcore] Error in the generated code, when a type with generics is wrapped and used as argument [message #1776510 is a reply to message #1776483] Fri, 17 November 2017 08:11 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is what generates support for EObject.eInvoke, which is much like EObject.eGet/eSet/eIsSet/eUnset; the former provides reflective access to operations just as the latter provides reflective access to features. Very little (not so much) infrastructure has been built around reflective operation invocation, so it's unlikely that you'll lose any significant functionality that you'd otherwise use. Note that you can hover over anything in the *.xcore file and it will show you information about what Java things are all generated for the given artifact in the Xcore model, including support to navigate to that thing.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] Timeout while prefetching
Next Topic:[CDO] Exception when switching to Oxygen
Goto Forum:
  


Current Time: Tue Apr 23 08:38:08 GMT 2024

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

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

Back to the top