Link to home
Start Free TrialLog in
Avatar of ksfoong
ksfoong

asked on

warning: finally clause cannot complete normally

when i try to compile my javabean (or a ajava file), using JDK1.4++, i will have this error :

warning : finally clause cannot complete normally }^


but if i change the JDK to JDK 1.3, then i am fine with the source code. ANyone can tell me what happend?
Avatar of Mick Barry
Mick Barry
Flag of Australia image

sounds like a nested try/catch block.
can u post your code.
Avatar of KarcOrigin
KarcOrigin

Hi,
Its seems that some where the braces is not closed as expected. Since your code works fine with JDK 1.3 I think it is better you post the source code. Object is right just post your code we want to see the close look of it.

Thx,
Karc
Avatar of ksfoong

ASKER

...
...
public class DayschServlet extends com.comex.cardpro.servlet.ActionBaseHttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        doPost(request, response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

        try {
            OB_CP_DAYSCH aOB_CP_DAYSCH = new OB_CP_DAYSCH(request);

            String action = request.getParameter("action1");

            if (request.getParameter("action1") != null) {


                processAction(request, action.trim(), aOB_CP_DAYSCH);
                request.setAttribute("OB_CP_DAYSCH", aOB_CP_DAYSCH);
            }

            RequestDispatcher rd =
                getServletContext().getRequestDispatcher(
                    request.getParameter("resultPage").trim());
            rd.forward(request, response);

        } catch (DBException ex) {
            Logger.error(this.getClass(), "Error performing doPost", ex);
            request.setAttribute("info", Encode.GToI("ϵͳ³ö´í£¬Çë֪ͨϵͳ¹ÜÀíÔ± £¡"));
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher("/jsp/main/errInfo.jsp");
            rd.forward(request, response);
            return;
        } catch (ServletException ex) {
            Logger.error(this.getClass(), "Error performing doPost", ex);
            request.setAttribute("info", Encode.GToI("ϵͳ³ö´í£¬Çë֪ͨϵͳ¹ÜÀíÔ± £¡"));
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher("/jsp/main/errInfo.jsp");
            rd.forward(request, response);
            return;
        } catch (DBE_RecordAlreadyExistsException e1) {
            Logger.error(this.getClass(), "record has existed,add error", e1);
            request.setAttribute("info", Encode.GToI("ϵͳ³ö´í£¬Çë֪ͨϵͳ¹ÜÀíÔ± £¡"));
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher("/jsp/main/errInfo.jsp");
            rd.forward(request, response);
            return;
        } catch (DBE_RecordNotFoundException e2) {
            Logger.error(this.getClass(), "Error finding Holidy", e2);
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher(
                    request.getParameter("resultPage").trim());
            rd.forward(request, response);
            return;
        } catch (DBE_Exception e3) {
            Logger.error(this.getClass(), "DBE_Exception", e3);
            request.setAttribute("info", Encode.GToI("ϵͳ³ö´í£¬Çë֪ͨϵͳ¹ÜÀíÔ± £¡"));
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher("/jsp/main/errInfo.jsp");
            rd.forward(request, response);
            return;
        } catch (Exception e) {
            Logger.error(this.getClass(), "error performing action", e);
            request.setAttribute("info", Encode.GToI("ϵͳ³ö´í£¬Çë֪ͨϵͳ¹ÜÀíÔ± £¡"));
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher("/jsp/main/errInfo.jsp");
            rd.forward(request, response);
            return;
        } finally {
            Logger.error(this.getClass(),"------some exception take place-----");
            return;
        }
    }
.............
.............
...........

Any idea??
Avatar of ksfoong

ASKER

this is another one:

