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

javac prints garbage characters on parse error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • 7
    • 7
    • tools
    • b03
    • 7
    • generic
    • generic

      If javac is asked to compile this (non-sensical) program

      public class PreviousBits {
          void testOutOfBounds(final Bar s) {
      g(IndexOutOfBoundsException.class,
      new F(){void f(){ s.ff();
      new F(){void f(){ s.ff();}});
          }
      }

      as of 7-b03, it prints duplicate error messages

      "reached end of file while parsing"
      and also prints garbage Ctrl-Z and NUL bytes to the screen.
       $ jver 7-b03 javac PreviousBits.java

      PreviousBits.java:5: ';' expected
      new F(){void f(){ s.ff();}});
      ^
      PreviousBits.java:7: reached end of file while parsing
      }
       ^
      PreviousBits.java:8: reached end of file while parsing
      ^Z^@^@^@^@^@
      ^
      3 errors


      The 7-b02 behavior is clearly preferable.

       $ jver 7-b02 javac PreviousBits.java
      PreviousBits.java:5: ';' expected
      new F(){void f(){ s.ff();}});
      ^
      PreviousBits.java:7: reached end of file while parsing
      }
       ^
      2 errors


      The Ctrl-Z and NUL characters may be invisible in your terminal emulator.
      If so, try running in an Emacs shell buffer, or use od -x, e.g.

      $ for v in 7-b02 7-b03; do echo $v; jver $v javac PreviousBits.java 2>&1 | od -x | grep -w 0000; done
      7-b02
      7-b03
      0000340 1a00 0000 0000 0000 0000 0a5e 0a33 2065

            jjg Jonathan Gibbons
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: