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

Support both GraalVM 19.2.1 and 19.3.1 #6574

Merged

Conversation

gwenneg
Copy link
Member

@gwenneg gwenneg commented Jan 16, 2020

Fixes #6483

@gwenneg
Copy link
Member Author

gwenneg commented Jan 16, 2020

JNI is currently enabled no matter which GraalVM version is used. Should we try to disable it when possible? I don't know if this can have an impact on the native image size with 19.2.1.

I'd like to run some tests again before this is merged, I didn't have enough time to test everything I wanted tonight.

Comment on lines +218 to +222
// 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)));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to find a simpler expression to force the exception throw here, but I didn't find anything that worked. I'm sure this expression could be much shorter...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's just fine. You are just trying to make sure the method exists right? It should be perfectly OK and in any case it should be temporary

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I only need to check if the com.oracle.svm.core.jdk.LocalizationFeature class is available, I'm not really interested in the method itself. But invoking a simple getName from LocalizationFeature wasn't enough to force an exception throw. That's not really a problem since this code is only a copy of the original code a few lines below and it is also temporary, but that's still not pretty :)

@geoand
Copy link
Contributor

geoand commented Jan 16, 2020

Something seems to be wrong with CI:

2020-01-16T07:06:26.4612036Z [ERROR] 'dependencies.dependency.version' for org.graalvm.nativeimage:svm:jar is missing. @ line 25, column 21

@geoand geoand mentioned this pull request Jan 16, 2020
7 tasks
@gsmet
Copy link
Member

gsmet commented Jan 16, 2020

It would be nice to force JNI only for 19.3. We don't need it to be as pretty as the patch you worked on.

Something like: if graalVMVersion.isPresent() && !graalVMVersion.contains(" 19.2.") enableJni = true; in NativeImageBuildStep.

We can refine with your other patch once we only support GraalVM 19.3.

@geoand
Copy link
Contributor

geoand commented Jan 16, 2020

It would be nice to force JNI only for 19.3. We don't need it to be as pretty as the patch you worked on.

Something like: if graalVMVersion.isPresent() && !graalVMVersion.contains(" 19.2.") enableJni = true; in NativeImageBuildStep.

We can refine with your other patch once we only support GraalVM 19.3.

It also means that the default value in NativeConfig needs to be false

@gwenneg
Copy link
Member Author

gwenneg commented Jan 16, 2020

Something seems to be wrong with CI:

2020-01-16T07:06:26.4612036Z [ERROR] 'dependencies.dependency.version' for org.graalvm.nativeimage:svm:jar is missing. @ line 25, column 21

I've seen that, but that's a weird issue, I don't know where it is coming from. There isn't a single org.graalvm.nativeimage left in any of the Quarkus pom.xml...

@geoand
Copy link
Contributor

geoand commented Jan 16, 2020

Yeah it is weird, especially given the fact that the PR built for me locally...

@gwenneg
Copy link
Member Author

gwenneg commented Jan 16, 2020

Thanks for checking! Everything is working fine on my computer too.

I'll update the PR with the JNI changes in a couple hours, we'll see if CI is happier then.

@geoand
Copy link
Contributor

geoand commented Jan 16, 2020

Great, thanks a lot!

@gwenneg gwenneg force-pushed the issue-6483-support-graalvm-19.2.1-and-19.3.1 branch from 50abff4 to dc2ff88 Compare January 16, 2020 11:02
@gwenneg
Copy link
Member Author

gwenneg commented Jan 16, 2020

JNI is now disabled by default with GraalVM 19.2.1 and enabled by default with GraalVM 19.3.1. All the enableJni build parameters that were removed from the integration tests pom.xml files in #5358 have been restored in this PR. I will update #6306 to remove them again once this PR is merged.

CI is still unhappy with the PR... @gsmet have you already seen the following kind of error before?

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.graalvm.nativeimage:svm:jar is missing. @ line 25, column 21
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project io.quarkus:quarkus-narayana-stm:999-SNAPSHOT (D:\a\1\s\extensions\narayana-stm\runtime\pom.xml) has 1 error
[ERROR]     'dependencies.dependency.version' for org.graalvm.nativeimage:svm:jar is missing. @ line 25, column 21
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

There's absolutely no trace of org.graalvm.nativeimage in the pom.xml mentioned in the error message...

@gwenneg gwenneg marked this pull request as ready for review January 16, 2020 13:32
@gsmet
Copy link
Member

gsmet commented Jan 16, 2020

You have to rebase and fix the artifact in the narayana-stm extension. I did it but I can't force push to your branch so you'll have to do it yourself :).

CI applies your PR on top of master.

@gwenneg gwenneg force-pushed the issue-6483-support-graalvm-19.2.1-and-19.3.1 branch 2 times, most recently from 2621c83 to d68ff6a Compare January 16, 2020 14:47
Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a few comments.

The last commit need to be squashed into the one already changing the artifacts.

