/*
* @test /nodynamiccopyright/
* @bug 4087314 4087314 4785453
* @summary Test access checking within 'extends' and 'implements' clause.
* @author William Maddox (maddox)
* @compile/fail/ref=ExtendsAccess.out -XDrawDiagnostics ExtendsAccess.java
*/
/*
* Should compile with errors as noted.
*/
class ExtendsAccess {
class defaultClass { }
public class publicClass { }
private class privateClass { }
protected class protectedClass { }
static class defaultStaticClass { }
public static class publicStaticClass { }
private static class privateStaticClass { }
protected static class protectedStaticClass { }
interface defaultInterface { }
public interface publicInterface { }
private interface privateInterface { }
protected interface protectedInterface { }
}
class ExtendsAccess1211 extends ExtendsAccess.publicClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
class ExtendsAccess1221 extends ExtendsAccess.defaultClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
class ExtendsAccess1231 extends ExtendsAccess.protectedClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
class ExtendsAccess1241 extends ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass'
class ExtendsAccess1212 extends p.ExtendsAccess.publicClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
class ExtendsAccess1222 extends p.ExtendsAccess.defaultClass { } // ERROR - cannot access 'defaultClass'
class ExtendsAccess1232 extends p.ExtendsAccess.protectedClass { } // ERROR - cannot access 'protectedClass'
class ExtendsAccess1242 extends p.ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass'
class N extends publicClass { }
}
class N extends defaultClass { }
}
class N extends protectedClass { }
}
class N extends privateClass { } // ERROR - cannot access 'privateClass'
}
class N extends publicClass { }
}
class N extends defaultClass { } // ERROR - cannot access 'defaultClass'
}
class N extends protectedClass { }
}
class N extends privateClass { } // ERROR - cannot access 'privateClass'
}
class N extends ExtendsAccess.publicClass { }
}
class N extends ExtendsAccess.defaultClass { }
}
class N extends ExtendsAccess.protectedClass { }
}
class N extends ExtendsAccess1441.protectedClass { }
}
}
class N extends p.ExtendsAccess.publicClass { }
}
}
}
class N extends ExtendsAccess1442.protectedClass { }
}
}
class ExtendsAccess213 extends protectedStaticClass { } // ERROR - 'protectedStaticClass' not in scope
class ExtendsAccess2241 extends ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
class ExtendsAccess2222 extends p.ExtendsAccess.defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass'
class ExtendsAccess2232 extends p.ExtendsAccess.protectedStaticClass { }// ERROR - cannot access 'protectedStaticClass'
class ExtendsAccess2242 extends p.ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
class N extends publicStaticClass { }
}
class N extends defaultStaticClass { }
}
class N extends protectedStaticClass { }
}
class N extends privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
}
class N extends publicStaticClass { }
}
class N extends defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass'
}
class N extends protectedStaticClass { }
}
class N extends privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
}
class N extends ExtendsAccess.publicStaticClass { }
}
class N extends ExtendsAccess.defaultStaticClass { }
}
}
class N extends ExtendsAccess2431.protectedStaticClass { }
}
}
class N extends p.ExtendsAccess.publicStaticClass { }
}
class N extends p.ExtendsAccess.defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass'
}
class N extends p.ExtendsAccess.protectedStaticClass { } // OK (was: should be error, see JLS 6.6.2)
}
class N extends ExtendsAccess2442.protectedStaticClass { }
}
class N extends p.ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
}
class ExtendsAccess311 extends ExtendsAccess implements publicInterface { } // ERROR - 'publicInterface' not in scope
class ExtendsAccess312 extends ExtendsAccess implements defaultInterface { } // ERROR - 'defaultInterface' not in scope
class ExtendsAccess313 extends ExtendsAccess implements protectedInterface { } // ERROR - 'protectedInterface' not in scope
class ExtendsAccess314 extends ExtendsAccess implements privateInterface { } // ERROR - 'privateInterface' not in scope
implements p.ExtendsAccess.publicInterface { }
class N implements publicInterface { }
}
class N implements defaultInterface { }
}
class N implements protectedInterface { }
}
class N implements privateInterface { } // ERROR - cannot access 'privateInterface'
}
class N implements publicInterface { }
}
class N implements defaultInterface { } // ERROR - cannot access 'defaultStaticClass'
}
class N implements protectedInterface { }
}
class N implements privateInterface { } // ERROR - cannot access 'privateInterface'
}
class N implements ExtendsAccess.publicInterface { }
}
class N implements ExtendsAccess.defaultInterface { }
}
}
class N implements ExtendsAccess3441.protectedInterface { }
}
}
class N implements p.ExtendsAccess.publicInterface { }
}
}
class N implements p.ExtendsAccess.protectedInterface { } // OK (was: should be error, see JLS 6.2.2)
}
class N implements ExtendsAccess3442.protectedInterface { }
}
}