0N/A/**
0N/A * @test /nodynamiccopyright/
0N/A * @bug 4216683 4346296 4656556 4785453
0N/A * @summary New rules for when deprecation messages are suppressed
0N/A * @author gafter
0N/A *
610N/A * @compile/ref=SuppressDeprecation.out -Xlint:deprecation -XDrawDiagnostics SuppressDeprecation.java
0N/A */
0N/A
0N/A/* Test for the contexts in which deprecations warnings should
0N/A * (and should not) be given. They should be given when
0N/A * o invoking a deprecated method from a non-deprecated one.
0N/A * o new X() using a deprecated constructor
0N/A * o super() to a deprecated constructor
0N/A * o extending a deprecated class.
0N/A * But deprecation messages are suppressed as follows:
0N/A * o Never complain about code in the same outermost class as
0N/A * the deprecated entity.
0N/A * o Extending a deprecated class with a deprecated one is OK.
0N/A * o Overriding a deprecated method with a deprecated one is OK.
0N/A * o Code appearing in a deprecated class is OK.
0N/A *
0N/A */
0N/A
0N/Aclass T {
0N/A /** var.
0N/A * @deprecated . */
0N/A int var;
0N/A
0N/A /** f.
0N/A * @deprecated . */
0N/A void f() {
0N/A }
0N/A
0N/A /** g.
0N/A * @deprecated . */
0N/A void g() {
0N/A f();
0N/A }
0N/A
0N/A void h() {
0N/A f();
0N/A }
0N/A
0N/A /** T.
0N/A * @deprecated . */
0N/A T() {
0N/A }
0N/A
0N/A /** T.
0N/A * @deprecated . */
0N/A T(int i) {
0N/A this();
0N/A }
0N/A
0N/A T(float f) {
0N/A this();
0N/A }
0N/A
0N/A void xyzzy() {
0N/A new T();
0N/A new T(1.4f);
0N/A }
0N/A /** plugh.
0N/A * @deprecated . */
0N/A void plugh() {
0N/A new T();
0N/A new T(1.45f);
0N/A }
0N/A
0N/A /** calcx..
0N/A * @deprecated . */
0N/A int calcx() { return 0; }
0N/A}
0N/A
0N/Aclass U extends T {
0N/A /** f.
0N/A * @deprecated . */
0N/A void f() {
0N/A }
0N/A
0N/A void g() { // error (1)
0N/A super.g(); // error (2)
0N/A var = 12; // error (3)
0N/A }
0N/A
0N/A U() {} // error (4)
0N/A
0N/A U(int i) {
0N/A super(i); // error (5)
0N/A }
0N/A
0N/A U(float f) {
0N/A super(1.3f);
0N/A }
0N/A}
0N/A
0N/Aclass V extends T {} // error (6)
0N/A
0N/A/** W.
0N/A * @deprecated . */
0N/Aclass W extends T { // ok - inside deprecated class
0N/A /** W.
0N/A * @deprecated . */
0N/A static {
0N/A new T(1.3f).g(); // ok - called from deprecated static block
0N/A }
0N/A
0N/A /** W.
0N/A * @deprecated . */
0N/A {
0N/A new T(1.3f).g(); // ok - called from deprecated block
0N/A }
0N/A
0N/A {
0N/A new T(1.3f).g(); // ok - inside deprecated class
0N/A }
0N/A
0N/A int x = calcx(); // ok - inside deprecated class
0N/A
0N/A /** y.
0N/A * @deprecated . */
0N/A int y = calcx();
0N/A}
0N/A
0N/A/** X.
0N/A * @deprecated . */
0N/Aclass X {}
0N/A
0N/Aclass Y extends X {} // ok - not overriding anything
0N/A
0N/A/** Z.
0N/A * @deprecated . */
0N/Aclass Z extends X {}