jdk/test/java/lang/invoke/VarHandles/accessibility/pkg/C.java
author psandoz
Mon, 11 Apr 2016 19:00:49 +0200
changeset 36974 86f49af093e5
permissions -rw-r--r--
8152645: VarHandle lookup access control tests Reviewed-by: mhaupt, redestad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36974
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
     1
/*
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
     4
 *
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
     7
 * published by the Free Software Foundation.
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
     8
 *
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    13
 * accompanied this code).
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    14
 *
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    18
 *
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    21
 * questions.
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    22
 */
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    23
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    24
package pkg;
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    25
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    26
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    27
import java.lang.invoke.MethodHandles;
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    28
import java.util.Set;
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    29
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    30
public class C {
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    31
    public static MethodHandles.Lookup lookup() {
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    32
        return MethodHandles.lookup();
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    33
    }
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    34
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    35
    public static Set<String> inaccessibleFields() {
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    36
        // Only private fields of pkg.A are not accessible to independent
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    37
        // class pkg.C
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    38
        // Note: protected fields are also package accessible
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    39
        return Set.of(
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    40
                "f_private",
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    41
                "f_private_final",
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    42
                "f_private_static",
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    43
                "f_private_static_final"
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    44
        );
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    45
    }
86f49af093e5 8152645: VarHandle lookup access control tests
psandoz
parents:
diff changeset
    46
}