Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[MJAVADOC-603] javadoc:fix failure on JDK10: java.lang.ClassNotFoundE… #303

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading