diff --git a/java/daikon/dcomp/DCInstrument.java b/java/daikon/dcomp/DCInstrument.java index 91dd052c6..4351df18b 100644 --- a/java/daikon/dcomp/DCInstrument.java +++ b/java/daikon/dcomp/DCInstrument.java @@ -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("") + && (classname.equals(classGen.getSuperclassName()) + || classname.equals(classGen.getClassName()))) { + this.constructor_is_initialized = true; + } + } + boolean targetInstrumented; if (invoke instanceof INVOKEDYNAMIC) { @@ -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 = @@ -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); @@ -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. @@ -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(); @@ -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("") - && (classname.equals(classGen.getSuperclassName()) - || classname.equals(classGen.getClassName()))) { - this.constructor_is_initialized = true; - } - } - return targetInstrumented; } diff --git a/java/daikon/dcomp/DCInstrument24.java b/java/daikon/dcomp/DCInstrument24.java index 07b2e5cf0..621a22600 100644 --- a/java/daikon/dcomp/DCInstrument24.java +++ b/java/daikon/dcomp/DCInstrument24.java @@ -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("") + && (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 = @@ -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); @@ -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. @@ -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. @@ -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("") - && (classname.equals(classGen.getSuperclassName()) - || classname.equals(classGen.getClassName()))) { - this.constructor_is_initialized = true; - } - } - return targetInstrumented; }