Skip to main content

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

Raise a bug for this.  It would be helpful to include how you are building the aspects and launching the system (for example, are the aspect built entirely separately from the code against which they apply or are you relying on reweaving at loadtime).  You may be able to build the code in a different way to avoid this problem but I need to know more about what you are doing.

If you change your instantiation model from perthis/pertarget (which I guess you are using as they are the models that result in ajcMightHaveAspect types) then that would prevent the type being generated at all - but that is just a temporary workaround of course. 

> 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?

looks like a comment made a long while ago by Matthew (maw) - i don't think there is an open bug to address anything here so definetly worth raising one.

Andy.

2009/3/31 Saxon D'Aubin <saxon@xxxxxxxxxxxx>
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




_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top