Operation type parameters not erased when generating eInvoke method [message #869530] |
Thu, 03 May 2012 14:40 |
Filip Krikava Messages: 45 Registered: January 2012 |
Member |
|
|
Hi,
I encountered a problem when generating a code in models that use type parameters for operations. All the generated code is fine but eInvoke. I checked the bug #326130 and it seems very related, but I did not find out in which release it has been fixed.
For example: having a following operation:
public <A> Registry register(A type, Class<A> manifest)
it generates:
@Override
@SuppressWarnings("unchecked")
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
switch (operationID) {
case MyPackage.REGISTRY___REGISTER__OBJECT_CLASS:
return register((A)arguments.get(0), (Class<A>)arguments.get(1));
}
return super.eInvoke(operationID, arguments);
}
while it could generate (the simplest)
return register(arguments.get(0), (Class)arguments.get(1));
with @SuppressWarnings({ "unchecked", "rawtypes" }) ?
btw: I'm using EMF 2.7.2.v20120130-0943
-
Attachment: emf-1.zip
(Size: 22.44KB, Downloaded 143 times)
|
|
|
Re: Operation type parameters not erased when generating eInvoke method [message #869782 is a reply to message #869530] |
Fri, 04 May 2012 09:52 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Filip,
Comments below.
On 03/05/2012 4:40 PM, Filip Krikava wrote:
> Hi,
>
> I encountered a problem when generating a code in models that use type parameters for operations.
That sounds familiar...
> All the generated code is fine but eInvoke. I checked the bug #326130 and it seems very related, but I did not find out in which release it has been fixed.
The comment says it's fixed in 2.8. That's the current stream that will
be released in June as part of the Juno coordinated release. You'll
need to get something like the 2.8M7 build to try it out (from the Juno
p2 repo).
>
> For example: having a following operation:
>
>
> public<A> Registry register(A type, Class<A> manifest)
>
>
> it generates:
>
>
> @Override
> @SuppressWarnings("unchecked")
> public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
> switch (operationID) {
> case MyPackage.REGISTRY___REGISTER__OBJECT_CLASS:
> return register((A)arguments.get(0), (Class<A>)arguments.get(1));
> }
> return super.eInvoke(operationID, arguments);
> }
>
>
> while it could generate (the simplest)
>
>
> return register(arguments.get(0), (Class)arguments.get(1));
>
>
> with @SuppressWarnings({ "unchecked", "rawtypes" }) ?
>
> btw: I'm using EMF 2.7.2.v20120130-0943
Yes, that won't have the fix.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03306 seconds