hotspot/src/share/vm/classfile/classFileParser.cpp
changeset 33799 77ebbd9b0ecc
parent 33612 b1487e78deee
child 34272 1b277b5ee6e3
equal deleted inserted replaced
33796:8745ee8ac1db 33799:77ebbd9b0ecc
    90 // - also used as the max version when running in jdk6
    90 // - also used as the max version when running in jdk6
    91 #define JAVA_6_VERSION                    50
    91 #define JAVA_6_VERSION                    50
    92 
    92 
    93 // Used for backward compatibility reasons:
    93 // Used for backward compatibility reasons:
    94 // - to check NameAndType_info signatures more aggressively
    94 // - to check NameAndType_info signatures more aggressively
       
    95 // - to disallow argument and require ACC_STATIC for <clinit> methods
    95 #define JAVA_7_VERSION                    51
    96 #define JAVA_7_VERSION                    51
    96 
    97 
    97 // Extension method support.
    98 // Extension method support.
    98 #define JAVA_8_VERSION                    52
    99 #define JAVA_8_VERSION                    52
    99 
   100 
  1995     if (_major_version < 51) { // backward compatibility
  1996     if (_major_version < 51) { // backward compatibility
  1996       flags = JVM_ACC_STATIC;
  1997       flags = JVM_ACC_STATIC;
  1997     } else if ((flags & JVM_ACC_STATIC) == JVM_ACC_STATIC) {
  1998     } else if ((flags & JVM_ACC_STATIC) == JVM_ACC_STATIC) {
  1998       flags &= JVM_ACC_STATIC | JVM_ACC_STRICT;
  1999       flags &= JVM_ACC_STATIC | JVM_ACC_STRICT;
  1999     } else {
  2000     } else {
  2000       // As of major_version 51, a method named <clinit> without ACC_STATIC is
  2001       classfile_parse_error("Method <clinit> is not static in class file %s", CHECK_(nullHandle));
  2001       // just another method. So, do a normal method modifer check.
       
  2002       verify_legal_method_modifiers(flags, is_interface, name, CHECK_(nullHandle));
       
  2003     }
  2002     }
  2004   } else {
  2003   } else {
  2005     verify_legal_method_modifiers(flags, is_interface, name, CHECK_(nullHandle));
  2004     verify_legal_method_modifiers(flags, is_interface, name, CHECK_(nullHandle));
  2006   }
  2005   }
  2007 
  2006 
  5157     // make sure caller's args_size will be less than 0 even for non-static
  5156     // make sure caller's args_size will be less than 0 even for non-static
  5158     // method so it will be recomputed in compute_size_of_parameters().
  5157     // method so it will be recomputed in compute_size_of_parameters().
  5159     return -2;
  5158     return -2;
  5160   }
  5159   }
  5161 
  5160 
       
  5161   // Class initializers cannot have args for class format version >= 51.
       
  5162   if (name == vmSymbols::class_initializer_name() &&
       
  5163       signature != vmSymbols::void_method_signature() &&
       
  5164       _major_version >= JAVA_7_VERSION) {
       
  5165     throwIllegalSignature("Method", name, signature, CHECK_0);
       
  5166     return 0;
       
  5167   }
       
  5168 
  5162   unsigned int args_size = 0;
  5169   unsigned int args_size = 0;
  5163   char buf[fixed_buffer_size];
  5170   char buf[fixed_buffer_size];
  5164   char* p = signature->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size);
  5171   char* p = signature->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size);
  5165   unsigned int length = signature->utf8_length();
  5172   unsigned int length = signature->utf8_length();
  5166   char* nextp;
  5173   char* nextp;
  5180       nextp = skip_over_field_signature(p, false, length, CHECK_0);
  5187       nextp = skip_over_field_signature(p, false, length, CHECK_0);
  5181     }
  5188     }
  5182     // The first non-signature thing better be a ')'
  5189     // The first non-signature thing better be a ')'
  5183     if ((length > 0) && (*p++ == JVM_SIGNATURE_ENDFUNC)) {
  5190     if ((length > 0) && (*p++ == JVM_SIGNATURE_ENDFUNC)) {
  5184       length--;
  5191       length--;
  5185       if (name == vmSymbols::object_initializer_name()) {
  5192       if (name->utf8_length() > 0 && name->byte_at(0) == '<') {
  5186         // All "<init>" methods must return void
  5193         // All internal methods must return void
  5187         if ((length == 1) && (p[0] == JVM_SIGNATURE_VOID)) {
  5194         if ((length == 1) && (p[0] == JVM_SIGNATURE_VOID)) {
  5188           return args_size;
  5195           return args_size;
  5189         }
  5196         }
  5190       } else {
  5197       } else {
  5191         // Now we better just have a return value
  5198         // Now we better just have a return value