test/hotspot/jtreg/runtime/Nestmates/privateStaticMethods/TestJNI.java
author dholmes
Sat, 23 Jun 2018 01:32:41 -0400
changeset 50735 2f2af62dfac7
permissions -rw-r--r--
8010319: Implementation of JEP 181: Nest-Based Access Control Reviewed-by: alanb, psandoz, mchung, coleenp, acorn, mcimadamore, forax, jlahoda, sspitsyn, abuckley Contributed-by: alex.buckley@oracle.com, maurizio.mimadamore@oracle.com, mandy.chung@oracle.com, tobias.hartmann@oracle.com, david.holmes@oracle.com, vladimir.x.ivanov@oracle.com, karen.kinnear@oracle.com, vladimir.kozlov@oracle.com, john.r.rose@oracle.com, daniel.smith@oracle.com, serguei.spitsyn@oracle.com, kumardotsrinivasan@gmail.com, boris.ulasevich@bell-sw.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50735
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
     1
/*
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
     4
 *
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
     8
 *
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    13
 * accompanied this code).
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    14
 *
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    18
 *
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    21
 * questions.
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    22
 */
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    23
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    24
/*
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    25
 * @test
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    26
 * @bug 8046171
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    27
 * @summary Test JNI access to private methods between nestmates and nest-host
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    28
 *          using different flavours of named nested types
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    29
 * @compile ../NestmatesJNI.java
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    30
 * @run main/othervm/native TestJNI
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    31
 * @run main/othervm/native -Xcheck:jni TestJNI
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    32
 */
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    33
public class TestJNI {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    34
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    35
    // Unlike reflection, the calling context is not relevant to JNI
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    36
    // calls, but we keep the same structure as the reflection tests.
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    37
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    38
    // Private static method of nest-host for nestmates to access
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    39
    private static void priv_static_invoke() {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    40
        System.out.println("TestJNI::priv_static_invoke");
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    41
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    42
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    43
    static final String METHOD = "priv_static_invoke";
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    44
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    45
    // public constructor so we aren't relying on private access
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    46
    public TestJNI() {}
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    47
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    48
    // Methods that will access private static methods of nestmates
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    49
    // We use the arguments for overloading purposes and use the fact
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    50
    // you can invoke a static method through an object reference for
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    51
    // convenience. Except for static interface methods of course.
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    52
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    53
    // NOTE: No InnerNested calls in this test because non-static nested types
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    54
    // can't have static method
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    55
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    56
    void access_priv(TestJNI o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    57
        doCall(o.getClass(), METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    58
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    59
    void access_priv(StaticNested o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    60
        doCall(o.getClass(), METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    61
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    62
    void access_priv(StaticIface o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    63
        // Can't use o.getClass() as the method is not in that class
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    64
        doCall(StaticIface.class, METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    65
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    66
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    67
    // The various nestmates
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    68
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    69
    static interface StaticIface {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    70
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    71
        private static void priv_static_invoke() {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    72
            System.out.println("StaticIface::priv_static_invoke");
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    73
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    74
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    75
        // Methods that will access private static methods of nestmates
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    76
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    77
        default void access_priv(TestJNI o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    78
            doCall(o.getClass(), METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    79
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    80
        default void access_priv(StaticNested o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    81
            doCall(o.getClass(), METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    82
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    83
        default void access_priv(StaticIface o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    84
            // Can't use o.getClass() as the method is not in that class
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    85
            doCall(StaticIface.class, METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    86
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    87
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    88
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    89
    static class StaticNested {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    90
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    91
        private static void priv_static_invoke() {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    92
            System.out.println("StaticNested::priv_static_invoke");
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    93
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    94
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    95
        // public constructor so we aren't relying on private access
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    96
        public StaticNested() {}
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    97
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    98
        // Methods that will access private static methods of nestmates
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
    99
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   100
        void access_priv(TestJNI o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   101
            doCall(o.getClass(), METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   102
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   103
        void access_priv(StaticNested o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   104
            doCall(o.getClass(), METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   105
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   106
        void access_priv(StaticIface o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   107
            // Can't use o.getClass() as the method is not in that class
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   108
            doCall(StaticIface.class, METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   109
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   110
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   111
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   112
    class InnerNested {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   113
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   114
        // public constructor so we aren't relying on private access
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   115
        public InnerNested() {}
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   116
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   117
        void access_priv(TestJNI o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   118
            doCall(o.getClass(), METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   119
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   120
        void access_priv(StaticNested o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   121
            doCall(o.getClass(), METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   122
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   123
        void access_priv(StaticIface o) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   124
            // Can't use o.getClass() as the method is not in that class
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   125
            doCall(StaticIface.class, METHOD);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   126
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   127
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   128
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   129
    public static void main(String[] args) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   130
        TestJNI o = new TestJNI();
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   131
        StaticNested s = new StaticNested();
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   132
        InnerNested i = o.new InnerNested();
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   133
        StaticIface intf = new StaticIface() {};
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   134
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   135
        o.access_priv(new TestJNI());
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   136
        o.access_priv(s);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   137
        o.access_priv(intf);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   138
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   139
        s.access_priv(o);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   140
        s.access_priv(new StaticNested());
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   141
        s.access_priv(intf);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   142
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   143
        i.access_priv(o);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   144
        i.access_priv(s);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   145
        i.access_priv(intf);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   146
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   147
        intf.access_priv(o);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   148
        intf.access_priv(s);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   149
        intf.access_priv(new StaticIface(){});
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   150
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   151
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   152
    static void doCall(Class<?> klass, String method) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   153
        String definingClass = klass.getName();
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   154
        String desc = "Static invocation of " + definingClass + "." + method;
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   155
        try {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   156
            NestmatesJNI.callStaticVoidVoid(definingClass, method);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   157
            System.out.println(desc + " - passed");
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   158
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   159
        catch (Throwable t) {
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   160
            throw new Error(desc + ": Unexpected exception: " + t, t);
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   161
        }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   162
    }
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
diff changeset
   163
}