test/jdk/java/lang/instrument/RedefineInterfaceMethods/redef/Xost.java
author lfoltan
Wed, 05 Jun 2019 22:19:09 -0700
changeset 55250 f74f0d3033a9
permissions -rw-r--r--
8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier Summary: Add new tests Reviewed-by: dholmes, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55250
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
     1
/*
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
     4
 *
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
     8
 *
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    13
 * accompanied this code).
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    14
 *
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    18
 *
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    21
 * questions.
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    22
 */
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    23
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    24
class Xost {
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    25
    static void log(String msg) { System.out.println(msg); }
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    26
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    27
    static interface B {
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    28
        int ORIGINAL_RETURN = 1;
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    29
        int NEW_RETURN = 2;
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    30
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    31
        private int privateMethod() {
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    32
            Runnable race1 = () -> log("Hello from inside privateMethod");
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    33
            race1.run();
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    34
            return NEW_RETURN;
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    35
        }
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    36
        public default int defaultMethod(String p) {
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    37
            log(p + "from interface B's defaultMethod");
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    38
             return privateMethod();
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    39
        }
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    40
    }
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    41
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    42
    static class Impl implements B {
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    43
    }
f74f0d3033a9 8225325: Add tests for redefining a class' private method during resolution of the bootstrap specifier
lfoltan
parents:
diff changeset
    44
}