Browse Source

Make all tests run on Java 16 via '-add-opens' JVM option

Due to JEP 260 (Encapsulate Most Internal APIs), aspect weaving on
Java 16 now requires '--add-opens java.base/java.lang=ALL-UNNAMED' on
the command line. Otherwise there will be illegal access exceptions for
some internal API calls AspectJ needs, most prominently when trying to
define classes in other packages or modules.

This had to be done on several levels:

  - Maven Surefire: running tests in a JVM directly forked by Surefire.
    In order to make this backwards compatible, I added two profiles
    with JDK-level-dependent auto-activation, one 8-15 and one 16+. In
    the latter a property containing the JVM parameter is defined, in
    the former it is empty, i.e. the JVM is started without the
    parameter. In Java 8 the parameter did not even exist, in Java 9+ we
    could use it, but we need to test how users use AspectJ.

  - RunSpec: Whenever an XML test is declared to use '<run>', we need to
    determine the current JVM version and again dynamically add the
    parameter when forking the target JVM.

  - AntSpec: Whenever an XML test is declared to use '<ant>', we need to
    determine the current JVM version dynamically add two properties
    usable from within Ant scripts: 'aj.addOpensKey' and
    'aj.addOpensValue'. Unfortunately, Ant needs to use two '<argLine>'
    parameters, because the two parts of the option are separated by a
    space character.

  - Ant scripts: When triggered by an AntSpec, each Ant target using LTW
    needs to manually set
      <jvmarg value="${aj.addOpensKey}"/>
      <jvmarg value="${aj.addOpensValue}"/>
    for each '<java>' task. It was quite tedious to find all(?) of them.

TODO: In the AspectJ 1.9.7 release notes we need to document that this
parameter is now needed for LTW.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tags/java16-add-opens^0
Alexander Kriegisch 3 years ago
parent
commit
79e44360cd

+ 64
- 12
pom.xml View File

@@ -50,7 +50,35 @@
<module>installer</module>
</modules>

<!--
Caveat: Automatic, JDK-based profile activation can *not* be inherited by child POMs defining
the same profiles. Thus, we have to repeat activation conditions there.

Note: We can check if automatic profile activation works via mvn help:active-profiles.
-->
<profiles>
<profile>
<id>jdk-8-to-15</id>
<activation>
<jdk>[1.8,16)</jdk>
</activation>
<properties>
<jvm.arg.addOpens/>
</properties>
</profile>
<profile>
<id>jdk-16-to-xx</id>
<activation>
<jdk>[16,)</jdk>
</activation>
<properties>
<jvm.arg.addOpens>--add-opens java.base/java.lang=ALL-UNNAMED</jvm.arg.addOpens>
</properties>
</profile>
</profiles>

<build>

<pluginManagement>
<plugins>
<plugin>
@@ -66,16 +94,21 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<!--
<testFailureIgnore>true</testFailureIgnore>
-->
<!--<testFailureIgnore>true</testFailureIgnore>-->
<argLine>${jvm.arg.addOpens}</argLine>
<excludes>
<exclude>**/*ModuleTests.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -88,7 +121,7 @@
</configuration>
<executions>
<execution>
<id>test-jar</id>
<id>test-jar</id>
<goals>
<goal>test-jar</goal>
</goals>
@@ -104,25 +137,44 @@
<fileset>
<directory>.</directory>
<includes>
<include>**/ajcore.*.txt</include>

</includes>
<include>**/ajcore.*.txt</include>
</includes>
<!--
<excludes> <exclude>**/important.log</exclude> <exclude>**/another-important.log</exclude>
</excludes> -->
<excludes>
<exclude>**/important.log</exclude>
<exclude>**/another-important.log</exclude>
</excludes>
-->
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>aj-build</directory>
<!-- <includes> <include>**/*.tmp</include> <include>**/*.log</include>
</includes> <excludes> <exclude>**/important.log</exclude> <exclude>**/another-important.log</exclude>
</excludes> -->
<!--
<includes>
<include>**/*.tmp</include>
<include>**/*.log</include>
</includes>
<excludes>
<exclude>**/important.log</exclude>
<exclude>**/another-important.log</exclude>
</excludes>
-->
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>

<!--
This plugin is nice to have in the POM, because then it is easy to double-click a goal such as 'effective-pom',
'active-profiles', 'effective-settings' or 'evaluate' from a modern IDE in order to get quick information about
the current build configuration for any given module.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
</plugin>

</plugins>

</build>

+ 2
- 0
run-all-junit-tests/pom.xml View File

@@ -288,6 +288,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<argLine>${jvm.arg.addOpens}</argLine>
</configuration>
<executions>
<execution>
@@ -311,6 +312,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<argLine>${jvm.arg.addOpens}</argLine>
</configuration>
<executions>
<execution>

+ 23
- 23
testing-drivers/pom.xml View File