@gwenneg
Copy link
Member Author

gwenneg commented Jan 17, 2020

There's a small issue visible in #6594 that needs to be fixed before this PR is merged:

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 19.3.1 CE
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] docker run -v /home/vsts/work/1/s/integration-tests/artemis-core/target/quarkus-integration-test-artemis-core-999-SNAPSHOT-native-image-source-jar:/project:z --user 1001:117 --rm quay.io/quarkus/ubi-quarkus-native-image:19.3.1-java8 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar quarkus-integration-test-artemis-core-999-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -J-Xmx6g -H:+AddAllCharsets -H:EnableURLProtocols=http -H:+JNI --no-server -H:-UseServiceLoaderFeature -H:+StackTrace quarkus-integration-test-artemis-core-999-SNAPSHOT-runner
[quarkus-integration-test-artemis-core-999-SNAPSHOT-runner:19]    classlist:  15,374.36 ms
[quarkus-integration-test-artemis-core-999-SNAPSHOT-runner:19]        (cap):   1,375.41 ms
[quarkus-integration-test-artemis-core-999-SNAPSHOT-runner:19]        setup:   3,503.42 ms
06:32:24,524 INFO  [org.jbo.threads] JBoss Threads version 3.0.0.Final
[quarkus-integration-test-artemis-core-999-SNAPSHOT-runner:19]     analysis:  52,563.75 ms
Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing com.oracle.svm.reflect.ClassLoader_defineClass_c6c343b4d6dc22ca64eb2d8503b13ac9c340dcb3.invoke(java.lang.Object, java.lang.Object[]) 
Parsing context:
	parsing java.lang.reflect.Method.invoke(Method.java:498)
	parsing javax.enterprise.util.AnnotationLiteral.invoke(AnnotationLiteral.java:288)
	parsing javax.enterprise.util.AnnotationLiteral.getMemberValue(AnnotationLiteral.java:276)
	parsing javax.enterprise.util.AnnotationLiteral.hashCode(AnnotationLiteral.java:246)
	parsing java.util.concurrent.CopyOnWriteArrayList.hashCode(CopyOnWriteArrayList.java:1062)
	parsing java.util.AbstractList.hashCode(AbstractList.java:541)
	parsing org.graalvm.collections.EconomicMapImpl.getHashIndex(EconomicMapImpl.java:414)
	parsing org.graalvm.collections.EconomicMapImpl.putHashEntry(EconomicMapImpl.java:577)
	parsing org.graalvm.collections.EconomicMapImpl.put(EconomicMapImpl.java:451)
	parsing org.graalvm.collections.EconomicMap.putAll(EconomicMap.java:84)
	parsing org.graalvm.collections.EconomicMapImpl.<init>(EconomicMapImpl.java:183)
	parsing org.graalvm.collections.EconomicMapImpl.create(EconomicMapImpl.java:158)
	parsing org.graalvm.collections.EconomicMap.create(EconomicMap.java:171)
	parsing org.graalvm.compiler.options.ModifiableOptionValues.update(ModifiableOptionValues.java:93)
	parsing com.oracle.svm.core.option.RuntimeOptionParser.parse(RuntimeOptionParser.java:164)
	parsing com.oracle.svm.core.option.RuntimeOptionParser.parseAndConsumeAllOptions(RuntimeOptionParser.java:77)
	parsing com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:132)
	parsing com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
	parsing com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)

	at com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:138)
	at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:327)
	at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:300)
	at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:107)
	at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultVirtualInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:191)
	at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:343)
	at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:385)
	at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:511)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:171)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.ClassLoader.defineClass(String, byte[], int, int) is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.lookup(AnnotationSubstitutionProcessor.java:183)
	at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:128)
	at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:128)
	at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:397)
	at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:377)
	at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:75)
	at com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess.lookupJavaMethod(UniverseMetaAccess.java:93)
	at com.oracle.graal.pointsto.meta.AnalysisMetaAccess.lookupJavaMethod(AnalysisMetaAccess.java:66)
	at com.oracle.graal.pointsto.meta.AnalysisMetaAccess.lookupJavaMethod(AnalysisMetaAccess.java:39)
	at com.oracle.svm.reflect.hosted.ReflectionSubstitutionType$ReflectiveInvokeMethod.buildGraph(ReflectionSubstitutionType.java:511)
	at com.oracle.graal.pointsto.meta.AnalysisMethod.buildGraph(AnalysisMethod.java:319)
	at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:185)
	at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:340)
	at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:310)
	... 12 more

@geoand
Copy link
Contributor

geoand commented Jan 17, 2020

As discussed with @gsmet, once this is in we should setup some simple GitHub Actions pipeline to ensure that things work properly for both GraalVM versions

@geoand
Copy link
Contributor

geoand commented Jan 17, 2020

@gwenneg that seems similar to what #6597 fixes. Mind giving it a try?

@gwenneg
Copy link
Member Author

