KmRemap

internal class KmRemap(val r: Remapper)

Rewrites a @Metadata proto so it agrees with the bytecode r just rewrote. One walk serves both directions: the direction is r's business and none of this walk's.

No direction flag, because member names go through Remapper.mapMethodName / Remapper.mapFieldName and ASM's base answers those with the name it was given — a class-only remapper opts out by not overriding them. The snippet weave does override them, and must: it renames an override in bytecode (getDescriptionId ->method_7876), and a proto still spelling the mojmap name is the same disagreement one level down.

Constructors

Link copied to clipboard
constructor(r: Remapper)

Properties

Link copied to clipboard
private val r: Remapper

Functions

Link copied to clipboard
private fun mapClassName(name: ClassName): ClassName?

The ClassName form of Remapper.map: metadata separates nested classes with '.' where bytecode uses '$', and a leading '.' marks a local class, which is never a mapped name. Null when unmapped — the identity a Remapper answers with instead is not a usable "no" for a caller that must leave the field untouched.

Link copied to clipboard
private fun mapMethod(owner: String, s: JvmMethodSignature): JvmMethodSignature

Both halves of a method signature, each read off the ORIGINAL: the name is looked up BY the old descriptor, so mapping the descriptor first would ask the tables about a signature that never existed.

Link copied to clipboard
fun rename(c: KmClass)

Rename c's own name, its supertypes, constructors and every member.

fun rename(p: KmPackage, owner: String)

Rename every member of a file facade or multi-file part. owner is the facade class the members live on — a KmPackage does not carry it, and member lookups need it.

Link copied to clipboard
private fun renameAnnotation(a: KmAnnotation): KmAnnotation

A type-use annotation has nowhere to live in the class file, so the proto is its only carrier — and its ARGUMENTS name classes just as its own type does.

Link copied to clipboard
private fun renameArgument(v: KmAnnotationArgument): KmAnnotationArgument

else takes the literals, and whatever argument kind a later metadata version adds: passing one through costs a stale name inside an annotation, throwing on it would cost the whole class.

Link copied to clipboard
private fun renameMembers(owner: String, fns: List<KmFunction>, props: List<KmProperty>, tas: List<KmTypeAlias>, locals: List<KmProperty>)

The type-bearing members of a class or package body — the shape openMembers walks for visibility, plus locals, the delegates declared inside a function body (val x by lazy {}), which carry a type of their own and reach the proto through no other list. The JVM signatures go too: they are what the backend and kotlin-reflect link against, so leaving them in the old namespace while the Kotlin types moved would split the two views of one member.

Link copied to clipboard
private fun renameParams(ps: List<KmValueParameter>)
Link copied to clipboard
private fun renameProperty(owner: String, p: KmProperty)
Link copied to clipboard
private fun renameType(t: KmType)

Rewrite every classifier reachable from t. Types nest through arguments, abbreviation, outer type and the flexible upper bound, so touching the classifier alone would miss most of a generic signature.

Link copied to clipboard
private fun renameTypeParams(ps: List<KmTypeParameter>)