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

Remove unused Platform.GC code #8115

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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 @@ -15,6 +15,9 @@ class Java9ModulesSmokeTest extends AbstractSmokeTest {
List<String> command = new ArrayList<>()
command.add(imageDir + "/bin/java")
command.addAll(defaultJavaProperties)
// temporarily turn off DDProf due to PROF-11066
command.removeAll { it.startsWith("-Ddd.profiling.ddprof.enabled") }
command.add("-Ddd.profiling.ddprof.enabled=false")
command.addAll((String[]) ["-m", "datadog.smoketest.moduleapp/datadog.smoketest.moduleapp.ModuleApplication"])
ProcessBuilder processBuilder = new ProcessBuilder(command)
processBuilder.directory(new File(buildDirectory))
Expand Down
1 change: 0 additions & 1 deletion internal-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ minimumInstructionCoverage = 0.8
excludedClassesCoverage += [
"datadog.trace.api.EndpointTracker",
"datadog.trace.api.Platform",
"datadog.trace.api.Platform.GC",
"datadog.trace.api.StatsDClient",
"datadog.trace.api.NoOpStatsDClient",
"datadog.trace.api.TraceSegment.NoOp",
Expand Down
42 changes: 4 additions & 38 deletions internal-api/src/main/java/datadog/trace/api/Platform.java
Original file line number Diff line number Diff line change
@@ -1,61 +1,27 @@
package datadog.trace.api;

import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
* This class is used early on during premain; it must not touch features like JMX or JUL in case
* they trigger early loading/binding.
*/
public final class Platform {
// A helper class to capture whether the executable is a native image or not.
// This class needs to be iniatlized at build only during the AOT compilation and build.
private static class Captured {
public static final boolean isNativeImage = checkForNativeImageBuilder();
}

public enum GC {
SERIAL("marksweep"),
PARALLEL("ps"),
CMS("concurrentmarksweep"),
G1("g1"),
SHENANDOAH("shenandoah"),
Z("z"),
UNKNOWN("");

private final String identifierPrefix;

GC(String identifierPrefix) {
this.identifierPrefix = identifierPrefix;
}

static GC current() {
for (GarbageCollectorMXBean mxBean : ManagementFactory.getGarbageCollectorMXBeans()) {
if (mxBean.isValid()) {
String name = mxBean.getName().toLowerCase(Locale.ROOT);
for (GC gc : GC.values()) {
if (gc != UNKNOWN && name.startsWith(gc.identifierPrefix)) {
return gc;
}
}
}
}
return UNKNOWN;
}
}

private static final Version JAVA_VERSION = parseJavaVersion(System.getProperty("java.version"));
private static final JvmRuntime RUNTIME = new JvmRuntime();

private static final GC GARBAGE_COLLECTOR = GC.current();

private static final boolean HAS_JFR = checkForJfr();
private static final boolean IS_NATIVE_IMAGE_BUILDER = checkForNativeImageBuilder();
private static final boolean IS_NATIVE_IMAGE = Captured.isNativeImage;

public static GC activeGarbageCollector() {
return GARBAGE_COLLECTOR;
}

public static boolean hasJfr() {
return HAS_JFR;
}
Expand Down
Loading