Path: blob/master/test/hotspot/jtreg/runtime/AccModule/ACCModule52.java
40942 views
/*1* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import jdk.internal.org.objectweb.asm.*;2425/*26* @test27* @summary Test that the JVM ignores ACC_MODULE if it is set for a version28* 52 class file.29* @bug 817538330* @library /test/lib31* @modules java.base/jdk.internal.org.objectweb.asm32* @compile -XDignore.symbol.file ACCModule52.java33* @run main ACCModule5234*/3536public class ACCModule52 {3738static final String CLASS_NAME = "ACCModule52Pkg";3940public static void main(String[] args) throws Exception {41int ACC_MODULE = 0x8000;42ClassWriter cw = new ClassWriter(0);43cw.visit(Opcodes.V1_8,44Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,45CLASS_NAME,46null,47"java/lang/Object",48null);4950cw.visitEnd();51byte[] bytes = cw.toByteArray();525354ClassLoader loader = new ClassLoader(ACCModule52.class.getClassLoader()) {55@Override56protected Class<?> findClass(String cn)throws ClassNotFoundException {57if (cn.equals(CLASS_NAME)) {58Class superClass = super.defineClass(cn, bytes, 0, bytes.length);59} else {60throw new ClassNotFoundException(cn);61}62return null;63}64};6566Class<?> clazz = loader.loadClass(CLASS_NAME);67}68}697071