Skip to content

Commit

Permalink
Drop GraalVM 19.2.1 support and deprecate enableJni option
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenneg committed Jan 25, 2020
1 parent e1fbff7 commit 05516c4
Show file tree
Hide file tree
Showing 96 changed files with 122 additions and 251 deletions.
6 changes: 3 additions & 3 deletions bom/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<maven-plugin-annotations.version>3.5.2</maven-plugin-annotations.version>
<plexus-component-annotations.version>1.7.1</plexus-component-annotations.version>
<!-- What we actually depend on for the annotations, as latest Graal is not available in Maven fast enough: -->
<graal-sdk.version>19.2.1</graal-sdk.version>
<graal-sdk.version>19.3.1</graal-sdk.version>
<gizmo.version>1.0.1.Final</gizmo.version>
<jackson.version>2.10.2</jackson.version>
<commons-logging-jboss-logging.version>1.0.0.Final</commons-logging-jboss-logging.version>
Expand Down Expand Up @@ -848,7 +848,7 @@
<version>${jboss-logmanager.version}</version>
<exclusions>
<exclusion>
<groupId>com.oracle.substratevm</groupId>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
</exclusion>
<exclusion>
Expand Down Expand Up @@ -1670,7 +1670,7 @@
</dependency>

<dependency>
<groupId>com.oracle.substratevm</groupId>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<version>${graal-sdk.version}</version>
<scope>provided</scope>
Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!-- These properties are needed in order for them to be resolvable by the documentation -->
<!-- The Graal version we suggest using in documentation - as that's
what we work with by self downloading it: -->
<graal-sdk.version-for-documentation>19.2.1</graal-sdk.version-for-documentation>
<graal-sdk.version-for-documentation>19.3.1</graal-sdk.version-for-documentation>
<rest-assured.version>4.1.1</rest-assured.version>
<axle-client.version>0.0.9</axle-client.version>
<vertx.version>3.8.4</vertx.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package io.quarkus.deployment;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

import org.jboss.logging.Logger;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.JniBuildItem;
Expand All @@ -13,6 +14,8 @@