..
..
...
....
      public DBI_Base performAction() {
            DBConnectionPool myPool = null;
            DBConnection myConnection = null;
            OBScrCMAP3200Deposit obR = (OBScrCMAP3200Deposit) dbiObj;
            OBScrCMAP3200DepositList ob = new OBScrCMAP3200DepositList();
            ob.DS_BRANCH_ID(obR.DS_BRANCH_ID());
            ob.DS_BATCH_NO(obR.DS_BATCH_NO());
            ob.DS_BATCH_YDDD(obR.DS_BATCH_YDDD());
            try {
                  myPool = DBConnectionPool.getInstance(ConnectionMgr.DBNAME);
                  myConnection = myPool.getConnection();
                  myConnection.setAutoCommit(false);
                  OB_CP_DEPSLO obDep = new OB_CP_DEPSLO();
                  DB_CP_DEPSLO dbDep = new DB_CP_DEPSLO(myConnection, request);
                  obDep.DS_BRANCH_ID(obR.DS_BRANCH_ID());
                  obDep.DS_BATCH_NO(obR.DS_BATCH_NO());
                  obDep.DS_BATCH_YDDD(obR.DS_BATCH_YDDD());
                  obDep.DS_REF_NO(obR.DS_REF_NO());
                  obDep.DS_SEQ_NO(obR.DS_SEQ_NO());
                  if (dbDep.doFind(obDep)) {
                        ob.setDepositExist(true);
                        //delete deposit
                        OB_CP_DEPSLO obDepD = new OB_CP_DEPSLO();
                        DB_CP_DEPSLO dbDepD = new DB_CP_DEPSLO(myConnection, request);
                        obDepD.DS_BRANCH_ID(obR.DS_BRANCH_ID());
                        obDepD.DS_BATCH_NO(obR.DS_BATCH_NO());
                        obDepD.DS_BATCH_YDDD(obR.DS_BATCH_YDDD());
                        obDepD.DS_REF_NO(obR.DS_REF_NO());
                        obDepD.DS_SEQ_NO(obR.DS_SEQ_NO());
                        dbDepD.doDelete(obDepD);
                Logger.debug(this.getClass(), "delete deposit ok ");
                //myConnection.commit();
                        //reduce the no of slip in the cp_depslo table
                        /*BigDecimal currRecord =
                              BatchFunction.getTotalBatchRec(
                                    request,
                                    obR.DS_BRANCH_ID(),
                                    obR.DS_BATCH_NO(),
                                    obR.DS_BATCH_YDDD());
                      Logger.debug(this.getClass(), "be currRecord="+currRecord);
                        currRecord = currRecord.subtract(new BigDecimal(1));
                        Logger.debug(this.getClass(), "af currRecord="+currRecord);
                        BigDecimal currDepositAmt =
                              BatchFunction.getCurrBatchAmt(
                                    request,
                                    obR.DS_BRANCH_ID(),
                                    obR.DS_BATCH_NO(),
                                    obR.DS_BATCH_YDDD());
                      Logger.debug(this.getClass(), "be currDepositAmt="+currDepositAmt);
                        currDepositAmt = currDepositAmt.subtract(obR.DS_TOTAL_AMT());
                        Logger.debug(this.getClass(), "af currDepositAmt="+currDepositAmt);
                        //BigDecimal seqNo = DepositFunction.getSeqNo(obR.SS_BRANCH_ID(),obR.SS_BATCH_YDDD(),obR.SS_BATCH_NO(),obR.SS_DEPOSIT_NO());

                        OB_CP_BATCHF obBat = new OB_CP_BATCHF();
                        DB_CP_BATCHF dbBat = new DB_CP_BATCHF(myConnection, request);
                        obBat.BA_BRANCH_ID(obR.DS_BRANCH_ID());
                        obBat.BA_BATCH_YDDD(obR.DS_BATCH_YDDD());
                        obBat.BA_BATCH_NO(obR.DS_BATCH_NO());
                        obBat.BA_NO_TRXN(currRecord);
                        obBat.BA_BATCH_AMT(currDepositAmt);

                        dbBat.doUpdate(obBat);
                        
                        Logger.debug(this.getClass(), "update CP_BATCHF ok");*/
                        
                        //check BA_TALLY_CODE
                  /*BigDecimal totalRec = BatchFunction.getTotalBatchRec(request,obR.DS_BRANCH_ID(),obR.DS_BATCH_NO(),obR.DS_BATCH_YDDD());
                ArrayList listCount = ob.list(obR.DS_BRANCH_ID(),obR.DS_BATCH_NO(),obR.DS_BATCH_YDDD());
                  int currentRecNo = listCount.size();
                  BigDecimal recLeft = totalRec.subtract(new BigDecimal(currentRecNo));
                  BigDecimal trxCurrCode = BatchFunction.getTrxCurrencyCode(request,obR.DS_BRANCH_ID(),obR.DS_BATCH_NO(),obR.DS_BATCH_YDDD());
                BigDecimal currExponent = DBHelper.retriveExponent(request,trxCurrCode);
                  BigDecimal batchAmt = BatchFunction.getCurrBatchAmt(request,obR.DS_BRANCH_ID(),obR.DS_BATCH_NO(),obR.DS_BATCH_YDDD());
                BigDecimal currBatchDepositAmt = BatchFunction.currBatchDepositAmt(request,obR.DS_BRANCH_ID(),obR.DS_BATCH_NO(),obR.DS_BATCH_YDDD());
                        String BA_TALLY_CODE="N";
                        if(recLeft.intValue() == 0 && batchAmt.intValue()==currBatchDepositAmt.intValue()) BA_TALLY_CODE="Y";
                        Logger.debug(this.getClass(),"BA_TALLY_CODE:"+BA_TALLY_CODE);
                  OB_CP_BATCHF aOB_CP_BATCHF = new OB_CP_BATCHF();
                        DB_CP_BATCHF aDB_CP_BATCHF = new DB_CP_BATCHF(request);
                        aOB_CP_BATCHF.BA_BRANCH_ID(obR.DS_BRANCH_ID());
                        aOB_CP_BATCHF.BA_BATCH_YDDD(obR.DS_BATCH_YDDD());
                        aOB_CP_BATCHF.BA_BATCH_NO(obR.DS_BATCH_NO());
                        aDB_CP_BATCHF.doFindByKey(aOB_CP_BATCHF);
               
                        OB_CP_BATCHF bOB_CP_BATCHF = new OB_CP_BATCHF();
                        bOB_CP_BATCHF.BA_BRANCH_ID(obR.DS_BRANCH_ID());
                        bOB_CP_BATCHF.BA_BATCH_YDDD(obR.DS_BATCH_YDDD());
                        bOB_CP_BATCHF.BA_BATCH_NO(obR.DS_BATCH_NO());
               
                        bOB_CP_BATCHF.BA_TALLY_CODE(BA_TALLY_CODE);
                        aDB_CP_BATCHF.doUpdate(bOB_CP_BATCHF);*/
                        Logger.debug(this.getClass(),"CP_BATCHF update ok");
                  } else {
                        ob.setError("CMAP3200.BATCH.NOTFOUND");
                        ob.setDepositExist(false);
                  }
                  myConnection.commit();
            } catch (Exception ex) {
                  Logger.error(this.getClass(), "Problem deleting deposit", ex);
                  ob.setError("CMAP3200.DEPOSIT.DELETE");
                  try {
                        myConnection.rollback();
                        Logger.info(this.getClass(), "connection rolled back");
                  } catch (Exception rolEx) {
                        Logger.error(
                              this.getClass(),
                              "Problem doing roll back ",
                              rolEx);
                  }
            } finally {
                  if (myPool != null) {
                        myPool.release(myConnection);
                  }
                  return ob;
            }
      }
}
.........
...........
Hi,
One closing brace is missing. Please close it at the appro. place. Most prob. the most last closing brace is missing.
Thx
Hi,
For second posted code one brace is extra. Remove the extra brace.
Thx
Hi,
The possible correction is the following.


public class DayschServlet extends com.comex.cardpro.servlet.ActionBaseHttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        doPost(request, response);
    }
   
    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

        try {
            OB_CP_DAYSCH aOB_CP_DAYSCH = new OB_CP_DAYSCH(request);

            String action = request.getParameter("action1");

            if (request.getParameter("action1") != null) {


                processAction(request, action.trim(), aOB_CP_DAYSCH);
                request.setAttribute("OB_CP_DAYSCH", aOB_CP_DAYSCH);
            }

            RequestDispatcher rd =
                getServletContext().getRequestDispatcher(
                    request.getParameter("resultPage").trim());
            rd.forward(request, response);

        } catch (DBException ex) {
            Logger.error(this.getClass(), "Error performing doPost", ex);
            request.setAttribute("info", Encode.GToI("ϵͳ³ö´í£¬Çë֪ͨϵͳ¹ÜÀíÔ± £¡"));
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher("/jsp/main/errInfo.jsp");
            rd.forward(request, response);
            return;
        } catch (ServletException ex) {
            Logger.error(this.getClass(), "Error performing doPost", ex);
            request.setAttribute("info", Encode.GToI("ϵͳ³ö´í£¬Çë֪ͨϵͳ¹ÜÀíÔ± £¡"));
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher("/jsp/main/errInfo.jsp");
            rd.forward(request, response);
            return;
        } catch (DBE_RecordAlreadyExistsException e1) {
            Logger.error(this.getClass(), "record has existed,add error", e1);
            request.setAttribute("info", Encode.GToI("ϵͳ³ö´í£¬Çë֪ͨϵͳ¹ÜÀíÔ± £¡"));
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher("/jsp/main/errInfo.jsp");
            rd.forward(request, response);
            return;
        } catch (DBE_RecordNotFoundException e2) {
            Logger.error(this.getClass(), "Error finding Holidy", e2);
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher(
                    request.getParameter("resultPage").trim());
            rd.forward(request, response);
            return;
        } catch (DBE_Exception e3) {
            Logger.error(this.getClass(), "DBE_Exception", e3);
            request.setAttribute("info", Encode.GToI("ϵͳ³ö´í£¬Çë֪ͨϵͳ¹ÜÀíÔ± £¡"));
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher("/jsp/main/errInfo.jsp");
            rd.forward(request, response);
            return;
        } catch (Exception e) {
            Logger.error(this.getClass(), "error performing action", e);
            request.setAttribute("info", Encode.GToI("ϵͳ³ö´í£¬Çë֪ͨϵͳ¹ÜÀíÔ± £¡"));
            RequestDispatcher rd =
                getServletContext().getRequestDispatcher("/jsp/main/errInfo.jsp");
            rd.forward(request, response);
            return;
        } finally {
            Logger.error(this.getClass(),"------some exception take place-----");
            return;
        }
    }
}



