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

Javac blocks with consecutive ';' and reports wrong error location

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • tools
    • x86
    • windows_2000



      Name: yyT116575 Date: 05/29/2001


      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)


      I have some code that I used to compile without any problem with JDK 1.3.0.
      When i installed the Beta version of 1.4 I could no more comile my code....
      so that I tried to find what was the problem ...
      finally I extracted this piece of code as being the one causing the error:
      <code>
      public class BugToto {
        /**
         *
         *
         *
         *
         */
        public String getString(){
          return "BugToto";;
        }
        
        public String getBidon(String a[]){
          for (int i=0;i<a.length;++i) if (a[i]!=null) return a[i];
          return null;
        }
      }
      </code>
      when compiling i have the following error message :
      <CODE>
        BugToto.java:13: unreachable statement
      for (int i=0;i<a.length;++i) if (a[i]!=null) return a[i];
                               ^
      1 error
      </CODE>
      In fact, the problem is the double ';' (in <code>return "BugToto";;</code>) but
      the error reporting is incorrect!
      Indeed, the compiler considers the second ';' as a statement coming after a
      return statement... so it is <B><I>unreachable </I></B>....
      but the same code goes well in jdk 1.3.
      further more, the error reporting calculates in a wrong way the position of the
      error because of the comments (which is a BUG)...
      hope i was helpful !!

      (Review ID: 125290)
      ======================================================================

            gafter Neal Gafter (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: