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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:09:39+00:00 2026-06-08T23:09:39+00:00

Normally, the Java compiler confirms that all checked exceptions that are thrown are in

  • 0

Normally, the Java compiler confirms that all checked exceptions that are thrown are in the throw specification. Does anything special happen when a native function throws a java checked exception that was not in the functions throw specification list, or does is the throw specification list simply ignored at runtime?

C++

void function(JNIEnv * env, jclass jc) {
    jclass newExcCls = env->FindClass("java/lang/NullPointerException");
    env->ThrowNew(newExcCls, "ERROR");
}

Java

public class Tester {
    static {
        System.loadLibrary( "MyLibrary" );
    }        
    private static native void function();
    public static void main(String [ ] args) {
        try {
            function();
        } catch( Exception e ) { //is it caught? Or what happens?
            e.printStackTrace();
        }        
    }
}

(The C++ function name would probably be mangled. Also loadLibrary should be in a try catch. Don’t care, I don’t believe it’s relevant to the problem. There’s possibly other errors in the code, but they’re probably not relevant either.)

  • 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-08T23:09:40+00:00Added an answer on June 8, 2026 at 11:09 pm

    You don’t even have to resort to native code to fool the checked exception mechanism. See the Javadoc on Thread.stop(Throwable). I was once left wondering for the entire day how my code threw an InterruptedException in the middle of code that did not declare it. I didn’t even find the answer then, but now I know 🙂

    Answering your immediate question: yes, the checked exception logic is a compiler-only feature and ignored at runtime.

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

Sidebar

Related Questions

We all know that Android runs Dalvik VM programs. Normally developers write programs in
I have jBoss running on Linux that runs a Java SOAP webservice. I normally
It appears that when you type in a number in Java, the compiler automatically
Normally with Java Swing you can set the background color of a button with:
RUBY_PLATFORM is java either way. Normally I can do system checks with uname but
Normally all the document related to an iOS application are stored in a document
I've heard that the advantage of java is that people can write code, compile
* Hello Guys..! * Normally a java program needs main() function to execute the
I normally create a String in Java the following way: String foo = 123456;
I am debugging a Java program in Eclipse. This program normally writes binary data

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.