Illegal static type import is allowed

Issue #289 resolved
Jesper Öqvist
created an issue

ExtendJ 8.1.0-48-ge065ff2 Java SE 8

Test.java:

// It should not be allowed to static-import a package-private type from another package.
// .result: COMPILE_FAIL
import static my.thing.A.Thing; // Error: illegal import.

public class Test { }
package my.thing;

public class A {
  static class Thing { }
}

Expected result: should fail to compile. Javac gives this error:

tests/pkg/static_import_06f/Test.java:3: error: cannot find symbol
import static my.thing.A.Thing; // Error: illegal import.
^
  symbol:   static Thing
  location: class
1 error

Actual result: compiles without error.

Comments (1)

  1. Log in to comment