From 242631cf8cc8480a065b260fbaaea001008064e2 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Thu, 13 Aug 2020 18:15:28 +0200 Subject: Fix compilation on Java 11 Signed-off-by: Lars Grefer --- .../src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java index 92aaec667..5af201700 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java @@ -834,13 +834,13 @@ public class JavaRun implements IAjcRun { throw new ExitCalledException(exitCode); } } - @Override + public void checkAwtEventQueueAccess() { if ((null != runThread) && runThread.equals(Thread.currentThread())) { throw new AwtUsedException(); } } - @Override + public void checkSystemClipboardAccess() { // permit } @@ -885,7 +885,7 @@ public class JavaRun implements IAjcRun { @Override public void checkListen(int arg0) { } - @Override + public void checkMemberAccess(Class arg0, int arg1) { } @Override @@ -930,7 +930,7 @@ public class JavaRun implements IAjcRun { @Override public void checkSetFactory() { } - @Override + public boolean checkTopLevelWindow(Object arg0) { return true; } -- cgit v1.2.3 From 621169bc7e1ddce8f542268510078928741b0ab9 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Thu, 13 Aug 2020 18:27:03 +0200 Subject: Print used tool versions Signed-off-by: Lars Grefer --- .github/workflows/maven.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index ebfdd0a30..fa012258e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -22,5 +22,7 @@ jobs: uses: actions/setup-java@v1 with: java-version: ${{ matrix.java }} + - run: java -version + - run: mvn --version - name: Build with Maven run: mvn -B package --file pom.xml -- cgit v1.2.3 From 551039d920aab19cc0ed926b5372b3c0cd9796a2 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Thu, 13 Aug 2020 18:31:20 +0200 Subject: Test more Java versions Signed-off-by: Lars Grefer --- .github/workflows/maven.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index fa012258e..1e09e7ae5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -14,8 +14,9 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - java: [ 1.8, 11 ] + java: [ 8, 9, 10, 11, 12, 13, 14 ] steps: - uses: actions/checkout@v2 - name: Set up JDK ${{ matrix.java }} -- cgit v1.2.3 From 31d2091f89ac5bfd3be705b7912ad6ea8b402f88 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Thu, 13 Aug 2020 21:32:03 +0200 Subject: Fix JRockitAgentTest for Java 9 and 10 Signed-off-by: Lars Grefer --- .../src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java b/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java index cd5590914..125a9e95c 100644 --- a/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java +++ b/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java @@ -54,7 +54,7 @@ public class JRockitAgentTest extends TestCase { } public void testJrockitRecursionProtection() { - if (LangUtil.is11VMOrGreater()) { + if (LangUtil.is19VMOrGreater()) { // Skip test, not castable to URLClassLoader return; } -- cgit v1.2.3 From 60b7a300df7068430ec193d2a52c6876e1891afa Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Thu, 13 Aug 2020 21:47:19 +0200 Subject: Fix compilation of JavadocRunner for Java 13+ Signed-off-by: Lars Grefer --- .../src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java index 64e53eead..20ec37f2f 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java @@ -32,10 +32,10 @@ class JavadocRunner { static boolean has14ToolsAvailable() { try { - Class jdMainClass = com.sun.tools.javadoc.Main.class; - Class[] paramTypes = new Class[] { String[].class }; + Class jdMainClass = Class.forName("com.sun.tools.javadoc.Main"); + Class[] paramTypes = new Class[] { String[].class }; jdMainClass.getMethod("execute", paramTypes); - } catch (NoClassDefFoundError e) { + } catch (NoClassDefFoundError | ClassNotFoundException e) { return false; } catch (UnsupportedClassVersionError e) { return false; @@ -73,13 +73,13 @@ class JavadocRunner { try { // for JDK 1.4 and above call the execute method... - Class jdMainClass = com.sun.tools.javadoc.Main.class; + Class jdMainClass = Class.forName("com.sun.tools.javadoc.Main"); Method executeMethod = null; try { Class[] paramTypes = new Class[] { String[].class }; executeMethod = jdMainClass.getMethod("execute", paramTypes); } catch (NoSuchMethodException e) { - com.sun.tools.javadoc.Main.main(javadocargs); + executeMethod = jdMainClass.getMethod("main", String[].class); // throw new UnsupportedOperationException("ajdoc requires a tools library from JDK 1.4 or later."); } try { @@ -96,6 +96,8 @@ class JavadocRunner { } catch (SecurityException se) { // Do nothing since we expect it to be thrown // System.out.println( ">> se: " + se.getMessage() ); + } catch (ClassNotFoundException | NoSuchMethodException e) { + throw new RuntimeException("Failed to invoke javadoc"); } // Set the security manager back // System.setSecurityManager(defaultSecurityManager); -- cgit v1.2.3 From f70aeb5ed94ccdfeaa8ab7b1260a6fcceb490b5a Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Fri, 14 Aug 2020 00:22:30 +0200 Subject: Always run javadoc using the ToolProvider API `com.sun.tools.javadoc.Main` isn't available in recent Java versions (13+) Signed-off-by: Lars Grefer --- .../org/aspectj/tools/ajdoc/JavadocRunner.java | 71 ---------------------- .../main/java/org/aspectj/tools/ajdoc/Main.java | 20 ++---- 2 files changed, 4 insertions(+), 87 deletions(-) diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java index 64e53eead..ed13fabe4 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java @@ -30,77 +30,6 @@ import javax.tools.ToolProvider; */ class JavadocRunner { - static boolean has14ToolsAvailable() { - try { - Class jdMainClass = com.sun.tools.javadoc.Main.class; - Class[] paramTypes = new Class[] { String[].class }; - jdMainClass.getMethod("execute", paramTypes); - } catch (NoClassDefFoundError e) { - return false; - } catch (UnsupportedClassVersionError e) { - return false; - } catch (NoSuchMethodException e) { - return false; - } - return true; - } - - static void callJavadoc(String[] javadocargs) { - // final SecurityManager defaultSecurityManager = System.getSecurityManager(); - // - // System.setSecurityManager( new SecurityManager() { - // public void checkExit(int status) { - // if (status == 0) { - // throw new SecurityException(); - // } - // else { - // System.setSecurityManager(defaultSecurityManager); - // //System.out.println("Error: javadoc exited unexpectedly"); - // System.exit(0); - // throw new SecurityException(); - // } - // } - // public void checkPermission( java.security.Permission permission ) { - // if ( defaultSecurityManager != null ) - // defaultSecurityManager.checkPermission( permission ); - // } - // public void checkPermission( java.security.Permission permission, - // Object context ) { - // if ( defaultSecurityManager != null ) - // defaultSecurityManager.checkPermission( permission, context ); - // } - // } ); - - try { - // for JDK 1.4 and above call the execute method... - Class jdMainClass = com.sun.tools.javadoc.Main.class; - Method executeMethod = null; - try { - Class[] paramTypes = new Class[] { String[].class }; - executeMethod = jdMainClass.getMethod("execute", paramTypes); - } catch (NoSuchMethodException e) { - com.sun.tools.javadoc.Main.main(javadocargs); - // throw new UnsupportedOperationException("ajdoc requires a tools library from JDK 1.4 or later."); - } - try { - executeMethod.invoke(null, new Object[] { javadocargs }); - } catch (IllegalArgumentException e1) { - throw new RuntimeException("Failed to invoke javadoc"); - } catch (IllegalAccessException e1) { - throw new RuntimeException("Failed to invoke javadoc"); - } catch (InvocationTargetException e1) { - throw new RuntimeException("Failed to invoke javadoc"); - } - // main method is documented as calling System.exit() - which stops us dead in our tracks - // com.sun.tools.javadoc.Main.main( javadocargs ); - } catch (SecurityException se) { - // Do nothing since we expect it to be thrown - // System.out.println( ">> se: " + se.getMessage() ); - } - // Set the security manager back - // System.setSecurityManager(defaultSecurityManager); - } - public static void callJavadocViaToolProvider(Vector options, List files) { DocumentationTool doctool = ToolProvider.getSystemDocumentationTool(); StandardJavaFileManager fm = doctool.getStandardFileManager(null, null, null); diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java index 2b2a24a26..26857b41c 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java @@ -35,7 +35,6 @@ import org.aspectj.asm.AsmManager; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.Version; import org.aspectj.util.FileUtil; -import org.aspectj.util.LangUtil; /** * This is an old implementation of ajdoc that does not use an OO style. However, it does the job, and should serve to evolve a @@ -104,11 +103,6 @@ public class Main implements Config { public static void main(String[] args) { clearState(); - if (!JavadocRunner.has14ToolsAvailable()) { - System.err.println("ajdoc requires a JDK 1.4 or later tools jar - exiting"); - aborted = true; - return; - } // STEP 1: parse the command line and do other global setup sourcepath.addElement("."); // add the current directory to the classapth @@ -267,11 +261,9 @@ public class Main implements Config { for (int k = 0; k < fileList.size(); k++) { javadocargs[numExtraArgs + options.size() + packageList.size() + k] = fileList.elementAt(k); } - if (LangUtil.is19VMOrGreater()) { - options = new Vector<>(); - for (String a: javadocargs) { - options.add(a); - } + options = new Vector<>(); + for (String a: javadocargs) { + options.add(a); } } else { javadocargs = new String[options.size() + signatureFiles.length]; @@ -285,11 +277,7 @@ public class Main implements Config { files.add(StructureUtil.translateAjPathName(signatureFile.getCanonicalPath())); } } - if (LangUtil.is19VMOrGreater()) { - JavadocRunner.callJavadocViaToolProvider(options, files); - } else { - JavadocRunner.callJavadoc(javadocargs); - } + JavadocRunner.callJavadocViaToolProvider(options, files); } /** -- cgit v1.2.3