src/hotspot/share/classfile/classFileParser.cpp
changeset 48355 4944950606ef
parent 48081 89829dd3cc54
child 48826 c4d9d1b08e2e
equal deleted inserted replaced
48354:c96d4c720995 48355:4944950606ef
    84 
    84 
    85 // We add assert in debug mode when class format is not checked.
    85 // We add assert in debug mode when class format is not checked.
    86 
    86 
    87 #define JAVA_CLASSFILE_MAGIC              0xCAFEBABE
    87 #define JAVA_CLASSFILE_MAGIC              0xCAFEBABE
    88 #define JAVA_MIN_SUPPORTED_VERSION        45
    88 #define JAVA_MIN_SUPPORTED_VERSION        45
    89 #define JAVA_MAX_SUPPORTED_VERSION        54
       
    90 #define JAVA_MAX_SUPPORTED_MINOR_VERSION  0
       
    91 
    89 
    92 // Used for two backward compatibility reasons:
    90 // Used for two backward compatibility reasons:
    93 // - to check for new additions to the class file format in JDK1.5
    91 // - to check for new additions to the class file format in JDK1.5
    94 // - to check for bug fixes in the format checker in JDK1.5
    92 // - to check for bug fixes in the format checker in JDK1.5
    95 #define JAVA_1_5_VERSION                  49
    93 #define JAVA_1_5_VERSION                  49
   107 #define JAVA_8_VERSION                    52
   105 #define JAVA_8_VERSION                    52
   108 
   106 
   109 #define JAVA_9_VERSION                    53
   107 #define JAVA_9_VERSION                    53
   110 
   108 
   111 #define JAVA_10_VERSION                   54
   109 #define JAVA_10_VERSION                   54
       
   110 
       
   111 #define JAVA_11_VERSION                   55
   112 
   112 
   113 void ClassFileParser::set_class_bad_constant_seen(short bad_constant) {
   113 void ClassFileParser::set_class_bad_constant_seen(short bad_constant) {
   114   assert((bad_constant == 19 || bad_constant == 20) && _major_version >= JAVA_9_VERSION,
   114   assert((bad_constant == 19 || bad_constant == 20) && _major_version >= JAVA_9_VERSION,
   115          "Unexpected bad constant pool entry");
   115          "Unexpected bad constant pool entry");
   116   if (_bad_constant_seen == 0) _bad_constant_seen = bad_constant;
   116   if (_bad_constant_seen == 0) _bad_constant_seen = bad_constant;
  4640           (is_public && is_private) ||
  4640           (is_public && is_private) ||
  4641           (is_protected && is_private));
  4641           (is_protected && is_private));
  4642 }
  4642 }
  4643 
  4643 
  4644 static bool is_supported_version(u2 major, u2 minor){
  4644 static bool is_supported_version(u2 major, u2 minor){
  4645   const u2 max_version = JAVA_MAX_SUPPORTED_VERSION;
  4645   const u2 max_version = JVM_CLASSFILE_MAJOR_VERSION;
  4646   return (major >= JAVA_MIN_SUPPORTED_VERSION) &&
  4646   return (major >= JAVA_MIN_SUPPORTED_VERSION) &&
  4647          (major <= max_version) &&
  4647          (major <= max_version) &&
  4648          ((major != max_version) ||
  4648          ((major != max_version) ||
  4649           (minor <= JAVA_MAX_SUPPORTED_MINOR_VERSION));
  4649           (minor <= JVM_CLASSFILE_MINOR_VERSION));
  4650 }
  4650 }
  4651 
  4651 
  4652 void ClassFileParser::verify_legal_field_modifiers(jint flags,
  4652 void ClassFileParser::verify_legal_field_modifiers(jint flags,
  4653                                                    bool is_interface,
  4653                                                    bool is_interface,
  4654                                                    TRAPS) const {
  4654                                                    TRAPS) const {
  5806       "%s has been compiled by a more recent version of the Java Runtime (class file version %u.%u), "
  5806       "%s has been compiled by a more recent version of the Java Runtime (class file version %u.%u), "
  5807       "this version of the Java Runtime only recognizes class file versions up to %u.%u",
  5807       "this version of the Java Runtime only recognizes class file versions up to %u.%u",
  5808       _class_name->as_C_string(),
  5808       _class_name->as_C_string(),
  5809       _major_version,
  5809       _major_version,
  5810       _minor_version,
  5810       _minor_version,
  5811       JAVA_MAX_SUPPORTED_VERSION,
  5811       JVM_CLASSFILE_MAJOR_VERSION,
  5812       JAVA_MAX_SUPPORTED_MINOR_VERSION);
  5812       JVM_CLASSFILE_MINOR_VERSION);
  5813     return;
  5813     return;
  5814   }
  5814   }
  5815 
  5815 
  5816   stream->guarantee_more(3, CHECK); // length, first cp tag
  5816   stream->guarantee_more(3, CHECK); // length, first cp tag
  5817   u2 cp_size = stream->get_u2_fast();
  5817   u2 cp_size = stream->get_u2_fast();