Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add support for building on Java 11 #80

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 9 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ on:

jobs:
build:

runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
java-version:
- 8
- 11
steps:
- uses: actions/checkout@v4
with:
show-progress: false
# needed for the git-commit-id-plugin to work
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v3
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '8'
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: maven
- name: Maven verify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.facebook.airlift.discovery.client;

import com.google.inject.internal.Annotations;

import java.lang.annotation.Annotation;

import static java.util.Objects.requireNonNull;
Expand All @@ -37,7 +39,7 @@ public String value()

public String toString()
{
return String.format("@%s(value=%s)", ServiceType.class.getName(), value);
return String.format("@%s(value=%s)", ServiceType.class.getName(), Annotations.memberValueString(value));
}

@Override
Expand Down
13 changes: 12 additions & 1 deletion jmx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,16 @@
</dependencies>
</profile>
</profiles>
</project>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Djdk.attach.allowAttachSelf=true</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
17 changes: 14 additions & 3 deletions jmx/src/main/java/com/facebook/airlift/jmx/JmxAgent8.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.facebook.airlift.log.Logger;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.net.HostAndPort;
import sun.management.Agent;
import sun.management.jmxremote.ConnectorBootstrap;
import sun.rmi.server.UnicastRef;

Expand All @@ -41,6 +40,8 @@ class JmxAgent8
{
private static final Logger log = Logger.get(JmxAgent.class);

private static final Class<?> AGENT_CLASS = getAgentClass();

private final JMXServiceURL url;

@Inject
Expand Down Expand Up @@ -76,7 +77,7 @@ public JmxAgent8(JmxConfig config)
System.setProperty("com.sun.management.jmxremote.ssl", "false");

try {
Agent.startAgent();
AGENT_CLASS.getMethod("startAgent").invoke(null);
}
catch (Exception e) {
throwIfUnchecked(e);
Expand Down Expand Up @@ -111,7 +112,7 @@ static HostAndPort getRunningAgentAddress(Integer registryPort, Integer serverPo
RemoteObject registry;
int actualRegistryPort;
try {
jmxServer = getField(Agent.class, JMXConnectorServer.class, "jmxServer");
jmxServer = getField(AGENT_CLASS, JMXConnectorServer.class, "jmxServer");
registry = getField(ConnectorBootstrap.class, RemoteObject.class, "registry");

if (jmxServer == null || registry == null) {
Expand Down Expand Up @@ -160,4 +161,14 @@ private static <T> T getField(Class<?> clazz, Class<T> returnType, String name)
throw new IllegalArgumentException(format("Field %s in class %s is not of type %s, actual: %s", name, clazz.getName(), returnType.getName(), field.getType().getName()), e);
}
}

private static Class<?> getAgentClass()
{
try {
return Class.forName("sun.management.Agent");
}
catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}
12 changes: 12 additions & 0 deletions skeleton-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,16 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Djdk.attach.allowAttachSelf=true</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
5 changes: 5 additions & 0 deletions stats/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
<artifactId>jackson-annotations</artifactId>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
Expand Down