src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6845426 Sdiff src/share/vm/classfile

src/share/vm/classfile/classFileParser.cpp

Print this page
rev 2113 : 6845426: non-static <clinit> method with no args is called during the class initialization process
Summary: Only call <clinit> with ACC_STATIC for classfiles with version > 50
Reviewed-by:


1598   int flags = cfs->get_u2_fast();
1599   u2 name_index = cfs->get_u2_fast();
1600   int cp_size = cp->length();
1601   check_property(
1602     valid_cp_range(name_index, cp_size) &&
1603       cp->tag_at(name_index).is_utf8(),
1604     "Illegal constant pool index %u for method name in class file %s",
1605     name_index, CHECK_(nullHandle));
1606   Symbol*  name = cp->symbol_at(name_index);
1607   verify_legal_method_name(name, CHECK_(nullHandle));
1608 
1609   u2 signature_index = cfs->get_u2_fast();
1610   guarantee_property(
1611     valid_cp_range(signature_index, cp_size) &&
1612       cp->tag_at(signature_index).is_utf8(),
1613     "Illegal constant pool index %u for method signature in class file %s",
1614     signature_index, CHECK_(nullHandle));
1615   Symbol*  signature = cp->symbol_at(signature_index);
1616 
1617   AccessFlags access_flags;
1618   if (name == vmSymbols::class_initializer_name()) {
1619     // We ignore the access flags for a class initializer. (JVM Spec. p. 116)
1620     flags = JVM_ACC_STATIC;


1621   } else {
1622     verify_legal_method_modifiers(flags, is_interface, name, CHECK_(nullHandle));
1623   }
1624 
1625   int args_size = -1;  // only used when _need_verify is true
1626   if (_need_verify) {
1627     args_size = ((flags & JVM_ACC_STATIC) ? 0 : 1) +
1628                  verify_legal_method_signature(name, signature, CHECK_(nullHandle));
1629     if (args_size > MAX_ARGS_SIZE) {
1630       classfile_parse_error("Too many arguments in method signature in class file %s", CHECK_(nullHandle));
1631     }
1632   }
1633 
1634   access_flags.set_flags(flags & JVM_RECOGNIZED_METHOD_MODIFIERS);
1635 
1636   // Default values for code and exceptions attribute elements
1637   u2 max_stack = 0;
1638   u2 max_locals = 0;
1639   u4 code_length = 0;
1640   u1* code_start = 0;




1598   int flags = cfs->get_u2_fast();
1599   u2 name_index = cfs->get_u2_fast();
1600   int cp_size = cp->length();
1601   check_property(
1602     valid_cp_range(name_index, cp_size) &&
1603       cp->tag_at(name_index).is_utf8(),
1604     "Illegal constant pool index %u for method name in class file %s",
1605     name_index, CHECK_(nullHandle));
1606   Symbol*  name = cp->symbol_at(name_index);
1607   verify_legal_method_name(name, CHECK_(nullHandle));
1608 
1609   u2 signature_index = cfs->get_u2_fast();
1610   guarantee_property(
1611     valid_cp_range(signature_index, cp_size) &&
1612       cp->tag_at(signature_index).is_utf8(),
1613     "Illegal constant pool index %u for method signature in class file %s",
1614     signature_index, CHECK_(nullHandle));
1615   Symbol*  signature = cp->symbol_at(signature_index);
1616 
1617   AccessFlags access_flags;
1618   if (name == vmSymbols::class_initializer_name() &&
1619       (flags & JVM_ACC_STATIC) == JVM_ACC_STATIC) {
1620     // We ignore the other access flags for a valid class initializer.
1621     // (JVM Spec 2nd ed., chapter 4.6)
1622     flags &= JVM_ACC_STATIC | JVM_ACC_STRICT;
1623   } else {
1624     verify_legal_method_modifiers(flags, is_interface, name, CHECK_(nullHandle));
1625   }
1626 
1627   int args_size = -1;  // only used when _need_verify is true
1628   if (_need_verify) {
1629     args_size = ((flags & JVM_ACC_STATIC) ? 0 : 1) +
1630                  verify_legal_method_signature(name, signature, CHECK_(nullHandle));
1631     if (args_size > MAX_ARGS_SIZE) {
1632       classfile_parse_error("Too many arguments in method signature in class file %s", CHECK_(nullHandle));
1633     }
1634   }
1635 
1636   access_flags.set_flags(flags & JVM_RECOGNIZED_METHOD_MODIFIERS);
1637 
1638   // Default values for code and exceptions attribute elements
1639   u2 max_stack = 0;
1640   u2 max_locals = 0;
1641   u4 code_length = 0;
1642   u1* code_start = 0;


src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File