--- old/src/share/vm/classfile/classFileParser.cpp 2017-02-14 09:36:09.886518410 -0500 +++ new/src/share/vm/classfile/classFileParser.cpp 2017-02-14 09:36:09.695971717 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -3052,7 +3052,21 @@ "Class is both outer and inner class in class file %s", CHECK_0); } // Access flags - jint flags = cfs->get_u2_fast() & RECOGNIZED_INNER_CLASS_MODIFIERS; + jint flags; + // Don't allow JVM_ACC_MODULE in JDK-9 and later. + if (_major_version >= JAVA_9_VERSION) { + flags = cfs->get_u2_fast() & (RECOGNIZED_INNER_CLASS_MODIFIERS | JVM_ACC_MODULE); + if (flags & JVM_ACC_MODULE) { + ResourceMark rm(THREAD); + Exceptions::fthrow( + THREAD_AND_LOCATION, + vmSymbols::java_lang_NoClassDefFoundError(), + "Illegal ACC_MODULE class modifier in class %s", + _class_name->as_C_string()); + } + } else { + flags = cfs->get_u2_fast() & RECOGNIZED_INNER_CLASS_MODIFIERS; + } if ((flags & JVM_ACC_INTERFACE) && _major_version < JAVA_6_VERSION) { // Set abstract bit for old class files for backward compatibility flags |= JVM_ACC_ABSTRACT; @@ -4532,14 +4546,14 @@ const bool is_super = (flags & JVM_ACC_SUPER) != 0; const bool is_enum = (flags & JVM_ACC_ENUM) != 0; const bool is_annotation = (flags & JVM_ACC_ANNOTATION) != 0; - const bool is_module_info= (flags & JVM_ACC_MODULE) != 0; + const bool is_module = (flags & JVM_ACC_MODULE) != 0; const bool major_gte_15 = _major_version >= JAVA_1_5_VERSION; + assert(!is_module, "JVM_ACC_MODULE should not be set"); if ((is_abstract && is_final) || (is_interface && !is_abstract) || (is_interface && major_gte_15 && (is_super || is_enum)) || - (!is_interface && major_gte_15 && is_annotation) || - is_module_info) { + (!is_interface && major_gte_15 && is_annotation)) { ResourceMark rm(THREAD); Exceptions::fthrow( THREAD_AND_LOCATION, @@ -5734,7 +5748,21 @@ stream->guarantee_more(8, CHECK); // flags, this_class, super_class, infs_len // Access flags - jint flags = stream->get_u2_fast() & JVM_RECOGNIZED_CLASS_MODIFIERS; + jint flags; + // Don't allow JVM_ACC_MODULE in JDK-9 and later. + if (_major_version >= JAVA_9_VERSION) { + flags = stream->get_u2_fast() & (JVM_RECOGNIZED_CLASS_MODIFIERS | JVM_ACC_MODULE); + if (flags & JVM_ACC_MODULE) { + ResourceMark rm(THREAD); + Exceptions::fthrow( + THREAD_AND_LOCATION, + vmSymbols::java_lang_NoClassDefFoundError(), + "Illegal ACC_MODULE class modifier in class %s", + _class_name->as_C_string()); + } + } else { + flags = stream->get_u2_fast() & JVM_RECOGNIZED_CLASS_MODIFIERS; + } if ((flags & JVM_ACC_INTERFACE) && _major_version < JAVA_6_VERSION) { // Set abstract bit for old class files for backward compatibility