Skip to content

Commit

Permalink
Drop "deployment" dependency on org.graalvm.nativeimage.impl package
Browse files Browse the repository at this point in the history
Resolves errors like:

```
[error]: Build step io.quarkus.deployment.steps.NativeImageFeatureStep#generateFeature threw an exception: java.lang.IllegalAccessError: class io.quarkus.deployment.steps.NativeImageFeatureStep (in unnamed module @0x53fa18a5) cannot access class org.graalvm.nativeimage.impl.ConfigurationCondition (in module org.graalvm.sdk) because module org.graalvm.sdk does not export org.graalvm.nativeimage.impl to unnamed module @0x53fa18a5
```

Note that this is a temporary work-around until the reliance on
`org.graalvm.nativeimage.impl` is completely dropped in favour of using
public APIs only.

(cherry picked from commit e9133ed)
  • Loading branch information
zakkak authored and gsmet committed Sep 20, 2022
1 parent 73f5a5f commit 7f13298
Showing 1 changed file with 6 additions and 6 deletions.
Expand Up @@ -19,7 +19,6 @@
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization;
import org.graalvm.nativeimage.hosted.RuntimeReflection;
import org.graalvm.nativeimage.impl.ConfigurationCondition;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand Down Expand Up @@ -76,14 +75,15 @@ public class NativeImageFeatureStep {
"org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport",
"rerunInitialization", void.class, Class.class, String.class);

public static final String CONFIGURATION_CONDITION = "org.graalvm.nativeimage.impl.ConfigurationCondition";
private static final MethodDescriptor CONFIGURATION_ALWAYS_TRUE = ofMethod(
"org.graalvm.nativeimage.impl.ConfigurationCondition",
"alwaysTrue", "org.graalvm.nativeimage.impl.ConfigurationCondition");
CONFIGURATION_CONDITION,
"alwaysTrue", CONFIGURATION_CONDITION);

private static final MethodDescriptor REGISTER_LAMBDA_CAPTURING_CLASS = ofMethod(
"org.graalvm.nativeimage.impl.RuntimeSerializationSupport",
"registerLambdaCapturingClass", void.class,
"org.graalvm.nativeimage.impl.ConfigurationCondition",
CONFIGURATION_CONDITION,
String.class);

private static final MethodDescriptor LOOKUP_METHOD = ofMethod(
Expand Down Expand Up @@ -311,7 +311,7 @@ public void write(String s, byte[] bytes) {

TryBlock tc = overallCatch.tryBlock();

ResultHandle resourcesArgTypes = tc.marshalAsArray(Class.class, tc.loadClassFromTCCL(ConfigurationCondition.class),
ResultHandle resourcesArgTypes = tc.marshalAsArray(Class.class, tc.loadClassFromTCCL(CONFIGURATION_CONDITION),
tc.loadClassFromTCCL(String.class));
AssignableResultHandle resourcesArgs = tc.createVariable(Object[].class);
tc.assign(resourcesArgs,
Expand Down Expand Up @@ -387,7 +387,7 @@ public void write(String s, byte[] bytes) {

ResultHandle runtimeResourceSupportClass = greaterThan22_2.loadClassFromTCCL(RUNTIME_RESOURCE_SUPPORT);
ResultHandle addResourceBundlesParams = greaterThan22_2.marshalAsArray(Class.class,
greaterThan22_2.loadClassFromTCCL(ConfigurationCondition.class),
greaterThan22_2.loadClassFromTCCL(CONFIGURATION_CONDITION),
greaterThan22_2.loadClassFromTCCL(String.class));
ResultHandle addResourceBundlesMethod = greaterThan22_2.invokeStaticMethod(
LOOKUP_METHOD,
Expand Down

0 comments on commit 7f13298

Please sign in to comment.