aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ltw
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2021-03-23 16:59:17 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2021-03-23 18:36:14 +0700
commit79e44360cd95b14fa255daaac069f9b76c488451 (patch)
treee8a0204bd324beec3513768a6e5a83f4137b78ce /tests/ltw
parent6be777e71708df5a62e41c6ef95da66bfd02f447 (diff)
downloadaspectj-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/ltw')
-rw-r--r--tests/ltw/ant-server.xml16
-rw-r--r--tests/ltw/ant.xml54
2 files changed, 43 insertions, 27 deletions
diff --git a/tests/ltw/ant-server.xml b/tests/ltw/ant-server.xml
index 31baef28f..c5f143fea 100644
--- a/tests/ltw/ant-server.xml
+++ b/tests/ltw/ant-server.xml
@@ -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>
diff --git a/tests/ltw/ant.xml b/tests/ltw/ant.xml
index dff2071e7..0cae97a36 100644
--- a/tests/ltw/ant.xml
+++ b/tests/ltw/ant.xml
@@ -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>