Skip to content
Open
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
38 changes: 18 additions & 20 deletions java/daikon/dcomp/DCInstrument.java
Original file line number Diff line number Diff line change
Expand Up @@ -2468,6 +2468,19 @@ private boolean isTargetInstrumented(
@ClassGetName String classname,
@Identifier String methodName,
Type[] paramTypes) {

if (invoke instanceof INVOKESPECIAL) {
// A call to the superclass constructor (super(...)) or to another constructor of this
// class (this(...)) both leave the receiver initialized: the delegated-to constructor runs
// the superclass constructor itself. Until one of them has been seen, `this` is
// uninitialized and tag fields must not be touched; see tag_fields_ok.
if (methodName.equals("<init>")
&& (classname.equals(classGen.getSuperclassName())
|| classname.equals(classGen.getClassName()))) {
this.constructor_is_initialized = true;
}
}

boolean targetInstrumented;

if (invoke instanceof INVOKEDYNAMIC) {
Expand All @@ -2476,9 +2489,9 @@ private boolean isTargetInstrumented(
if (debugHandleInvoke) {
System.out.printf("invokedynamic NOT the classname: %s%n", classname);
}
targetInstrumented = false;
return false;
} else if (is_object_method(methodName, invoke.getArgumentTypes(pool))) {
targetInstrumented = false;
return false;
} else {
// At this point, we will never see classname = java.lang.Object.
targetInstrumented =
Expand Down Expand Up @@ -2581,8 +2594,7 @@ private boolean isTargetInstrumented(
if (debugHandleInvoke) {
System.out.printf("Unable to locate class: %s%n%n", targetClassname);
}
targetInstrumented = false;
break;
return false;
}
if (debugHandleInvoke) {
System.out.println("target class: " + targetClassname);
Expand Down Expand Up @@ -2612,8 +2624,7 @@ private boolean isTargetInstrumented(
found = getDefiningInterface(targetClass, methodName, paramTypes);
} catch (Throwable e) {
// We cannot locate or read the .class file, better assume it is not instrumented.
targetInstrumented = false;
break;
return false;
}
if (found != null) {
// We have a match.
Expand All @@ -2635,8 +2646,7 @@ private boolean isTargetInstrumented(
if (debugHandleInvoke) {
System.out.printf("Unable to locate method: %s%n%n", methodName);
}
targetInstrumented = false;
break;
return false;
}
// Recurse looking in the superclass.
targetClassname = targetClass.getSuperclassName();
Expand All @@ -2645,18 +2655,6 @@ private boolean isTargetInstrumented(
}
}

if (invoke instanceof INVOKESPECIAL) {
// A call to the superclass constructor (super(...)) or to another constructor of this
// class (this(...)) both leave the receiver initialized: the delegated-to constructor runs
// the superclass constructor itself. Until one of them has been seen, `this` is
// uninitialized and tag fields must not be touched; see tag_fields_ok.
if (methodName.equals("<init>")
&& (classname.equals(classGen.getSuperclassName())
|| classname.equals(classGen.getClassName()))) {
this.constructor_is_initialized = true;
}
}

return targetInstrumented;
}

Expand Down
35 changes: 16 additions & 19 deletions java/daikon/dcomp/DCInstrument24.java
Original file line number Diff line number Diff line change
Expand Up @@ -3129,8 +3129,20 @@ private boolean isTargetInstrumented(
boolean targetInstrumented;
Opcode op = invoke.opcode();

if (op.equals(INVOKESPECIAL)) {
// A call to the superclass constructor (super(...)) or to another constructor of this
// class (this(...)) both leave the receiver initialized: the delegated-to constructor runs
// the superclass constructor itself. Until one of them has been seen, `this` is
// uninitialized and tag fields must not be touched; see tag_fields_ok.
if (methodName.equals("<init>")
&& (classname.equals(classGen.getSuperclassName())
|| classname.equals(classGen.getClassName()))) {
this.constructor_is_initialized = true;
}
}

if (is_object_method(methodName, paramTypes)) {
targetInstrumented = false;
return false;
} else {
// At this point, we will never see classname = java.lang.Object.
targetInstrumented =
Expand Down Expand Up @@ -3231,8 +3243,7 @@ private boolean isTargetInstrumented(
if (debugHandleInvoke) {
System.out.printf("Unable to locate class: %s%n%n", targetClassname);
}
targetInstrumented = false;
break;
return false;
}
if (debugHandleInvoke) {
System.out.println("target class: " + targetClassname);
Expand Down Expand Up @@ -3263,8 +3274,7 @@ private boolean isTargetInstrumented(
found = getDefiningInterface(targetClass, methodName, paramTypes);
} catch (Throwable e) {
// We cannot locate or read the .class file, better assume it is not instrumented.
targetInstrumented = false;
break;
return false;
}
if (found != null) {
// We have a match.
Expand All @@ -3285,8 +3295,7 @@ private boolean isTargetInstrumented(
if (debugHandleInvoke) {
System.out.printf("Unable to locate method: %s%n%n", methodName);
}
targetInstrumented = false;
break;
return false;
}

// Recurse looking in the superclass.
Expand All @@ -3296,18 +3305,6 @@ private boolean isTargetInstrumented(
}
}

if (op.equals(INVOKESPECIAL)) {
// A call to the superclass constructor (super(...)) or to another constructor of this
// class (this(...)) both leave the receiver initialized: the delegated-to constructor runs
// the superclass constructor itself. Until one of them has been seen, `this` is
// uninitialized and tag fields must not be touched; see tag_fields_ok.
if (methodName.equals("<init>")
&& (classname.equals(classGen.getSuperclassName())
|| classname.equals(classGen.getClassName()))) {
this.constructor_is_initialized = true;
}
}

return targetInstrumented;
}

Expand Down
Loading