Skip to content

Commit 4a2c9ea

Browse files
radekdoulikjonpryor
authored andcommitted
[jnimarshalmethod-gen] Fix multiple assemblies processing (#352)
Clear the type caches between moving types in multiple assemblies. (Note to self, in case we want to process and move multiple assemblies in parallel, we would need to make the caches per TypeMover instance.) [Ed. note: Mono.Cecil isn't thread safe, so processing multiple assemblies in parallel is likely a nonstarter; see b1667a2.] Also fix debug prints, as `Console.WriteLine(string)` reference needs to be imported.
1 parent 8298c72 commit 4a2c9ea

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/jnimarshalmethod-gen/TypeMover.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public void Move ()
3636
{
3737
int movedTypesCount = 0;
3838

39+
typeMap.Clear ();
40+
resolvedTypeMap.Clear ();
41+
3942
foreach (var type in Types.Values) {
4043
Move (type);
4144
movedTypesCount++;
@@ -327,7 +330,7 @@ bool AnalyzeAndImprove (Mono.Collections.Generic.Collection<Instruction> instruc
327330

328331
if (App.Debug) {
329332
newInstructions.Add (Instruction.Create (OpCodes.Ldstr, $"Registering JNI marshal methods in {opStr}"));
330-
newInstructions.Add (Instruction.Create (OpCodes.Call, consoleWriteLine));
333+
newInstructions.Add (Instruction.Create (OpCodes.Call, module.ImportReference (consoleWriteLine)));
331334
}
332335

333336
return true;

0 commit comments

Comments
 (0)