Skip to content

Commit

Permalink
Prepare for GraalVM and JDK 11
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenneg committed Nov 14, 2019
1 parent 8be0f98 commit 3746489
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.quarkus.runtime.graal;

import java.net.Inet4Address;

import org.wildfly.common.net.Inet;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(Inet.class)
final class Target_org_wildfly_common_net_Inet {

/*
* The following fields recomputations are required because of a new restriction in GraalVM 19.3.0 that prohibits the
* presence of java.net.Inet4Address in the image heap.
*/

@Alias
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)
public static Inet4Address INET4_ANY = Inet.getInet4Address(0, 0, 0, 0);

@Alias
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)
public static Inet4Address INET4_LOOPBACK = Inet.getInet4Address(127, 0, 0, 1);

@Alias
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)
public static Inet4Address INET4_BROADCAST = Inet.getInet4Address(255, 255, 255, 255);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.wildfly.common.net.CidrAddress;

/**
* Test some MicroProfile config primitives.
Expand All @@ -19,6 +20,9 @@ public class MicroProfileConfigResource {
@ConfigProperty(name = "microprofile.custom.value")
MicroProfileCustomValue value;

@ConfigProperty(name = "microprofile.cidr-address")
CidrAddress cidrAddress;

@Inject
Config config;

Expand All @@ -36,4 +40,10 @@ public String getPropertyNames() throws Exception {
public String getCustomValue() {
return Integer.toString(value.getNumber());
}

@GET
@Path("/get-cidr-address")
public String getCidrAddress() {
return cidrAddress.getNetworkAddress().getHostAddress();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ names=quarkus,redhat
schedulerservice.cron.expr=0/10 * * * * ?

microprofile.custom.value = 456
microprofile.cidr-address=10.0.0.20/24
configproperties.message=Hello
configproperties.other=1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ public void testMicroprofileConfigGetCustomValue() {
.when().get("/microprofile-config/get-custom-value")
.then().body(is("456"));
}

@Test
public void testCidrAddress() {
RestAssured
.when().get("/microprofile-config/get-cidr-address")
.then().body(is("10.0.0.0"));
}
}

0 comments on commit 3746489

Please sign in to comment.