--- /dev/null
+package aaa.bbb;
+import ddd.D;
+
+public class A {
+ public static void main(String []argv) {
+ System.out.println("A running");
+ D.foo();
+ }
+}
--- /dev/null
+package ddd;
+
+public class D {
+ public static void foo() {}
+}
--- /dev/null
+module my.module {
+ exports aaa.bbb;
+}
--- /dev/null
+package aaa.bbb;
+import ddd.D;
+
+public class A {
+ public static void main(String []argv) {
+ System.out.println("A running");
+ D.foo();
+ }
+}
--- /dev/null
+package ddd;
+
+public class D {
+ public static void foo() {}
+}
--- /dev/null
+module my.module.a {
+ exports ddd;
+}
--- /dev/null
+module my.module.b {
+ exports aaa.bbb;
+}
--- /dev/null
+import javax.xml.transform.TransformerFactory;\r
+import javax.xml.bind.JAXBContext;\r
+import javax.xml.parsers.DocumentBuilderFactory;\r
+\r
+//import org.slf4j.Logger;\r
+//import org.slf4j.LoggerFactory;\r
+import org.w3c.dom.Document;\r
+\r
+public class UsesJAXB {\r
+\r
+ // private static final Logger LOG = LoggerFactory.getLogger(UsesJAXB.class);\r
+ \r
+ TransformerFactory tf = TransformerFactory.newInstance();\r
+ \r
+ public UsesJAXB() {\r
+ // LOG.error("UMS001");\r
+ Document document;\r
+ JAXBContext context;\r
+ }\r
+\r
+}\r
import java.io.File;
import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater;
import junit.framework.Test;
/**
* @author Andy Clement
*/
-public class Ajc190Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+public class Ajc190Tests extends XMLBasedAjcTestCaseForJava9OrLater {
public void testAnnotMethodHasMember_pr156962_1() { // From similar in Ajc153Tests
runTest("Test Annot Method Has Member 1");
public void testWeaveModule() throws Exception {
runTest("weave module");
}
+
+ public void testUsesJaxb() {
+ runTest("java use of java.xml.bind");
+ }
// ---
import java.io.File;
-import junit.framework.Test;
-
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.Code;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater;
+
+import junit.framework.Test;
/**
- * Building and weaving with modules in the picture...
+ * Building and weaving with modules in the picture.
*
* @author Andy Clement
*
*/
-public class ModuleTests extends org.aspectj.testing.XMLBasedAjcTestCase {
+public class ModuleTests extends XMLBasedAjcTestCaseForJava9OrLater {
public void testBuildAModule() {
runTest("build a module");
public void testBuildModuleIncludingAspects() {
runTest("compile module including aspects");
}
+
+ public void testBuildModuleAndApplyAspectsFromAspectPath() {
+ runTest("compile module and apply aspects via aspectpath");
+ }
public void testBinaryWeavingAModuleJar() {
// Pass a module on inpath, does it weave ok with a source aspect, does it run afterwards?
runTest("binary weaving module");
}
- // can't really write these tests now... pure jdt seems to allow type resolution against module path for types
- // not in modules being compiled but javac does not
-
- public void xtestReferenceTypesFromModuleInBuildingSomeCode() {
- runTest("compile regular code using module code");
- }
-
- public void xtestReferenceTypesFromModuleInBuildingSomeCodeButCantSeeThem() {
- runTest("compile regular code using module code that isn't visible");
+ public void testModulepathClasspathResolution1() {
+ runTest("module path vs classpath 1");
}
- public void xtestBinaryWeavingInvolvingTypesOnModulePath() {
- fail();
+// public void testModulepathClasspathResolution2() {
+// runTest("module path vs classpath 2");
+// }
+
+ // This tests that when using --add-modules with one of the JDK modules (in the jmods subfolder of the JDK)
+ // that it can be found without needing to set --module-path (this seems to be implicitly included by javac too)
+ public void testAddModules1() {
+ runTest("java use of java.xml.bind");
}
- public void xtestLoadtimeWeavingWithModulePathContainingTypes() {
- fail();
- }
-
/* For the specified class, check that each method has a stackmap attribute */
private void checkStackMapExistence(String classname, String toIgnore) throws ClassNotFoundException {
toIgnore = "_" + (toIgnore == null ? "" : toIgnore) + "_";
return XMLBasedAjcTestCase.loadSuite(ModuleTests.class);
}
+ @Override
protected File getSpecFile() {
return getClassResource("ajc190.xml");
}
</run>
</ajc-test>
+ <ajc-test dir="bugs190/modules/eee" title="compile module and apply aspects via aspectpath">
+ <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="my.module.jar"/>
+ <file deletefile="module-info.java"/>
+ <file deletefile="aaa"/>
+ <compile files="Azpect.java" outjar="azpects.jar"/>
+ <compile options="-showWeaveInfo" inpath="my.module.jar" aspectpath="azpects.jar" outjar="my.module.woven.jar">
+ <message kind="weave" text="Join point 'method-execution(void aaa.bbb.A.main(java.lang.String[]))' in Type 'aaa.bbb.A' (A.java:4) advised by before advice from 'aspects.Azpect' (azpects.jar!Azpect.class:4(from Azpect.java))"/>
+ </compile>
+ <file deletefile="my.module.jar"/>
+ <run classpath="my.module.woven.jar:azpects.jar" class="aaa.bbb.A">
+ <stdout>
+ <line text="Azpect running"/>
+ <line text="A running"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs190/modules/ggg" title="module path vs classpath 1">
+ <!-- build some simple code into a jar we can depend on *not a module* -->
+ <compile files="ddd/D.java" options="-1.9" outjar="foo.jar"/>
+ <file deletefile="ddd/D.java"/>
+ <!-- compile a module that depends on that -->
+ <!-- this fails because if you start working with modules you commit to the modules story and classpath
+ becomes irrelevant -->
+ <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="module.jar" classpath="foo.jar">
+ <message kind="error" text="The import ddd cannot be resolved"/>
+ <message kind="error" text="D cannot be resolved"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs190/modules/hhh" title="module path vs classpath 2">
+ <!-- build some simple code into a jar we can depend on *not a module* -->
+ <file renamefrom="module-info-a.java" renameto="module-info.java"/>
+ <compile files="module-info.java ddd/D.java" options="-1.9" outjar="my.module.a.jar"/>
+ <!--
+ <file renamefrom="module-info-b.java" renameto="module-info.java"/>
+ <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="my.module.b.jar" modulepath="my.module.a.jar"/>
+ -->
+ </ajc-test>
+
+ <ajc-test dir="bugs190/modules/iii" title="java use of java.xml.bind">
+ <compile files="UsesJAXB.java" options="--add-modules java.xml.bind -1.9"/>
+ </ajc-test>
+
+ <!--
+ <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="module.jar" aspectpath="foo.jar"/>
+ <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="my.module.jar"/>
+ <file deletefile="module-info.java"/>
+ <file deletefile="aaa"/>
+ <compile files="Azpect.java" outjar="azpects.jar"/>
+ <compile options="-showWeaveInfo" inpath="my.module.jar" aspectpath="azpects.jar" outjar="my.module.woven.jar">
+ <message kind="weave" text="Join point 'method-execution(void aaa.bbb.A.main(java.lang.String[]))' in Type 'aaa.bbb.A' (A.java:4) advised by before advice from 'aspects.Azpect' (azpects.jar!Azpect.class:4(from Azpect.java))"/>
+ </compile>
+ <file deletefile="my.module.jar"/>
+ <run classpath="my.module.woven.jar:azpects.jar" class="aaa.bbb.A">
+ <stdout>
+ <line text="Azpect running"/>
+ <line text="A running"/>
+ </stdout>
+ </run>
+ </ajc-test>
+ -->
+
<ajc-test dir="bugs190/modules" title="weave module">
<compile files="aspect1/Azpect1.java" inpath="module1/module-one.jar" outjar="runner.jar" options="-1.8"/>
<java classpath="runner.jar" class="a.b.c.Code"/>