Skip to content

Commit 88c493c

Browse files
authored
Remove unused Platform.GC code (#8115)
* Remove unused Platform.GC code; add warning about accessing JMX too early * temporarily turn off DDProf due to PROF-11066
1 parent 90899e0 commit 88c493c

File tree

3 files changed

+7
-39
lines changed

3 files changed

+7
-39
lines changed

dd-smoke-tests/java9-modules/src/test/groovy/datadog/smoketest/Java9ModulesSmokeTest.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class Java9ModulesSmokeTest extends AbstractSmokeTest {
1515
List<String> command = new ArrayList<>()
1616
command.add(imageDir + "/bin/java")
1717
command.addAll(defaultJavaProperties)
18+
// temporarily turn off DDProf due to PROF-11066
19+
command.removeAll { it.startsWith("-Ddd.profiling.ddprof.enabled") }
20+
command.add("-Ddd.profiling.ddprof.enabled=false")
1821
command.addAll((String[]) ["-m", "datadog.smoketest.moduleapp/datadog.smoketest.moduleapp.ModuleApplication"])
1922
ProcessBuilder processBuilder = new ProcessBuilder(command)
2023
processBuilder.directory(new File(buildDirectory))

internal-api/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ minimumInstructionCoverage = 0.8
2727
excludedClassesCoverage += [
2828
"datadog.trace.api.EndpointTracker",
2929
"datadog.trace.api.Platform",
30-
"datadog.trace.api.Platform.GC",
3130
"datadog.trace.api.StatsDClient",
3231
"datadog.trace.api.NoOpStatsDClient",
3332
"datadog.trace.api.TraceSegment.NoOp",

internal-api/src/main/java/datadog/trace/api/Platform.java

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,27 @@
11
package datadog.trace.api;
22

3-
import java.lang.management.GarbageCollectorMXBean;
4-
import java.lang.management.ManagementFactory;
53
import java.util.ArrayList;
64
import java.util.List;
75
import java.util.Locale;
86

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

16-
public enum GC {
17-
SERIAL("marksweep"),
18-
PARALLEL("ps"),
19-
CMS("concurrentmarksweep"),
20-
G1("g1"),
21-
SHENANDOAH("shenandoah"),
22-
Z("z"),
23-
UNKNOWN("");
24-
25-
private final String identifierPrefix;
26-
27-
GC(String identifierPrefix) {
28-
this.identifierPrefix = identifierPrefix;
29-
}
30-
31-
static GC current() {
32-
for (GarbageCollectorMXBean mxBean : ManagementFactory.getGarbageCollectorMXBeans()) {
33-
if (mxBean.isValid()) {
34-
String name = mxBean.getName().toLowerCase(Locale.ROOT);
35-
for (GC gc : GC.values()) {
36-
if (gc != UNKNOWN && name.startsWith(gc.identifierPrefix)) {
37-
return gc;
38-
}
39-
}
40-
}
41-
}
42-
return UNKNOWN;
43-
}
44-
}
45-
4618
private static final Version JAVA_VERSION = parseJavaVersion(System.getProperty("java.version"));
4719
private static final JvmRuntime RUNTIME = new JvmRuntime();
4820

49-
private static final GC GARBAGE_COLLECTOR = GC.current();
50-
5121
private static final boolean HAS_JFR = checkForJfr();
5222
private static final boolean IS_NATIVE_IMAGE_BUILDER = checkForNativeImageBuilder();
5323
private static final boolean IS_NATIVE_IMAGE = Captured.isNativeImage;
5424

55-
public static GC activeGarbageCollector() {
56-
return GARBAGE_COLLECTOR;
57-
}
58-
5925
public static boolean hasJfr() {
6026
return HAS_JFR;
6127
}

0 commit comments

Comments
 (0)