Skip to content
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 @@ -57,6 +57,8 @@ public class ConfigurationUpdater implements DebuggerContext.ProbeResolver, Conf
private static final int MINUTES_BETWEEN_ERROR_LOG = 5;
private static final boolean JAVA_AT_LEAST_19 = JavaVirtualMachine.isJavaVersionAtLeast(19);
private static final boolean JAVA_AT_LEAST_16 = JavaVirtualMachine.isJavaVersionAtLeast(16);
private static final boolean JAVA_AT_LEAST_25_0_4 =
JavaVirtualMachine.isJavaVersionAtLeast(25, 0, 4);
Comment on lines +60 to +61

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Gate the workaround by each JDK feature line

On JDK 26.0.1 this evaluates true because the major version is greater than 25, but JDK-8376185 is listed as fixed in the JDK 26.0.2 update, not 26.0.1 (Oracle release notes). That means both record-type-annotation safety checks are bypassed on unfixed JDK 26 builds, so a probe on a record with TYPE_USE annotations can be instrumented/retransformed again and re-expose the NoSuchFieldError/JVM-corruption path this guard is meant to avoid. Please make this a per-feature-line check, e.g. 25 >= 25.0.4 and 26 >= 26.0.2, instead of a single lower bound.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

True, but can ask to upgrade. so acceptable and marginal for JDK 26

private static final Method GET_RECORD_COMPONENTS_METHOD;
private static final Method GET_ANNOTATED_TYPES_METHOD;

Expand Down Expand Up @@ -353,8 +355,9 @@ private static class JDKVersionSpecificHelper {

public static List<Class<?>> detectRecordWithTypeAnnotation(
Consumer<String> reportError, List<Class<?>> changedClasses) {
if (!JAVA_AT_LEAST_16) {
if (!JAVA_AT_LEAST_16 || JAVA_AT_LEAST_25_0_4) {
// records introduced in JDK 16 (final version)
// JDK-8376185 fixed since JDK 25.0.4
return changedClasses;
}
List<Class<?>> result = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public class DebuggerTransformer implements ClassFileTransformer {
SpanProbe.class);
private static final String JAVA_IO_TMPDIR = "java.io.tmpdir";
private static final boolean JAVA_AT_LEAST_19 = JavaVirtualMachine.isJavaVersionAtLeast(19);
private static final boolean JAVA_AT_LEAST_25_0_4 =
JavaVirtualMachine.isJavaVersionAtLeast(25, 0, 4);
public static Path DUMP_PATH = Paths.get(SystemProperties.get(JAVA_IO_TMPDIR), "debugger");
private static final String[] SKIPPED_PACKAGES =
new String[] {
Expand Down Expand Up @@ -353,6 +355,9 @@ private boolean checkMethodParameters(
*/
private boolean checkRecordTypeAnnotation(
ClassNode classNode, List<ProbeDefinition> definitions, String fullyQualifiedClassName) {
if (JAVA_AT_LEAST_25_0_4) {
return true;
}
if (!ASMHelper.isRecord(classNode)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3283,6 +3283,10 @@ public void noInstrumentationForAgentClasses() throws Exception {
@Test
@EnabledForJreRange(min = JRE.JAVA_17)
public void recordWithTypeAnnotation() throws IOException, URISyntaxException {
if (JavaVirtualMachine.isJavaVersionAtLeast(25, 0, 4)) {
// Fixed since JDK 25.0.4
return;
}
final String CLASS_NAME = "com.datadog.debugger.CapturedSnapshot33";
LogProbe probe1 = createMethodProbeAtExit(PROBE_ID1, CLASS_NAME, "parse", null);
TestSnapshotListener listener = installProbes(probe1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,10 @@ public void methodParametersAttributeRecord()
@EnabledForJreRange(min = JRE.JAVA_17)
public void recordWithTypeAnnotation()
throws IOException, URISyntaxException, UnmodifiableClassException {
// make sure record method are not detected as having methodParameters attribute.
// /!\ record canonical constructor has the MethodParameters attribute,
// but not returned by Class::getDeclaredMethods()
if (JavaVirtualMachine.isJavaVersionAtLeast(25, 0, 4)) {
// Fixed since JDK 25.0.4
return;
}
final String CLASS_NAME = "com.datadog.debugger.CapturedSnapshot33";
Map<String, byte[]> buffers = compile(CLASS_NAME, SourceCompiler.DebugInfo.ALL, "17");
Class<?> testClass = loadClass(CLASS_NAME, buffers);
Expand Down
Loading