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 - valid statement reported as syntax error
Summary: valid statement reported as syntax error
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.0
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-26 02:39 UTC by emiddio
Modified: 2011-04-27 07:43 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
java file reported with syntax error (411 bytes, application/octet-stream)
2011-04-26 02:39 UTC, emiddio
Details
see red bad error message (425.17 KB, image/jpeg)
2011-04-26 21:25 UTC, emiddio
Details

Note You need to log in before you can comment on or make changes to this bug.
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.