Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment: use GetValue for all parameters in the marshal methods #391

Open
radekdoulik opened this issue Nov 2, 2018 · 1 comment
Open
Labels
callable-wrappers Issues with Java Callable Wrappers enhancement Proposed change to current functionality

Comments

@radekdoulik
Copy link
Member

The jnimarshalmethod-gen's generated marshal methods now can use code provided by predefined and custom marshalers.

That idea comes from the discussion about #388 where we have concerns about using custom marshalers for interfaces.

Would it make sense to leave that for runtime? So that GetValue would go through the custom marshalers, as it already can?

Could that also be used for the return values? Note that we would also need to find out the return value type at the time we generate the methods. Context: #387

PRO:

  • simpler generated methods
  • do not need to know the custom marshaler at the time when we generate methods (that might not work for the return types though)

CONS:

  • performance overhead
  • complex change with unknown result

Alternative solution:

  • instead of using interface custom marshaler, allow specifing custom marshal manager for the jnimarshalmethod-gen.exe as the command line option?
@jonpryor
Copy link
Member

jonpryor commented Dec 16, 2019

Example generator-emitted marshal method:

static void n_Foo(IntPtr jnienv, IntPtr __this, IntPtr __intArray)
{
	var __envp = new JniTransition(__jnienv);
	try
	{
		var __jvm = JniEnvironment.Runtime;
		var __vm = __jvm.ValueManager;
		__vm.WaitForGCBridgeProcessing();
		var __this_val = __vm.GetValue<ExportTest>(__this);
		var intArray = __vm.GetValue<int[]>(__intArray);
		__this_val.Foo(intArray);
	}
	catch (Exception __e) if (__jvm.ExceptionShouldTransitionToJni(__e))
	{
		__envp.SetPendingException(__e);
	}
	finally
	{
		__envp.Dispose();
	}
}

@jpobst jpobst added callable-wrappers Issues with Java Callable Wrappers enhancement Proposed change to current functionality labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
callable-wrappers Issues with Java Callable Wrappers enhancement Proposed change to current functionality
Projects
None yet
Development

No branches or pull requests

3 participants