< prev index next >

test/jdk/java/lang/invoke/AccessControlTest.java

Print this page
rev 50246 : imported patch jep181-rev1

*** 1,7 **** /* ! * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 239,260 **** return true; LookupCase lc = this.in(c2); int m1 = lc.lookupModes(); int m2 = fixMods(m.getModifiers()); ! // privacy is strictly enforced on lookups ! if (c1 != c2) m1 &= ~PRIVATE; // protected access is sometimes allowed if ((m2 & PROTECTED) != 0) { int prev = m2; m2 |= PACKAGE; // it acts like a package method also if ((lookupModes() & PROTECTED) != 0 && c2.isAssignableFrom(c1)) m2 |= PUBLIC; // from a subclass, it acts like a public method also } if (verbosity >= 2) ! System.out.println(this+" willAccess "+lc+" m1="+m1+" m2="+m2+" => "+((m2 & m1) != 0)); return (m2 & m1) != 0; } /** Predict the success or failure of accessing this class. */ public boolean willAccessClass(Class<?> c2, boolean load) { --- 239,262 ---- return true; LookupCase lc = this.in(c2); int m1 = lc.lookupModes(); int m2 = fixMods(m.getModifiers()); ! // allow private lookup on nestmates. Otherwise, privacy is strictly enforced ! if (c1 != c2 && ((m2 & PRIVATE) == 0 || !c1.isNestmateOf(c2))) { ! m1 &= ~PRIVATE; ! } // protected access is sometimes allowed if ((m2 & PROTECTED) != 0) { int prev = m2; m2 |= PACKAGE; // it acts like a package method also if ((lookupModes() & PROTECTED) != 0 && c2.isAssignableFrom(c1)) m2 |= PUBLIC; // from a subclass, it acts like a public method also } if (verbosity >= 2) ! System.out.format("%s willAccess %s m1=0x%h m2=0x%h => %s%n", this, lc, m1, m2, ((m2 & m1) != 0)); return (m2 & m1) != 0; } /** Predict the success or failure of accessing this class. */ public boolean willAccessClass(Class<?> c2, boolean load) {
< prev index next >