Skip to content

Commit 097c636

Browse files
committed
Reorganize build to better support Java 11+
1 parent c26a439 commit 097c636

4 files changed

Lines changed: 49 additions & 11 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
with:
8484
java-version: '8'
8585
architecture: 'x64'
86-
distribution: zulu
86+
distribution: adopt
8787
server-id: ossrh
8888
server-username: SONATYPE_USER
8989
server-password: SONATYPE_PW

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ until one succeeds.
260260
on the classpath, the `GetAdaptersAddresses` API is used.
261261
- On Android the `ConnectivityManager` is used (requires initialization using
262262
`org.xbill.DNS.config.AndroidResolverConfigProvider.setContext`).
263-
- The `sun.net.dns.ResolverConfiguration` class is queried if enabled.
263+
- The `sun.net.dns.ResolverConfiguration` class is queried if enabled. As of
264+
Java 16 the JVM flag `--add-opens java.base/sun.net.dns=ALL-UNNAMED` is also
265+
required.
264266
- If available and no servers have been found yet,
265267
[JNDI-DNS](https://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-dns.html) is used.
266268
- If still no servers have been found yet, use the fallback properties. This can be used to query

pom.xml

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,14 @@
9090
<artifactId>maven-compiler-plugin</artifactId>
9191
<version>3.8.1</version>
9292
<configuration>
93-
<source>${target.jdk}</source>
94-
<target>${target.jdk}</target>
9593
<compilerArgument>-Xlint:unchecked</compilerArgument>
94+
<annotationProcessorPaths>
95+
<path>
96+
<groupId>org.projectlombok</groupId>
97+
<artifactId>lombok</artifactId>
98+
<version>${lombok.version}</version>
99+
</path>
100+
</annotationProcessorPaths>
96101
</configuration>
97102
</plugin>
98103

@@ -426,23 +431,39 @@
426431
</dependencies>
427432

428433
<profiles>
434+
<profile>
435+
<id>java8</id>
436+
<activation>
437+
<jdk>[,9)</jdk>
438+
</activation>
439+
<build>
440+
<plugins>
441+
<plugin>
442+
<groupId>org.apache.maven.plugins</groupId>
443+
<artifactId>maven-compiler-plugin</artifactId>
444+
<configuration>
445+
<source>${target.jdk}</source>
446+
<target>${target.jdk}</target>
447+
</configuration>
448+
</plugin>
449+
</plugins>
450+
</build>
451+
</profile>
452+
429453
<profile>
430454
<!-- JDK9 removed the Nameservice SPI as per bug 8134577. There's no replacement. -->
431455
<id>no-spi-on-java9</id>
432456
<activation>
433-
<jdk>[1.9,)</jdk>
457+
<jdk>[9,)</jdk>
434458
</activation>
435459

436-
<properties>
437-
<target.jdk>11</target.jdk>
438-
<maven.compiler.release>${target.jdk}</maven.compiler.release>
439-
</properties>
440460
<build>
441461
<plugins>
442462
<plugin>
443463
<groupId>org.apache.maven.plugins</groupId>
444464
<artifactId>maven-compiler-plugin</artifactId>
445465
<configuration>
466+
<release>${target.jdk}</release>
446467
<excludes>
447468
<exclude>org/xbill/DNS/spi/**</exclude>
448469
</excludes>
@@ -456,6 +477,16 @@
456477
<excludePackageNames>*.spi</excludePackageNames>
457478
</configuration>
458479
</plugin>
480+
481+
<plugin>
482+
<groupId>org.apache.maven.plugins</groupId>
483+
<artifactId>maven-surefire-plugin</artifactId>
484+
<configuration>
485+
<argLine>
486+
--add-opens java.base/sun.net.dns=ALL-UNNAMED
487+
</argLine>
488+
</configuration>
489+
</plugin>
459490
</plugins>
460491

461492
<resources>

src/main/java/org/xbill/DNS/config/SunJvmResolverConfigProvider.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
* Resolver config provider that queries the traditional class {@code
1010
* sun.net.dns.ResolverConfiguration} via reflection.
1111
*
12-
* <p>As of Java 9, this generates an illegal reflective access exception and on Windows, this may
13-
* return invalid nameservers of disconnected NICs.
12+
* <ul>
13+
* <li>As of Java 9, generates an illegal reflective access exception.
14+
* <li>As of Java 16, adding the JVM flag {@code --add-opens java.base/sun.net.dns=ALL-UNNAMED} is
15+
* required.
16+
* <li>On Windows, may return invalid nameservers of disconnected NICs before Java 15, <a
17+
* href="https://bugs.openjdk.java.net/browse/JDK-7006496">JDK-7006496</a>.
18+
* </ul>
1419
*/
1520
public class SunJvmResolverConfigProvider extends BaseResolverConfigProvider {
1621
public void initialize() throws InitializationException {

0 commit comments

Comments
 (0)