Skip to content

Commit d8c0b22

Browse files
committed
Add logging for #80.
1 parent 7f8db2e commit d8c0b22

File tree

1 file changed

+17
-2
lines changed
  • edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/safe

1 file changed

+17
-2
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/safe/Util.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package edu.cuny.hunter.streamrefactoring.core.safe;
22

33
import java.util.Iterator;
4+
import java.util.logging.Logger;
45

56
import com.ibm.wala.classLoader.CallSiteReference;
67
import com.ibm.wala.classLoader.IMethod;
@@ -17,6 +18,8 @@
1718
import com.ibm.wala.util.collections.Pair;
1819
import com.ibm.wala.util.strings.Atom;
1920

21+
import edu.cuny.hunter.streamrefactoring.core.utils.LoggerNames;
22+
2023
public class Util {
2124

2225
/**
@@ -35,6 +38,8 @@ public class Util {
3538
private static final TypeName STREAM_SUPPORT_TYPE_NAME = TypeName
3639
.string2TypeName("Ljava/util/stream/StreamSupport");
3740

41+
private static final Logger LOGGER = Logger.getLogger(LoggerNames.LOGGER_NAME);
42+
3843
/**
3944
* True iff the given {@link InstanceKey} corresponds with the given
4045
* {@link SSAInvokeInstruction} in the given {@link CallGraph}. In other words,
@@ -56,6 +61,9 @@ public static boolean instanceKeyCorrespondsWithInstantiationInstruction(Instanc
5661
// graph.
5762
Iterator<Pair<CGNode, NewSiteReference>> creationSites = instanceKey.getCreationSites(callGraph);
5863

64+
CallSiteReference instructionCallSite = instruction.getCallSite();
65+
LOGGER.fine("instruction call site is: " + instructionCallSite);
66+
5967
// for each creation site.
6068
while (creationSites.hasNext()) {
6169
Pair<CGNode, NewSiteReference> pair = creationSites.next();
@@ -76,14 +84,19 @@ public static boolean instanceKeyCorrespondsWithInstantiationInstruction(Instanc
7684
// for each call site reference.
7785
for (int i = 0; i < callSiteRefs.length; i++) {
7886
CallSiteReference callSiteReference = callSiteRefs[i];
87+
LOGGER.fine("Call site reference at " + i + " is: " + callSiteReference);
88+
7989
IMethod method = methods[i];
80-
CallSiteReference instructionCallSite = instruction.getCallSite();
90+
LOGGER.fine("Method at " + i + " is: " + method);
8191

8292
// if the call site reference equals the call site corresponding
8393
// to the creation instruction.
8494
if (callSiteReference.equals(instructionCallSite)
85-
&& method.getReference().getSignature().equals(instructionEnclosingMethod.getSignature()))
95+
&& method.getReference().getSignature().equals(instructionEnclosingMethod.getSignature())) {
96+
LOGGER.fine("Match found. Instance key: " + instanceKey + " corresponds with instruction: "
97+
+ instruction + ".");
8698
return true;
99+
}
87100
// workaround #80.
88101
else if (callSiteReference.getProgramCounter() == instructionCallSite.getProgramCounter()) {
89102
// compare declared targets.
@@ -103,6 +116,8 @@ else if (callSiteReference.getProgramCounter() == instructionCallSite.getProgram
103116
}
104117
}
105118
}
119+
LOGGER.fine("No match found. Instance key: " + instanceKey + " does not correspond with instruction: "
120+
+ instruction + ".");
106121
return false;
107122
}
108123

0 commit comments

Comments
 (0)