Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Can I intercept before a class is load time weaved

Hi Choudary,

a) It is about the temporary classloader I need so that I can load the
class and use ObjectStreamClass.lookup(clazz).getSerialVersionUID() to
find the SUID that Java would generate. For this I need to know the
application classpath. I am assuming (and it is working in a client's
Swing application) that the classloader instance passed to the
Aj.preProcess(...) is URLClassLoader and I am calling getURLs() to get
all the paths to search. I am passing null as the parent of my
temporary classloader as the class should not be loaded before passing
to the AspectJ weaver. Is this going to break in a J2EE environment?
Is there a better way to find the classpaths to search? I couldn't
find any temporary classloader implementation in your samples.

I think of two problems here:

- the creation of a temp classloader to figure out the SUID of the class that the JVM would generate sounds like a lot of overhead at runtime. Are you sure this performs well enough for your setting?

- The assumption of an URL classloader is fragile, I think. In an OSGi environment this wouldn't work and I assume this could break in a JEE environment as well.

Wouldn't it be possible to operate on the BCEL level only and calculate the SUID from that yourself without using the method of ObjectStreamClass? This would also solve your dependency on the URLClassLoader.

Just my 2 cents,
-Martin



Back to the top