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

Unifying InputStream & OutputStream as System.IO.Stream causes overloaded methods/ctors failed to bind #1211

Open
tuyen-vuduc opened this issue Apr 11, 2024 · 1 comment
Labels
bug Component does not function as intended generator Issues binding a Java library (generator, class-parse, etc.)

Comments

@tuyen-vuduc
Copy link

There was issue #494 mentioning about this, but the situation was different. I am creating a binding library where there are overloaded methods/ctors only different between Java.IO.InputStream adn Java.IO.OutputStream.

Can we map?

  • Java.IO.InputStream -> System.IO.StreamReader
  • Java.IO.OutputStream -> System.IO.StreamWriter
@jpobst
Copy link
Contributor

jpobst commented Apr 12, 2024

Unfortunately there is no support to opt out of the Java.IO.[Input|Output]Stream -> System.IO.Stream mapping. Likewise you cannot just assign it to a random C# type like System.IO.Stream[Reader|Writer] and expect it to work.

Some things to try:

You can try using managedType on the parameter to force it to be Java.IO.InputStream, etc. But I suspect the generating plumbing code will still try to use System.IO.Stream and it probably won't compile.


For overloaded methods you might could use managedName on the method name to rename them so they are different like ProcessStreamIn () and ProcessStreamOut ().

For overloaded constructors that probably won't work. However if you aren't creating the type in C# you likely don't need both constructors.


Failing all else, you can manually write the binding code and use Java.IO.[Input|Output]Stream instead of System.IO.Stream, though that is a painful route.


Or of course if you don't actually need the methods/ctors in C# you can simply remove them.

@jpobst jpobst added bug Component does not function as intended generator Issues binding a Java library (generator, class-parse, etc.) labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Component does not function as intended generator Issues binding a Java library (generator, class-parse, etc.)
Projects
None yet
Development

No branches or pull requests

2 participants