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

Initialize build runner in AwtProcessor before usage #34296

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

import io.quarkus.awt.runtime.graal.DarwinAwtFeature;
Expand All @@ -21,6 +22,8 @@
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedPackageBuildItem;
import io.quarkus.deployment.builditem.nativeimage.UnsupportedOSBuildItem;
import io.quarkus.deployment.pkg.builditem.NativeImageRunnerBuildItem;
import io.quarkus.deployment.pkg.builditem.ProcessInheritIODisabled;
import io.quarkus.deployment.pkg.builditem.ProcessInheritIODisabledBuildItem;
import io.quarkus.deployment.pkg.steps.GraalVM;
import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;

Expand Down Expand Up @@ -95,7 +98,11 @@ ReflectiveClassBuildItem setupReflectionClassesWithMethods() {
void setupAWTInit(BuildProducer<JniRuntimeAccessBuildItem> jc,
BuildProducer<JniRuntimeAccessMethodBuildItem> jm,
BuildProducer<JniRuntimeAccessFieldBuildItem> jf,
NativeImageRunnerBuildItem nativeImageRunnerBuildItem) {
NativeImageRunnerBuildItem nativeImageRunnerBuildItem,
Optional<ProcessInheritIODisabled> processInheritIODisabled,
Optional<ProcessInheritIODisabledBuildItem> processInheritIODisabledBuildItem) {
nativeImageRunnerBuildItem.getBuildRunner()
.setup(processInheritIODisabled.isPresent() || processInheritIODisabledBuildItem.isPresent());
Comment on lines +104 to +105
Copy link
Member

Choose a reason for hiding this comment

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

If we have to do that, there is something wrong. I'll have to have a look later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I am misusing the setup(...) method, but I can say that setup() has not yet been called when AwtProcessor is executed. Without the call to setup(...), the successive call to nativeImageRunnerBuildItem.getBuildRunner().getGraalVMVersion() would trigger the initial image pull.

final GraalVM.Version v = nativeImageRunnerBuildItem.getBuildRunner().getGraalVMVersion();
// Dynamically loading shared objects instead
// of baking in static libs: https://github.com/oracle/graal/issues/4921
Expand All @@ -118,7 +125,11 @@ void setupAWTInit(BuildProducer<JniRuntimeAccessBuildItem> jc,
}

@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
JniRuntimeAccessBuildItem setupJava2DClasses(NativeImageRunnerBuildItem nativeImageRunnerBuildItem) {
JniRuntimeAccessBuildItem setupJava2DClasses(NativeImageRunnerBuildItem nativeImageRunnerBuildItem,
Optional<ProcessInheritIODisabled> processInheritIODisabled,
Optional<ProcessInheritIODisabledBuildItem> processInheritIODisabledBuildItem) {
nativeImageRunnerBuildItem.getBuildRunner()
.setup(processInheritIODisabled.isPresent() || processInheritIODisabledBuildItem.isPresent());
final GraalVM.Version v = nativeImageRunnerBuildItem.getBuildRunner().getGraalVMVersion();
final List<String> classes = new ArrayList<>();
classes.add("com.sun.imageio.plugins.jpeg.JPEGImageReader");
Expand Down