Skip to content

Commit 86bf0cd

Browse files
committed
change signature format
1 parent 0cbd535 commit 86bf0cd

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/concrete/InstrumentationContext.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.utbot.framework.concrete
22

3-
import org.utbot.framework.plugin.api.util.signature
43
import java.lang.reflect.Method
54
import java.util.IdentityHashMap
5+
import org.objectweb.asm.Type
6+
import org.utbot.framework.plugin.api.util.signature
67

78
/**
89
* Some information, which is computed after classes instrumentation.
@@ -66,7 +67,9 @@ class InstrumentationContext {
6667
}
6768

6869
fun updateMocks(obj: Any?, method: Method, values: List<*>) {
69-
updateMocks(obj, method.signature, values)
70+
val type = Type.getInternalName(method.declaringClass)
71+
val signature = method.signature
72+
updateMocks(obj, "$type@$signature", values)
7073
}
7174
}
7275
}

utbot-framework/src/main/kotlin/org/utbot/framework/concrete/MethodMockController.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.utbot.instrumentation.instrumentation.mock.MockConfig
66
import java.lang.reflect.Field
77
import java.lang.reflect.Method
88
import java.lang.reflect.Modifier
9+
import org.objectweb.asm.Type
910

1011

1112
/**
@@ -31,7 +32,9 @@ class MethodMockController(
3132
error("$method is an instance method, but instance is null!")
3233
}
3334

34-
val id = instrumentationContext.methodSignatureToId[method.signature]
35+
val type = Type.getInternalName(method.declaringClass)
36+
val computedSignature = "$type@${method.signature}"
37+
val id = instrumentationContext.methodSignatureToId[computedSignature]
3538

3639
isMockField = clazz.declaredFields.firstOrNull { it.name == MockConfig.IS_MOCK_FIELD + id }
3740
?: error("No field ${MockConfig.IS_MOCK_FIELD + id} in $clazz")

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/mock/MockClassVisitor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class MockClassVisitor(
7373
val isStatic = access and Opcodes.ACC_STATIC != 0
7474
val isVoidMethod = Type.getReturnType(descriptor) == Type.VOID_TYPE
7575

76-
val computedSignature = name + descriptor
76+
val computedSignature = "$internalClassName@$name$descriptor"
7777
val id = signatureToId.size
7878
signatureToId[computedSignature] = id
7979

0 commit comments

Comments
 (0)