1749N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1749N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1749N/A *
1749N/A * This code is free software; you can redistribute it and/or modify it
1749N/A * under the terms of the GNU General Public License version 2 only, as
1749N/A * published by the Free Software Foundation.
1749N/A *
1749N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1749N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1749N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1749N/A * version 2 for more details (a copy is included in the LICENSE file that
1749N/A * accompanied this code).
1749N/A *
1749N/A * You should have received a copy of the GNU General Public License version
1749N/A * 2 along with this work; if not, write to the Free Software Foundation,
1749N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1749N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1749N/A */
1749N/A
1749N/A/*
1749N/A * @test
1749N/A * @bug 6648344
1749N/A * @summary Test that default accessibility is false
1749N/A * @author Joseph D. Darcy
1749N/A */
1749N/A
1749N/Aimport java.lang.reflect.*;
1749N/A
1749N/Apublic class DefaultAccessibility {
1749N/A private DefaultAccessibility() {
1749N/A super();
1749N/A }
1749N/A
1749N/A private static int f = 42;
1749N/A
1749N/A public static void main(String... args) throws Exception {
1749N/A Class<?> daClass = (new DefaultAccessibility()).getClass();
1749N/A
1749N/A int elementCount = 0;
1749N/A for(Constructor<?> ctor : daClass.getDeclaredConstructors()) {
1749N/A elementCount++;
1749N/A if (ctor.isAccessible())
1749N/A throw new RuntimeException("Unexpected accessibility for constructor " +
1749N/A ctor);
1749N/A }
1749N/A
1749N/A for(Method method : daClass.getDeclaredMethods()) {
1749N/A elementCount++;
1749N/A if (method.isAccessible())
1749N/A throw new RuntimeException("Unexpected accessibility for method " +
1749N/A method);
1749N/A }
1749N/A
1749N/A for(Field field : daClass.getDeclaredFields()) {
1749N/A elementCount++;
1749N/A if (field.isAccessible())
1749N/A throw new RuntimeException("Unexpected accessibility for field " +
1749N/A field);
1749N/A }
1749N/A
1749N/A if (elementCount < 3)
1749N/A throw new RuntimeException("Expected at least three members; only found " +
1749N/A elementCount);
1749N/A }
1749N/A}