Expose connection between mangling internal names in backend and jdiEval
This commit is contained in:
@@ -959,7 +959,7 @@ public class KotlinTypeMapper {
|
|||||||
if (!(descriptor instanceof ConstructorDescriptor) &&
|
if (!(descriptor instanceof ConstructorDescriptor) &&
|
||||||
descriptor.getVisibility() == Visibilities.INTERNAL &&
|
descriptor.getVisibility() == Visibilities.INTERNAL &&
|
||||||
!DescriptorUtilsKt.isPublishedApi(descriptor)) {
|
!DescriptorUtilsKt.isPublishedApi(descriptor)) {
|
||||||
return name + "$" + NameUtils.sanitizeAsJavaIdentifier(moduleName);
|
return InternalNameMapper.mangleInternalName(name, moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
@@ -1510,4 +1510,24 @@ public class KotlinTypeMapper {
|
|||||||
}
|
}
|
||||||
return TypeSignatureMappingKt.computeInternalName(classDescriptor, typeMappingConfiguration);
|
return TypeSignatureMappingKt.computeInternalName(classDescriptor, typeMappingConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class InternalNameMapper {
|
||||||
|
public static String mangleInternalName(@NotNull String name, @NotNull String moduleName) {
|
||||||
|
return name + "$" + NameUtils.sanitizeAsJavaIdentifier(moduleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canBeMangledInternalName(@NotNull String name) {
|
||||||
|
return name.indexOf('$') != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static String internalNameWithoutModuleSuffix(@NotNull String name) {
|
||||||
|
int indexOfDollar = name.indexOf('$');
|
||||||
|
if (indexOfDollar == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name.substring(0, indexOfDollar) + '$';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,6 @@
|
|||||||
<orderEntry type="library" name="kotlin-reflect" level="project" />
|
<orderEntry type="library" name="kotlin-reflect" level="project" />
|
||||||
<orderEntry type="library" name="asm" level="project" />
|
<orderEntry type="library" name="asm" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="junit-4.12" level="project" />
|
<orderEntry type="library" scope="TEST" name="junit-4.12" level="project" />
|
||||||
|
<orderEntry type="module" module-name="backend" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
@@ -19,6 +19,8 @@ package org.jetbrains.eval4j.jdi
|
|||||||
import com.sun.jdi.*
|
import com.sun.jdi.*
|
||||||
import org.jetbrains.eval4j.*
|
import org.jetbrains.eval4j.*
|
||||||
import org.jetbrains.eval4j.Value
|
import org.jetbrains.eval4j.Value
|
||||||
|
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper.InternalNameMapper.canBeMangledInternalName
|
||||||
|
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper.InternalNameMapper.internalNameWithoutModuleSuffix
|
||||||
import org.jetbrains.org.objectweb.asm.Type
|
import org.jetbrains.org.objectweb.asm.Type
|
||||||
import java.lang.reflect.AccessibleObject
|
import java.lang.reflect.AccessibleObject
|
||||||
import com.sun.jdi.Type as jdi_Type
|
import com.sun.jdi.Type as jdi_Type
|
||||||
@@ -216,11 +218,12 @@ class JDIEval(
|
|||||||
return method
|
return method
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methodName.contains('$')) {
|
// Module name can be different for internal functions during evaluation and compilation
|
||||||
// Module name can be different for internal functions during evaluation and compilation
|
val internalNameWithoutSuffix = internalNameWithoutModuleSuffix(methodName)
|
||||||
val internalNamePrefix = methodName.substringBefore('$') + '$'
|
if (internalNameWithoutSuffix != null) {
|
||||||
val internalMethods = _class.visibleMethods().filter {
|
val internalMethods = _class.visibleMethods().filter {
|
||||||
it.name().startsWith(internalNamePrefix) && it.signature() == methodDesc.desc
|
val name = it.name()
|
||||||
|
name.startsWith(internalNameWithoutSuffix) && canBeMangledInternalName(name) && it.signature() == methodDesc.desc
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!internalMethods.isEmpty()) {
|
if (!internalMethods.isEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user