]> source.dussan.org Git - aspectj.git/commitdiff
Fix compilation of JavadocRunner for Java 13+
authorLars Grefer <eclipse@larsgrefer.de>
Thu, 13 Aug 2020 19:47:19 +0000 (21:47 +0200)
committerLars Grefer <eclipse@larsgrefer.de>
Thu, 13 Aug 2020 19:47:19 +0000 (21:47 +0200)
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java

index 64e53eead02ac0448968453d5bf210ca6d84764d..20ec37f2fb8a62b70ccabcf7fd9a5a37007d3d3d 100644 (file)
@@ -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);