Bug 76244 - [1.5] No error on invalid static import declaration
Summary: [1.5] No error on invalid static import declaration
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-14 07:54 EDT by Frederic Fusier CLA
Modified: 2004-11-03 09:47 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2004-10-14 07:54:56 EDT
Using HEAD, compiler does not report any error on following invalid static import:

import static java.lang.System;
public class X {
   public static void main (String[] args) {
      out.println("SUCCESS");
   }
}

Valid static import are only:
import static <type ref>.*;
import static <type ref>.<identifier>;

Sun JDK 1.5 javac reports following errors:
X.java:1: cannot find symbol
symbol  : class lang
location: package java
import static java.lang.System;
                   ^
X.java:1: static import only from classes and interfaces
import static java.lang.System;
^
X.java:4: cannot find symbol
symbol  : variable out
location: class X
      out.println("SUCCESS");
      ^
3 errors
Comment 1 Frederic Fusier CLA 2004-10-14 08:05:01 EDT
Oooops, in fact compiler reports errors on comment 0 syntax:
- unused import
- out unresolved

Syntax which does not provide any error is:
import static java.lang.System;
public class X {
   public static void main (String[] args) {
      System.out.println("SUCCESS");
   }
}
Comment 2 Frederic Fusier CLA 2004-10-14 08:06:34 EDT
On comment 1 syntax, javac reports following errors:
X.java:1: cannot find symbol
symbol  : class lang
location: package java
import static java.lang.System;
                   ^
X.java:1: static import only from classes and interfaces
import static java.lang.System;
^
2 errors
Comment 3 Kent Johnson CLA 2004-10-14 12:59:42 EDT
Fixed. Added StaticImportTest.test008().
Comment 4 David Audel CLA 2004-11-03 09:47:01 EST
Verified for 3.1M3 with build I20041102