Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Accessing the GenModel nsUri
Accessing the GenModel nsUri [message #236379] Fri, 17 July 2009 14:10 Go to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi,

I've come across a really strange issue with the Galileo release of GMF.

I have a plugin that has the following code:

import org.eclipse.gmf.codegen.gmfgen.GMFGenPackage;
.....
System.err.println(GMFGenPackage.eNS_URI);

When I export my plugin from 3.4, install it and run it in 3.5 I get

http://www.eclipse.org/gmf/2008/GenModel

Now when I move my plugin source to 3.5 and run it there I get

http://www.eclipse.org/gmf/2009/GenModel (2009 instead of 2008)

I'm experiencing this in a clean Galileo Eclipse Modeling package
obtained here:
http://www.eclipse.org/downloads/download.php?file=/technolo gy/epp/downloads/release/galileo/R/eclipse-modeling-galileo- incubation-win32.zip

Strangely enough, substituting the offending line with

System.err.println(GMFGenPackage.eINSTANCE.getNsURI());

prints (the expected)

http://www.eclipse.org/gmf/2009/GenModel

in both cases.

Any thoughts on this would be appreciated...

Cheers,
Dimitris
Re: Accessing the GenModel nsUri [message #236894 is a reply to message #236379] Mon, 20 July 2009 13:54 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Dimitris,

In GMF 2.2 we've changed GMFGenPackage NS URI to http://www.eclipse.org/gmf/2009/GenModel.

If you compile plugin with previouse version of GMF then constants will be
inlined by Java compiler, so

System.err.println(GMFGenPackage.eNS_URI);

call will be represented as:

System.err.println("http://www.eclipse.org/gmf/2008/GenModel");

in bytecode. This is a reqson why you can see http://www.eclipse.org/gmf/2008/GenModel
line printed with Gallileo 3.5 by System.err.println(GMFGenPackage.eNS_URI);
compiled in 3.4

Be careful using static constants wich can be changed with plugin version...

-----------------
Alex Shatalin
Re: Accessing the GenModel nsUri [message #237041 is a reply to message #236894] Tue, 21 July 2009 09:12 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Alex,

Many thanks for your response. That's what I originally thought but when
I decompiled the .class from the jar, the value wasn't inlined in the
decompiled source. Then I thought that perhaps the compiler inlines it
but also maintains some metadata in the .class file which the decompiler
then uses to recover the name of the constant.

I've also confirmed that this is not the case with plain vanilla command
line javac so this must be an (unfortunate) optimization of the Eclipse
Java compiler. I'll look into this a bit more and let you know how it goes.

Cheers,
Dimitris

Alex Shatalin wrote:
> Hello Dimitris,
>
> In GMF 2.2 we've changed GMFGenPackage NS URI to
> http://www.eclipse.org/gmf/2009/GenModel.
>
> If you compile plugin with previouse version of GMF then constants will
> be inlined by Java compiler, so
> System.err.println(GMFGenPackage.eNS_URI);
>
> call will be represented as:
>
> System.err.println("http://www.eclipse.org/gmf/2008/GenModel");
>
> in bytecode. This is a reqson why you can see
> http://www.eclipse.org/gmf/2008/GenModel line printed with Gallileo 3.5
> by System.err.println(GMFGenPackage.eNS_URI); compiled in 3.4
>
> Be careful using static constants wich can be changed with plugin
> version...
>
> -----------------
> Alex Shatalin
>
>
Previous Topic:Generating diagram code in build process
Next Topic:Problem with Affixed Parent Side
Goto Forum:
  


Current Time: Thu Apr 09 21:42:12 GMT 2020

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

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

Back to the top