---------------------------------------------------------------------------------------------------------------

     public DBI_Base performAction() {
          DBConnectionPool myPool = null;
          DBConnection myConnection = null;
          OBScrCMAP3200Deposit obR = (OBScrCMAP3200Deposit) dbiObj;
          OBScrCMAP3200DepositList ob = new OBScrCMAP3200DepositList();
          ob.DS_BRANCH_ID(obR.DS_BRANCH_ID());
          ob.DS_BATCH_NO(obR.DS_BATCH_NO());
          ob.DS_BATCH_YDDD(obR.DS_BATCH_YDDD());
          try {
               myPool = DBConnectionPool.getInstance(ConnectionMgr.DBNAME);
               myConnection = myPool.getConnection();
               myConnection.setAutoCommit(false);
               OB_CP_DEPSLO obDep = new OB_CP_DEPSLO();
               DB_CP_DEPSLO dbDep = new DB_CP_DEPSLO(myConnection, request);
               obDep.DS_BRANCH_ID(obR.DS_BRANCH_ID());
               obDep.DS_BATCH_NO(obR.DS_BATCH_NO());
               obDep.DS_BATCH_YDDD(obR.DS_BATCH_YDDD());
               obDep.DS_REF_NO(obR.DS_REF_NO());
               obDep.DS_SEQ_NO(obR.DS_SEQ_NO());
               if (dbDep.doFind(obDep)) {
                    ob.setDepositExist(true);
                    //delete deposit
                    OB_CP_DEPSLO obDepD = new OB_CP_DEPSLO();
                    DB_CP_DEPSLO dbDepD = new DB_CP_DEPSLO(myConnection, request);
                    obDepD.DS_BRANCH_ID(obR.DS_BRANCH_ID());
                    obDepD.DS_BATCH_NO(obR.DS_BATCH_NO());
                    obDepD.DS_BATCH_YDDD(obR.DS_BATCH_YDDD());
                    obDepD.DS_REF_NO(obR.DS_REF_NO());
                    obDepD.DS_SEQ_NO(obR.DS_SEQ_NO());
                    dbDepD.doDelete(obDepD);
                Logger.debug(this.getClass(), "delete deposit ok ");
                //myConnection.commit();
                    //reduce the no of slip in the cp_depslo table
                    /*BigDecimal currRecord =
                         BatchFunction.getTotalBatchRec(
                              request,
                              obR.DS_BRANCH_ID(),
                              obR.DS_BATCH_NO(),
                              obR.DS_BATCH_YDDD());
                   Logger.debug(this.getClass(), "be currRecord="+currRecord);
                    currRecord = currRecord.subtract(new BigDecimal(1));
                    Logger.debug(this.getClass(), "af currRecord="+currRecord);
                    BigDecimal currDepositAmt =
                         BatchFunction.getCurrBatchAmt(
                              request,
                              obR.DS_BRANCH_ID(),
                              obR.DS_BATCH_NO(),
                              obR.DS_BATCH_YDDD());
                   Logger.debug(this.getClass(), "be currDepositAmt="+currDepositAmt);
                    currDepositAmt = currDepositAmt.subtract(obR.DS_TOTAL_AMT());
                    Logger.debug(this.getClass(), "af currDepositAmt="+currDepositAmt);
                    //BigDecimal seqNo = DepositFunction.getSeqNo(obR.SS_BRANCH_ID(),obR.SS_BATCH_YDDD(),obR.SS_BATCH_NO(),obR.SS_DEPOSIT_NO());

                    OB_CP_BATCHF obBat = new OB_CP_BATCHF();
                    DB_CP_BATCHF dbBat = new DB_CP_BATCHF(myConnection, request);
                    obBat.BA_BRANCH_ID(obR.DS_BRANCH_ID());
                    obBat.BA_BATCH_YDDD(obR.DS_BATCH_YDDD());
                    obBat.BA_BATCH_NO(obR.DS_BATCH_NO());
                    obBat.BA_NO_TRXN(currRecord);
                    obBat.BA_BATCH_AMT(currDepositAmt);

                    dbBat.doUpdate(obBat);
                   
                    Logger.debug(this.getClass(), "update CP_BATCHF ok");*/
                   
                    //check BA_TALLY_CODE
                 /*BigDecimal totalRec = BatchFunction.getTotalBatchRec(request,obR.DS_BRANCH_ID(),obR.DS_BATCH_NO(),obR.DS_BATCH_YDDD());
                ArrayList listCount = ob.list(obR.DS_BRANCH_ID(),obR.DS_BATCH_NO(),obR.DS_BATCH_YDDD());
                 int currentRecNo = listCount.size();
                 BigDecimal recLeft = totalRec.subtract(new BigDecimal(currentRecNo));
                 BigDecimal trxCurrCode = BatchFunction.getTrxCurrencyCode(request,obR.DS_BRANCH_ID(),obR.DS_BATCH_NO(),obR.DS_BATCH_YDDD());
                BigDecimal currExponent = DBHelper.retriveExponent(request,trxCurrCode);
                 BigDecimal batchAmt = BatchFunction.getCurrBatchAmt(request,obR.DS_BRANCH_ID(),obR.DS_BATCH_NO(),obR.DS_BATCH_YDDD());
                BigDecimal currBatchDepositAmt = BatchFunction.currBatchDepositAmt(request,obR.DS_BRANCH_ID(),obR.DS_BATCH_NO(),obR.DS_BATCH_YDDD());
                    String BA_TALLY_CODE="N";
                    if(recLeft.intValue() == 0 && batchAmt.intValue()==currBatchDepositAmt.intValue()) BA_TALLY_CODE="Y";
                    Logger.debug(this.getClass(),"BA_TALLY_CODE:"+BA_TALLY_CODE);
                 OB_CP_BATCHF aOB_CP_BATCHF = new OB_CP_BATCHF();
                    DB_CP_BATCHF aDB_CP_BATCHF = new DB_CP_BATCHF(request);
                    aOB_CP_BATCHF.BA_BRANCH_ID(obR.DS_BRANCH_ID());
                    aOB_CP_BATCHF.BA_BATCH_YDDD(obR.DS_BATCH_YDDD());
                    aOB_CP_BATCHF.BA_BATCH_NO(obR.DS_BATCH_NO());
                    aDB_CP_BATCHF.doFindByKey(aOB_CP_BATCHF);
               
                    OB_CP_BATCHF bOB_CP_BATCHF = new OB_CP_BATCHF();
                    bOB_CP_BATCHF.BA_BRANCH_ID(obR.DS_BRANCH_ID());
                    bOB_CP_BATCHF.BA_BATCH_YDDD(obR.DS_BATCH_YDDD());
                    bOB_CP_BATCHF.BA_BATCH_NO(obR.DS_BATCH_NO());
               
                    bOB_CP_BATCHF.BA_TALLY_CODE(BA_TALLY_CODE);
                    aDB_CP_BATCHF.doUpdate(bOB_CP_BATCHF);*/
                    Logger.debug(this.getClass(),"CP_BATCHF update ok");
               } else {
                    ob.setError("CMAP3200.BATCH.NOTFOUND");
                    ob.setDepositExist(false);
               }
               myConnection.commit();
          } catch (Exception ex) {
               Logger.error(this.getClass(), "Problem deleting deposit", ex);
               ob.setError("CMAP3200.DEPOSIT.DELETE");
               try {
                    myConnection.rollback();
                    Logger.info(this.getClass(), "connection rolled back");
               } catch (Exception rolEx) {
                    Logger.error(
                         this.getClass(),
                         "Problem doing roll back ",
                         rolEx);
               }
          } finally {
               if (myPool != null) {
                    myPool.release(myConnection);
               }
               return ob;
          }
     }


ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ksfoong

