attila@463: /* attila@463: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. attila@463: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. attila@962: * attila@463: * This code is free software; you can redistribute it and/or modify it attila@463: * under the terms of the GNU General Public License version 2 only, as attila@463: * published by the Free Software Foundation. attila@962: * attila@463: * This code is distributed in the hope that it will be useful, but WITHOUT attila@463: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or attila@463: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License attila@463: * version 2 for more details (a copy is included in the LICENSE file that attila@463: * accompanied this code). attila@962: * attila@463: * You should have received a copy of the GNU General Public License version attila@463: * 2 along with this work; if not, write to the Free Software Foundation, attila@463: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. attila@962: * attila@463: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA attila@463: * or visit www.oracle.com if you need additional information or have any attila@463: * questions. attila@463: */ attila@463: attila@463: /** attila@463: * JDK-8021129: Test prevention of access to members of restricted classes. attila@463: * Note that even though the script runs as trusted, we still don't allow attila@463: * access to non-public portions of restricted classes. attila@962: * attila@463: * @test attila@463: * @run attila@463: */ attila@464: sundar@468: var InternalRunnableSuperclass = Java.type("jdk.nashorn.test.models.InternalRunnableSuperclass"); sundar@468: var r1 = InternalRunnableSuperclass.makeInternalRunnable(); attila@463: r1.run() // Can execute method from an implemented non-restricted interface attila@463: print(r1.toString()) // Can execute public method from a superclass attila@463: attila@463: print(r1.restrictedRun === undefined) // Can't see method from a restricted interface attila@463: print(r1.canNotInvokeThis === undefined) // Can't see any other public methods attila@463: print(r1.invisibleProperty === undefined) // Can't see any other properties attila@463: print(r1.canSeeThisField === undefined) // Can't see fields from superclasses attila@463: print(r1.canNotSeeThisField === undefined) // Can't see its own fields attila@463: sundar@468: var r2 = new InternalRunnableSuperclass(); attila@464: print(r2.canSeeThisField) // Superclass field works fine on its own