apache / apache/maven

[MNG-6371] Use ServiceLoader mechanism in JDK9 in maven plugins

Open
#7,460 2 comments 0 reactions 0 assignees View on GitHub
enhancement priority:major
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[John Poth](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jpoth)** opened **[MNG-6371](https://issues.apache.org/jira/browse/MNG-6371?redirect=false)** and commented

It'd be nice to be able to use the ServiceLoader mechanism in maven plugins when using JDK9:

 

```java

import org.apache.maven.plugin.AbstractMojo;

public class MyMojo extends AbstractMojo {

public void execute() throws MojoExecutionException {

// this is empty

Iterator iterator = ServiceLoader.load(javax.tools.Tool.class).iterator();
}
}
```

 

Work around is to use a different classloader.

---

**Affects:** 3.5.2

**Issue Links:**
- [MNG-6275](https://issues.apache.org/jira/browse/MNG-6275) ServiceLoaderFactory can't find implementations via ClassRealm

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.