<artifactId>org.eclipse.jdt.core</artifactId>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<useProjectArtifact>false</useProjectArtifact>
<includes>
<include>org.aspectj:org.eclipse.jdt.core</include>
- <include>org.aspectj:asm-renamed</include>
+ <include>org.ow2.asm:asm</include>
</includes>
</dependencySet>
</dependencySets>
<configuration>
<classifier>sources</classifier>
<!--<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>-->
- <includeArtifactIds>org.eclipse.jdt.core,asm-renamed</includeArtifactIds>
+ <includeGroupIds>org.aspectj,org.ow2.asm</includeGroupIds>
+ <includeArtifactIds>org.eclipse.jdt.core,asm</includeArtifactIds>
<outputDirectory>${project.build.directory}/unzipped-sources</outputDirectory>
<!-- Avoid accidentally shading test-scoped dependencies like JUnit -->
<includeScope>runtime</includeScope>
</executions>
</plugin>
+ <!--
+ Relocate ASM from 'org.objectweb.asm' to 'aj.org.objectweb.asm'
+
+ TODO: Using Maven Shade after Maven Assembly instead of creating uber JAR and relocating package names at the
+ same time is suboptimal and maybe slower than doing both at the same time. Migrating from Assembly to Shade
+ requires all dependencies to produce source JARs, though, which currently is not the case. Because we also
+ want to create a complete source JAR, for now we keep Assembly around, because it manually copies project
+ sources from their respective directories before zipping them up.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <createSourcesJar>true</createSourcesJar>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ </configuration>
+ <executions>
+ <execution>
+ <id>asm-relocate</id>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <minimizeJar>false</minimizeJar>
+ <shadeSourcesContent>true</shadeSourcesContent>
+ <artifactSet>
+ <includes>
+ <include>${project.groupId}:${project.artifactId}</include>
+ </includes>
+ </artifactSet>
+ <relocations>
+ <relocation>
+ <pattern>org.objectweb.asm</pattern>
+ <shadedPattern>aj.org.objectweb.asm</shadedPattern>
+ </relocation>
+ </relocations>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
<!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
</dependencies>
<!-- Avoid warning when trying to add non-existing main artifact JAR -->
<useProjectArtifact>false</useProjectArtifact>
<includes>
- <include>org.aspectj:asm-renamed</include>
+ <include>org.ow2.asm:asm</include>
</includes>
</dependencySet>
</dependencySets>
<configuration>
<classifier>sources</classifier>
<!--<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>-->
- <includeArtifactIds>asm-renamed</includeArtifactIds>
+ <includeGroupIds>org.ow2.asm</includeGroupIds>
+ <includeArtifactIds>asm</includeArtifactIds>
<outputDirectory>${project.build.directory}/unzipped-sources</outputDirectory>
<!-- Avoid accidentally shading test-scoped dependencies like JUnit -->
<includeScope>runtime</includeScope>
</executions>
</plugin>
+ <!--
+ Relocate ASM from 'org.objectweb.asm' to 'aj.org.objectweb.asm'
+
+ TODO: Using Maven Shade after Maven Assembly instead of creating uber JAR and relocating package names at the
+ same time is suboptimal and maybe slower than doing both at the same time. Migrating from Assembly to Shade
+ requires all dependencies to produce source JARs, though, which currently is not the case. Because we also
+ want to create a complete source JAR, for now we keep Assembly around, because it manually copies project
+ sources from their respective directories before zipping them up.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <createSourcesJar>true</createSourcesJar>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ </configuration>
+ <executions>
+ <execution>
+ <id>asm-relocate</id>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <minimizeJar>false</minimizeJar>
+ <shadeSourcesContent>true</shadeSourcesContent>
+ <artifactSet>
+ <includes>
+ <include>${project.groupId}:${project.artifactId}</include>
+ </includes>
+ </artifactSet>
+ <relocations>
+ <relocation>
+ <pattern>org.objectweb.asm</pattern>
+ <shadedPattern>aj.org.objectweb.asm</shadedPattern>
+ </relocation>
+ </relocations>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
<!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
</dependencies>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
</dependencies>
*/
protected Ajc ajc;
- public static final String CLASSPATH_ASM_RENAMED =
+ public static final String CLASSPATH_ASM =
Arrays.stream(System.getProperty("java.class.path")
.split(File.pathSeparator))
- .filter(path -> path.contains("asm-renamed"))
+ .filter(path -> path.replace('\\', '/').contains("org/ow2/asm/"))
.findFirst()
- .orElseThrow(() -> new RuntimeException("library 'asm-renamed' not found on classpath"));
+ .orElseThrow(() -> new RuntimeException("ASM library not found on classpath"));
// see Ajc and AntSpec
public static final String DEFAULT_CLASSPATH_ENTRIES =
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "junit" + File.separator + "junit.jar"
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator + "bcel.jar"
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator + "bcel-verifier.jar"
- + File.pathSeparator + CLASSPATH_ASM_RENAMED
+ + File.pathSeparator + CLASSPATH_ASM
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "testing-client.jar"
// hmmm, this next one should perhaps point to an aj-build jar...
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "aspectjrt.jar"
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<usedDependencies>
<!-- The tests need these during runtime, even though no direct usage is in our classes -->
<usedDependency>ant:ant-launcher</usedDependency>
- <usedDependency>org.aspectj:asm-renamed</usedDependency>
+ <usedDependency>org.ow2.asm:asm</usedDependency>
<usedDependency>org.aspectj:ajde</usedDependency>
<usedDependency>org.aspectj:build</usedDependency>
<usedDependency>org.aspectj:tests</usedDependency>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
<dependency>
<!-- Identical to lib/ant/lib/ant.jar, a former system-scoped dependency -->
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
</dependencies>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
-import aj.org.objectweb.asm.ClassWriter;
-import aj.org.objectweb.asm.Opcodes;
-import aj.org.objectweb.asm.MethodVisitor;
-import aj.org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.AnnotationVisitor;
/**
* @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>asm-renamed</artifactId>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
</dependency>
</dependencies>
</project>
// are required (unless turning off the verifier)
if ((myGen.getMajor() == Constants.MAJOR_1_6 && world.shouldGenerateStackMaps()) || myGen.getMajor() > Constants.MAJOR_1_6) {
if (!AsmDetector.isAsmAround) {
- throw new BCException("Unable to find Asm for stackmap generation (Looking for 'aj.org.objectweb.asm.ClassReader'). Stackmap generation for woven code is required to avoid verify errors on a Java 1.7 or higher runtime");
+ throw new BCException(
+ "Unable to find ASM classes (" + AsmDetector.CLASS_READER + ", " + AsmDetector.CLASS_VISITOR + ") " +
+ "for stackmap generation. Stackmap generation for woven code is required to avoid verify errors " +
+ "on a Java 1.7 or higher runtime."
+ );
}
wovenClassFileData = StackMapAdder.addStackMaps(world, wovenClassFileData);
}
* ******************************************************************/
package org.aspectj.weaver.bcel.asm;
-import java.lang.reflect.Method;
-
/**
* Determines if a version of asm is around that will enable us to add stack map attributes to classes that we produce.
- *
+ *
* @author Andy Clement
*/
public class AsmDetector {
-
+ public static final String CLASS_READER = "org.objectweb.asm.ClassReader";
+ public static final String CLASS_VISITOR = "org.objectweb.asm.ClassVisitor";
public static boolean isAsmAround;
static {
try {
- Class<?> reader = Class.forName("aj.org.objectweb.asm.ClassReader");
- Class<?> visitor = Class.forName("aj.org.objectweb.asm.ClassVisitor");
- Method m = reader.getMethod("accept", new Class[] { visitor, Integer.TYPE });
- isAsmAround = m != null;
+ Class<?> reader = Class.forName(CLASS_READER);
+ Class<?> visitor = Class.forName(CLASS_VISITOR);
+ reader.getMethod("accept", visitor, Integer.TYPE);
+ isAsmAround = true;
} catch (Exception e) {
isAsmAround = false;
}
- // System.out.println(isAsmAround?"ASM detected":"No ASM found");
+ //System.out.println(isAsmAround ? "ASM detected" : "No ASM found");
}
}
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.World;
-import aj.org.objectweb.asm.ClassReader;
-import aj.org.objectweb.asm.ClassVisitor;
-import aj.org.objectweb.asm.ClassWriter;
-import aj.org.objectweb.asm.MethodVisitor;
-import aj.org.objectweb.asm.Opcodes;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
/**
* Uses asm to add the stack map attribute to methods in a class. The class is passed in as pure byte data and then a reader/writer