src/hotspot/share/classfile/classFileParser.cpp
changeset 53768 5f02b8c98b35
parent 53745 a535ba736cab
child 53882 ca682d9d8db5
equal deleted inserted replaced
53767:f940579715a5 53768:5f02b8c98b35
  5018     }
  5018     }
  5019   }
  5019   }
  5020   return true;
  5020   return true;
  5021 }
  5021 }
  5022 
  5022 
  5023 // Take pointer to a string. Skip over the longest part of the string that could
  5023 // Take pointer to a UTF8 byte string (not NUL-terminated).
       
  5024 // Skip over the longest part of the string that could
  5024 // be taken as a fieldname. Allow '/' if slash_ok is true.
  5025 // be taken as a fieldname. Allow '/' if slash_ok is true.
  5025 // Return a pointer to just past the fieldname.
  5026 // Return a pointer to just past the fieldname.
  5026 // Return NULL if no fieldname at all was found, or in the case of slash_ok
  5027 // Return NULL if no fieldname at all was found, or in the case of slash_ok
  5027 // being true, we saw consecutive slashes (meaning we were looking for a
  5028 // being true, we saw consecutive slashes (meaning we were looking for a
  5028 // qualified path but found something that was badly-formed).
  5029 // qualified path but found something that was badly-formed).
  5096     return (not_first_ch) ? old_p : NULL;
  5097     return (not_first_ch) ? old_p : NULL;
  5097   }
  5098   }
  5098   return (not_first_ch) ? p : NULL;
  5099   return (not_first_ch) ? p : NULL;
  5099 }
  5100 }
  5100 
  5101 
  5101 // Take pointer to a string. Skip over the longest part of the string that could
  5102 // Take pointer to a UTF8 byte string (not NUL-terminated).
       
  5103 // Skip over the longest part of the string that could
  5102 // be taken as a field signature. Allow "void" if void_ok.
  5104 // be taken as a field signature. Allow "void" if void_ok.
  5103 // Return a pointer to just past the signature.
  5105 // Return a pointer to just past the signature.
  5104 // Return NULL if no legal signature is found.
  5106 // Return NULL if no legal signature is found.
  5105 const char* ClassFileParser::skip_over_field_signature(const char* signature,
  5107 const char* ClassFileParser::skip_over_field_signature(const char* signature,
  5106                                                        bool void_ok,
  5108                                                        bool void_ok,
  5130         }
  5132         }
  5131       }
  5133       }
  5132       else {
  5134       else {
  5133         // Skip leading 'L' and ignore first appearance of ';'
  5135         // Skip leading 'L' and ignore first appearance of ';'
  5134         signature++;
  5136         signature++;
  5135         char* c = strchr((char*) signature, ';');
  5137         const char* c = (const char*) memchr(signature, ';', length - 1);
  5136         // Format check signature
  5138         // Format check signature
  5137         if (c != NULL) {
  5139         if (c != NULL) {
  5138           int newlen = c - (char*) signature;
  5140           int newlen = c - (char*) signature;
  5139           bool legal = verify_unqualified_name(signature, newlen, LegalClass);
  5141           bool legal = verify_unqualified_name(signature, newlen, LegalClass);
  5140           if (!legal) {
  5142           if (!legal) {
  5197     ResourceMark rm(THREAD);
  5199     ResourceMark rm(THREAD);
  5198     assert(_class_name != NULL, "invariant");
  5200     assert(_class_name != NULL, "invariant");
  5199     Exceptions::fthrow(
  5201     Exceptions::fthrow(
  5200       THREAD_AND_LOCATION,
  5202       THREAD_AND_LOCATION,
  5201       vmSymbols::java_lang_ClassFormatError(),
  5203       vmSymbols::java_lang_ClassFormatError(),
  5202       "Illegal class name \"%s\" in class file %s", bytes,
  5204       "Illegal class name \"%.*s\" in class file %s", length, bytes,
  5203       _class_name->as_C_string()
  5205       _class_name->as_C_string()
  5204     );
  5206     );
  5205     return;
  5207     return;
  5206   }
  5208   }
  5207 }
  5209 }
  5230     ResourceMark rm(THREAD);
  5232     ResourceMark rm(THREAD);
  5231     assert(_class_name != NULL, "invariant");
  5233     assert(_class_name != NULL, "invariant");
  5232     Exceptions::fthrow(
  5234     Exceptions::fthrow(
  5233       THREAD_AND_LOCATION,
  5235       THREAD_AND_LOCATION,
  5234       vmSymbols::java_lang_ClassFormatError(),
  5236       vmSymbols::java_lang_ClassFormatError(),
  5235       "Illegal field name \"%s\" in class %s", bytes,
  5237       "Illegal field name \"%.*s\" in class %s", length, bytes,
  5236       _class_name->as_C_string()
  5238       _class_name->as_C_string()
  5237     );
  5239     );
  5238     return;
  5240     return;
  5239   }
  5241   }
  5240 }
  5242 }
  5267     ResourceMark rm(THREAD);
  5269     ResourceMark rm(THREAD);
  5268     assert(_class_name != NULL, "invariant");
  5270     assert(_class_name != NULL, "invariant");
  5269     Exceptions::fthrow(
  5271     Exceptions::fthrow(
  5270       THREAD_AND_LOCATION,
  5272       THREAD_AND_LOCATION,
  5271       vmSymbols::java_lang_ClassFormatError(),
  5273       vmSymbols::java_lang_ClassFormatError(),
  5272       "Illegal method name \"%s\" in class %s", bytes,
  5274       "Illegal method name \"%.*s\" in class %s", length, bytes,
  5273       _class_name->as_C_string()
  5275       _class_name->as_C_string()
  5274     );
  5276     );
  5275     return;
  5277     return;
  5276   }
  5278   }
  5277 }
  5279 }