Skip to content

Commit

Permalink
Bump AspectJ to 1.9.23-SNAPSHOT
Browse files Browse the repository at this point in the history
The AspectJ snapshot was deployed on OSSRH Snapshots and contains two
crucial changes:
  1. Method ClassLoaderWeavingAdaptor::defineClass is now protected,
     i.e. we can call it via 'super'.
  2. aspectjtools now contains asm-commons, which is helpful when
     working with the 'intellij' profile referring to aspectjtools. This
     way, it is easier to run tests from the IDE.
  • Loading branch information
kriegaex committed Apr 7, 2024
1 parent c05e515 commit 3639580
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
Expand Up @@ -19,7 +19,6 @@
package org.eclipse.equinox.weaving.aspectj.loadtime;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -149,40 +148,21 @@ public OSGiWeavingAdaptor(final ClassLoader loader,
this.namespace = namespace;
}

private void defineClass(final ClassLoader loader, final String name,
final byte[] bytes) {
protected void defineClass(final ClassLoader loader, final String name, final byte[] bytes) {
if (trace.isTraceEnabled()) {
trace.enter("defineClass", this,
new Object[] { loader, name, bytes });
}
Object clazz = null;
debug("generating class '" + name + "'");

try {
// TODO: For 2024-06 (4.32), make ClassLoaderWeavingAdaptor::defineClass protected and call it via super
// from here instead of duplicating class definition code or hackily calling a private method
if (defineClassMethod == null) {
defineClassMethod = ClassLoaderWeavingAdaptor.class.getDeclaredMethod(
"defineClass",
ClassLoader.class, String.class, byte[].class
);
}
defineClassMethod.setAccessible(true);
clazz = defineClassMethod.invoke(this, loader, name, bytes);
} catch (final 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());
}
super.defineClass(loader, name, bytes);
} catch (final Exception e) {
warn("define generated class failed", e);
}

if (trace.isTraceEnabled()) {
trace.exit("defineClass", clazz);
trace.exit("defineClass", name);
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -64,7 +64,7 @@
<aspectj-maven-compiler-version>1.14</aspectj-maven-compiler-version>

<!-- AspectJ Core binaries + sources (tools, weaver, runtime) to include in AJDT -->
<aspectj.version>1.9.22</aspectj.version>
<aspectj.version>1.9.23-SNAPSHOT</aspectj.version>

<aspectj.exclude.meta-data>
META-INF/**,
Expand Down

0 comments on commit 3639580

Please sign in to comment.