|
19 | 19 |
|
20 | 20 | public class Util {
|
21 | 21 |
|
| 22 | + /** |
| 23 | + * {@link Atom} corresponding the the stream() method. |
| 24 | + */ |
| 25 | + private static final Atom STREAM_METHOD_NAME_ATOM = Atom.findOrCreateAsciiAtom("stream"); |
| 26 | + |
| 27 | + /** |
| 28 | + * The {@link TypeName} of the type {@link java.util.Arrays}. |
| 29 | + */ |
| 30 | + private static final TypeName ARRAYS_TYPE_NAME = TypeName.string2TypeName("Ljava/util/Arrays"); |
| 31 | + |
| 32 | + /** |
| 33 | + * The {@link TypeName} for the type {@link java.util.stream.StreamSupport}. |
| 34 | + */ |
| 35 | + private static final TypeName STREAM_SUPPORT_TYPE_NAME = TypeName |
| 36 | + .string2TypeName("Ljava/util/stream/StreamSupport"); |
| 37 | + |
22 | 38 | private Util() {
|
23 | 39 | }
|
24 | 40 |
|
@@ -75,19 +91,21 @@ public static boolean instanceKeyCorrespondsWithInstantiationInstruction(Instanc
|
75 | 91 | else if (callSiteReference.getProgramCounter() == instructionCallSite.getProgramCounter()) {
|
76 | 92 | // compare declared targets.
|
77 | 93 | MethodReference callSiteDeclaredTarget = callSiteReference.getDeclaredTarget();
|
| 94 | + TypeName callSiteTargetDeclaringClassName = callSiteDeclaredTarget.getDeclaringClass().getName(); |
| 95 | + |
78 | 96 | MethodReference instructionCallDeclaredTarget = instructionCallSite.getDeclaredTarget();
|
| 97 | + TypeName instructionTargetDeclaringClassName = instructionCallDeclaredTarget.getDeclaringClass() |
| 98 | + .getName(); |
79 | 99 |
|
80 |
| - if (callSiteDeclaredTarget.getDeclaringClass().getName() |
81 |
| - .equals(instructionCallDeclaredTarget.getDeclaringClass().getName()) |
82 |
| - && callSiteDeclaredTarget.getDeclaringClass().getName() |
83 |
| - .equals(TypeName.string2TypeName("Ljava/util/Arrays")) |
| 100 | + if (callSiteTargetDeclaringClassName.equals(instructionTargetDeclaringClassName) |
| 101 | + && (callSiteTargetDeclaringClassName.equals(ARRAYS_TYPE_NAME) |
| 102 | + || callSiteTargetDeclaringClassName.equals(STREAM_SUPPORT_TYPE_NAME)) |
84 | 103 | && callSiteDeclaredTarget.getName().equals(instructionCallDeclaredTarget.getName())
|
85 |
| - && callSiteDeclaredTarget.getName().equals(Atom.findOrCreateAsciiAtom("stream"))) |
| 104 | + && callSiteDeclaredTarget.getName().equals(STREAM_METHOD_NAME_ATOM)) |
86 | 105 | return true;
|
87 | 106 | }
|
88 | 107 | }
|
89 | 108 | }
|
90 | 109 | return false;
|
91 | 110 | }
|
92 |
| - |
93 | 111 | }
|
0 commit comments