gwenneg commented Jan 17, 2020

That's the same one indeed. Both this PR and #6594 are editable, feel free to rebase both on master once #6597 is merged if you want quick results. I won't be able to push anything before the end of the day (which just started for me).

@gsmet
Copy link
Member

gsmet commented Jan 17, 2020

Let's merge that one and make progress from there. Additional 19.3.1 issues can be fixed later, they are independent from this PR.

@gsmet gsmet merged commit 8d0b94e into quarkusio:master Jan 17, 2020
@geoand
Copy link
Contributor

geoand commented Jan 17, 2020

@gwenneg will do, thanks

@ozkanpakdil
Copy link
Contributor

Sorry to bother. I tried to use 1.2.0.CR1. I have small maven project which uses quarkus. and I just wanted to compile it with graalvm 19.3 but it did not work
<properties> <maven.compiler.parameters>true</maven.compiler.parameters> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <compiler-plugin.version>3.8.1</compiler-plugin.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <quarkus-plugin.version>1.1.1.Final</quarkus-plugin.version> <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id> <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id> <quarkus.platform.version>1.2.0.CR1</quarkus.platform.version> <surefire-plugin.version>2.22.2</surefire-plugin.version> </properties>

I have changed quarkus.platform.version and ran mvn install just to see if build works but failed. with
[ERROR] The project com.mascix:quarkus-command-runner:1.0-SNAPSHOT (D:\Projects\quarkus-command-runner\pom.xml) has 7 errors [ERROR] Non-resolvable import POM: Could not find artifact io.quarkus:quarkus-universe-bom:pom:1.2.0.CR1 in central (https://repo.maven.apache.org/maven2) @ line 23, column 25 -> [Help 2]

if you dont mind can you tell me how to test new CRs ? or better just point me to an example repo where you test CR1 :) I can copy from there

@geoand
Copy link
Contributor

geoand commented Jan 22, 2020

The quarkus-universe-bom hasn't been released yet. However you can replace it with quarkus-bom and everything should be OK

@ozkanpakdil
Copy link
Contributor

ozkanpakdil commented Jan 23, 2020

thank you very much and here is result
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] C:\Program Files\GraalVM\graalvm-ce-java11-19.3.0\bin\native-image.cmd -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar quarkus-command-runner-1.0-SNAPSHOT-runner.jar -J-Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:+AddAllCharsets -H:EnableURLProtocols=http -H:-JNI -H:-UseServiceLoaderFeature -H:+StackTrace quarkus-command-runner-1.0-SNAPSHOT-runner Warning: the '=' character in program arguments is not fully supported. Make sure that command line arguments using it are wrapped in double quotes. Example: "--vm.Dfoo=bar"

Error: Unknown arguments: 100, io.quarkus.vertx.core.runtime.VertxLogDelegateFactory, true, DISABLED, 1, com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime, 1, 0, http, quarkus-command-runner-1.0-SNAPSHOT-runner`
probably there is already a bug/issue for it somewhere 😃 good day

@geoand
Copy link
Contributor

geoand commented Jan 23, 2020

@ozkanpakdil Maybe you can ask on the Quarkus Zulip chat?

@gwenneg
Copy link
Member Author

gwenneg commented Jan 23, 2020

@ozkanpakdil My answer won't be directly related to your issue, but please note that GraalVM 19.3.0 is not supported by Quarkus 1.2.0-CR1. You need to use either GraalVM 19.2.1 or 19.3.1. You should also know that the GraalVM support for the Windows platform is still experimental as explained here. Furthermore, the JDK 11 support was introduced very recently in GraalVM, it was experimental with 19.3.0 and I don't know what the official status is with 19.3.1.

If you still can't generate your native image with GraalVM 19.3.1, please open a new GitHub issue from here. It will be easier for us to help you that way. Thanks!

@bradcupit
Copy link

bradcupit commented Jan 23, 2020

@ozkanpakdil: I got it working with a combination of these changes:

    <quarkus-plugin.version>1.2.0.Final</quarkus-plugin.version>
    <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
    <quarkus.platform.version>1.2.0.CR1</quarkus.platform.version>

quarkus-plugin.version is the maven plugin and without upgrading it I would get this error:

Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.IllegalStateException: Unsupported version of GraalVM detected: GraalVM Version 19.3.1 CE. Please use GraalVM 19.2.1.

Use quarkus-bom instead of quarkus-universe-bom (thanks @geoand!) since quarkus-universe-bom 1.2.0.Final hasn't been released

Set quarkus.platform.version to 1.2.0.CR1 works. 1.2.0.Final gets close to working but failed with the below error so I had to use 1.2.0.CR1 instead:

... Could not transfer artifact io.quarkus:quarkus-core:jar:1.2.0.Final ...

I'm assuming the 1.2.0.Final release is imminent, perhaps even in progress as we speak, and that's why we're having to cobble a few things together for the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Double GraalVM compatibility effort
5 participants