@@ -71,27 +71,27 @@
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<excludes>
<exclude>**/*AjcTestSpecAsTest*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<argLine>${jvm.arg.addOpens}</argLine>
<excludes>
<exclude>**/*AjcTestSpecAsTest*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

+ 31
- 10
testing/src/test/java/org/aspectj/testing/AntSpec.java View File

@@ -26,21 +26,33 @@ import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.types.Path;
import org.aspectj.tools.ajc.AjcTestCase;

import static org.aspectj.util.LangUtil.is16VMOrGreater;

/**
* Element that allow to run an abritrary Ant target in a sandbox.
* <p/>
* Such a spec is used in a "<ajc-test><ant file="myAnt.xml" [target="..."] [verbose="true"]/> XML element. The "target" is
* optional. If not set, default myAnt.xml target is used. The "file" file is looked up from the <ajc-test dir="..."/> attribute. If
* "verbose" is set to "true", the ant -v output is piped, else nothing is reported except errors.
* Such a spec is used in a {@code <ajc-test><ant file="myAnt.xml" [target="..."] [verbose="true"]/>} XML element. The
* {@code target} is optional. If not set, default <i>myAnt.xml</i> target is used. The {@code file} is looked up from
* the {@code <ajc-test dir="..."/>} attribute. If @{code verbose} is set to {@code true}, the {@code ant -v} output is
* piped, else nothing is reported except errors.
* <p/>
* The called Ant target benefits from 2 implicit variables: "${aj.sandbox}" points to the test current sandbox folder. "aj.path" is
* an Ant refid on the classpath formed with the sandbox folder + ltw + the AjcTestCase classpath (ie usually aspectjrt, junit, and
* testing infra)
* The called Ant target benefits from some implicit variables:
* <ul>
* <li>{@code ${aj.sandbox}} points to the test current sandbox folder.</li>
* <li>
* {@code ${aj.path}} is an Ant refid on the classpath formed with the sandbox folder + ltw + the AjcTestCase
* classpath (i.e. usually aspectjrt, junit, and testing infra).
* </li>
* <li>
* For Java 16+, {@code ${aj.addOpensKey}} and {@code ${aj.addOpensValue}} together add {@code --add-opens} and
* {@code java.base/java.lang=ALL-UNNAMED} as JVM parameters. They have to be used together and consecutively in
* this order as {@code jvmarg} parameter tags inside the {@code java} Ant task.
* </li>
* </ul>
* <p/>
* Element "<stdout><line text="..">" and "<stderr><line text="..">" can be used. For now a full match is performed on the output of
* the runned target only (not the whole Ant invocation). This is experimental and advised to use a "<junit>" task instead or a
* "<java>" whose main that throws some exception upon failure.
*
* Element {@code <stdout><line text="..">} and {@code <stderr><line text="..">} can be used. For now, a full match is
* performed on the output of the runned target only (not the whole Ant invocation). This is experimental and you are
* advised to use a {@code <junit>} task instead or a {@code <java>} whose main throws some exception upon failure.
*
* @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
*/
@@ -92,6 +104,15 @@ public class AntSpec implements ITestStep {
// setup aj.dir "modules" folder
p.setUserProperty("aj.root", new File("..").getAbsolutePath());

// On Java 16+, LTW no longer works without this parameter. Add the argument here and not in AjcTestCase::run,
// because even if 'useLTW' and 'useFullLTW' are not set, we might in the future have tests for weaver attachment
// during runtime. See also docs/dist/doc/README-187.html.
//
// Attention: Ant 1.6.3 under Linux neither likes "" (empty string) nor " " (space), on Windows it would not be
// a problem. So we use "_dummy" Java system properties, even though they pollute the command line.
p.setUserProperty("aj.addOpensKey", is16VMOrGreater() ? "--add-opens" : "-D_dummy");
p.setUserProperty("aj.addOpensValue", is16VMOrGreater() ? "java.base/java.lang=ALL-UNNAMED" : "-D_dummy");

// create the test implicit path aj.path that contains the sandbox + regular test infra path
Path path = new Path(p, inTestCase.getSandboxDirectory().getAbsolutePath());
populatePath(path, DEFAULT_LTW_CLASSPATH_ENTRIES);

+ 9
- 0
testing/src/test/java/org/aspectj/testing/RunSpec.java View File

@@ -22,6 +22,8 @@ import java.util.StringTokenizer;
import org.aspectj.tools.ajc.AjcTestCase;
import org.aspectj.util.FileUtil;

import static org.aspectj.util.LangUtil.is16VMOrGreater;

/**
* @author Adrian Colyer
*/
@@ -63,6 +65,13 @@ public class RunSpec implements ITestStep {
try {
setSystemProperty("test.base.dir", inTestCase.getSandboxDirectory().getAbsolutePath());

if (vmargs == null)
vmargs = "";
// On Java 16+, LTW no longer works without this parameter. Add the argument here and not in AjcTestCase::run,
// because even if 'useLTW' and 'useFullLTW' are not set, we might in the future have tests for weaver attachment
// during runtime. See also docs/dist/doc/README-187.html.
vmargs += is16VMOrGreater() ? " --add-opens java.base/java.lang=ALL-UNNAMED" : "";

AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(), getModuleToRun(), args, vmargs, getClasspath(), getModulepath(), useLtw, "true".equalsIgnoreCase(usefullltw));

if (stdErrSpec != null) {

+ 4
- 2
tests/bugs153/pr155033/ant.xml View File

@@ -15,12 +15,14 @@
<jvmarg value="-Dorg.aspectj.weaver.Dump.condition=error"/>
<sysproperty key="org.aspectj.dump.directory" path="${aj.sandbox}"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg line="${jdwp}"/>-->
<!--
<!--
<jvmarg value="-Dorg.aspectj.tracing.enabled=true"/>
<jvmarg value="-Dorg.aspectj.tracing.factory=default"/>
<jvmarg value="-Dorg.aspectj.tracing.messages=true"/>
-->
-->
</java>
</target>


+ 4
- 2
tests/bugs153/pr157474/ant-server.xml View File

@@ -9,16 +9,18 @@
<target name="TestServer with duplicate configuration">
<copy file="${aj.root}/tests/bugs153/pr157474/server-applicationandlibrary.properties"
tofile="${aj.sandbox}/server.properties"/>
<mkdir dir="${aj.sandbox}/Application"/>
<copy file="${aj.root}/tests/bugs153/pr157474/aop-application.xml"
tofile="${aj.sandbox}/Application/META-INF/aop.xml"/>
<java fork="yes" classname="org.aspectj.testing.server.TestServer" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-Daj.weaving.verbose=true"/>
<jvmarg value="-Dorg.aspectj.weaver.showWeaveInfo=true"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg value="-Dorg.aspectj.testing.server.debug=true"/>-->
<arg path="${aj.sandbox}"/>
</java>

+ 2
- 0
tests/bugs153/pr158957/ant.xml View File

@@ -20,6 +20,8 @@
<jvmarg value="-Dorg.aspectj.tracing.enabled=true"/>
<jvmarg value="-Dorg.aspectj.tracing.factory=default"/>
<jvmarg value="-Dorg.aspectj.tracing.messages=true"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg line="${jdwp}"/>-->
</java>
</target>

+ 42
- 8
tests/java5/ataspectj/ajc-ant.xml View File

@@ -24,6 +24,8 @@
<!-- use META-INF/aop.xml style -->
<classpath path="ataspectj/pathentry"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg line="${jdwp}"/>-->
</java>
</target>
@@ -34,6 +36,8 @@
<java fork="yes" classname="ataspectj.PerClauseTest" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg line="${jdwp}"/> -->
</java>
</target>
@@ -44,6 +48,8 @@
<java fork="yes" classname="ataspectj.AroundInlineMungerTest" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!--<jvmarg line="${jdwp}"/>--><!-- uncomment to debug with JDWP -->
</java>
</target>
@@ -54,6 +60,8 @@
<java fork="yes" classname="ataspectj.AroundInlineMungerTest2" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
</target>

@@ -61,6 +69,8 @@
<java fork="yes" classname="ataspectj.DumpTest" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
</target>

@@ -70,6 +80,8 @@
<java fork="yes" classname="ataspectj.TestProxyGenerator" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
</target>

@@ -89,6 +101,8 @@
<pathelement path="${aj.sandbox}/main1.jar"/>
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
</target>

@@ -100,27 +114,33 @@
</javac>
<copy file="ataspectj/ltwlog/aop-silent.xml"
tofile="${aj.sandbox}/META-INF/aop.xml"
overwrite="yes"
overwrite="yes"
/>
<java fork="yes" classname="ataspectj.ltwlog.MainSilent" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
<copy file="ataspectj/ltwlog/aop-verbsoe.xml"
tofile="${aj.sandbox}/META-INF/aop.xml"
overwrite="yes"
overwrite="yes"
/>
<java fork="yes" classname="ataspectj.ltwlog.MainVerbose" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
<copy file="ataspectj/ltwlog/aop-verboseandshow.xml"
tofile="${aj.sandbox}/META-INF/aop.xml"
overwrite="yes"
overwrite="yes"
/>
<java fork="yes" classname="ataspectj.ltwlog.MainVerboseAndShow" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
</target>

@@ -142,30 +162,36 @@
<pathelement path="${aj.root}/lib/asm/asm-2.0.jar"/>
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
</target>

<target name="ltw.Decp">
<copy file="ataspectj/aop-decptest.xml"
tofile="${aj.sandbox}/META-INF/aop.xml"
overwrite="yes"
overwrite="yes"
/>
<java fork="yes" classname="ataspectj.DeclareParentsInterfaceTest" failonerror="yes">
<classpath>
<path refid="aj.path"/>
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>

<copy file="ataspectj/aop-decptest.xml"
tofile="${aj.sandbox}/META-INF/aop.xml"
overwrite="yes"
overwrite="yes"
/>
<java fork="yes" classname="ataspectj.DeclareParentsImplementsTest" failonerror="yes">
<classpath>
<path refid="aj.path"/>
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
</target>

@@ -187,6 +213,8 @@
<path refid="aj.path"/>
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
</target>

@@ -204,6 +232,8 @@
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-DaspectDeclared=true"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
<!--Now ensure that the error is not produced when the declaration is made.-->
<copy file="ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml"
@@ -216,6 +246,8 @@
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-DaspectDeclared=false"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
</target>

@@ -243,6 +275,8 @@
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-Daj.weaving.verbose=true"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
</java>
</target>

@@ -256,13 +290,13 @@
<pathelement path="${aj.sandbox}/aspects.jar"/>
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<!--
-->
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-Daj.weaving.verbose=true"/>
<jvmarg value="-Djava.util.logging.config.file=${aj.root}/weaver5/testdata/logging.properties"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg line="${jdwp}"/>-->
</java>
</target>

</project>
</project>

+ 10
- 6
tests/ltw/ant-server.xml View File

@@ -14,9 +14,11 @@
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-Daj.weaving.verbose=true"/>
<jvmarg value="-Dorg.aspectj.weaver.showWeaveInfo=true"/>
<sysproperty key="org.aspectj.dump.directory" path="${aj.sandbox}"/>
<!-- <jvmarg value="-Dorg.aspectj.testing.server.debug=true"/>-->
<arg path="${aj.sandbox}"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!--<jvmarg value="-Dorg.aspectj.testing.server.debug=true"/>-->
<sysproperty key="org.aspectj.dump.directory" path="${aj.sandbox}"/>
<arg path="${aj.sandbox}"/>
</java>
</target>

@@ -28,9 +30,11 @@
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-Daj.weaving.verbose=true"/>
<jvmarg value="-Dorg.aspectj.weaver.showWeaveInfo=true"/>
<sysproperty key="org.aspectj.dump.directory" path="${aj.sandbox}"/>
<!-- <jvmarg value="-Dorg.aspectj.testing.server.debug=true"/>-->
<arg path="${aj.sandbox}"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!--<jvmarg value="-Dorg.aspectj.testing.server.debug=true"/>-->
<sysproperty key="org.aspectj.dump.directory" path="${aj.sandbox}"/>
<arg path="${aj.sandbox}"/>
</java>
</target>


+ 33
- 21
tests/ltw/ant.xml View File

@@ -11,15 +11,17 @@
<java fork="yes" classname="HelloWorldWithException" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-Djava.system.class.loader=org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
<sysproperty key="aj.class.path" path="${aj.sandbox}/hello.jar:${aj.sandbox}/handler.jar"/>
<!--
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<jvmarg value="-Dorg.aspectj.tracing.debug=true"/>
<!--
<jvmarg value="-Daj.weaving.verbose=true"/>
<jvmarg value="-Dorg.aspectj.weaver.showWeaveInfo=true"/>
-->
<jvmarg value="-Dorg.aspectj.tracing.debug=true"/>
-->
<!-- use META-INF/aop.xml style -->
<!-- <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>-->
<!-- <jvmarg line="${jdwp}"/>-->
<!--<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>-->
<!--<jvmarg line="${jdwp}"/>-->
<sysproperty key="aj.class.path" path="${aj.sandbox}/hello.jar:${aj.sandbox}/handler.jar"/>
</java>
</target>

@@ -27,22 +29,24 @@
<java fork="yes" classname="HelloWorldWithException" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-Djava.system.class.loader=org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
<sysproperty key="aj.class.path" path="${aj.sandbox}/hello.jar:${aj.sandbox}/handler.jar"/>
<sysproperty key="aj.aspect.path" path="${aj.sandbox}/handler.jar"/>
<!--
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<jvmarg value="-Dorg.aspectj.tracing.debug=true"/>
<!--
<jvmarg value="-Daj.weaving.verbose=true"/>
<jvmarg value="-Dorg.aspectj.weaver.showWeaveInfo=true"/>
-->
<jvmarg value="-Dorg.aspectj.tracing.debug=true"/>
-->
<!-- use META-INF/aop.xml style -->
<!-- <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>-->
<!-- <jvmarg line="${jdwp}"/>-->
<!--<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>-->
<!--<jvmarg line="${jdwp}"/>-->
<sysproperty key="aj.class.path" path="${aj.sandbox}/hello.jar:${aj.sandbox}/handler.jar"/>
<sysproperty key="aj.aspect.path" path="${aj.sandbox}/handler.jar"/>
</java>
</target>

<!-- We have three JARs files, two containing aspects (ExceptionHandler and Tracing)
for which aop-ajc.xml files have been generate. However we supply our own
aop.xml which declares only ExceptionHandler. We then override the
aop.xml which declares only ExceptionHandler. We then override the
configuration search path -->
<target name="override default path using -Dorg.aspectj.weaver.loadtime.configuration">
<copy file="${aj.root}/tests/ltw/aop-orgaspectjweaverloadtimeconfiguration.xml"
@@ -58,22 +62,26 @@
<jvmarg value="-Dorg.aspectj.tracing.messages=true"/>
<!-- use META-INF/aop.xml style -->
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg line="${jdwp}"/>-->
</java>
</target>

<!-- Beware, this is complicated! We need to intercept class loading on
<!-- Beware, this is complicated! We need to intercept class loading on
the System class loader before any classes are loaded. We do this
by replacing the URLClassLoader. We then define a custom
SecurityManager that will be loaded _before_ the class loader
hierarch is fully initialized. -->
<target name="NPE with custom agent">
<java fork="yes" classname="HelloWorldWithException" failonerror="yes">
<!-- Prepend custom URLClassLoader and append AspectJ
to bootclasspath -->
<jvmarg value="-Xbootclasspath/p:${aj.sandbox}"/>
<jvmarg value="-Xbootclasspath/a:${aj.bootpath}"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>

<classpath>
<pathelement path="${aj.sandbox}/hello.jar:${aj.sandbox}/handler.jar:${aj.sandbox}/security.jar"/>
@@ -82,15 +90,15 @@
<!-- Specify custom SecurityManager that will be loaded
and woven very early -->
<jvmarg value="-Djava.security.manager=NullSecurityManager"/>
<jvmarg value="-Daj.weaving.verbose=true"/>
<jvmarg value="-Dorg.aspectj.weaver.showWeaveInfo=true"/>
<!--
<!--
<jvmarg value="-Dorg.aspectj.tracing.enabled=true"/>
<jvmarg value="-Dorg.aspectj.tracing.factory=default"/>
<jvmarg value="-Dorg.aspectj.tracing.messages=true"/>
-->
-->
</java>
</target>

@@ -101,6 +109,8 @@
<classpath refid="aj.path"/>
<!-- use META-INF/aop.xml style -->
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg line="${jdwp}"/>-->
</java>
</target>
@@ -114,8 +124,10 @@
<sysproperty key="org.aspectj.dump.directory" path="${aj.sandbox}"/>
<!-- use META-INF/aop.xml style -->
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<!-- <jvmarg line="${jdwp}"/>-->
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<jvmarg value="-Dorg.aspectj.tracing.factory=default"/>
<!-- <jvmarg line="${jdwp}"/>-->
</java>
</target>


+ 1
- 2
tests/pom.xml View File

@@ -131,20 +131,19 @@


<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration combine.self="override">
<testFailureIgnore>false</testFailureIgnore>
<argLine>${jvm.arg.addOpens}</argLine>
<includes>
<include>**/TestsModuleTests*</include>
</includes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>

+ 71
- 67
tests/profiling/build.xml View File

@@ -2,12 +2,12 @@

<!--
Copyright 2006 contributors.
All rights reserved.
This program and the accompanying materials are made available
under the terms of the Eclipse Public License v1.0
which accompanies this distribution and is available at
http://eclipse.org/legal/epl-v10.html
All rights reserved.
This program and the accompanying materials are made available
under the terms of the Eclipse Public License v1.0
which accompanies this distribution and is available at
http://eclipse.org/legal/epl-v10.html

Contributors: Adrian Colyer
-->
@@ -16,14 +16,14 @@

<!-- project.properties contains your local settings, not checked into CVS -->
<property file="project.properties"/>
<!-- default property settings, version controlled -->
<property file="build.properties"/>

<!-- pull in the ant file defining the paths etc. for the target application -->
<import file="${target.application.definitions.file}"/>

<!-- list of useful targets... -->
<!-- list of useful targets... -->
<target name="usage">
<echo message="ant build script for profiling AspectJ compiler"/>
<echo message="useful targets are:"/>
@@ -43,13 +43,13 @@
<echo message="for available customisations)"/>
</target>

<!-- handy suites -->
<!-- handy suites -->
<target name="gc.suite" depends="source.compile.gc,binary.weave.gc,loadtime.weave.gc,ajdt.compile.gc"/>
<target name="full.profile.suite" depends="source.compile,binary.weave,loadtime.weave,ajdt.compile"/>
<!--
<!--
how to obtain the aspectj compiler - if the use.aspectjtools.jar property
is set to true, will use the version of aspectjtools.jar in
is set to true, will use the version of aspectjtools.jar in
aspectj.lib.dir. If use.aspectjtools.jar property is false, will use
the bin directories from the projects in your aspectj.workspace.root.
-->
@@ -57,14 +57,14 @@
<condition property="ajtools.jar">
<istrue value="${use.aspectjtools.jar}"/>
</condition>
<condition property="iajc.local">
<istrue value="${use.local.iajc.task.class}"/>
</condition>
<path id="aspectj.compiler.path">
<dirset dir=".">
<include name="classes" if="iajc.local"/>
<include name="classes" if="iajc.local"/>
</dirset>
<fileset dir="${aspectj.lib.dir}">
<include name="aspectjtools.jar" if="ajtools.jar"/>
@@ -83,7 +83,7 @@
<include name="test*/bin"/>
</dirset>
</path>
<!-- define the iajc task -->
<taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
<classpath>
@@ -105,33 +105,33 @@
<target name="check.iajc.ajtools" unless="iajc.local">
<echo message="using version of iajc from aspectjtools.jar"/>
</target>
<!-- init and clean... -->
<target name="init">
<mkdir dir="${results.dir}"/>
<mkdir dir="${results.dir}/${target.application.name}"/>
<mkdir dir="${results.dir}/ltw-app"/>
<mkdir dir="${results.dir}/ltw-app/META-INF"/>
<mkdir dir="${results.dir}"/>
<mkdir dir="${results.dir}/${target.application.name}"/>
<mkdir dir="${results.dir}/ltw-app"/>
<mkdir dir="${results.dir}/ltw-app/META-INF"/>
</target>
<target name="clean" depends="init">
<delete dir="${results.dir}"/>
</target>

<!-- classpath to use for all targets -->
<path id="iajc.class.path">
<path refid="build.class.path"/>
<pathelement location="${aspectj.lib.dir}/aspectjrt.jar"/>
<path refid="aspectj.compiler.path"/>
</path>
</path>
<!-- source compilation (ajc style) with various profiling -->
<target name="source.compile" depends="init,config-check">
<iajc destdir="${results.dir}/${target.application.name}/classes"
<iajc destdir="${results.dir}/${target.application.name}/classes"
fork="true" maxmem="${ajc.maxmem}"
debug="on"
source="${source.level}" target="${target.level}"
@@ -141,17 +141,17 @@
<jvmarg value="${hprof.args}"/>
<jvmarg value="${gc.args}"/>
</iajc>
<tstamp>
<format property="ajc.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
</tstamp>
<property name="ajc.hprof.out" value="${results.dir}/${target.application.name}/ajc.java.hprof.${ajc.runtime}.txt"/>
<property name="ajc.gc.out" value="${results.dir}/${target.application.name}/ajc.gc.${ajc.runtime}.txt"/>
<move file="java.hprof.txt" tofile="${ajc.hprof.out}"/>
<move file="java.hprof.txt" tofile="${ajc.hprof.out}"/>
<move file="gc.txt" tofile="${ajc.gc.out}"/>
<echo message="hprof data written to ${ajc.hprof.out}"/>
<echo message="gc data written to ${ajc.gc.out}"/>
<echo message="analyse with e.g. HATS and JTune"/>
<echo message="analyse with e.g. HATS and JTune"/>
</target>

<target name="source.compile.gc" depends="init,config-check">
@@ -159,8 +159,8 @@
<format property="ajc.starttime" pattern="HH:mm:ss"/>
</tstamp>
<echo message="ajc compile started at: ${ajc.starttime}"/>
<iajc destdir="${results.dir}/${target.application.name}/classes"
<iajc destdir="${results.dir}/${target.application.name}/classes"
fork="true" maxmem="${ajc.maxmem}"
debug="on"
source="${source.level}" target="${target.level}"
@@ -169,7 +169,7 @@
time="true">
<jvmarg value="${gc.args}"/>
</iajc>
<tstamp>
<format property="ajc.endtime" pattern="HH:mm:ss"/>
</tstamp>
@@ -182,10 +182,10 @@
<echo message="gc data written to ${ajc.gc.only.out}"/>
<echo message="analyze with JTune"/>
</target>
<!-- binary weaving with various profiling options -->
<!-- build an aspect library to use for binary weaving, so that we
<!-- build an aspect library to use for binary weaving, so that we
profile weaving only... -->
<target name="aspectlib" depends="init">
<iajc outjar="${results.dir}/aspectlib.jar"
@@ -197,7 +197,7 @@
classpathref="iajc.class.path">
</iajc>
</target>
<target name="binary.weave" depends="init,aspectlib">
<iajc outjar="${results.dir}/woven.jar"
debug="on"
@@ -215,17 +215,17 @@
<jvmarg value="${hprof.args}"/>
<jvmarg value="${gc.args}"/>
</iajc>
<tstamp>
<format property="bw.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
</tstamp>
<property name="bw.hprof.out" value="${results.dir}/${target.application.name}/weave.java.hprof.${bw.runtime}.txt"/>
<property name="bw.gc.out" value="${results.dir}/${target.application.name}/weave.gc.${bw.runtime}.txt"/>
<move file="java.hprof.txt" tofile="${bw.hprof.out}"/>
<move file="java.hprof.txt" tofile="${bw.hprof.out}"/>
<move file="gc.txt" tofile="${bw.gc.out}"/>
<echo message="hprof data written to ${bw.hprof.out}"/>
<echo message="gc data written to ${bw.gc.out}"/>
<echo message="analyse with e.g. HATS and JTune"/>
<echo message="analyse with e.g. HATS and JTune"/>
</target>

<target name="binary.weave.gc" depends="init,aspectlib">
@@ -233,7 +233,7 @@
<format property="bw.starttime" pattern="HH:mm:ss"/>
</tstamp>
<echo message="weave started at: ${bw.starttime}"/>
<iajc outjar="${results.dir}/woven.jar"
debug="on"
source="${source.level}"
@@ -249,7 +249,7 @@
</aspectpath>
<jvmarg value="${gc.args}"/>
</iajc>
<tstamp>
<format property="bw.endtime" pattern="HH:mm:ss"/>
</tstamp>
@@ -262,26 +262,26 @@
<echo message="gc data written to ${bw.gc.only.out}"/>
<echo message="analyze with JTune"/>
</target>
<!-- loadtime weaving with various profiling options -->
<target name="ltw-app" depends="init"
description="builds an application that we can run with ltw. The app does
Class.forName(..) on every type within the jar file passed to
it as an argument, thus forcing all those types (and types they
reference) to be woven)">

<javac srcdir="ltw-app/src" destdir="${results.dir}/ltw-app">
<javac srcdir="ltw-app/src" destdir="${results.dir}/ltw-app">
</javac>
<copy file="${ltw.aop.xml}" todir="${results.dir}/ltw-app/META-INF"/>
<copy file="${ltw.aop.xml}" todir="${results.dir}/ltw-app/META-INF"/>
</target>
<target name="check-using-jars" unless="ajtools.jar">
<echo message="WARNING: cannot run load-time weaving from workspace dirs"/>
<echo message="use.aspectjtools.jar setting will be ignored and the jar"/>
<echo message="${aspectj.lib.dir}/aspectjweaver.jar will be used for LTW instead"/>
<echo message="${aspectj.lib.dir}/aspectjweaver.jar will be used for LTW instead"/>
</target>
<target name="loadtime.weave" depends="check-using-jars,aspectlib,ltw-app">
<java classname="org.aspectj.profiling.LTWApp"
fork="true"
@@ -290,6 +290,8 @@
<jvmarg value="${gc.args}"/>
<jvmarg value="${hprof.args}"/>
<jvmarg value="-javaagent:${aspectj.lib.dir}/aspectjweaver.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<classpath>
<pathelement location="${results.dir}/ltw-app"/>
<pathelement location="${results.dir}/aspectlib.jar"/>
@@ -297,30 +299,32 @@
<path refid="iajc.class.path"/>
</classpath>
</java>
<tstamp>
<tstamp>
<format property="ltw.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
</tstamp>
<property name="ltw.hprof.out" value="${results.dir}/${target.application.name}/ltw.java.hprof.${ltw.runtime}.txt"/>
<property name="ltw.gc.out" value="${results.dir}/${target.application.name}/ltw.gc.${ltw.runtime}.txt"/>
<move file="java.hprof.txt" tofile="${ltw.hprof.out}"/>
<move file="java.hprof.txt" tofile="${ltw.hprof.out}"/>
<move file="gc.txt" tofile="${ltw.gc.out}"/>
<echo message="hprof data written to ${ltw.hprof.out}"/>
<echo message="gc data written to ${ltw.gc.out}"/>
<echo message="analyse with e.g. HATS and JTune"/>
<echo message="analyse with e.g. HATS and JTune"/>
</target>
<target name="loadtime.weave.gc" depends="check-using-jars,aspectlib,ltw-app">
<tstamp>
<format property="ltw.starttime" pattern="HH:mm:ss"/>
</tstamp>
<echo message="ltw started at: ${ltw.starttime}"/>
<java classname="org.aspectj.profiling.LTWApp"
fork="true"
maxmemory="${ajc.maxmem}">
<arg value="${weave.injar}"/>
<jvmarg value="${gc.args}"/>
<jvmarg value="-javaagent:${aspectj.lib.dir}/aspectjweaver.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<classpath>
<pathelement location="${results.dir}/ltw-app"/>
<pathelement location="${results.dir}/aspectlib.jar"/>
@@ -328,7 +332,7 @@
<path refid="iajc.class.path"/>
</classpath>
</java>
<tstamp>
<format property="ltw.endtime" pattern="HH:mm:ss"/>
</tstamp>
@@ -341,9 +345,9 @@
<echo message="gc data written to ${ltw.gc.only.out}"/>
<echo message="analyze with JTune"/>
</target>
<!-- "AJDT-like" compiles with various profiling options -->
<target name="prepare-project" depends="init">
<delete dir="${results.dir}/ajdt-workspace-root"/>
<mkdir dir="${results.dir}/ajdt-workspace-root"/>
@@ -353,7 +357,7 @@
<param name="todir" value="${results.dir}/ajdt-workspace-root/${target.application.name}/base"/>
</antcall>
</target>
<target name="ajdt.compile" depends="prepare-project">

<java classname="org.aspectj.systemtest.incremental.tools.AjdeInteractionTestbedLauncher"
@@ -370,16 +374,16 @@
</classpath>
</java>

<tstamp>
<tstamp>
<format property="ajdt.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
</tstamp>
<property name="ajdt.hprof.out" value="${results.dir}/${target.application.name}/ajdt.java.hprof.${ajdt.runtime}.txt"/>
<property name="ajdt.gc.out" value="${results.dir}/${target.application.name}/ajdt.gc.${ajdt.runtime}.txt"/>
<move file="java.hprof.txt" tofile="${ajdt.hprof.out}"/>
<move file="java.hprof.txt" tofile="${ajdt.hprof.out}"/>
<move file="gc.txt" tofile="${ajdt.gc.out}"/>
<echo message="hprof data written to ${ajdt.hprof.out}"/>
<echo message="gc data written to ${ajdt.gc.out}"/>
<echo message="analyse with e.g. HATS and JTune"/>
<echo message="analyse with e.g. HATS and JTune"/>

</target>

@@ -388,7 +392,7 @@
<format property="ajdt.starttime" pattern="HH:mm:ss"/>
</tstamp>
<echo message="AJDT started at: ${ajdt.starttime}"/>
<java classname="org.aspectj.systemtest.incremental.tools.AjdeInteractionTestbedLauncher"
fork="true"
maxmemory="${ajc.maxmem}">
@@ -401,7 +405,7 @@
<pathelement location="${aspectj.lib.dir}/aspectjrt.jar"/>
</classpath>
</java>
<tstamp>
<format property="ajdt.endtime" pattern="HH:mm:ss"/>
</tstamp>
@@ -414,5 +418,5 @@
<echo message="gc data written to ${ajdt.gc.only.out}"/>
<echo message="analyze with JTune"/>
</target>
</project>
</project>

+ 9
- 7
tests/src/test/java/org/aspectj/systemtest/ajc167/Ajc167Tests.java View File

@@ -10,9 +10,8 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc167;

import org.aspectj.testing.XMLBasedAjcTestCase;

import junit.framework.Test;
import org.aspectj.testing.XMLBasedAjcTestCase;

public class Ajc167Tests extends org.aspectj.testing.XMLBasedAjcTestCase {

@@ -27,14 +26,17 @@ public class Ajc167Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
runTest("optimizing string anno value binding");
}

// FIXME: This test is flaky - can depend on machine load
public void testOptimizingAnnotationBinding() {
runTest("optimizing annotation binding");
}

// bit flakey - can depend on machine load
// public void testOptimizingAnnotationBindingPerfTest() {
// runTest("optimizing annotation binding - 2");
// }
// FIXME: This test is flaky - can depend on machine load
/*
public void testOptimizingAnnotationBindingPerfTest() {
runTest("optimizing annotation binding - 2");
}
*/

/*
* public void testPerThisLTW_295092() { runTest("perthis ltw"); }
@@ -84,4 +86,4 @@ public class Ajc167Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
return getClassResource("ajc167.xml");
}

}
}

+ 10
- 2
tests/tracing/ant.xml View File

@@ -33,6 +33,8 @@
<jvmarg value="-Dorg.aspectj.tracing.messages=true"/>
<!-- use META-INF/aop.xml style -->
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg line="${jdwp}"/>-->
</java>
</target>
@@ -46,6 +48,8 @@
<!-- <jvmarg value="-verbose:class"/>-->
<!-- use META-INF/aop.xml style -->
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg line="${jdwp}"/>-->
</java>
</target>
@@ -59,6 +63,8 @@
<jvmarg value="-Djava.util.logging.config.file=logging.properties"/>
<!-- use META-INF/aop.xml style -->
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg line="${jdwp}"/>-->
</java>
</target>
@@ -69,11 +75,13 @@
<jvmarg value="-Dorg.aspectj.tracing.enabled=true"/>
<jvmarg value="-Dorg.aspectj.tracing.factory=default"/>
<jvmarg value="-Dorg.aspectj.tracing.messages=true"/>
<sysproperty key="org.aspectj.tracing.file" path="${aj.sandbox}/tracing.txt"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="${aj.addOpensKey}"/>
<jvmarg value="${aj.addOpensValue}"/>
<!-- <jvmarg value="-verbose:class"/>-->
<!-- use META-INF/aop.xml style -->
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<!-- <jvmarg line="${jdwp}"/>-->
<sysproperty key="org.aspectj.tracing.file" path="${aj.sandbox}/tracing.txt"/>
</java>
</target>


Loading…
Cancel
Save