Bug 76244

Summary: [1.5] No error on invalid static import declaration
Product: [Eclipse Project] JDT Reporter: Frederic Fusier <frederic_fusier>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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