diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-03-23 16:59:17 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-03-23 18:36:14 +0700 |
commit | 79e44360cd95b14fa255daaac069f9b76c488451 (patch) | |
tree | e8a0204bd324beec3513768a6e5a83f4137b78ce /tests/profiling/build.xml | |
parent | 6be777e71708df5a62e41c6ef95da66bfd02f447 (diff) | |
download | aspectj-79e44360cd95b14fa255daaac069f9b76c488451.tar.gz aspectj-79e44360cd95b14fa255daaac069f9b76c488451.zip |
Make all tests run on Java 16 via '-add-opens' JVM optionjava16-add-opens
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>
Diffstat (limited to 'tests/profiling/build.xml')
-rw-r--r-- | tests/profiling/build.xml | 138 |
1 files changed, 71 insertions, 67 deletions
diff --git a/tests/profiling/build.xml b/tests/profiling/build.xml index 67ce475a1..ccb4d8f82 100644 --- a/tests/profiling/build.xml +++ b/tests/profiling/build.xml @@ -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>
\ No newline at end of file + +</project> |