Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8982495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:35:34+00:00 2026-06-15T20:35:34+00:00

I have a class that inherits from Java.IO.FileInputStream. It looks something like this: public

  • 0

I have a class that inherits from Java.IO.FileInputStream. It looks something like this:

public class DeviceInputStream : FileInputStream
{
    private FileDescriptor descriptor = null;
    private byte currentValue;

    public DeviceInputStream(FileDescriptor fd) : base(fd)
    {
        descriptor = fd;
    }

    public DeviceInputStream(File file) : base(file){}

    public DeviceInputStream(string fileName):base(fileName){}

    public override int Read()
    {
        int byteRead = base.Read();
        currentValue = (byte) byteRead;
        return byteRead;
    }

    public byte CurrentValue
    {
        get { return currentValue; }
    }
}

However, when I compile this I get the following error:

unreported exception FileNotFoundException; must be caught or declared to be thrown
super (p0);
DeviceInputStream.java:20

Any ideas as to what might be causing this problem? Thanks.

-Shaun

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:35:36+00:00Added an answer on June 15, 2026 at 8:35 pm

    It seems this is an issue with Xamarin Monodroid and has been filed as a bug to extend the ExportAttribute to constructors. Details are from here:

    http://forums.xamarin.com/discussion/500/inheriting-from-fileinputstream

    At build time, Android Callable Wrappers (ACWs) are generated for each Java.Lang.Object subclass, which includes our DeviceInputStream type:

    public class DeviceInputStream
    extends java.io.FileInputStream
    implements
        mono.android.IGCUserPeer
    {
    static final String __md_methods;
    static {
        __md_methods = 
            "n_read:()I:GetReadHandler\n" +
            "";
        mono.android.Runtime.register ("Scratch.ContentProvidersHateApplications.DeviceInputStream, Scratch.ContentProvidersHateApplications, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", DeviceInputStream.class, __md_methods);
    }
    
    
    public DeviceInputStream (java.io.File p0)
    {
        super (p0);
        if (getClass () == DeviceInputStream.class)
            mono.android.TypeManager.Activate ("Scratch.ContentProvidersHateApplications.DeviceInputStream, Scratch.ContentProvidersHateApplications, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Java.IO.File, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c4c4237547e4b6cd", this, new java.lang.Object[] { p0 });
    }
    
    
    public DeviceInputStream (java.io.FileDescriptor p0)
    {
        super (p0);
        if (getClass () == DeviceInputStream.class)
            mono.android.TypeManager.Activate ("Scratch.ContentProvidersHateApplications.DeviceInputStream, Scratch.ContentProvidersHateApplications, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Java.IO.FileDescriptor, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c4c4237547e4b6cd", this, new java.lang.Object[] { p0 });
    }
    
    
    public DeviceInputStream (java.lang.String p0)
    {
        super (p0);
        if (getClass () == DeviceInputStream.class)
            mono.android.TypeManager.Activate ("Scratch.ContentProvidersHateApplications.DeviceInputStream, Scratch.ContentProvidersHateApplications, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "System.String, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", this, new java.lang.Object[] { p0 });
    }
    
    
        public int read ()
        {
            return n_read ();
        }
    
        private native int n_read ();
    
    /* ... */
    }
    

    Since ACWs are Java code, they need to be valid Java code. Unfortunately, in this circumstance they’re not, because the super(p0) invocation in e.g. the DeviceInputStream(String) constructor is FileInputStream(String), which throws a FileNotFoundException.

    Since the DeviceInputStream(String) constructor invokes a method which may thrown an exception, DeviceInputStream(String) must either contain a throws clause or have a try/catch block around the super(p0) statement. Neither happens, hence the compiler error.

    Unfortunately, there is no workaround at this time; there isn’t a way to add a throws to the ACW on constructor bodies, and there is no other way to customize the ACW’s constructor, so you’re stuck. 🙁

    Support to extend ExportAttribute so that this could work has been filed at bug 8754.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is .NET 4.0/C#. I have a class that inherits from an interface: public
I have a class that inherits from a base class (this contains a lot
I have a class that inherits from Page, called APage. public abstract class APage:
I have a repository class that inherits from a generic implementation: public namespace RepositoryImplementation
I have the following situation. I have a Java Class that inherits from another
I have made a class Location which looks like this: package TruckingCompany; public class
I have a class that inherits from a generic dictionary as follows: Class myClass
Example: I have an class that inherits from UIImageView. An object creates an instance
If we have a class that inherits from multiple interfaces, and the interfaces have
Suppose I have a class Baz that inherits from classes Foo and Bar ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.