# HG changeset patch # User asaha # Date 1336501761 25200 # Node ID 6d2c830e025d59886210a93b973c4ba124d805b8 # Parent 5142b51102147a3263f10466c6f10b930a95e7c6# Parent d558e01a72c0878b7ca3ae54c3d1ce3208f31862 Merge diff -r 5142b5110214 -r 6d2c830e025d src/share/vm/classfile/verifier.cpp --- a/src/share/vm/classfile/verifier.cpp Tue May 08 07:29:27 2012 -0700 +++ b/src/share/vm/classfile/verifier.cpp Tue May 08 11:29:21 2012 -0700 @@ -1880,10 +1880,10 @@ VerificationType type = current_frame->pop_stack( VerificationType::reference_check(), CHECK_VERIFY(this)); if (type == VerificationType::uninitialized_this_type()) { - // The method must be an method of either this class, or one of its - // superclasses + // The method must be an method of this class or its superclass + klassOop superk = current_class()->super(); if (ref_class_type.name() != current_class()->name() && - !name_in_supers(ref_class_type.name(), current_class())) { + ref_class_type.name() != superk->klass_part()->name()) { verify_error(bci, "Bad method call"); return; } diff -r 5142b5110214 -r 6d2c830e025d test/runtime/7160757/Test7160757.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/7160757/Test7160757.java Tue May 08 11:29:21 2012 -0700 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2012, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test Test7160757.java + * @bug 7160757 + * @summary Tests that superclass initialization is not skipped + */ + +public class Test7160757 { + + public static void main(String args[]) throws Exception { + + ClassLoader loader = new SLoader(); + try { + Class.forName("S", true, loader); + System.out.println("FAILED"); + throw new Exception("Should have thrown a VerifyError."); + } catch (VerifyError e) { + System.out.println(e); + System.out.println("PASSED"); + } + } + + static class SLoader extends ClassLoader { + + /** + * public class S extends Throwable { + * public S() { + * aload_0 + * invokespecial Object.() + * return + * } + * } + */ + static byte b(int i) { return (byte)i; } + static byte S_class[] = { + b(0xca), b(0xfe), b(0xba), b(0xbe), 0x00, 0x00, 0x00, 0x32, + 0x00, 0x0c, 0x0a, 0x00, 0x0b, 0x00, 0x07, 0x07, + 0x00, 0x08, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06, + 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00, + 0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x04, 0x43, + 0x6f, 0x64, 0x65, 0x0c, 0x00, 0x04, 0x00, 0x05, + 0x01, 0x00, 0x01, 0x53, 0x01, 0x00, 0x13, 0x6a, + 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, + 0x2f, 0x54, 0x68, 0x72, 0x6f, 0x77, 0x61, 0x62, + 0x6c, 0x65, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, + 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x07, 0x00, 0x0a, + 0x00, 0x21, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x04, + 0x00, 0x05, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00, + 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x05, 0x2a, b(0xb7), 0x00, 0x01, b(0xb1), 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + public Class findClass(String name) throws ClassNotFoundException { + return defineClass(name, S_class, 0, S_class.length); + } + } +}