Community
Participate
Working Groups
Build Identifier: 20100917-0705 Consider the following code snippet which has a syntax error at line 19: import java.math.*; import java.util.Arrays; public class Welcome { /** * This program is a dummy program. */ public static void main(String[] args) { int[] a = {1, 2, 3, 4, 5}; for (int i = 0; i < 5; i++) { a[i] = i; System.out.println("The value of a[" + i + "] is:" + i); } //BUGGY int[] a_clone Arrays.copyOf(a, a.length); //should read int[] a_clone = Arrays.copyOf(a, a.length); for (int i = 0; i < 5; i++) { a_clone [i] = i; System.out.println("The value of a_clone [" + i + "] is:" + i); } } } When compiling the error displayed reads, as follows, and, this is misleading, because the code snippet is already terminated with a semicolon(;). Exception in thread "main" java.lang.Error: Unresolved compilation problem: Syntax error, insert ";" to complete LocalVariableDeclarationStatement at Welcome.main(Welcome.java:19) It would also be suggested, to have the following features within the Debug perspective: 1. Step through the code line by line using shortcut keys 2. Step over a particular (e.g. buggy) line of code to view the effect on the other variables when that line or group of lines is not executed. Similar features are available within Visual Studio 2008, and, possibly within Visual Studio 2010. Reproducible: Always Steps to Reproduce: See details
(In reply to comment #0) > It would also be suggested, to have the following features within the Debug > perspective: > 1. Step through the code line by line using shortcut keys Can't you already do that with F5, F6, and F7? > 2. Step over a particular (e.g. buggy) line of code to view the effect on the > other variables when that line or group of lines is not executed. See bug 163831. When you have multiple items to report, you should open multiple bugs instead of grouping them all into one, by the way.
(In reply to comment #0) > When compiling the error displayed reads, as follows, and, this is misleading, > because the code snippet is already terminated with a semicolon(;). > Exception in thread "main" java.lang.Error: Unresolved compilation problem: > Syntax error, insert ";" to complete LocalVariableDeclarationStatement > > at Welcome.main(Welcome.java:19) In the editor the error is associated only to the name "a_clone" not the whole line. In that context the message is correct, because there is no ";" after "a_clone" and inserting one fixes the syntax error. This is only misleading when you *run* the buggy program, because then you get the error message without precise context. But going back to the editor you should see where exactly the compiler complains. Isn't that sufficient?
(In reply to comment #2) > [..] > In the editor the error is associated only to the name "a_clone" > not the whole line. In that context the message is correct, because > there is no ";" after "a_clone" and inserting one fixes the syntax error. I agree. This is a legitimate error because inserting a ';' after a_clone would result in a valid local variable declaration statement. This is exactly what the compiler is trying to tell you.
The issued message is correct and the same as 'javac' issues.
Verified for 3.7M4