diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusDevModeLauncher.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusDevModeLauncher.java index d5e2b05b68da4..4f99d00ef5eb6 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusDevModeLauncher.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusDevModeLauncher.java @@ -67,6 +67,12 @@ public B preventnoverify(boolean preventnoverify) { return (B) this; } + @SuppressWarnings("unchecked") + public B forceC2(boolean force) { + forceC2 = force; + return (B) this; + } + @SuppressWarnings("unchecked") public B jvmArgs(String jvmArgs) { args.add(jvmArgs); @@ -316,6 +322,7 @@ public R build() throws Exception { private String targetJavaVersion; private Set buildFiles = new HashSet<>(0); private boolean deleteDevJar = true; + private boolean forceC2 = false; private String baseName; private Consumer entryPointCustomizer; private String applicationArgs; @@ -335,7 +342,7 @@ protected QuarkusDevModeLauncher() { protected void prepare() throws Exception { JBossVersion.disableVersionLogging(); - if (!JavaVersionUtil.isGraalvmJdk()) { + if (!JavaVersionUtil.isGraalvmJdk() && !forceC2) { // prevent C2 compiler for kicking in - makes startup a little faster // it only makes sense in dev-mode but it is not available when GraalVM is used as the JDK args.add("-XX:TieredStopAtLevel=1"); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java index d748b2d1e078b..5cc8b1319ac2f 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java @@ -93,6 +93,7 @@ public abstract class QuarkusDev extends QuarkusTask { private final MapProperty environmentVariables; private final Property preventNoVerify; + private final Property forceC2; private final Property shouldPropagateJavaCompilerArgs; private final ListProperty args; private final ListProperty jvmArgs; @@ -128,6 +129,9 @@ public QuarkusDev( preventNoVerify = objectFactory.property(Boolean.class); preventNoVerify.convention(false); + forceC2 = objectFactory.property(Boolean.class); + forceC2.convention(false); + shouldPropagateJavaCompilerArgs = objectFactory.property(Boolean.class); shouldPropagateJavaCompilerArgs.convention(true); @@ -222,6 +226,11 @@ public boolean isPreventnoverify() { return getPreventNoVerify().get(); } + @Input + public Property getForceC2() { + return forceC2; + } + /** * @deprecated see {@link #getPreventNoVerify()} */ @@ -414,6 +423,7 @@ private QuarkusDevModeLauncher newLauncher(final AnalyticsService analyticsServi } GradleDevModeLauncher.Builder builder = GradleDevModeLauncher.builder(getLogger(), java) .preventnoverify(getPreventNoVerify().getOrElse(false)) + .forceC2(getForceC2().getOrElse(false)) .projectDir(projectDir) .buildDir(buildDir) .outputDir(buildDir) diff --git a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java index 8879a3e604cab..f605744e82af5 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -296,6 +296,15 @@ public class DevMojo extends AbstractMojo { @Parameter(defaultValue = "${preventnoverify}") private boolean preventnoverify = false; + /** + * This value is intended to be set to true when we want to require C2 compilation instead of preventing it from + * ever kicking in. + * Setting this will likely have a small negative effect on startup time and should only be done when it absolutely + * makes sense. + */ + @Parameter(defaultValue = "${forceC2}") + private boolean forceC2 = false; + /** * Whether changes in the projects that appear to be dependencies of the project containing the application to be launched * should trigger hot-reload. By default, they do. @@ -1247,6 +1256,7 @@ private QuarkusDevModeLauncher newLauncher(String actualDebugPort, String bootst final MavenDevModeLauncher.Builder builder = MavenDevModeLauncher.builder(java, getLog()) .preventnoverify(preventnoverify) + .forceC2(forceC2) .buildDir(buildDir) .outputDir(outputDirectory) .suspend(suspend)