Solved

warning: finally clause cannot complete normally

Posted on 2004-03-27
28
1,971 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
  • 10
  • 6
  • 5
  • +3
28 Comments
 
LVL 92

Expert Comment

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

Expert Comment

by:KarcOrigin
Comment Utility
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
Comment Utility
...
...
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
 

Author Comment

by:ksfoong
Comment Utility
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
Comment Utility
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
Comment Utility
Hi,
For second posted code one brace is extra. Remove the extra brace.
Thx
0
 
LVL 5

Expert Comment

by:KarcOrigin
Comment Utility
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 135 total points
Comment Utility
>        } finally {
>            Logger.error(this.getClass(),"------some exception take place-----");
>            return;
>        }

Get rid of that finally block
0
 

Author Comment

by:ksfoong
Comment Utility
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 27

Expert Comment

by:rrz
Comment Utility
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
Comment Utility
> 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
Comment Utility
getting rid of the return in the finally block could also possibly fix it.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
you should never return from within a finally block. Reason being that an exception may have been thrown that will get lost.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Expert Comment

by:kennethxu
Comment Utility
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
Comment Utility
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
Comment Utility
ken,, rrz, same error.

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

Expert Comment

by:objects
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility

> 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
Comment Utility
>> 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
Comment Utility
I'd think fixing that cause of the warning would be more approprite than just ignoring it.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
Comment Utility
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
Comment Utility
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
Comment Utility
> 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
Comment Utility
>> 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
Comment Utility
thanks for closing question :)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now