Skip to content
Prev Previous commit
Next Next commit
Fix bug
  • Loading branch information
egiptipavel committed Aug 11, 2023
commit 9c61a346d15d8ea0bae109bd7dd6e1048f326f85
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ fun <T> ConcreteExecutor<*, *>.computeStaticField(fieldId: FieldId): Result<T> =
fun ConcreteExecutor<*, *>.getInstrumentationResult(methodUnderTest: ExecutableId): ResultOfInstrumentation =
runBlocking {
withProcess {
val params = GetResultOfInstrumentationParams(methodUnderTest.classId.name, methodUnderTest.name)
val params = GetResultOfInstrumentationParams(methodUnderTest.classId.name, methodUnderTest.signature)
val result = instrumentedProcessModel.getResultOfInstrumentation.startSuspending(lifetime, params)
kryoHelper.readObject(result.result)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ data class PutStaticInstruction(

private data class ClassToMethod(
val className: String,
val methodName: String
val methodSignature: String
)

class ProcessingStorage {
Expand All @@ -77,8 +77,8 @@ class ProcessingStorage {
return classToId[className]!!.toLong() * SHIFT + localId
}

fun addClassMethod(className: String, methodName: String): Int {
val classToMethod = ClassToMethod(className, methodName)
fun addClassMethod(className: String, methodSignature: String): Int {
val classToMethod = ClassToMethod(className, methodSignature)
val id = classMethodToId.getOrPut(classToMethod) { classMethodToId.size }
idToClassMethod.putIfAbsent(id, classToMethod)
return id
Expand Down Expand Up @@ -106,8 +106,8 @@ class ProcessingStorage {
return instructionsData.getValue(id)
}

fun getInstructionsIds(className: String, methodName: String): List<Long>? {
val methodId = classMethodToId[ClassToMethod(className, methodName)]
fun getInstructionsIds(className: String, methodSignature: String): List<Long>? {
val methodId = classMethodToId[ClassToMethod(className, methodSignature)]
return methodIdToInstructionsIds[methodId]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TraceListStrategy(
methodVisitor: MethodVisitor
) {
currentMethodSignature = name + descriptor
currentClassMethodId = storage.addClassMethod(className, name)
currentClassMethodId = storage.addClassMethod(className, currentMethodSignature)
}

override fun visitCode(mv: MethodVisitor, lvs: LocalVariablesSorter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class SimpleUtExecutionInstrumentation(
}
}

override fun getResultOfInstrumentation(className: String, methodName: String): ResultOfInstrumentation =
ResultOfInstrumentation(traceHandler.processingStorage.getInstructionsIds(className, methodName))
override fun getResultOfInstrumentation(className: String, methodSignature: String): ResultOfInstrumentation =
ResultOfInstrumentation(traceHandler.processingStorage.getInstructionsIds(className, methodSignature))

override fun getStaticField(fieldId: FieldId): Result<UtModel> =
delegateInstrumentation.getStaticField(fieldId).map { value ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ interface UtExecutionInstrumentation : Instrumentation<UtConcreteExecutionResult
phasesWrapper: PhasesController.(invokeBasePhases: () -> UtConcreteExecutionResult) -> UtConcreteExecutionResult
): UtConcreteExecutionResult

fun getResultOfInstrumentation(className: String, methodName: String): ResultOfInstrumentation
fun getResultOfInstrumentation(className: String, methodSignature: String): ResultOfInstrumentation

interface Factory<out TInstrumentation : UtExecutionInstrumentation> : Instrumentation.Factory<UtConcreteExecutionResult, TInstrumentation> {
override fun create(): TInstrumentation = create(SimpleInstrumentationContext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class SpringUtExecutionInstrumentation(
}
}

override fun getResultOfInstrumentation(className: String, methodName: String): ResultOfInstrumentation =
delegateInstrumentation.getResultOfInstrumentation(className, methodName)
override fun getResultOfInstrumentation(className: String, methodSignature: String): ResultOfInstrumentation =
delegateInstrumentation.getResultOfInstrumentation(className, methodSignature)

override fun getStaticField(fieldId: FieldId): Result<*> = delegateInstrumentation.getStaticField(fieldId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ private fun InstrumentedProcessModel.setup(kryoHelper: KryoHelper, watchdog: Idl
}
watchdog.measureTimeForActiveCall(getResultOfInstrumentation, "Getting instrumentation result") { params ->
HandlerClassesLoader.loadClass(params.className)
val result = (instrumentation as UtExecutionInstrumentation)
.getResultOfInstrumentation(params.className, params.methodName)
val result = (instrumentation as UtExecutionInstrumentation).getResultOfInstrumentation(
params.className, params.methodSignature
)
GetResultOfInstrumentationResult(kryoHelper.writeObject(result))
}
watchdog.measureTimeForActiveCall(addPaths, "User and dependency classpath setup") { params ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class InstrumentedProcessModel private constructor(
}


const val serializationHash = -7487216533584583779L
const val serializationHash = 5470408548487674098L

}
override val serializersOwner: ISerializersOwner get() = InstrumentedProcessModel
Expand Down Expand Up @@ -505,7 +505,7 @@ data class ComputeStaticFieldResult (
*/
data class GetResultOfInstrumentationParams (
val className: String,
val methodName: String
val methodSignature: String
) : IPrintable {
//companion

Expand All @@ -515,13 +515,13 @@ data class GetResultOfInstrumentationParams (
@Suppress("UNCHECKED_CAST")
override fun read(ctx: SerializationCtx, buffer: AbstractBuffer): GetResultOfInstrumentationParams {
val className = buffer.readString()
val methodName = buffer.readString()
return GetResultOfInstrumentationParams(className, methodName)
val methodSignature = buffer.readString()
return GetResultOfInstrumentationParams(className, methodSignature)
}

override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: GetResultOfInstrumentationParams) {
buffer.writeString(value.className)
buffer.writeString(value.methodName)
buffer.writeString(value.methodSignature)
}


Expand All @@ -538,23 +538,23 @@ data class GetResultOfInstrumentationParams (
other as GetResultOfInstrumentationParams

if (className != other.className) return false
if (methodName != other.methodName) return false
if (methodSignature != other.methodSignature) return false

return true
}
//hash code trait
override fun hashCode(): Int {
var __r = 0
__r = __r*31 + className.hashCode()
__r = __r*31 + methodName.hashCode()
__r = __r*31 + methodSignature.hashCode()
return __r
}
//pretty print
override fun print(printer: PrettyPrinter) {
printer.println("GetResultOfInstrumentationParams (")
printer.indent {
print("className = "); className.print(printer); println()
print("methodName = "); methodName.print(printer); println()
print("methodSignature = "); methodSignature.print(printer); println()
}
printer.print(")")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object InstrumentedProcessModel : Ext(InstrumentedProcessRoot) {

val GetResultOfInstrumentationParams = structdef {
field("className", PredefinedType.string)
field("methodName", PredefinedType.string)
field("methodSignature", PredefinedType.string)
}

val GetResultOfInstrumentationResult = structdef {
Expand Down