Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

warning: finally clause cannot complete normally

Posted on 2004-03-27
28
Medium Priority
?
1,994 Views
Last Modified: 2008-03-10
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?
0
Comment
Question by:ksfoong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 6
  • 5
  • +3
28 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10697671
sounds like a nested try/catch block.
can u post your code.
0
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 10698553
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
0
 

Author Comment

by:ksfoong
ID: 10700618
...
...
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??
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ksfoong
ID: 10700631
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;
            }
      }
}
.........
...........
0
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 10700670
Hi,
One closing brace is missing. Please close it at the appro. place. Most prob. the most last closing brace is missing.
Thx
0
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 10700678
Hi,
For second posted code one brace is extra. Remove the extra brace.
Thx
0
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 10700695
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;
          }
     }


0
 
LVL 92

Accepted Solution

by:
objects earned 540 total points
ID: 10700737
>        } finally {
>            Logger.error(this.getClass(),"------some exception take place-----");
>            return;
>        }

Get rid of that finally block
0
 

Author Comment

by:ksfoong
ID: 10701079
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?
0
 
LVL 28

Expert Comment

by:rrz
ID: 10701112
You didn't show us the import lines in your code.
What type is  " Logger"  ?  
Since   JDK1.4++   we have  
java.util.logging.Logger
0
 
LVL 92

Expert Comment

by:objects
ID: 10701155
> 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.

0
 
LVL 92

Expert Comment

by:objects
ID: 10701207
getting rid of the return in the finally block could also possibly fix it.
0
 
LVL 92

Expert Comment

by:objects
ID: 10701217
you should never return from within a finally block. Reason being that an exception may have been thrown that will get lost.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10701314
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 '{}()'
0
 

Author Comment

by:ksfoong
ID: 10701336
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.
0
 

Author Comment

by:ksfoong
ID: 10701366
ken,, rrz, same error.

are you all faced this kind of problem?
0
 
LVL 92

Expert Comment

by:objects
ID: 10702701
Its got nothing to do with the encoding or locale.
Remove the return statement in your finally block, and try compiling.

0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10704704
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
0
 

Author Comment

by:ksfoong
ID: 10709753
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?

0
 
LVL 92

Expert Comment

by:objects
ID: 10709782

> 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.

0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10710595
>> 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.
0
 
LVL 92

Expert Comment

by:objects
ID: 10710631
I'd think fixing that cause of the warning would be more approprite than just ignoring it.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10742225
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

 
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10743734
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. :-)
0
 
LVL 92

Expert Comment

by:objects
ID: 10745116
> 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.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10745327
>> 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?
0
 
LVL 92

Expert Comment

by:objects
ID: 11219004
thanks for closing question :)
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working from home is a dream for many people who aren’t happy about getting up early, going to the office, and spending long hours at work. There are lots of benefits of remote work for employees.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question