Illegal static type import is allowed

Issue #289 resolved
Jesper Öqvist created an issue

ExtendJ 8.1.0-48-ge065ff2 Java SE 8

// 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/ 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. Jesper Öqvist reporter

    Improve single-static-import access checking

    Add check for importing non-accessible type by single-static-import.

    Also added a check that the imported type is static.

    fixes #289 (bitbucket)

    → <<cset b15842627181>>

  2. Log in to comment