1 /* 2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 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 import jdk.internal.org.objectweb.asm.*; 25 26 /* 27 * @test 28 * @summary Test that the JVM ignores ACC_MODULE if it is set for a version 29 * 52 class file. 30 * @bug 8175383 31 * @library /test/lib 32 * @modules java.base/jdk.internal.org.objectweb.asm 33 * @compile -XDignore.symbol.file ACCModule52.java 34 * @run main ACCModule52 35 */ 36 37 public class ACCModule52 { 38 39 static final String CLASS_NAME = "ACCModule52Pkg"; 40 41 public static void main(String[] args) throws Exception { 42 int ACC_MODULE = 0x8000; 43 ClassWriter cw = new ClassWriter(0); 44 cw.visit(Opcodes.V1_8, 45 Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE, 46 CLASS_NAME, 47 null, 48 "java/lang/Object", 49 null); 50 51 cw.visitEnd(); 52 byte[] bytes = cw.toByteArray(); 53 54 55 ClassLoader loader = new ClassLoader(ACCModule52.class.getClassLoader()) { 56 @Override 57 protected Class<?> findClass(String cn)throws ClassNotFoundException { 58 if (cn.equals(CLASS_NAME)) { 59 Class superClass = super.defineClass(cn, bytes, 0, bytes.length); 60 } else { 61 throw new ClassNotFoundException(cn); 62 } 63 return null; 64 } 65 }; 66 67 Class<?> clazz = loader.loadClass(CLASS_NAME); 68 } 69 }