Remove ASM-renamed, replace by dynamic relocation via Maven Shadetags/V1_9_7_M2
<artifactId>org.eclipse.jdt.core</artifactId> | <artifactId>org.eclipse.jdt.core</artifactId> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | <groupId>org.aspectj</groupId> |
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | <groupId>org.aspectj</groupId> |
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | <groupId>org.aspectj</groupId> |
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
<modelVersion>4.0.0</modelVersion> | |||||
<!-- The AspectJ root POM is the parent, but this module is not a submodule --> | |||||
<parent> | |||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>aspectj-parent</artifactId> | |||||
<version>1.9.7.BUILD-SNAPSHOT</version> | |||||
</parent> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<version>${asm.version}</version> | |||||
<name>ASM for AspectJ</name> | |||||
<description> | |||||
This module relocates the original ASM artifact from package name 'org.objectweb.asm' to 'aj.org.objectweb.asm', | |||||
using Maven Shade Plugin. | |||||
In order to avoid committing the binary to the AspectJ SCM repository and using it as a system-scoped dependency, we | |||||
deploy it to aspectj.dev. | |||||
Whenever it is necessary to upgrade to a new ASM version in order to make AspectJ compatible with a new Java | |||||
version, please build and deploy this module after upgrading property 'asm.version'. Make sure you have the | |||||
credentials for write access to the aspectj.dev Maven repository WebDAV share and the correct server, profile and | |||||
property entries in settings.xml. | |||||
Then you should be able to run 'mvn clean deploy' for this module and be fine. | |||||
Caveat for IntelliJ IDEA: The project cannot be built in IDEA (Ctrl-F9) if this module is visible in the Maven view. | |||||
If so, right-click it and select "Unlink Maven Projects". Unfortunately, "Ignore Projects" is not enough. If Maven | |||||
knows of this Maven module, it cannot compile other modules depending on shaded class names, because it cannot find | |||||
the binaries. IDEA will just stop looking at the local Maven repository in this case. | |||||
</description> | |||||
<properties> | |||||
<!-- By default, do not deploy artifacts - but deploy this one used by the main build --> | |||||
<maven.deploy.skip>false</maven.deploy.skip> | |||||
</properties> | |||||
<build> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-compiler-plugin</artifactId> | |||||
<executions> | |||||
<!-- Nothing to compile in this module --> | |||||
<execution> | |||||
<id>default-compile</id> | |||||
<phase>none</phase> | |||||
</execution> | |||||
<execution> | |||||
<id>default-testCompile</id> | |||||
<phase>none</phase> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-source-plugin</artifactId> | |||||
<configuration> | |||||
<!-- Re-create original source JAR in order to avoid re-shading already shaded JAR in non-clean builds --> | |||||
<forceCreation>true</forceCreation> | |||||
<!-- | |||||
Avoid attaching the source JAR here, because Maven Shade will add the source uber JAR later. Because both | |||||
JARs have the same final name, Maven Install/Deploy would see two artifacts attached to the build, which | |||||
would lead to double deployment and hence to an error "Transfer failed for ...-sources.jar 409 Conflict". | |||||
See also https://issues.apache.org/jira/browse/MDEPLOY-254 and comments by Alexander Kriegisch. | |||||
--> | |||||
<attach>false</attach> | |||||
<archive> | |||||
<addMavenDescriptor>false</addMavenDescriptor> | |||||
</archive> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<id>attach-sources</id> | |||||
<phase>package</phase> | |||||
<goals> | |||||
<goal>jar-no-fork</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-jar-plugin</artifactId> | |||||
<configuration> | |||||
<archive> | |||||
<addMavenDescriptor>false</addMavenDescriptor> | |||||
</archive> | |||||
<!-- Re-create original JAR in order to avoid re-shading already shaded JAR in non-clean builds --> | |||||
<forceCreation>true</forceCreation> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<!-- Avoid creating test JAR --> | |||||
<id>test-jar</id> | |||||
<phase>none</phase> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<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> | |||||
<excludes> | |||||
<exclude>${project.groupId}</exclude> | |||||
</excludes> | |||||
</artifactSet> | |||||
<filters> | |||||
<filter> | |||||
<artifact>*</artifact> | |||||
<excludes> | |||||
<exclude>META-INF/*</exclude> | |||||
</excludes> | |||||
</filter> | |||||
</filters> | |||||
<relocations> | |||||
<relocation> | |||||
<pattern>org.objectweb.asm</pattern> | |||||
<shadedPattern>aj.org.objectweb.asm</shadedPattern> | |||||
</relocation> | |||||
</relocations> | |||||
</configuration> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.codehaus.mojo</groupId> | |||||
<artifactId>flatten-maven-plugin</artifactId> | |||||
<version>1.2.2</version> | |||||
<executions> | |||||
<!-- Remove shaded dependencies from uber JAR --> | |||||
<execution> | |||||
<id>flatten</id> | |||||
<phase>process-resources</phase> | |||||
<goals> | |||||
<goal>flatten</goal> | |||||
</goals> | |||||
<configuration> | |||||
<flattenMode>defaults</flattenMode> | |||||
<pomElements> | |||||
<dependencies>remove</dependencies> | |||||
</pomElements> | |||||
<outputDirectory>${project.build.directory}</outputDirectory> | |||||
<flattenedPomFilename>flattened-pom.xml</flattenedPomFilename> | |||||
</configuration> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
</plugins> | |||||
</build> | |||||
<dependencies> | |||||
<dependency> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | |||||
</dependencies> | |||||
</project> |
<useProjectArtifact>false</useProjectArtifact> | <useProjectArtifact>false</useProjectArtifact> | ||||
<includes> | <includes> | ||||
<include>org.aspectj:org.eclipse.jdt.core</include> | <include>org.aspectj:org.eclipse.jdt.core</include> | ||||
<include>org.aspectj:asm-renamed</include> | |||||
<include>org.ow2.asm:asm</include> | |||||
</includes> | </includes> | ||||
</dependencySet> | </dependencySet> | ||||
</dependencySets> | </dependencySets> |
<configuration> | <configuration> | ||||
<classifier>sources</classifier> | <classifier>sources</classifier> | ||||
<!--<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>--> | <!--<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> | <outputDirectory>${project.build.directory}/unzipped-sources</outputDirectory> | ||||
<!-- Avoid accidentally shading test-scoped dependencies like JUnit --> | <!-- Avoid accidentally shading test-scoped dependencies like JUnit --> | ||||
<includeScope>runtime</includeScope> | <includeScope>runtime</includeScope> | ||||
</executions> | </executions> | ||||
</plugin> | </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 --> | <!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module --> | ||||
<plugin> | <plugin> | ||||
<groupId>org.codehaus.mojo</groupId> | <groupId>org.codehaus.mojo</groupId> | ||||
<artifactId>org.eclipse.jdt.core</artifactId> | <artifactId>org.eclipse.jdt.core</artifactId> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
</dependencies> | </dependencies> | ||||
<!-- Avoid warning when trying to add non-existing main artifact JAR --> | <!-- Avoid warning when trying to add non-existing main artifact JAR --> | ||||
<useProjectArtifact>false</useProjectArtifact> | <useProjectArtifact>false</useProjectArtifact> | ||||
<includes> | <includes> | ||||
<include>org.aspectj:asm-renamed</include> | |||||
<include>org.ow2.asm:asm</include> | |||||
</includes> | </includes> | ||||
</dependencySet> | </dependencySet> | ||||
</dependencySets> | </dependencySets> |
<configuration> | <configuration> | ||||
<classifier>sources</classifier> | <classifier>sources</classifier> | ||||
<!--<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>--> | <!--<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>--> | ||||
<includeArtifactIds>asm-renamed</includeArtifactIds> | |||||
<includeGroupIds>org.ow2.asm</includeGroupIds> | |||||
<includeArtifactIds>asm</includeArtifactIds> | |||||
<outputDirectory>${project.build.directory}/unzipped-sources</outputDirectory> | <outputDirectory>${project.build.directory}/unzipped-sources</outputDirectory> | ||||
<!-- Avoid accidentally shading test-scoped dependencies like JUnit --> | <!-- Avoid accidentally shading test-scoped dependencies like JUnit --> | ||||
<includeScope>runtime</includeScope> | <includeScope>runtime</includeScope> | ||||
</executions> | </executions> | ||||
</plugin> | </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 --> | <!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module --> | ||||
<plugin> | <plugin> | ||||
<groupId>org.codehaus.mojo</groupId> | <groupId>org.codehaus.mojo</groupId> | ||||
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
</dependencies> | </dependencies> | ||||
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | <groupId>org.aspectj</groupId> |
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
</dependencies> | </dependencies> | ||||
*/ | */ | ||||
protected Ajc ajc; | protected Ajc ajc; | ||||
public static final String CLASSPATH_ASM_RENAMED = | |||||
public static final String CLASSPATH_ASM = | |||||
Arrays.stream(System.getProperty("java.class.path") | Arrays.stream(System.getProperty("java.class.path") | ||||
.split(File.pathSeparator)) | .split(File.pathSeparator)) | ||||
.filter(path -> path.contains("asm-renamed")) | |||||
.filter(path -> path.replace('\\', '/').contains("org/ow2/asm/")) | |||||
.findFirst() | .findFirst() | ||||
.orElseThrow(() -> new RuntimeException("library 'asm-renamed' not found on classpath")); | |||||
.orElseThrow(() -> new RuntimeException("ASM library not found on classpath")); | |||||
// see Ajc and AntSpec | // see Ajc and AntSpec | ||||
public static final String DEFAULT_CLASSPATH_ENTRIES = | 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 + "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.jar" | ||||
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator + "bcel-verifier.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" | + 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... | // hmmm, this next one should perhaps point to an aj-build jar... | ||||
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "aspectjrt.jar" | + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "aspectjrt.jar" |
<module>run-all-junit-tests</module> | <module>run-all-junit-tests</module> | ||||
<module>docs</module> | <module>docs</module> | ||||
<!-- FYI: These are NOT meant to be sub-modules but a stand-alone projects built and deployed independently. --> | |||||
<!-- | |||||
<module>asm-renamed</module> | |||||
--> | |||||
<!-- create the important artifacts we care about --> | <!-- create the important artifacts we care about --> | ||||
<module>aspectjrt</module> | <module>aspectjrt</module> | ||||
<module>aspectjweaver</module> | <module>aspectjweaver</module> |
<scope>test</scope> | <scope>test</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
<scope>test</scope> | <scope>test</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<usedDependencies> | <usedDependencies> | ||||
<!-- The tests need these during runtime, even though no direct usage is in our classes --> | <!-- The tests need these during runtime, even though no direct usage is in our classes --> | ||||
<usedDependency>ant:ant-launcher</usedDependency> | <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:ajde</usedDependency> | ||||
<usedDependency>org.aspectj:build</usedDependency> | <usedDependency>org.aspectj:build</usedDependency> | ||||
<usedDependency>org.aspectj:tests</usedDependency> | <usedDependency>org.aspectj:tests</usedDependency> |
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<!-- Identical to lib/ant/lib/ant.jar, a former system-scoped dependency --> | <!-- Identical to lib/ant/lib/ant.jar, a former system-scoped dependency --> |
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
</dependencies> | </dependencies> | ||||
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | <groupId>org.aspectj</groupId> |
import org.aspectj.lang.annotation.Aspect; | import org.aspectj.lang.annotation.Aspect; | ||||
import org.aspectj.lang.annotation.Before; | 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> | * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> |
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | <groupId>org.aspectj</groupId> |
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.aspectj</groupId> | |||||
<artifactId>asm-renamed</artifactId> | |||||
<groupId>org.ow2.asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
</dependency> | </dependency> | ||||
</dependencies> | </dependencies> | ||||
</project> | </project> |
// are required (unless turning off the verifier) | // are required (unless turning off the verifier) | ||||
if ((myGen.getMajor() == Constants.MAJOR_1_6 && world.shouldGenerateStackMaps()) || myGen.getMajor() > Constants.MAJOR_1_6) { | if ((myGen.getMajor() == Constants.MAJOR_1_6 && world.shouldGenerateStackMaps()) || myGen.getMajor() > Constants.MAJOR_1_6) { | ||||
if (!AsmDetector.isAsmAround) { | 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); | wovenClassFileData = StackMapAdder.addStackMaps(world, wovenClassFileData); | ||||
} | } |
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.weaver.bcel.asm; | 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. | * 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 | * @author Andy Clement | ||||
*/ | */ | ||||
public class AsmDetector { | 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; | public static boolean isAsmAround; | ||||
static { | static { | ||||
try { | 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) { | } catch (Exception e) { | ||||
isAsmAround = false; | 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.UnresolvedType; | ||||
import org.aspectj.weaver.World; | 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 | * 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 |