11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 8046171 27 * @summary Test nestmate checks are no longer used when check_final_method_override is executed during parsing 28 * @run main TestFinalMethodOverride 29 */ 30 31 public class TestFinalMethodOverride { 32 33 public static class Super { 34 private final void theMethod() {} 35 } 36 37 public static class Inner extends Super { 38 // define our own theMethod 39 public void theMethod() {} 40 } 41 42 public static void main(String[] args) { 43 Inner i = new Inner(); 44 } 45 } | 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 8046171 27 * @summary Test nestmate checks are no longer used when check_final_method_override is executed during parsing 28 * @run main TestFinalMethodOverride 29 */ 30 31 // The check_final_method_override function in ClassfileParser uses an 32 // accessability check to see if the subclass method overrides a same-named 33 // superclass method. This would result in a nestmate access check if the 34 // super class method is private, which in turn could lead to classloading 35 // and possibly exceptions and cause havoc in the classfile parsing process. 36 // To fix that we added a check for whether the super class method is private, 37 // and if so, we skip the override check as by definition you can't override 38 // a private method. 39 // 40 // This test simply sets up the case where a public subclass method has the 41 // same signature as a private superclass method - the case we now skip when 42 // doing check_final_method_override. The test should trivially complete 43 // normally. 44 45 public class TestFinalMethodOverride { 46 47 public static class Super { 48 private final void theMethod() {} 49 } 50 51 public static class Inner extends Super { 52 // define our own theMethod 53 public void theMethod() {} 54 } 55 56 public static void main(String[] args) { 57 Inner i = new Inner(); 58 } 59 } 60 |