Skip to content

Stop unifying InputStream & OutputStream as System.IO.Stream #494

Closed
@jonpryor

Description

@jonpryor

Context: dotnet/android#3646

One of the long-ago design choices we made in binding Java code was we bound java.io.InputStream and java.io.OutputStream as System.IO.Stream, because we thought this would make it easier for new Java code to be used with existing .NET code.

Unfortunately, in the process we forgot about exception handling semantics: Android.Runtime.InputStreamInvoker wraps a Java.IO.InputStream, but does no "exception mapping". Thus, calling System.IO.Stream.Read() may cause a Java.IO.IOException to be thrown, which is not an exception type documented as throwable by Stream.Read().

We can't (easily) fix our existing bindings.

We can prevent new bindings from following this madness.

Update generator so that the e.g. "bind java.io.InputStream as System.IO.Stream" behavior can be controlled via Metadata.xml, and change the default behavior so that java.io.InputStream is bound as Java.IO.InputStream, not System.IO.Stream. (The metadata support is so that existing bindings can enable the previous behavior and maintain API compatibility.)

This way, we won't make the problem worse.

We should also re-evaluate type bindings and stop similar mappings, e.g. XmlPullParserSymbol and XmlResourceParserSymbol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions