@@ -18,18 +18,18 @@ import kotlin.io.path.createDirectories
18
18
import kotlin.random.Random
19
19
import kotlin.random.nextUInt
20
20
21
- internal object InjectionHandler : SafeTransformer {
21
+ public object InjectionHandler : SafeTransformer {
22
22
/* *
23
23
* JVM argument to dump bytecode to disk. Can be enabled by adding
24
24
* `-DdumpBytecode=true` to your JVM arguments when launching with Weave.
25
25
*
26
26
* Defaults to `false`.
27
27
*/
28
- val dumpBytecode = System .getProperty(" dumpBytecode" )?.toBoolean() ? : false
28
+ public val dumpBytecode: Boolean = System .getProperty(" dumpBytecode" )?.toBoolean() ? : false
29
29
30
30
private val modifiers = mutableListOf<Modifier >()
31
31
32
- fun registerModifier (modifier : Modifier ) {
32
+ public fun registerModifier (modifier : Modifier ) {
33
33
modifiers + = modifier
34
34
}
35
35
@@ -60,7 +60,20 @@ internal object InjectionHandler : SafeTransformer {
60
60
inverseConflictsMapping[" ${node.name} .${tempName}${m.desc} " ] = m.name
61
61
}
62
62
63
- node.remap(SimpleRemapper (conflictsMapping))
63
+ // Hack: SimpleRemapper.map() can return null, and that breaks remap()
64
+ node.remap(object : SimpleRemapper (conflictsMapping) {
65
+ override fun map (key : String ): String {
66
+ return super .map(key) ? : key.run {
67
+ // for an unknown reason, `key` isn't just internal name only
68
+ // for example, <owner>.<name><descriptor> is sometimes passed to this method
69
+
70
+ if (contains(' .' )) {
71
+ if (contains(' (' )) substringAfter(' .' ).substringBefore(' (' )
72
+ else substringAfter(' .' )
73
+ } else this
74
+ }
75
+ }
76
+ })
64
77
65
78
val hookConfig = AssemblerConfigImpl ()
66
79
val modNs = groupedModifiers.keys
@@ -91,24 +104,24 @@ internal object InjectionHandler : SafeTransformer {
91
104
}
92
105
}
93
106
94
- internal interface Modifier {
95
- val namespace: String
96
- val targets: Set <String >
97
- fun apply (node : ClassNode , cfg : Hook .AssemblerConfig )
107
+ public interface Modifier {
108
+ public val namespace: String
109
+ public val targets: Set <String >
110
+ public fun apply (node : ClassNode , cfg : Hook .AssemblerConfig )
98
111
}
99
112
100
113
/* *
101
114
* @param hook Hook class
102
115
*/
103
- internal data class ModHook (
116
+ public data class ModHook (
104
117
override val namespace : String ,
105
118
val hook : Hook ,
106
119
// TODO: jank
107
120
override val targets : Set <String > = hook.targets.mapTo(hashSetOf()) {
108
121
MappingsHandler .mapper(namespace, MappingsHandler .environmentNamespace).map(it)
109
122
}
110
123
): Modifier {
111
- override fun apply (node : ClassNode , cfg : Hook .AssemblerConfig ) = hook.transform(node, cfg)
124
+ override fun apply (node : ClassNode , cfg : Hook .AssemblerConfig ): Unit = hook.transform(node, cfg)
112
125
}
113
126
114
127
public class AssemblerConfigImpl : Hook .AssemblerConfig {
0 commit comments