Skip to content

Commit

Permalink
[MJAVADOC-603] javadoc:fix failure on JDK10: java.lang.ClassNotFoundE…
Browse files Browse the repository at this point in the history
…xception: java.sql.Connection

This closes #303
  • Loading branch information
michael-o committed Jul 17, 2024
1 parent 0a26a7e commit eab964c
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import com.thoughtworks.qdox.parser.ParseException;
import com.thoughtworks.qdox.type.TypeResolver;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
Expand All @@ -79,6 +80,7 @@
import org.apache.maven.settings.Settings;
import org.apache.maven.shared.invoker.MavenInvocationException;
import org.codehaus.plexus.components.interactivity.InputHandler;
import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
Expand Down Expand Up @@ -201,6 +203,8 @@ public abstract class AbstractFixJavadocMojo extends AbstractMojo {
*/
private static final String CLIRR_MAVEN_PLUGIN_GOAL = "check";

private static final JavaVersion JAVA_VERSION = JavaVersion.JAVA_SPECIFICATION_VERSION;

/**
* Java Files Pattern.
*/
Expand Down Expand Up @@ -837,7 +841,17 @@ private ClassLoader getProjectClassLoader() throws MojoExecutionException {
}
}

projectClassLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), null);
ClassLoader parent = null;
if (JAVA_VERSION.isAtLeast("9")) {
try {
parent = (ClassLoader) MethodUtils.invokeStaticMethod(ClassLoader.class, "getPlatformClassLoader");
} catch (Exception e) {
throw new MojoExecutionException(
"Failed to invoke ClassLoader#getPlatformClassLoader() dynamically", e);
}
}

projectClassLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), parent);
}

return projectClassLoader;
Expand Down

0 comments on commit eab964c

Please sign in to comment.