Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6435972

"except.never.thrown.in.try" have to be reported in extra cases

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 6
    • tools
    • None
    • generic
    • generic

      A DESCRIPTION OF THE FIX :
      Review ID : 683811
        Bug Description : Message "except.never.thrown.in.try" have to be reported in extra cases
      Diff Baseline : Mustang b78.
      Diff :
      diff -u -r old/com/sun/tools/javac/comp/Flow.java src/com/sun/tools/javac/comp/Flow.java
      --- old/com/sun/tools/javac/comp/Flow.java 2006-04-03 12:42:39.445934100 +0300
      +++ src/com/sun/tools/javac/comp/Flow.java 2006-04-12 11:50:01.387040000 +0300
      @@ -956,6 +956,8 @@
        int nextadrCatch = nextadr;
       
        List<Type> caughtInTry = List.nil();
      + boolean isErrorAlreadyCaught = false;
      + boolean isRuntimeExceptionAlreadyCaught = false;
        for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
        alive = true;
        JCVariableDecl param = l.head.param;
      @@ -964,13 +966,17 @@
        log.error(l.head.pos(),
        "except.already.caught", exc);
        } else if (!chk.isUnchecked(l.head.pos(), exc) &&
      - exc.tsym != syms.throwableType.tsym &&
      - exc.tsym != syms.exceptionType.tsym &&
      - !chk.intersects(exc, thrownInTry)) {
      - log.error(l.head.pos(),
      + (exc.tsym != syms.throwableType.tsym || isErrorAlreadyCaught && isRuntimeExceptionAlreadyCaught) &&
      + (exc.tsym != syms.exceptionType.tsym || isRuntimeExceptionAlreadyCaught) &&
      + !chk.intersects(exc, chk.diff(thrownInTry, caughtInTry))) {
      + log.warning(l.head.pos(),
        "except.never.thrown.in.try", exc);
        }
        caughtInTry = chk.incl(exc, caughtInTry);
      + if (exc.tsym == syms.errorType.tsym)
      + isErrorAlreadyCaught = true;
      + else if (exc.tsym == syms.runtimeExceptionType.tsym)
      + isRuntimeExceptionAlreadyCaught = true;
        inits = initsTry.dup();
        uninits = uninitsTry.dup();
        scan(param);
      diff -u -r old/com/sun/tools/javac/resources/compiler.properties src/com/sun/tools/javac/resources/compiler.properties
      --- old/com/sun/tools/javac/resources/compiler.properties 2006-04-03 12:42:40.008430500 +0300
      +++ src/com/sun/tools/javac/resources/compiler.properties 2006-04-12 11:55:52.976289600 +0300
      @@ -149,8 +149,6 @@
           error reading {0}; {1}
       compiler.err.except.already.caught= exception {0} has already been caught
      -compiler.err.except.never.thrown.in.try=- exception {0} is never thrown in body of corresponding try statement
       
       compiler.err.final.parameter.may.not.be.assigned= final parameter {0} may not be assigned
      @@ -698,6 +696,9 @@
       compiler.warn.annotation.method.not.found.reason= Cannot find annotation method ''{1}()'' in type ''{0}'': {2}
       
      +compiler.warn.except.never.thrown.in.try=+ exception {0} is never thrown in body of corresponding try statement
      +
       #####
       
       ## The following are tokens which are non-terminals in the language. They should
      diff -u -r old/com/sun/tools/javac/resources/compiler_ja.properties src/com/sun/tools/javac/resources/compiler_ja.properties
      --- old/com/sun/tools/javac/resources/compiler_ja.properties 2006-04-03 12:42:40.008430500 +0300
      +++ src/com/sun/tools/javac/resources/compiler_ja.properties 2006-04-11 18:50:03.921832000 +0300
      @@ -147,8 +147,6 @@
           {0} \u306e\u8aad\u307f\u8fbc\u307f\u30a8\u30e9\u30fc\u3067\u3059\u3002{1}
       compiler.err.except.already.caught= \u4f8b\u5916 {0} \u306f\u3059\u3067\u306b\u30ad\u30e3\u30c3\u30c1\u3055\u308c\u3066\u3044\u307e\u3059\u3002
      -compiler.err.except.never.thrown.in.try=- \u4f8b\u5916 {0} \u306f\u5bfe\u5fdc\u3059\u308b try \u6587\u306e\u672c\u4f53\u3067\u306f\u30b9\u30ed\u30fc\u3055\u308c\u307e\u305b\u3093\u3002
       
       compiler.err.final.parameter.may.not.be.assigned= final \u30d1\u30e9\u30e1\u30fc\u30bf {0} \u306b\u5024\u3092\u4ee3\u5165\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002
      @@ -614,6 +612,9 @@
       compiler.warn.empty.if= [empty] if \u4ee5\u964d\u304c\u7a7a\u306e\u6587\u3067\u3059
       
      +compiler.warn.except.never.thrown.in.try=+ \u4f8b\u5916 {0} \u306f\u5bfe\u5fdc\u3059\u308b try \u6587\u306e\u672c\u4f53\u3067\u306f\u30b9\u30ed\u30fc\u3055\u308c\u307e\u305b\u3093\u3002
      +
       #####
       
       ## The following are tokens which are non-terminals in the language. They should
      diff -u -r old/com/sun/tools/javac/resources/compiler_zh_CN.properties src/com/sun/tools/javac/resources/compiler_zh_CN.properties
      --- old/com/sun/tools/javac/resources/compiler_zh_CN.properties 2006-04-03 12:42:40.024055400 +0300
      +++ src/com/sun/tools/javac/resources/compiler_zh_CN.properties 2006-04-11 18:50:11.546734400 +0300
      @@ -147,8 +147,6 @@
       \u8bfb\u53d6 {0} \u65f6\u51fa\u9519\uff1b{1}
       compiler.err.except.already.caught= \u5df2\u6355\u6349\u5230\u5f02\u5e38 {0}
      -compiler.err.except.never.thrown.in.try=-\u5728\u76f8\u5e94\u7684 try \u8bed\u53e5\u4e3b\u4f53\u4e2d\u4e0d\u80fd\u629b\u51fa\u5f02\u5e38 {0}
       
       compiler.err.final.parameter.may.not.be.assigned= \u4e0d\u80fd\u6307\u5b9a\u6700\u7ec8\u53c2\u6570 {0}
      @@ -614,6 +612,9 @@
       compiler.warn.empty.if= [\u7a7a] if \u4e4b\u540e\u6ca1\u6709\u8bed\u53e5
       
      +compiler.warn.except.never.thrown.in.try=+\u5728\u76f8\u5e94\u7684 try \u8bed\u53e5\u4e3b\u4f53\u4e2d\u4e0d\u80fd\u629b\u51fa\u5f02\u5e38 {0}
      +
       #####
       
       ## The following are tokens which are non-terminals in the language. They should

            Unassigned Unassigned
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: