8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 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 8058575 27 * @summary Test that bad host classes cause exceptions to get thrown. 28 * @library /test/lib 29 * @modules java.base/jdk.internal.misc 30 * java.base/jdk.internal.org.objectweb.asm 31 * @run main TestBadHostClass 32 */ 33 34 35 import java.lang.*; 36 import java.lang.reflect.Field; 37 import jdk.internal.misc.Unsafe; 38 import jdk.test.lib.unsafe.UnsafeHelper; 39 import jdk.internal.org.objectweb.asm.ClassWriter; 40 import static jdk.internal.org.objectweb.asm.Opcodes.*; 41 42 // Test that bad host classes cause exceptions. 43 public class TestBadHostClass { 44 45 private static final Unsafe unsafe = Unsafe.getUnsafe(); 46 47 private static String packageName(Class<?> c) { 48 if (c.isArray()) { 49 return packageName(c.getComponentType()); 50 } else { 51 String name = c.getName(); 52 int dot = name.lastIndexOf('.'); 53 if (dot == -1) return ""; 54 return name.substring(0, dot); 55 } 56 } 57 58 private static int constantPoolSize(byte[] classFile) { | 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 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 8058575 27 * @summary Test that bad host classes cause exceptions to get thrown. 28 * @modules java.base/jdk.internal.misc 29 * java.base/jdk.internal.org.objectweb.asm 30 * @run main TestBadHostClass 31 */ 32 33 34 import java.lang.*; 35 import java.lang.reflect.Field; 36 import jdk.internal.misc.Unsafe; 37 import jdk.internal.org.objectweb.asm.ClassWriter; 38 import static jdk.internal.org.objectweb.asm.Opcodes.*; 39 40 // Test that bad host classes cause exceptions. 41 public class TestBadHostClass { 42 43 private static final Unsafe unsafe = Unsafe.getUnsafe(); 44 45 private static String packageName(Class<?> c) { 46 if (c.isArray()) { 47 return packageName(c.getComponentType()); 48 } else { 49 String name = c.getName(); 50 int dot = name.lastIndexOf('.'); 51 if (dot == -1) return ""; 52 return name.substring(0, dot); 53 } 54 } 55 56 private static int constantPoolSize(byte[] classFile) { |