ASKER

KarcOrigin, tq for your sharp eye-sighting..

But i think is the miss-out when i paste the code in here. Let's assume that the code ("{") is ok, because it can compile in JDK 1.3. No error. I think there must be some other errors... that cause this "warning: finally clause cannot complete normally "

Object, get rid of the finally block? Ha. i think that's a best suggestion to avoid this "warning" message.. :-)

But do you know what happend or why this happend? I mean the code is complie ok in JDK 1.3 but not in JDK 1.4. Have you guys face this kind of problem before?
You didn't show us the import lines in your code.
What type is  " Logger"  ?  
Since   JDK1.4++   we have  
java.util.logging.Logger
> i think that's a best suggestion to avoid this "warning" message.. :-)

it is one solution.
Also can't see what the point of that finally block is as it will get executed regardless of whether an exception is thrown or not so the log meesages does not appear valid.

getting rid of the return in the finally block could also possibly fix it.
you should never return from within a finally block. Reason being that an exception may have been thrown that will get lost.
IMO, it's jdk default encoding/locale issue. your jdk1.3 is localized to one language and jdk1.4 is localized to another language that falsely identifies some character as one of '{}()'
Avatar of ksfoong

ASKER

ken,  rrz@871311, that make sense.

Let me re-compile the whole package, and let me observe is that the only reason that the JDK's logger cause me error.

