@@ -58,155 +58,161 @@ private String mapRefMapEntry(String mixinClass, String old, MappingTree tree, S
58
58
}
59
59
60
60
private String mapRefMapEntry (String mixinClass , String old , TinyRemapper remapper ) {
61
- TrRemapper trRemapper = remapper .getEnvironment ().getRemapper ();
62
- List <String > supers = ModRemappingAPIImpl .getCurrentContext ().getMixinData ().getMixin2TargetMap ().get (mixinClass );
63
- // format is:
64
- // owner + name + quantifier + (desc == null || desc.startsWith("(") ? "" : ":") + desc + (tail != null ? " -> " : "") + tail
65
- String owner ; // can be ""
66
- String name ; // can be ""
67
- String quantifier ; // can be ""
68
- String desc ; // can be ""
69
- String tail ; // can be ""
70
-
71
- // read the entry
72
- {
73
- String rest ;
74
- // get tail
61
+ try {
62
+ TrRemapper trRemapper = remapper .getEnvironment ().getRemapper ();
63
+ List <String > supers = ModRemappingAPIImpl .getCurrentContext ().getMixinData ().getMixin2TargetMap ().get (mixinClass );
64
+ // format is:
65
+ // owner + name + quantifier + (desc == null || desc.startsWith("(") ? "" : ":") + desc + (tail != null ? " -> " : "") + tail
66
+ String owner ; // can be ""
67
+ String name ; // can be ""
68
+ String quantifier ; // can be ""
69
+ String desc ; // can be ""
70
+ String tail ; // can be ""
71
+
72
+ // read the entry
75
73
{
76
- String arrow = " -> " ;
77
- int arrowPosition = old .indexOf (arrow );
78
- if (arrowPosition == -1 ) { // tail == null
79
- tail = "" ;
80
- rest = old ;
81
- } else {
82
- rest = old .substring (0 , arrowPosition );
83
- tail = old .substring (arrowPosition + arrow .length ());
74
+ String rest ;
75
+ // get tail
76
+ {
77
+ String arrow = " -> " ;
78
+ int arrowPosition = old .indexOf (arrow );
79
+ if (arrowPosition == -1 ) { // tail == null
80
+ tail = "" ;
81
+ rest = old ;
82
+ } else {
83
+ rest = old .substring (0 , arrowPosition );
84
+ tail = old .substring (arrowPosition + arrow .length ());
85
+ }
84
86
}
85
- }
86
87
87
- // get desc
88
- {
89
- int separatorPosition = rest .indexOf (":" );
90
- if (separatorPosition == -1 ) { // separator == null
91
- int parenthesisPosition = rest .indexOf ("(" );
92
- if (parenthesisPosition == -1 ) {
93
- desc = "" ;
88
+ // get desc
89
+ {
90
+ int separatorPosition = rest .indexOf (":" );
91
+ if (separatorPosition == -1 ) { // separator == null
92
+ int parenthesisPosition = rest .indexOf ("(" );
93
+ if (parenthesisPosition == -1 ) {
94
+ desc = "" ;
95
+ } else {
96
+ // if there's no ':', then there must be an opening bracket or **the desc is null**
97
+ desc = rest .substring (parenthesisPosition );
98
+ rest = rest .substring (0 , parenthesisPosition );
99
+ }
94
100
} else {
95
- // if there's no ':', then there must be an opening bracket or **the desc is null**
96
- desc = rest .substring (parenthesisPosition );
97
- rest = rest .substring (0 , parenthesisPosition );
101
+ desc = rest .substring (separatorPosition + 1 );
102
+ rest = rest .substring (0 , separatorPosition );
98
103
}
99
- } else {
100
- desc = rest .substring (separatorPosition + 1 );
101
- rest = rest .substring (0 , separatorPosition );
102
104
}
103
- }
104
105
105
- // get owner
106
- {
107
- if (rest .startsWith ("L" )) { // owner != null
108
- int endPosition = rest .indexOf (";" );
109
- if (endPosition == -1 ) {
110
- throw new RuntimeException (
111
- "Cannot parse refmap entry of class " + mixinClass + ": it starts with 'L', and doesn't contain a ';': " + old );
106
+ // get owner
107
+ {
108
+ if (rest .startsWith ("L" )) { // owner != null
109
+ int endPosition = rest .indexOf (";" );
110
+ if (endPosition == -1 ) {
111
+ throw new RuntimeException (
112
+ "Cannot parse refmap entry of class " + mixinClass + ": it starts with 'L', and doesn't contain a ';': " + old );
113
+ } else {
114
+ owner = rest .substring (1 , endPosition );
115
+ rest = rest .substring (endPosition + 1 ); // we don't want the ';' here
116
+ }
112
117
} else {
113
- owner = rest .substring (1 , endPosition );
114
- rest = rest .substring (endPosition + 1 ); // we don't want the ';' here
118
+ owner = "" ;
115
119
}
116
- } else {
117
- owner = "" ;
118
120
}
119
- }
120
121
121
- // get quantifier
122
- {
123
- // try to find either '{', '+' or '*'
124
- int bracesPosition = rest .indexOf ("{" );
125
- if (bracesPosition == -1 )
126
- bracesPosition = rest .indexOf ("*" );
127
- if (bracesPosition == -1 )
128
- bracesPosition = rest .indexOf ("+" );
129
-
130
- if (bracesPosition == -1 ) {
131
- // try the * and +
132
- quantifier = "" ;
133
- } else {
134
- quantifier = rest .substring (bracesPosition );
135
- rest = rest .substring (0 , bracesPosition );
122
+ // get quantifier
123
+ {
124
+ // try to find either '{', '+' or '*'
125
+ int bracesPosition = rest .indexOf ("{" );
126
+ if (bracesPosition == -1 )
127
+ bracesPosition = rest .indexOf ("*" );
128
+ if (bracesPosition == -1 )
129
+ bracesPosition = rest .indexOf ("+" );
130
+
131
+ if (bracesPosition == -1 ) {
132
+ // try the * and +
133
+ quantifier = "" ;
134
+ } else {
135
+ quantifier = rest .substring (bracesPosition );
136
+ rest = rest .substring (0 , bracesPosition );
137
+ }
136
138
}
137
- }
138
139
139
- // get name
140
- {
141
- name = rest ; // only name is left
140
+ // get name
141
+ {
142
+ name = rest ; // only name is left
142
143
// if (name.isEmpty()) {
143
144
// throw new RuntimeException("Cannot parse refmap entry of class " + mixinClass +
144
145
// ": the name is \"\", so something went wrong: owner = \"" + owner + "\", name = \"" + name +
145
146
// "\", quantifier = \"" + quantifier + "\", desc = \"" + desc + "\", tail = \"" + tail +
146
147
// "\", old = \"" + old + "\"");
147
148
// }
149
+ }
148
150
}
149
- }
150
151
151
- // for now just stop here, most stuff doesn't use quantifiers or tails
152
- if (!quantifier .isEmpty ())
153
- throw new RuntimeException ("Quantifiers are not yet supported: " + old );
154
- if (!tail .isEmpty ())
155
- throw new RuntimeException ("Tails are not yet supported: " + tail );
152
+ // for now just stop here, most stuff doesn't use quantifiers or tails
153
+ if (!quantifier .isEmpty ())
154
+ throw new RuntimeException ("Quantifiers are not yet supported: " + old );
155
+ if (!tail .isEmpty ())
156
+ throw new RuntimeException ("Tails are not yet supported: " + tail );
156
157
157
- // do the actual mapping
158
+ // do the actual mapping
158
159
159
- // it's a class
160
- if (owner .isEmpty () && desc .isEmpty ()) {
161
- return trRemapper .map (name );
162
- }
160
+ // it's a class
161
+ if (owner .isEmpty () && desc .isEmpty ()) {
162
+ return trRemapper .map (name );
163
+ }
163
164
164
- // it's a method
165
- if (desc .startsWith ("(" ) && desc .contains (")" )) {
166
- if (owner .isEmpty ()) { // it's an @Invoker
167
- if (supers == null || supers .isEmpty ()) {
168
- throw new RuntimeException ("Can't find target class for mixin " + mixinClass );
169
- }
165
+ // it's a method
166
+ if (desc .startsWith ("(" ) && desc .contains (")" )) {
167
+ if (owner .isEmpty ()) { // it's an @Invoker
168
+ if (supers == null || supers .isEmpty ()) {
169
+ throw new RuntimeException ("Can't find target class for mixin " + mixinClass );
170
+ }
170
171
171
- final String originalName = name ;
172
- String newDesc = trRemapper .mapMethodDesc (desc );
172
+ final String originalName = name ;
173
+ String newDesc = trRemapper .mapMethodDesc (desc );
173
174
174
- if (!originalName .isEmpty ()) {
175
- for (String own : supers ) {
176
- name = trRemapper .mapMethodName (own , name , desc );
175
+ if (!originalName .isEmpty ()) {
176
+ for (String own : supers ) {
177
+ name = trRemapper .mapMethodName (own , name , desc );
177
178
178
- if (!originalName .equals (name )) {
179
- return name + newDesc ;
179
+ if (!originalName .equals (name )) {
180
+ return name + newDesc ;
181
+ }
180
182
}
181
183
}
182
- }
183
184
184
- return originalName + newDesc ;
185
- } else { // just a normal method
186
- return "L" + trRemapper .map (owner ) + ";" + trRemapper .mapMethodName (owner , name , desc ) + trRemapper .mapMethodDesc (desc );
185
+ return originalName + newDesc ;
186
+ } else { // just a normal method
187
+ return "L" + trRemapper .map (owner ) + ";" + trRemapper .mapMethodName (owner , name , desc ) + trRemapper .mapMethodDesc (desc );
188
+ }
187
189
}
188
- }
189
190
190
- // it's an @Accessor
191
- if (owner .isEmpty ()) {
192
- if (supers == null || supers .isEmpty ()) {
193
- throw new RuntimeException ("Can't find target class for mixin " + mixinClass );
194
- }
191
+ // it's an @Accessor
192
+ if (owner .isEmpty ()) {
193
+ if (supers == null || supers .isEmpty ()) {
194
+ throw new RuntimeException ("Can't find target class for mixin " + mixinClass );
195
+ }
195
196
196
- final String originalName = name ;
197
+ final String originalName = name ;
197
198
198
- for (String own : supers ) {
199
- name = trRemapper .mapFieldName (own , name , desc );
199
+ for (String own : supers ) {
200
+ name = trRemapper .mapFieldName (own , name , desc );
200
201
201
- if (!originalName .equals (name )) {
202
- return name ;
202
+ if (!originalName .equals (name )) {
203
+ return name ;
204
+ }
203
205
}
206
+
207
+ return originalName ;
204
208
}
205
209
206
- return originalName ;
210
+ // just a normal field
211
+ return "L" + trRemapper .map (owner ) + ";" + trRemapper .mapFieldName (owner , name , desc ) + (!desc .isEmpty () ? ":" + trRemapper .mapDesc (desc ) : "" );
212
+ } catch (Throwable t ) {
213
+ System .err .println ("Error while remapping refmap entry: " + old + " for mixin " + mixinClass );
214
+ System .err .println (t );
215
+ return old ;
207
216
}
208
-
209
- // just a normal field
210
- return "L" + trRemapper .map (owner ) + ";" + trRemapper .mapFieldName (owner , name , desc ) + ":" + trRemapper .mapDesc (desc );
211
217
}
212
218
}
0 commit comments