0 Replies Latest reply on Oct 7, 2019 7:54 PM by 2902897

    Examples for best practices for handling "CheckedToUncheckedException" java exceptions


      Does anyone have any experience in developing working java code for Oracle Configurator v12 (uses JDK7) to catch errors that escape the checked error handling.

      Have done some research on the web, looked through different Oracle related sites and Oracle documentation for Configurator Extensions but don't see anything that looks completely relevant.

      The goal would be to develop some code that will give the user some information to understand what went wrong in the event that an unchecked java error occurs.

      Have seen many error situations in configurator that are very puzzling due to this defect in the way that unchecked errors are communicated to the user and searching for ideas to better define java best practices and thereby to aid other developers so that an unchecked java error can be bubbled up to the attention of the user.


      Here is  what I am thinking may work (have not tested), comments please, or let me know if you have something that does work for you:

      Within the main parent routine, this would be the main exception handler at bottom of the routine to allow for handling of “unchecked” exceptions (i.e. not swallow them and leave everyone clueless):


      import oracle.apps.cz.utilities.CheckedToUncheckedException;



               //code in main try block here


      } catch (NoSuchChildException nsce) {

                  // handle various types of checked exceptions if needed.


      }catch (RunTimeException rntex) {

      //handle unchecked runtime exception & issue an informational message that runtime error occurred & log error.

                rntex. printStackTrace();


      //catches NullPointerException, IllegalArgumentException, NumberFormatException, ClassCastException, IndexOutOfBoundsException(for example)


      } catch (Exception ex)

                  // handle checked exceptions in main routine or if not handled in child routines

                  //catches general Exception’s

      //print stacktrace if needed and/or log an error


      } catch (CheckedToUncheckedException unchkex){

      //handle unchecked exceptions, issue an informational message that unchecked exception occurred & log error.

                unchkex. printStackTrace();

      //catches “java.lang” errors: OutOfMemoryError, NoClassDefFoundError, AssertionError (for example)



      Subroutines called by parent code would need to have this construct to bubble up the error to the parent code above:

      private void testUnchecked() throws RuntimeException, CheckedToUncheckedException  {

           //add code here that can throw various types of exceptions


          //handle general “Exception” within this subroutine or pass up to parent by adding "Exception" after the “throws” above