test/hotspot/jtreg/runtime/linkResolver/TestDeletedMethod.java
author dholmes
Tue, 09 Oct 2018 20:19:22 -0400
changeset 52066 49a21be61dcd
permissions -rw-r--r--
8211065: Private method check in linkResolver is incorrect Reviewed-by: acorn, lfoltan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52066
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
     1
/*
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
     4
 *
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
     7
 * published by the Free Software Foundation.
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
     8
 *
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    13
 * accompanied this code).
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    14
 *
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    18
 *
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    21
 * questions.
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    22
 */
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    23
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    24
/*
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    25
 * @test
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    26
 * @bug 8211065
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    27
 * @summary Test that deleting a subclass method implementation results in
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    28
 * execution of a superclass implementation - if it is accessible.
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    29
 * @compile TestDeletedMethod.java
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    30
 * @compile TestDeletedMethod_Sub.jcod TestDeletedMethod_Super.jcod
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    31
 * @run main/othervm -XX:+RelaxAccessControlCheck TestDeletedMethod
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    32
 */
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    33
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    34
// The access control relaxation was originally done to ensure an assertion
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    35
// in the nestmate logic would not trigger unintentionally because it
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    36
// assumed only nestmates could be involved. The assertion no longer exists
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    37
// but we keep the test as a non-nestmate version of the situation.
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    38
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    39
/* package */ class TestDeletedMethod_Super {
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    40
    public static final int ID = 2;
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    41
    private static int m() {
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    42
        System.out.println("Super.m");
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    43
        return ID;
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    44
    }
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    45
}
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    46
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    47
/* package */ class TestDeletedMethod_Sub extends TestDeletedMethod_Super {
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    48
    public static final int ID = 1;
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    49
    // At runtime this implementation is not present
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    50
    private static int m() {
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    51
        System.out.println("Sub.m");
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    52
        return ID;
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    53
    }
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    54
    public static int test() {
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    55
        return TestDeletedMethod_Sub.m();
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    56
    }
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    57
}
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    58
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    59
public class TestDeletedMethod {
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    60
    public static void main(String[] args) {
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    61
        int x = TestDeletedMethod_Sub.test();
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    62
        if (x != TestDeletedMethod_Super.ID)
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    63
            throw new RuntimeException("Wrong method invoked: " + x);
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    64
    }
49a21be61dcd 8211065: Private method check in linkResolver is incorrect
dholmes
parents:
diff changeset
    65
}