Skip to content

Commit

Permalink
Merge pull request quarkusio#6574 from gwenneg/issue-6483-support-gra…
Browse files Browse the repository at this point in the history
…alvm-19.2.1-and-19.3.1

Support both GraalVM 19.2.1 and 19.3.1
  • Loading branch information
gsmet authored Jan 17, 2020
2 parents 64067b9 + 2d68b72 commit 8d0b94e
Show file tree
Hide file tree
Showing 86 changed files with 121 additions and 69 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.3.0.2</graal-sdk.version>
<graal-sdk.version>19.2.1</graal-sdk.version>
<gizmo.version>1.0.0.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 @@ -841,7 +841,7 @@
<version>${jboss-logmanager.version}</version>
<exclusions>
<exclusion>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</exclusion>
<exclusion>
Expand Down Expand Up @@ -1653,7 +1653,7 @@
</dependency>

<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</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.3.0.2</graal-sdk.version-for-documentation>
<graal-sdk.version-for-documentation>19.2.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
Expand Up @@ -38,7 +38,7 @@ public class NativeConfig {
/**
* If JNI should be enabled
*/
@ConfigItem(defaultValue = "true")
@ConfigItem(defaultValue = "false")
public boolean enableJni;

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa
if (!nativeConfig.enableIsolates) {
command.add("-H:-SpawnIsolates");
}
if (nativeConfig.enableJni) {
if (nativeConfig.enableJni || (graalVMVersion.isPresent() && !graalVMVersion.get().contains(" 19.2."))) {
command.add("-H:+JNI");
} else {
command.add("-H:-JNI");
Expand Down Expand Up @@ -322,12 +322,13 @@ 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.");
final List<String> obsoleteGraalVmVersions = Arrays.asList("1.0.0", "19.0.", "19.1.", "19.2.0");
final boolean vmVersionIsObsolete = version.contains(" 19.3.0 ")
|| obsoleteGraalVmVersions.stream().anyMatch(v -> version.contains(" " + v));
if (vmVersionIsObsolete) {
throw new IllegalStateException(
"Out of date build of GraalVM detected: " + version + ". Please upgrade to GraalVM 19.3.0.2");
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.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
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 @@ -66,6 +67,8 @@ 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 @@ -205,7 +208,26 @@ public void write(String s, byte[] bytes) {
}

if (!resourceBundles.isEmpty()) {
ResultHandle locClass = overallCatch.loadClass(LOCALIZATION_FEATURE);
/*
* 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 params = overallCatch.marshalAsArray(Class.class, overallCatch.loadClass(String.class));
ResultHandle registerMethod = overallCatch.invokeVirtualMethod(
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>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down
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>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class QuarkusNative extends QuarkusTask {

private boolean enableServer = false;

private boolean enableJni = true;
private boolean enableJni = false;

private boolean autoServiceLoaderRegistration = false;

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

@Parameter(defaultValue = "true")
@Parameter(defaultValue = "false")
private Boolean enableJni;

@Parameter(defaultValue = "false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<enableServer>false</enableServer>
<dumpProxies>false</dumpProxies>
<graalvmHome>${graalvmHome}</graalvmHome>
<enableJni>true</enableJni>
<enableAllSecurityServices>true</enableAllSecurityServices>
<enableReports>false</enableReports>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion extensions/agroal/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<artifactId>quarkus-narayana-jta</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion extensions/amazon-lambda-http/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<artifactId>quarkus-amazon-lambda-http</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/amazon-lambda-http/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<artifactId>aws-serverless-java-container-core</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/artemis-core/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</dependency>

<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/azure-functions-http/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<artifactId>quarkus-vertx-http-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/azure-functions-http/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<artifactId>quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion extensions/caffeine/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<artifactId>caffeine</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/elasticsearch-rest-client/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/elytron-security-common/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<artifactId>quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<artifactId>quarkus-elytron-security</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion extensions/elytron-security/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<artifactId>quarkus-vertx-http</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion extensions/flyway/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<artifactId>quarkus-narayana-jta</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion extensions/hibernate-orm/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<artifactId>jakarta.transaction-api</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion extensions/hibernate-search-elasticsearch/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<artifactId>hibernate-search-mapper-orm</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/hibernate-validator/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/infinispan-client/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<artifactId>protostream-processor</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/infinispan-embedded/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<artifactId>jakarta.transaction-api</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/jaeger/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<artifactId>jaeger-thrift</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion extensions/jaxb/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<description>XML serialization support</description>
<dependencies>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion extensions/jdbc/jdbc-derby/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<artifactId>derbyclient</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/jdbc/jdbc-h2/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
-->
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
import org.h2.engine.ConnectionInfo;
import org.h2.engine.Session;

import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(className = "org.h2.engine.Engine")
@Substitute
public final class Engine {

@Substitute
public static org.h2.engine.Engine getInstance() {
return SubstrateUtil.cast(new Engine(), org.h2.engine.Engine.class);
}

@Substitute
public Session createSession(ConnectionInfo ci) {
throw new UnsupportedOperationException(
Expand Down
2 changes: 1 addition & 1 deletion extensions/jdbc/jdbc-mariadb/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<artifactId>mariadb-java-client</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/jdbc/jdbc-mssql/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>
Expand Down
Loading

0 comments on commit 8d0b94e

Please sign in to comment.