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

Andy,
I'm trying to compile the Glassbox source with the source & target set to 1.5.  The aspects in the source are compiled, but weaving is used to hook into non-Glassbox classes at runtime and record invocation metrics.  When the source is set to 1.4, all of the glassbox code is ignored in the runtime weave (it's listed in the aop excludes).  When the source is set to 1.5, the compiled classes contain annotations, and even though their packages are listed in the excludes, the weaving classloader notices the annotations and tries to reweave them.  If I could just make the weaving classloader ignore my classes I'd be in good shape, but the behavior of the classloader is different when the source level is changed from 1.4 to 1.5.

Yes, a perthis is used on the class that experiences a problem.  The code looks like this:

    @Aspect("perthis(within(AbstractMonitorClass+) && execution(new(..)))")
    public class RuntimeControl {
    }

I'll open a bug, but a workaround would be great.  The problem exists in the current stable developer build.
Thanks
-Saxon


On Mar 31, 2009, at 2:36 PM, Andy Clement wrote:

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


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

Saxon D'Aubin
Principal Engineer
+1 503 975 1423

( ( ))  New Relic
Twitter: NewRelic




Back to the top