public class JniProcessor {

private static final Logger LOGGER = Logger.getLogger(JniProcessor.class);

JniConfig jni;

@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
Expand All @@ -24,16 +27,22 @@ static class JniConfig {
Optional<List<String>> libraryPaths;

/**
* Enable JNI support.
* @deprecated JNI is always enabled starting from GraalVM 19.3.1.
*/
@ConfigItem(defaultValue = "false")
boolean enable = false;
@Deprecated
@ConfigItem(defaultValue = "true")
boolean enable = true;
}

@BuildStep
void setupJni(BuildProducer<JniBuildItem> jniProducer) {
if ((jni.enable) || jni.libraryPaths.isPresent()) {
jniProducer.produce(new JniBuildItem(jni.libraryPaths.orElse(Collections.emptyList())));
if (!jni.enable) {
LOGGER.warn("Your application is setting the deprecated 'quarkus.jni.enable' configuration key to false. Please"
+ " consider removing this configuration key as it is ignored (JNI is always enabled) and it will be"
+ " removed in a future Quarkus version.");
}
if (jni.libraryPaths.isPresent()) {
jniProducer.produce(new JniBuildItem(jni.libraryPaths.get()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ public final class JniBuildItem extends MultiBuildItem {

private final List<String> libraryPaths;

/**
* @deprecated This method was previously used to enable JNI from Quarkus extensions, but JNI is always enabled starting
* from GraalVM 19.3.1.
*/
@Deprecated
public JniBuildItem() {
this(Collections.emptyList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ public class NativeConfig {
public boolean enableAllSecurityServices;

/**
* If JNI should be enabled
* @deprecated JNI is always enabled starting from GraalVM 19.3.1.
*/
@ConfigItem(defaultValue = "false")
@Deprecated
@ConfigItem(defaultValue = "true")
public boolean enableJni;

/**
Expand Down Expand Up @@ -132,7 +133,7 @@ public class NativeConfig {
/**
* The docker image to use to do the image build
*/
@ConfigItem(defaultValue = "quay.io/quarkus/ubi-quarkus-native-image:19.2.1")
@ConfigItem(defaultValue = "quay.io/quarkus/ubi-quarkus-native-image:19.3.1-java8")
public String builderImage;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa
//todo: this should be specific build items
if (prop.getKey().equals("quarkus.ssl.native") && prop.getValue() != null) {
enableSslNative = Boolean.parseBoolean(prop.getValue());
} else if (prop.getKey().equals("quarkus.jni.enable") && prop.getValue() != null) {
nativeConfig.enableJni |= Boolean.parseBoolean(prop.getValue());
} else if (prop.getKey().equals("quarkus.jni.enable") && prop.getValue().equals("false")) {
log.warn("Your application is setting the deprecated 'quarkus.jni.enable' configuration key to false."
+ " Please consider removing this configuration key as it is ignored (JNI is always enabled) and it"
+ " will be removed in a future Quarkus version.");
} else if (prop.getKey().equals("quarkus.native.enable-all-security-services") && prop.getValue() != null) {
nativeConfig.enableAllSecurityServices |= Boolean.parseBoolean(prop.getValue());
} else if (prop.getKey().equals("quarkus.native.enable-all-charsets") && prop.getValue() != null) {
Expand All @@ -195,13 +197,13 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa
}
if (enableSslNative) {
nativeConfig.enableHttpsUrlHandler = true;
nativeConfig.enableJni = true;
nativeConfig.enableAllSecurityServices = true;
}

nativeConfig.additionalBuildArgs.ifPresent(l -> l.stream().map(String::trim).forEach(command::add));
command.add("--initialize-at-build-time=");
command.add("-H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime"); //the default collection policy results in full GC's 50% of the time
command.add("-H:+JNI");
command.add("-jar");
command.add(runnerJarName);

Expand Down Expand Up @@ -266,10 +268,10 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa
if (!nativeConfig.enableIsolates) {
command.add("-H:-SpawnIsolates");
}
if (nativeConfig.enableJni || (graalVMVersion.isPresent() && !graalVMVersion.get().contains(" 19.2."))) {
command.add("-H:+JNI");
} else {
command.add("-H:-JNI");
if (!nativeConfig.enableJni) {
log.warn("Your application is setting the deprecated 'quarkus.native.enable-jni' configuration key to false."
+ " Please consider removing this configuration key as it is ignored (JNI is always enabled) and it"
+ " will be removed in a future Quarkus version.");
}
if (!nativeConfig.enableServer && !IS_WINDOWS) {
command.add("--no-server");
Expand Down Expand Up @@ -322,12 +324,11 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa

private void checkGraalVMVersion(String version) {
log.info("Running Quarkus native-image plugin on " + version);
final List<String> obsoleteGraalVmVersions = Arrays.asList("1.0.0", "19.0.", "19.1.", "19.2.0", "19.3.0");
final List<String> obsoleteGraalVmVersions = Arrays.asList("1.0.0", "19.0.", "19.1.", "19.2.", "19.3.0");
final boolean vmVersionIsObsolete = obsoleteGraalVmVersions.stream().anyMatch(v -> version.contains(" " + v));
if (vmVersionIsObsolete) {
throw new IllegalStateException("Unsupported version of GraalVM detected: " + version + "."
+ " Quarkus currently offers a stable support of GraalVM 19.2.1 and a preview support of GraalVM 19.3.1."
+ " Please upgrade GraalVM to one of these versions.");
throw new IllegalStateException(
"Out of date version of GraalVM detected: " + version + ". Please upgrade to GraalVM 19.3.1.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.deployment.builditem.nativeimage.UnsafeAccessedFieldBuildItem;
import io.quarkus.gizmo.AssignableResultHandle;
import io.quarkus.gizmo.CatchBlockCreator;
import io.quarkus.gizmo.ClassCreator;
import io.quarkus.gizmo.ClassOutput;
Expand All @@ -67,8 +66,6 @@ public class NativeImageAutoFeatureStep {
static final String BEFORE_ANALYSIS_ACCESS = Feature.BeforeAnalysisAccess.class.getName();
static final String DYNAMIC_PROXY_REGISTRY = "com.oracle.svm.core.jdk.proxy.DynamicProxyRegistry";
static final String LOCALIZATION_FEATURE = "com.oracle.svm.core.jdk.LocalizationFeature";
// TODO: Delete the following line when Quarkus no longer supports GraalVM 19.2.1.
static final String LOCALIZATION_SUPPORT = "com.oracle.svm.core.jdk.LocalizationSupport";

@BuildStep
List<NativeImageResourceBuildItem> registerPackageResources(
Expand Down Expand Up @@ -208,26 +205,7 @@ public void write(String s, byte[] bytes) {
}

if (!resourceBundles.isEmpty()) {
/*
* Start of a temporary workaround to support both GraalVM 19.2.1 and 19.3.1 at the same time.
* TODO: Delete this workaround when Quarkus no longer supports GraalVM 19.2.1.
*/
AssignableResultHandle locClass = overallCatch.createVariable(Class.class);
TryBlock workaroundTryBlock = overallCatch.tryBlock();
workaroundTryBlock.assign(locClass, workaroundTryBlock.loadClass(LOCALIZATION_FEATURE));
// The following line is required to throw an exception and make sure we load the 19.2.1 class when needed.
workaroundTryBlock.invokeVirtualMethod(
ofMethod(Class.class, "getDeclaredMethod", Method.class, String.class, Class[].class), locClass,
workaroundTryBlock.load("addBundleToCache"),
workaroundTryBlock.marshalAsArray(Class.class, workaroundTryBlock.loadClass(String.class)));
CatchBlockCreator workaroundCatchBlock = workaroundTryBlock.addCatch(Throwable.class);
workaroundCatchBlock.assign(locClass, workaroundCatchBlock.loadClass(LOCALIZATION_SUPPORT));
/*
* End of the temporary workaround.
*/

// TODO: Uncomment the following line when the temporary workaround above is deleted.
//ResultHandle locClass = overallCatch.loadClass(LOCALIZATION_FEATURE);
ResultHandle locClass = overallCatch.loadClass(LOCALIZATION_FEATURE);

ResultHandle params = overallCatch.marshalAsArray(Class.class, overallCatch.loadClass(String.class));
ResultHandle registerMethod = overallCatch.invokeVirtualMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,16 @@ void build(SslContextConfigurationRecorder sslContextConfigurationRecorder,
}
nativeImage.produce(new NativeImageSystemPropertyBuildItem("quarkus.ssl.native", sslNativeEnabled.toString()));

boolean requireJni = false;
if (!enableAllSecurityServicesBuildItems.isEmpty()) {
requireJni = true;
nativeImage.produce(new NativeImageSystemPropertyBuildItem("quarkus.native.enable-all-security-services", "true"));
}

if (!jniBuildItems.isEmpty() || requireJni) {
for (JniBuildItem jniBuildItem : jniBuildItems) {
if (jniBuildItem.getLibraryPaths() != null && !jniBuildItem.getLibraryPaths().isEmpty()) {
for (String path : jniBuildItem.getLibraryPaths()) {
javaLibraryPathAdditionalPath
.produce(new JavaLibraryPathAdditionalPathBuildItem(path));
}
for (JniBuildItem jniBuildItem : jniBuildItems) {
if (jniBuildItem.getLibraryPaths() != null && !jniBuildItem.getLibraryPaths().isEmpty()) {
for (String path : jniBuildItem.getLibraryPaths()) {
javaLibraryPathAdditionalPath.produce(new JavaLibraryPathAdditionalPathBuildItem(path));
}
}
nativeImage.produce(new NativeImageSystemPropertyBuildItem("quarkus.jni.enable", "true"));
}

if (!nativeImageEnableAllCharsetsBuildItems.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion core/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<artifactId>graal-sdk</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.substratevm</groupId>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion core/test-extension/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.substratevm</groupId>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public class QuarkusNative extends QuarkusTask {

private boolean enableServer = false;

private boolean enableJni = false;
/**
* @deprecated JNI is always enabled starting from GraalVM 19.3.1.
*/
@Deprecated
private boolean enableJni = true;

private boolean autoServiceLoaderRegistration = false;

Expand Down Expand Up @@ -200,11 +204,16 @@ public void setEnableServer(boolean enableServer) {
}

@Input
@Deprecated
public boolean isEnableJni() {
return enableJni;
}

@Option(description = "Enable jni", option = "enable-jni")
/**
* @deprecated JNI is always enabled starting from GraalVM 19.3.1.
*/
@Option(description = "Enable jni (deprecated)", option = "enable-jni")
@Deprecated
public void setEnableJni(boolean enableJni) {
this.enableJni = enableJni;
}
Expand Down Expand Up @@ -416,7 +425,6 @@ private Map<String, String> createCustomConfig() {

configs.put("quarkus.native.enable-http-url-handler", Boolean.toString(enableHttpUrlHandler));
configs.put("quarkus.native.enable-isolates", Boolean.toString(enableIsolates));
configs.put("quarkus.native.enable-jni", Boolean.toString(enableJni));

configs.put("quarkus.native.enable-server", Boolean.toString(enableServer));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public class NativeImageMojo extends AbstractMojo {
@Parameter(defaultValue = "false")
private Boolean enableServer;

@Parameter(defaultValue = "false")
/**
* @deprecated JNI is always enabled starting from GraalVM 19.3.1.
*/
@Deprecated
@Parameter(defaultValue = "true")
private Boolean enableJni;

@Parameter(defaultValue = "false")
Expand Down Expand Up @@ -369,8 +373,10 @@ private Map<String, String> createCustomConfig() {
if (enableIsolates != null) {
configs.put("quarkus.native.enable-isolates", enableIsolates.toString());
}
if (enableJni != null) {
configs.put("quarkus.native.enable-jni", enableJni.toString());
if (Boolean.FALSE.equals(enableJni)) {
getLog().warn("Your application is setting the deprecated 'enableJni' Maven option to false. Please"
+ " consider removing this option as it is ignored (JNI is always enabled) and it will be removed"
+ " in a future Quarkus version.");
}

if (enableServer != null) {
Expand Down
Loading

0 comments on commit 05516c4

Please sign in to comment.