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 8364981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:33:24+00:00 2026-06-09T12:33:24+00:00

Is it possible to figure out all possible exceptions that can be thrown that

  • 0

Is it possible to figure out all possible exceptions that can be thrown that are not necessarily listed by the method’s signature.

There are 2 cases

1) runtime exceptions that don’t have to be declared (obviously some are obvious, such as null pointer, but there are other runtime exceptions that I’d want to catch that can be due to bad data, which while in development I don’t know is bad data yet).

2) exceptions that are subclasses of the exception listed in the signature.

a motivation example

imagine I call getInputStream() on an HttpURLConnection object, it throws java.io.Exception, but in reality, it throws other exceptions that are sublcasses of java.io.Exception (ala java.io.FileNotFoundException), which I’d want to handle in a unique manner (i.e. don’t want to lump all java.io.Exceptions together).

so while I can learn in practice by catching java.io.Exception and printing out the actual exception, and then modifying code to handle that case, was wondering if there was a better method 🙂

thanks

edit: I think people are missing my 2nd problem. Methods that throw checked exceptions that are fully consistent with the method’s signature, but aren’t listed in it due to the method’s signature only having some sort of base class.

  • 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-09T12:33:25+00:00Added an answer on June 9, 2026 at 12:33 pm

    No. You can’t know in principle ahead of time what exception classes will be present on the CLASSPATH at runtime, for a start, nor can you know ahead of time the possible set of classes that implement the interface you are looking at, or extend the class you are looking at and override the method, unless the class or method is final. Your own example is a perfect case in point: you are looking at HttpURLConnection, but it is an abstract class, and the actual implementation class that appears at runtime can vary depending on your configuration: the HTTP URLStreamHandler class used can be redefined so as to use one that returns a different implementation of HttpURLConnection.

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

Sidebar

Related Questions

I can't figure out how (or if it's at all possible) to use the
Specifically, I'm trying to figure out if it's possible to generate SQL that does
We've got confluence and it's all good and stuff. Can't figure out one thing
I am thinking about this all day and can't seem to figure out an
I am trying to figure out a clean way to intercept uncaught exceptions that
long time reader, first time writer here. I'm trying to figure out all possible
I'm trying to figure out if this is possible. I have a class, BaseGameEntity,
I'm trying to figure out if its possible to stop a foreach loop in
Possible Duplicate: Regex question mark I am trying to figure out how to parse
I was trying to figure out if it was possible to pass in a

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.