I am using customise Log4J in my sistem.

let me get bcakt o you.
Avatar of ksfoong

ASKER

ken,, rrz, same error.

are you all faced this kind of problem?
Its got nothing to do with the encoding or locale.
Remove the return statement in your finally block, and try compiling.

object is right on the return statement in finally block, have a look at this:
http://sharon.cselt.it/projects/jade/jade-develop-archive/0103.html

BTW, this is a warning message, not an error condition, your programs are compiled fine. they can be used and will excuted as it was with jdk1.3
Avatar of ksfoong

ASKER

ken, the link you posted didn't say much on how " Diego Alonso " sovle the same problem i do. I am earger to know what is happening..

OK. Object, i have change the coding. To transfer the return from the finally { } block to outside. And no error prompt out. :-) But my design is no matter what happend, i want the message to get return to the calling program. That's why i put it in the finally block. As i remember, finally {} block will execute no matter what happend to the program. right?


> I am earger to know what is happening..

I explained above. What exactly don't you understand.

> i want the message to get return to the calling program.

what message?

> As i remember, finally {} block will execute no matter what happend to the program. right?

correct.
That does not however mean that you need to add a return in finally to ensure your method returns. Your method will return fine without it.
In fact as I mentioned earlier you should *never* return from a finally block.

>> the link you posted didn't say much on how " Diego Alonso " sovle the same problem i do.
what you get is just a *warning* message, if you *believe* what you did in jdk1.3 was correct, then you can simply ignore the warning. as I said above, you code will run as it was in jdk1.3.
I'd think fixing that cause of the warning would be more approprite than just ignoring it.
your return in finally block is a void return anyways...!!! i.e. that return is not returning any value to the calling method/program....

even if you remove that return from the finally block.. the running thread ( which is deamon most probably) will return back to the calling location......for the simple reason that the metod call is finished...

So All in all you do not need that return in that finally block...

and its a JDK directive not to use return in finally block..

https://jjguidelines.dev.java.net/book/html/apas04.html#JAC_062

 
I guess what ksfoong meant was he want to method to return instead of throw exception. And indeed, the return in finally block does it.

I absolutely agree on those conventions. The convention said do not return from try block as well (same level of no return in finally block), but yet a lot of people returning from try block. I have come across it in sun's code. :-)
> I guess what ksfoong meant was he want to method to return instead of throw exception.
> And indeed, the return in finally block does it.

Absolutely not. If you want to return instead of throwing the exception then you should catch the exception.
Repeating you should not  return from a finally block.

> The convention said do not return from try block as well (same level of no return in finally block)

Thats for unrelated reasons.
>> Absolutely not.
why not?

>> If you want to return instead of throwing the exception then you should catch the exception.
that everybody know.

>> Repeating you should not  return from a finally block.
the same result as catch the exception and ignore it, what to lose?
thanks for closing question :)