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

  • Home
  • SEARCH
  • 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 6241353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:45:13+00:00 2026-05-24T11:45:13+00:00

I test exceptions using in java an dobjective-C programs. In these tests, I see

  • 0

I test exceptions using in java an dobjective-C programs.

In these tests, I see a difference in the way of finally block is reached when an exception is catched and rethrown.

Here my java test :

    try {
        Boolean bThrow = true;
        System.out.println("try : before exception sent");
        if (bThrow) {
            throw new Exception();
        }
        System.out.println("try : after sent");
    }
    catch (Exception e) {
        System.out.println("catch, rethrow");
        throw e;
    }
    finally {
        System.out.println("finally");
    }

which displays :

try: before exception sent
catch, rethrow
finally

And here my objective-c test :

    @try {
        NSException *myexc = [NSException exceptionWithName:@"exceptionTest" reason:@"exceptionTest" userInfo:nil];
        BOOL bThrow = YES;
        NSLog(@"try : before exception sent");
        if (bThrow) {
            @throw myexc;
        }
        NSLog(@"try : after sent");
    }
    @catch (Exception *exception) {
        NSLog(@"catch, rethrow");
        @throw exception;
    }
    @finally {
        NSLog(@"finally");
    }

which displays :

try: before exception sent
catch, rethrown
*** Terminating app

Code in finally block is not reached !

Why this difference ?

[EDIT] Sorry, @try … @try … @try… was a mistake.
I changed it, but the problem is the same, i can’t reach finally block in objective-c test

  • 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-05-24T11:45:14+00:00Added an answer on May 24, 2026 at 11:45 am

    OK, i solved my problem.

    In my objective-c test, application crashed, that’s why finally block was not reached.

    If I add a try catch block in the main, now in my function, finally block is reached !

    So, I confirm that finally block is still reached whatever an excpetion occurs (and is rethrown) or not).

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

Sidebar

Related Questions

Visual Studio Test can check for expected exceptions using the ExpectedException attribute. You can
I would like to test some exception handling logic in the empty catch block
I have a unit test that tests if an Exception is throw, but this
I want to test whether a remote system is reachable using Java or in
I am trying to test some exceptions in my project and one of the
Is it possible to test for multiple exceptions in a single JUnit unit test?
Can someone tell me why this unit test that checks for exceptions fails? Obviously
I truly love NUnit's new(er) ability to test for expected exception testing, ie: var
I am trying to test that a particular method throws an expected exception from
I hate generating an exception for things that I can simply test with an

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.