Skip to content

Commit

Permalink
Remove more n_s?!
Browse files Browse the repository at this point in the history
9027591 tried to fix
Java.Interop.Export-Tests, and in the process broke
Java.Base-Tests!

	A total of 1 test files matched the specified pattern.
	  Failed InterfaceInvokerMethod [100 ms]
	  Error Message:
	   Java.Interop.JavaException : 'void example.MyIntConsumer.accept(int)'
	  Stack Trace:
	     at Java.Interop.JniEnvironment.InstanceMethods.CallVoidMethod(JniObjectReference instance, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 20370
	   at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeAbstractVoidMethod(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 47
	   at Java.Lang.IRunnableInvoker.Run() in /Users/runner/work/1/s/src/Java.Base/obj/Release-net7.0/mcw/Java.Lang.IRunnable.cs:line 34
	   at Java.BaseTests.JavaToManagedTests.InterfaceInvokerMethod() in /Users/runner/work/1/s/tests/Java.Base-Tests/Java.Base/JavaToManagedTests.cs:line 28
	   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
	   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
	  --- End of managed Java.Interop.JavaException stack trace ---
	java.lang.UnsatisfiedLinkError: 'void example.MyIntConsumer.accept(int)'
		at example.MyIntConsumer.accept(Native Method)
		at com.microsoft.java_base_tests.Invoker$1.run(Invoker.java:15)

The problem? That pesky `n_`!  Or rather, the lack thereof this time.

The issue is that `JreTypeManager`/etc. and `jcw-gen` need to be consistent.
9027591 altered the consistency,
breaking Java.Base tests.

Commit this to verify that things work on CI, not just locally.

Assuming it works on CI, next step will be to largely revert
9027591, and then fix
`Java.Interop.Export-Tests` to use an `n_` prefix on all `native`
method declarations.  That bit is hand-written; it can change.
Keeping the tooling consistent is more important.
  • Loading branch information
jonpryor committed Nov 7, 2023
1 parent 1d422da commit 902fe28
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static void AddJniMethod (JniMethodMap toRegister, MethodInfo declaringMethod, M
if (signature == null || string.IsNullOrEmpty (signature.MemberName)) {
return;
}
toRegister [("n_" + signature.MemberName, signature.MemberSignature)] = targetMethod ?? declaringMethod;
toRegister [(signature.MemberName, signature.MemberSignature)] = targetMethod ?? declaringMethod;
}

static void AddClassMethods (JniMethodMap toRegister, Type type)
Expand Down

0 comments on commit 902fe28

Please sign in to comment.