Skip to content

Commit

Permalink
Removal of legacy code related to unsupported Java 13 and 16 version
Browse files Browse the repository at this point in the history
 * removal of isJava13OrHigher and isJava16OrLower methods from JavaVersionUtil
 * removal of preventnoverify which is deadcode because it is relevant for Java 12 and lower
  • Loading branch information
rsvoboda committed Jan 14, 2025
1 parent 529a20d commit 0fef7e7
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import io.quarkus.deployment.util.CommandLineUtil;
import io.quarkus.maven.dependency.ArtifactKey;
import io.quarkus.runtime.logging.JBossVersion;
import io.quarkus.runtime.util.JavaVersionUtil;
import io.quarkus.utilities.JavaBinFinder;

public class DevModeCommandLineBuilder {
Expand Down Expand Up @@ -137,19 +136,6 @@ protected DevModeCommandLineBuilder(String java) {
args.add(javaTool);
}

public DevModeCommandLineBuilder preventnoverify(boolean preventnoverify) {
if (!preventnoverify) {
// in Java 13 and up, preventing verification is deprecated - see https://bugs.openjdk.java.net/browse/JDK-8218003
// this test isn't absolutely correct in the sense that depending on the user setup, the actual Java binary
// that is used might be different that the one running Maven, but given how small of an impact this has
// it's probably better than running an extra command on 'javaTool' just to figure out the version
if (!JavaVersionUtil.isJava13OrHigher()) {
args.add("-Xverify:none");
}
}
return this;
}

public DevModeCommandLineBuilder forceC2(Boolean force) {
forceC2 = force;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ public class JavaVersionUtil {

private static final Pattern PATTERN = Pattern.compile("(?:1\\.)?(\\d+)");

private static boolean IS_JAVA_13_OR_NEWER;
private static boolean IS_GRAALVM_JDK;
private static boolean IS_JAVA_16_OR_OLDER;
private static boolean IS_JAVA_17_OR_NEWER;
private static boolean IS_JAVA_19_OR_NEWER;
private static boolean IS_JAVA_21_OR_NEWER;
Expand All @@ -23,14 +21,10 @@ static void performChecks() {
Matcher matcher = PATTERN.matcher(System.getProperty("java.specification.version", ""));
if (matcher.matches()) {
int first = Integer.parseInt(matcher.group(1));
IS_JAVA_13_OR_NEWER = (first >= 13);
IS_JAVA_16_OR_OLDER = (first <= 16);
IS_JAVA_17_OR_NEWER = (first >= 17);
IS_JAVA_19_OR_NEWER = (first >= 19);
IS_JAVA_21_OR_NEWER = (first >= 21);
} else {
IS_JAVA_13_OR_NEWER = false;
IS_JAVA_16_OR_OLDER = false;
IS_JAVA_17_OR_NEWER = false;
IS_JAVA_19_OR_NEWER = false;
IS_JAVA_21_OR_NEWER = false;
Expand All @@ -40,14 +34,6 @@ static void performChecks() {
IS_GRAALVM_JDK = (vmVendor != null) && vmVendor.startsWith("GraalVM");
}

public static boolean isJava13OrHigher() {
return IS_JAVA_13_OR_NEWER;
}

public static boolean isJava16OrLower() {
return IS_JAVA_16_OR_OLDER;
}

public static boolean isJava17OrHigher() {
return IS_JAVA_17_OR_NEWER;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,27 @@ class JavaVersionUtilTest {
@Test
void testJava8() {
testWithVersion("1.8", () -> {
assertFalse(JavaVersionUtil.isJava13OrHigher());
assertFalse(JavaVersionUtil.isJava17OrHigher());
});
}

@Test
void testJava11() {
testWithVersion("11", () -> {
assertFalse(JavaVersionUtil.isJava13OrHigher());
assertFalse(JavaVersionUtil.isJava17OrHigher());
});
}

@Test
void testJava14() {
testWithVersion("14", () -> {
assertTrue(JavaVersionUtil.isJava13OrHigher());
assertFalse(JavaVersionUtil.isJava17OrHigher());
});
}

@Test
void testJava17() {
testWithVersion("17", () -> {
assertTrue(JavaVersionUtil.isJava13OrHigher());
assertTrue(JavaVersionUtil.isJava17OrHigher());
assertFalse(JavaVersionUtil.isJava21OrHigher());
});
Expand All @@ -42,7 +41,7 @@ void testJava17() {
@Test
void testJava21() {
testWithVersion("21", () -> {
assertTrue(JavaVersionUtil.isJava13OrHigher());
assertTrue(JavaVersionUtil.isJava17OrHigher());
assertTrue(JavaVersionUtil.isJava21OrHigher());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public abstract class QuarkusDev extends QuarkusTask {
private final Property<File> workingDirectory;
private final MapProperty<String, String> environmentVariables;

private final Property<Boolean> preventNoVerify;
private final Property<Boolean> forceC2;
private final Property<Boolean> shouldPropagateJavaCompilerArgs;
private final ListProperty<String> args;
Expand Down Expand Up @@ -129,9 +128,6 @@ public QuarkusDev(

environmentVariables = objectFactory.mapProperty(String.class, String.class);

preventNoVerify = objectFactory.property(Boolean.class);
preventNoVerify.convention(false);

forceC2 = objectFactory.property(Boolean.class);

shouldPropagateJavaCompilerArgs = objectFactory.property(Boolean.class);
Expand Down Expand Up @@ -212,40 +208,12 @@ public Map<String, String> getEnvVars() {
return environmentVariables.get();
}

@Input
public Property<Boolean> getPreventNoVerify() {
return preventNoVerify;
}

/**
* @return boolean value of getPreventNoVerify()
* @deprecated see {@link #getPreventNoVerify()}
*/
@SuppressWarnings("SpellCheckingInspection")
@Deprecated
@Internal
public boolean isPreventnoverify() {
return getPreventNoVerify().get();
}

@Input
@Optional
public Property<Boolean> getForceC2() {
return forceC2;
}

/**
* @deprecated see {@link #getPreventNoVerify()}
*/
@SuppressWarnings("SpellCheckingInspection")
@Deprecated
@Option(description = "value is intended to be set to true when some generated bytecode is" +
" erroneous causing the JVM to crash when the verify:none option is set " +
"(which is on by default)", option = "prevent-noverify")
public void setPreventnoverify(boolean preventNoVerify) {
getPreventNoVerify().set(preventNoVerify);
}

@Input
public ListProperty<String> getJvmArguments() {
return jvmArgs;
Expand Down Expand Up @@ -439,7 +407,6 @@ private DevModeCommandLine newLauncher(final AnalyticsService analyticsService)
}
}
DevModeCommandLineBuilder builder = DevModeCommandLine.builder(java)
.preventnoverify(getPreventNoVerify().getOrElse(false))
.forceC2(getForceC2().getOrNull())
.projectDir(projectDir)
.buildDir(buildDir)
Expand Down
8 changes: 0 additions & 8 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,6 @@ public class DevMojo extends AbstractMojo {
@Parameter(defaultValue = "${project.remotePluginRepositories}", readonly = true, required = true)
private List<RemoteRepository> pluginRepos;

/**
* This value is intended to be set to true when some generated bytecode
* is erroneous causing the JVM to crash when the <code>verify:none</code> option is set (which is on by default)
*/
@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.
Expand Down Expand Up @@ -1285,7 +1278,6 @@ private DevModeCommandLine newLauncher(String actualDebugPort, String bootstrapI
}

final DevModeCommandLineBuilder builder = DevModeCommandLine.builder(java)
.preventnoverify(preventnoverify)
.forceC2(forceC2)
.buildDir(buildDir)
.outputDir(outputDirectory)
Expand Down

0 comments on commit 0fef7e7

Please sign in to comment.