Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Suppressing LinkageError during runtime weaving

Hi,
I'm trying to get past a LinkageError logged at warning level during runtime weaving.  I'm using AspectJ1.6.3, but the same problem occurs in 1.5.  I have some compiled aspects that use annotations.  The compilation step creates an inner ajcMightHaveAspect class.  When I start my app, the weaving classloader tries to create this class again, a LinkageError is thrown, caught, and logged at warn level.  Here's the aspectj code:

/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java (line 799 is the logging)

try {
// TODO av protection domain, and optimize
Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] { String.class, bytes.getClass(),
int.class, int.class });
defineClass.setAccessible(true);
clazz = defineClass.invoke(loader, new Object[] { name, bytes, new Integer(0), new Integer(bytes.length) });
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof LinkageError) {
warn("define generated class failed", e.getTargetException());
// is already defined (happens for X$ajcMightHaveAspect interfaces since aspects are reweaved)
// TODO maw I don't think this is OK and
} else {
warn("define generated class failed", e.getTargetException());
}

I want to know how to avoid this warning.  Logging an exception at this level is not acceptable.  Is there any way to compile my aspects to avoid this error?  Is there some hint that can be added to the annotations?  

The comment "maw I don't think this is OK" makes it sound like you guys planned to revisit how this case is handled.  If there is no way to work around this problem, could you guys at least lower the level that this statement to a very low level?
Thanks
-Saxon




Back to the top