Skip to content

Commit 059fd76

Browse files
authored
Prevent instrumenting first line of a constructor (#10772)
Prevent instrumenting first line of a constructor Because a constructor need to call first the super or this, instrumenting here will generate a VerifyError for loaded class. We are preventing this by detecting at instrumentation time if this is a constructor (<init>) and the first line of it. We are removing also for SymbolDB the first line of a constructor in the injectible lines. Works also for default constructor (line of the class declaration) fix test Co-authored-by: jean-philippe.bempel <jean-philippe.bempel@datadoghq.com>
1 parent 4d0bac2 commit 059fd76

6 files changed

Lines changed: 93 additions & 54 deletions

File tree

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/instrumentation/CapturedContextInstrumenter.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,15 @@ private boolean addLineCaptures(ClassFileLines classFileLines) {
119119
int till = sourceLine.getTill();
120120

121121
boolean isSingleLine = from == till;
122-
122+
if (isSingleLine) {
123+
List<MethodNode> methods = classFileLines.getMethodsByLine(from);
124+
if (methods.size() == 1 && "<init>".equals(methods.get(0).name)) {
125+
if (from == classFileLines.getMethodStart(methodNode)) {
126+
reportError("Cannot instrument the first line of a constructor");
127+
return false;
128+
}
129+
}
130+
}
123131
LabelNode beforeLabel = classFileLines.getLineLabel(from);
124132
// single line N capture translates to line range (N, N+1)
125133
LabelNode afterLabel = classFileLines.getLineLabel(till + (isSingleLine ? 1 : 0));

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/symbol/SymbolExtractor.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ private static Scope extractScopes(ClassNode classNode, String jarName) {
5757
int classStartLine = Integer.MAX_VALUE;
5858
int classEndLine = 0;
5959
for (Scope scope : methodScopes) {
60-
classStartLine = Math.min(classStartLine, scope.getStartLine());
61-
classEndLine = Math.max(classEndLine, scope.getEndLine());
60+
if (scope.getStartLine() > 0) {
61+
classStartLine = Math.min(classStartLine, scope.getStartLine());
62+
}
63+
if (scope.getEndLine() > 0) {
64+
classEndLine = Math.max(classEndLine, scope.getEndLine());
65+
}
6266
}
6367
List<Symbol> fields = extractFields(classNode);
6468
LanguageSpecifics classSpecifics =
@@ -505,7 +509,18 @@ private static MethodLineInfo extractMethodLineInfo(
505509
node = node.getNext();
506510
}
507511
lineNo.sort(Integer::compareTo);
508-
int startLine = lineNo.isEmpty() ? 0 : lineNo.get(0);
512+
if (methodNode.name.equals("<init>") && !lineNo.isEmpty()) {
513+
// for constructors we are dropping the first line because it is not instrumentable:
514+
// it needs to call the super or this before
515+
lineNo.remove(0);
516+
}
517+
int startLine;
518+
if (lineNo.isEmpty()) {
519+
startLine = 0;
520+
maxLine = 0;
521+
} else {
522+
startLine = lineNo.get(0);
523+
}
509524
List<Scope.LineRange> ranges = buildRanges(lineNo);
510525
return new MethodLineInfo(startLine, maxLine, map, ranges);
511526
}

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturedSnapshotTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,22 @@ public void constructor() throws IOException, URISyntaxException {
256256
assertOneSnapshot(listener);
257257
}
258258

259+
@Test
260+
public void constructorFirstLine() throws IOException, URISyntaxException {
261+
final String CLASS_NAME = "CapturedSnapshot02";
262+
int line = getLineForLineProbe(CLASS_NAME, LINE_PROBE_ID2);
263+
TestSnapshotListener listener = installLineProbe(LINE_PROBE_ID2, CLASS_NAME, line);
264+
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
265+
int result = Reflect.onClass(testClass).call("main", "f").get();
266+
assertEquals(42, result);
267+
ArgumentCaptor<ProbeId> probeIdCaptor = ArgumentCaptor.forClass(ProbeId.class);
268+
ArgumentCaptor<String> strCaptor = ArgumentCaptor.forClass(String.class);
269+
verify(probeStatusSink).addError(probeIdCaptor.capture(), strCaptor.capture());
270+
assertEquals(LINE_PROBE_ID2.getId(), probeIdCaptor.getAllValues().get(0).getId());
271+
assertEquals(
272+
"Cannot instrument the first line of a constructor", strCaptor.getAllValues().get(0));
273+
}
274+
259275
@Test
260276
public void overloadedConstructor() throws IOException, URISyntaxException {
261277
final String CLASS_NAME = "CapturedSnapshot02";

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/symbol/SymbolExtractionTransformerTest.java

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ public void symbolExtraction01() throws IOException, URISyntaxException {
8585
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
8686
Reflect.on(testClass).call("main", "1").get();
8787
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
88-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 2, 20, SOURCE_FILE, 2, 0);
89-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 2, 2, SOURCE_FILE, 0, 0);
90-
assertLineRanges(classScope.getScopes().get(0), "2-2");
88+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 4, 20, SOURCE_FILE, 2, 0);
89+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
90+
assertFalse(classScope.getScopes().get(0).hasInjectibleLines());
9191
Scope mainMethodScope = classScope.getScopes().get(1);
9292
assertScope(mainMethodScope, ScopeType.METHOD, "main", 4, 20, SOURCE_FILE, 1, 1);
9393
assertLineRanges(mainMethodScope, "4-15", "17-17", "19-20");
@@ -154,9 +154,9 @@ public void symbolExtraction02() throws IOException, URISyntaxException {
154154
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
155155
Reflect.on(testClass).call("main", "1").get();
156156
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
157-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 3, 6, SOURCE_FILE, 2, 0);
158-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 3, 3, SOURCE_FILE, 0, 0);
159-
assertLineRanges(classScope.getScopes().get(0), "3-3");
157+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 5, 6, SOURCE_FILE, 2, 0);
158+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
159+
assertFalse(classScope.getScopes().get(0).hasInjectibleLines());
160160
Scope mainMethodScope = classScope.getScopes().get(1);
161161
assertScope(mainMethodScope, ScopeType.METHOD, "main", 5, 6, SOURCE_FILE, 1, 1);
162162
assertLineRanges(mainMethodScope, "5-6");
@@ -185,9 +185,9 @@ public void symbolExtraction03() throws IOException, URISyntaxException {
185185
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
186186
Reflect.on(testClass).call("main", "1").get();
187187
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
188-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 4, 28, SOURCE_FILE, 2, 0);
189-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 4, 4, SOURCE_FILE, 0, 0);
190-
assertLineRanges(classScope.getScopes().get(0), "4-4");
188+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 6, 28, SOURCE_FILE, 2, 0);
189+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
190+
assertFalse(classScope.getScopes().get(0).hasInjectibleLines());
191191
Scope mainMethodScope = classScope.getScopes().get(1);
192192
assertScope(mainMethodScope, ScopeType.METHOD, "main", 6, 28, SOURCE_FILE, 1, 1);
193193
assertLineRanges(mainMethodScope, "6-21", "23-24", "27-28");
@@ -256,9 +256,9 @@ public void symbolExtraction04() throws IOException, URISyntaxException {
256256
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
257257
Reflect.on(testClass).call("main", "1").get();
258258
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
259-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 3, 18, SOURCE_FILE, 2, 0);
260-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 3, 3, SOURCE_FILE, 0, 0);
261-
assertLineRanges(classScope.getScopes().get(0), "3-3");
259+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 5, 18, SOURCE_FILE, 2, 0);
260+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
261+
assertFalse(classScope.getScopes().get(0).hasInjectibleLines());
262262
Scope mainMethodScope = classScope.getScopes().get(1);
263263
assertScope(mainMethodScope, ScopeType.METHOD, "main", 5, 18, SOURCE_FILE, 1, 1);
264264
assertLineRanges(mainMethodScope, "5-12", "14-15", "18-18");
@@ -331,9 +331,9 @@ public void symbolExtraction05() throws IOException, URISyntaxException {
331331
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
332332
Reflect.on(testClass).call("main", "1").get();
333333
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
334-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 3, 15, SOURCE_FILE, 2, 0);
335-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 3, 3, SOURCE_FILE, 0, 0);
336-
assertLineRanges(classScope.getScopes().get(0), "3-3");
334+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 5, 15, SOURCE_FILE, 2, 0);
335+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
336+
assertFalse(classScope.getScopes().get(0).hasInjectibleLines());
337337
Scope mainMethodScope = classScope.getScopes().get(1);
338338
assertScope(mainMethodScope, ScopeType.METHOD, "main", 5, 15, SOURCE_FILE, 1, 1);
339339
assertLineRanges(mainMethodScope, "5-15");
@@ -380,9 +380,9 @@ public void symbolExtraction06() throws IOException, URISyntaxException {
380380
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
381381
Reflect.on(testClass).call("main", "1").get();
382382
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
383-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 3, 13, SOURCE_FILE, 2, 0);
384-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 3, 3, SOURCE_FILE, 0, 0);
385-
assertLineRanges(classScope.getScopes().get(0), "3-3");
383+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 5, 13, SOURCE_FILE, 2, 0);
384+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
385+
assertFalse(classScope.getScopes().get(0).hasInjectibleLines());
386386
Scope mainMethodScope = classScope.getScopes().get(1);
387387
assertScope(mainMethodScope, ScopeType.METHOD, "main", 5, 13, SOURCE_FILE, 1, 1);
388388
assertLineRanges(mainMethodScope, "5-5", "7-11", "13-13");
@@ -429,9 +429,9 @@ public void symbolExtraction07() throws IOException, URISyntaxException {
429429
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
430430
Reflect.on(testClass).call("main", "1").get();
431431
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
432-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 3, 10, SOURCE_FILE, 2, 0);
433-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 3, 3, SOURCE_FILE, 0, 0);
434-
assertLineRanges(classScope.getScopes().get(0), "3-3");
432+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 5, 10, SOURCE_FILE, 2, 0);
433+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
434+
assertFalse(classScope.getScopes().get(0).hasInjectibleLines());
435435
Scope mainMethodScope = classScope.getScopes().get(1);
436436
assertScope(mainMethodScope, ScopeType.METHOD, "main", 5, 10, SOURCE_FILE, 1, 1);
437437
assertLineRanges(mainMethodScope, "5-5", "7-10");
@@ -464,9 +464,9 @@ public void symbolExtraction08() throws IOException, URISyntaxException {
464464
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
465465
Reflect.on(testClass).call("main", "1").get();
466466
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
467-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 3, 11, SOURCE_FILE, 2, 0);
468-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 3, 3, SOURCE_FILE, 0, 0);
469-
assertLineRanges(classScope.getScopes().get(0), "3-3");
467+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 5, 11, SOURCE_FILE, 2, 0);
468+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
469+
assertFalse(classScope.getScopes().get(0).hasInjectibleLines());
470470
Scope mainMethodScope = classScope.getScopes().get(1);
471471
assertScope(mainMethodScope, ScopeType.METHOD, "main", 5, 11, SOURCE_FILE, 1, 1);
472472
assertLineRanges(mainMethodScope, "5-5", "7-9", "11-11");
@@ -501,7 +501,7 @@ public void symbolExtraction09() throws IOException, URISyntaxException {
501501
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
502502
Reflect.on(testClass).call("main", "1").get();
503503
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
504-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 5, 23, SOURCE_FILE, 6, 2);
504+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 6, 23, SOURCE_FILE, 6, 2);
505505
assertSymbol(
506506
classScope.getSymbols().get(0),
507507
SymbolType.STATIC_FIELD,
@@ -515,8 +515,8 @@ public void symbolExtraction09() throws IOException, URISyntaxException {
515515
Integer.TYPE.getTypeName(),
516516
0);
517517
assertScope(
518-
classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 5, 17, SOURCE_FILE, 0, 0);
519-
assertLineRanges(classScope.getScopes().get(0), "5-5", "17-17");
518+
classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 17, 17, SOURCE_FILE, 0, 0);
519+
assertLineRanges(classScope.getScopes().get(0), "17-17");
520520
Scope mainMethodScope = classScope.getScopes().get(1);
521521
assertScope(mainMethodScope, ScopeType.METHOD, "main", 8, 14, SOURCE_FILE, 1, 1);
522522
assertLineRanges(mainMethodScope, "8-10", "14-14");
@@ -601,9 +601,9 @@ public void symbolExtraction10() throws IOException, URISyntaxException {
601601
Reflect.on(testClass).call("main", "1").get();
602602
assertEquals(2, symbolSinkMock.jarScopes.get(0).getScopes().size());
603603
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
604-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 3, 6, SOURCE_FILE, 2, 0);
605-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 3, 3, SOURCE_FILE, 0, 0);
606-
assertLineRanges(classScope.getScopes().get(0), "3-3");
604+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 5, 6, SOURCE_FILE, 2, 0);
605+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
606+
assertFalse(classScope.getScopes().get(0).hasInjectibleLines());
607607
Scope mainMethodScope = classScope.getScopes().get(1);
608608
assertScope(mainMethodScope, ScopeType.METHOD, "main", 5, 6, SOURCE_FILE, 1, 1);
609609
assertLineRanges(mainMethodScope, "5-6");
@@ -618,16 +618,16 @@ public void symbolExtraction10() throws IOException, URISyntaxException {
618618
"com.datadog.debugger.symboltest.SymbolExtraction10$Inner",
619619
5);
620620
Scope innerClassScope = symbolSinkMock.jarScopes.get(0).getScopes().get(1);
621-
assertScope(innerClassScope, ScopeType.CLASS, CLASS_NAME + "$Inner", 9, 13, SOURCE_FILE, 2, 1);
621+
assertScope(innerClassScope, ScopeType.CLASS, CLASS_NAME + "$Inner", 10, 13, SOURCE_FILE, 2, 1);
622622
assertSymbol(
623623
innerClassScope.getSymbols().get(0),
624624
SymbolType.FIELD,
625625
"field1",
626626
Integer.TYPE.getTypeName(),
627627
0);
628628
assertScope(
629-
innerClassScope.getScopes().get(0), ScopeType.METHOD, "<init>", 9, 10, SOURCE_FILE, 0, 0);
630-
assertLineRanges(innerClassScope.getScopes().get(0), "9-10");
629+
innerClassScope.getScopes().get(0), ScopeType.METHOD, "<init>", 10, 10, SOURCE_FILE, 0, 0);
630+
assertLineRanges(innerClassScope.getScopes().get(0), "10-10");
631631
Scope addToMethod = innerClassScope.getScopes().get(1);
632632
assertScope(addToMethod, ScopeType.METHOD, "addTo", 12, 13, SOURCE_FILE, 1, 1);
633633
assertLineRanges(addToMethod, "12-13");
@@ -656,11 +656,11 @@ public void symbolExtraction11() throws IOException, URISyntaxException {
656656
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
657657
Reflect.on(testClass).call("main", 1).get();
658658
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
659-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 3, 11, SOURCE_FILE, 2, 1);
659+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 4, 11, SOURCE_FILE, 2, 1);
660660
assertSymbol(
661661
classScope.getSymbols().get(0), SymbolType.FIELD, "field1", Integer.TYPE.getTypeName(), 0);
662-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 3, 4, SOURCE_FILE, 0, 0);
663-
assertLineRanges(classScope.getScopes().get(0), "3-4");
662+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 4, 4, SOURCE_FILE, 0, 0);
663+
assertLineRanges(classScope.getScopes().get(0), "4-4");
664664
Scope mainMethodScope = classScope.getScopes().get(1);
665665
assertScope(mainMethodScope, ScopeType.METHOD, "main", 6, 11, SOURCE_FILE, 1, 1);
666666
assertLineRanges(mainMethodScope, "6-9", "11-11");
@@ -693,9 +693,9 @@ public void symbolExtraction12() throws IOException, URISyntaxException {
693693
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
694694
Reflect.on(testClass).call("main", 1).get();
695695
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
696-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 6, 20, SOURCE_FILE, 7, 0);
697-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 6, 6, SOURCE_FILE, 0, 0);
698-
assertLineRanges(classScope.getScopes().get(0), "6-6");
696+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 8, 20, SOURCE_FILE, 7, 0);
697+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
698+
assertFalse(classScope.getScopes().get(0).hasInjectibleLines());
699699
Scope mainMethodScope = classScope.getScopes().get(1);
700700
assertScope(mainMethodScope, ScopeType.METHOD, "main", 8, 13, SOURCE_FILE, 1, 1);
701701
assertLineRanges(mainMethodScope, "8-13");
@@ -936,21 +936,21 @@ public void symbolExtraction15() throws IOException, URISyntaxException {
936936
null,
937937
null);
938938
Scope initMethodScope = classScope.getScopes().get(0);
939-
assertScope(initMethodScope, ScopeType.METHOD, "<init>", 10, 10, SOURCE_FILE, 0, 3);
939+
assertScope(initMethodScope, ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 3);
940940
assertSymbol(
941941
initMethodScope.getSymbols().get(0),
942942
SymbolType.ARG,
943943
"firstName",
944944
String.class.getTypeName(),
945-
10);
945+
0);
946946
assertSymbol(
947947
initMethodScope.getSymbols().get(1),
948948
SymbolType.ARG,
949949
"lastName",
950950
String.class.getTypeName(),
951-
10);
951+
0);
952952
assertSymbol(
953-
initMethodScope.getSymbols().get(2), SymbolType.ARG, "age", Integer.TYPE.getTypeName(), 10);
953+
initMethodScope.getSymbols().get(2), SymbolType.ARG, "age", Integer.TYPE.getTypeName(), 0);
954954
Scope mainMethodScope = classScope.getScopes().get(1);
955955
assertScope(mainMethodScope, ScopeType.METHOD, "main", 13, 13, SOURCE_FILE, 0, 1);
956956
Scope toStringMethodScope = classScope.getScopes().get(2);
@@ -1002,7 +1002,7 @@ public void symbolExtraction16() throws IOException, URISyntaxException {
10021002
}
10031003
assertEquals(2, symbolSinkMock.jarScopes.size());
10041004
Scope classScope = symbolSinkMock.jarScopes.get(0).getScopes().get(0);
1005-
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 0, 17, SOURCE_FILE, 4, 1);
1005+
assertScope(classScope, ScopeType.CLASS, CLASS_NAME, 6, 17, SOURCE_FILE, 4, 1);
10061006
assertLangSpecifics(
10071007
classScope.getLanguageSpecifics(),
10081008
asList("public", "final"),
@@ -1016,7 +1016,7 @@ public void symbolExtraction16() throws IOException, URISyntaxException {
10161016
"Companion",
10171017
CLASS_NAME + "$Companion",
10181018
0);
1019-
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 3, 3, SOURCE_FILE, 0, 0);
1019+
assertScope(classScope.getScopes().get(0), ScopeType.METHOD, "<init>", 0, 0, SOURCE_FILE, 0, 0);
10201020
Scope f1MethodScope = classScope.getScopes().get(1);
10211021
assertScope(f1MethodScope, ScopeType.METHOD, "f1", 6, 6, SOURCE_FILE, 0, 1);
10221022
assertSymbol(
@@ -1029,7 +1029,7 @@ public void symbolExtraction16() throws IOException, URISyntaxException {
10291029

10301030
Scope companionClassScope = symbolSinkMock.jarScopes.get(1).getScopes().get(0);
10311031
assertScope(
1032-
companionClassScope, ScopeType.CLASS, CLASS_NAME + "$Companion", 0, 23, SOURCE_FILE, 3, 0);
1032+
companionClassScope, ScopeType.CLASS, CLASS_NAME + "$Companion", 22, 23, SOURCE_FILE, 3, 0);
10331033
assertLangSpecifics(
10341034
classScope.getLanguageSpecifics(),
10351035
asList("public", "final"),
@@ -1041,8 +1041,8 @@ public void symbolExtraction16() throws IOException, URISyntaxException {
10411041
companionClassScope.getScopes().get(0),
10421042
ScopeType.METHOD,
10431043
"<init>",
1044-
20,
1045-
20,
1044+
0,
1045+
0,
10461046
SOURCE_FILE,
10471047
0,
10481048
0);

dd-java-agent/agent-debugger/src/test/resources/CapturedSnapshot02.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class CapturedSnapshot02 {
1010
private CapturedSnapshot02 cause;
1111

1212
CapturedSnapshot02() {
13-
this(new Object().toString(), createObject());
13+
this(new Object().toString(), createObject()); // beae1817-f3b0-4ea8-a74f-000000000002
1414
}
1515

1616
CapturedSnapshot02(Throwable throwable) {

0 commit comments

Comments
 (0)