This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 198074

Summary: valid statement reported as syntax error
Product: java Reporter: emiddio <emiddio>
Component: EditorAssignee: Dusan Balek <dbalek>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P3    
Version: 7.0   
Hardware: PC   
OS: Windows 7 x64   
Issue Type: DEFECT Exception Reporter:
Attachments: java file reported with syntax error
see red bad error message

Description emiddio 2011-04-26 02:39:15 UTC
Created attachment 107935 [details]
java file reported with syntax error

see attached file;

essentially the following is an syntax error:

public static void main(String[] args) {
        File f = new File(".");
        if (f.isDirectory()) 
            File[] lf = f.listFiles();
    }


where 
public static void main(String[] args) {
        File f = new File(".");
        if (f.isDirectory()) {
            File[] lf = f.listFiles();
        }
    }

is legal

editor complains; and compilation fails
Comment 1 Dusan Balek 2011-04-26 11:31:55 UTC
Unfortunately, I cannot reproduce the problem in the current dev build (the attached java file can be opened without any syntax errors reported). What particular syntax error is reported on your side?
Comment 2 emiddio 2011-04-26 21:25:12 UTC
Created attachment 107955 [details]
see red bad error message
Comment 3 emiddio 2011-04-26 21:27:55 UTC
compilation errors reported:


init:
Deleting: C:\Sun\JavaProjects\nb70\jf\build\built-jar.properties
deps-jar:
Updating property file: C:\Sun\JavaProjects\nb70\jf\build\built-jar.properties
Compiling 1 source file to C:\Sun\JavaProjects\nb70\jf\build\classes
C:\Sun\JavaProjects\nb70\jf\src\jf\Jf2.java:24: '.class' expected
            File[] lf = f.listFiles();
C:\Sun\JavaProjects\nb70\jf\src\jf\Jf2.java:24: not a statement
            File[] lf = f.listFiles();
C:\Sun\JavaProjects\nb70\jf\src\jf\Jf2.java:24: illegal start of expression
            File[] lf = f.listFiles();
C:\Sun\JavaProjects\nb70\jf\src\jf\Jf2.java:24: ';' expected
            File[] lf = f.listFiles();
4 errors
C:\Sun\JavaProjects\nb70\jf\nbproject\build-impl.xml:626: The following error occurred while executing this line:
C:\Sun\JavaProjects\nb70\jf\nbproject\build-impl.xml:245: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
Comment 4 Dusan Balek 2011-04-27 07:43:29 UTC
The red error badge is reported correctly on the following code snippet

public static void main(String[] args) {
    File f = new File(".");
    if (f.isDirectory()) 
        File[] lf = f.listFiles();
}

because THERE IS a syntax error - see the Java Language Specification - 14.9 The if Statement - variable declaration cannot be used inside if-statement. Closing as invalid.