Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » working with JavaRefFactory
working with JavaRefFactory [message #145084] Wed, 25 June 2008 20:40 Go to next message
Andrew Mak is currently offline Andrew Mak
Messages: 41
Registered: July 2009
Member
Hi,

I have some code that generates a Java class file which I subsequently try
to reflect using the JavaRefFactory, like so:

EMFNature nature = JemProjectUtilities.getJEM_EMF_Nature(myProject,
true);
JavaClass javaClass = (JavaClass) JavaRefFactory.eINSTANCE
.reflectType(myClassName, nature.getResourceSet());

I then try to get the list of methods from the javaClass:

List methods = javaClass.getMethods();
// do stuff with methods

The problem I'm running into is that very ocasionally, the list of methods
returned is empty even though the class has methods. It seems to happen
randomly.

Any ideas why that is? Could this be a timing issue? If so, is there some
way I can ensure the model is up-to-date before I reflect the class?

Thanks in advance.
Re: working with JavaRefFactory [message #145256 is a reply to message #145084] Tue, 08 July 2008 20:17 Go to previous message
Andrew Mak is currently offline Andrew Mak
Messages: 41
Registered: July 2009
Member
Hi,

I've since found that if I do a build between the generate and reflect
steps, then the list of methods returned is always correct.

However, I'm not sure if this works because the build is in fact
triggering the model to be up-to-date, or if it works simply because its
adding seconds between the 2 steps. I'm also not too keen about this
solution since I have to incur the overhead associated with the build.

I'm wondering if anyone know of a more lightweight approach than
triggering a build to ensure the model is up-to-date? Thanks in advance.


Andrew Mak wrote:

> Hi,

> I have some code that generates a Java class file which I subsequently try
> to reflect using the JavaRefFactory, like so:

> EMFNature nature = JemProjectUtilities.getJEM_EMF_Nature(myProject,
> true);
> JavaClass javaClass = (JavaClass) JavaRefFactory.eINSTANCE
> .reflectType(myClassName, nature.getResourceSet());

> I then try to get the list of methods from the javaClass:

> List methods = javaClass.getMethods();
> // do stuff with methods

> The problem I'm running into is that very ocasionally, the list of methods
> returned is empty even though the class has methods. It seems to happen
> randomly.

> Any ideas why that is? Could this be a timing issue? If so, is there some
> way I can ensure the model is up-to-date before I reflect the class?

> Thanks in advance.
Re: working with JavaRefFactory [message #617243 is a reply to message #145084] Tue, 08 July 2008 20:17 Go to previous message
Andrew Mak is currently offline Andrew Mak
Messages: 41
Registered: July 2009
Member
Hi,

I've since found that if I do a build between the generate and reflect
steps, then the list of methods returned is always correct.

However, I'm not sure if this works because the build is in fact
triggering the model to be up-to-date, or if it works simply because its
adding seconds between the 2 steps. I'm also not too keen about this
solution since I have to incur the overhead associated with the build.

I'm wondering if anyone know of a more lightweight approach than
triggering a build to ensure the model is up-to-date? Thanks in advance.


Andrew Mak wrote:

> Hi,

> I have some code that generates a Java class file which I subsequently try
> to reflect using the JavaRefFactory, like so:

> EMFNature nature = JemProjectUtilities.getJEM_EMF_Nature(myProject,
> true);
> JavaClass javaClass = (JavaClass) JavaRefFactory.eINSTANCE
> .reflectType(myClassName, nature.getResourceSet());

> I then try to get the list of methods from the javaClass:

> List methods = javaClass.getMethods();
> // do stuff with methods

> The problem I'm running into is that very ocasionally, the list of methods
> returned is empty even though the class has methods. It seems to happen
> randomly.

> Any ideas why that is? Could this be a timing issue? If so, is there some
> way I can ensure the model is up-to-date before I reflect the class?

> Thanks in advance.
Previous Topic:Having a problem with VE/Eclipse
Next Topic:Having a problem with VE/Eclipse
Goto Forum:
  


Current Time: Sat Sep 20 04:04:26 GMT 2014

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

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