Yep, I did that but I am not happy with it. I will go through the details: I
am toying with relations inside SimpleDS. Let's say that I have two
entities, A and B:

public class A {
   private Key bKey;
   public B getB() {
       throw new UnsupportedOperationException();
   }
}

getB() exists only to be able to compile (if I was working with groovy I
would not have that problem, but that's not the case). I can generate the
code using ASM, but the only solution I have been able to put together was:

* generate a child class (this is created at runtime):

public class A__ds__ extends A {
   public B getB() {
      return EntityManagerFactory.getEntityManager().get(bKey);
   }
}

* load "A__ds__": this can only be done using a child ClassLoader.

I suspect that I cannot replace class "A" in memory (that was the original
question), in which case my best bet is to return extended classes (A__ds__)
from entityManager.get() methods. This means that a.getB() will work or fail
depending if the instance is transient or not. I don't like that.

Am I missing something obvious? Ideas are welcome.

On Fri, May 21, 2010 at 4:29 PM, Didier Durand <[email protected]>wrote:

> Hi Nacho,
>
> Did you try through the class loader ? The page
> http://code.google.com/appengine/docs/java/runtime.html
>
> says:
>
> Custom Class Loading
> Custom class loading is fully supported under App Engine. Please be
> aware, though, that App Engine overrides all ClassLoaders to assign
> the same permissions to all classes loaded by your application. If you
> perform custom class loading, be cautious when loading untrusted third-
> party code.
>
> didier
>
> On May 21, 8:48 am, Nacho Coloma <[email protected]> wrote:
> > Hi, I know this is probably bad timing as most Googlers will probably
> > be at I/O, but anyway:
> >
> > Do I have any way to instrument a class (AKA: modify its bytecode on
> > class loading) inside GAE? I suppose not, and that's why datanucleus
> > is using compile time, but I'm asking just to be sure.
> >
> > This far I have been able to use ASM to create a second class that
> > extends the original and load using a child ClassLoader, but that's a
> > half-assed solution. Is there no way to instrument the original class?
> >
> > -- Nacho
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> > To post to this group, send email to
> [email protected].
> > To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> > For more options, visit this group athttp://
> groups.google.com/group/google-appengine-java?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to