src/share/vm/compiler/compilerOracle.cpp

Print this page
rev 6074 : 8036122: Fix warning 'format not a string literal'


 357   tty->print_cr("  exclude java/lang/StringBuffer.append");
 358   tty->print_cr("  compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;");
 359   tty->print_cr("  exclude java/lang/String*.*");
 360   tty->print_cr("  exclude *.toString");
 361 }
 362 
 363 
 364 // The characters allowed in a class or method name.  All characters > 0x7f
 365 // are allowed in order to handle obfuscated class files (e.g. Volano)
 366 #define RANGEBASE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_<>" \
 367         "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \
 368         "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \
 369         "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \
 370         "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \
 371         "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \
 372         "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \
 373         "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \
 374         "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
 375 
 376 #define RANGE0 "[*" RANGEBASE "]"
 377 #define RANGEDOT "[*" RANGEBASE ".]"
 378 #define RANGESLASH "[*" RANGEBASE "/]"
 379 
 380 
 381 // Accept several syntaxes for these patterns
 382 //  original syntax
 383 //   cmd  java.lang.String foo
 384 //  PrintCompilation syntax
 385 //   cmd  java.lang.String::foo
 386 //  VM syntax
 387 //   cmd  java/lang/String[. ]foo
 388 //
 389 
 390 static const char* patterns[] = {
 391   "%*[ \t]%255" RANGEDOT    " "     "%255"  RANGE0 "%n",
 392   "%*[ \t]%255" RANGEDOT   "::"     "%255"  RANGE0 "%n",
 393   "%*[ \t]%255" RANGESLASH "%*[ .]" "%255"  RANGE0 "%n",
 394 };
 395 
 396 static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
 397   int match = MethodMatcher::Exact;
 398   while (name[0] == '*') {
 399     match |= MethodMatcher::Suffix;
 400     strcpy(name, name + 1);
 401   }
 402 
 403   if (strcmp(name, "*") == 0) return MethodMatcher::Any;
 404 
 405   size_t len = strlen(name);
 406   while (len > 0 && name[len - 1] == '*') {
 407     match |= MethodMatcher::Prefix;
 408     name[--len] = '\0';
 409   }
 410 
 411   if (strstr(name, "*") != NULL) {
 412     error_msg = "  Embedded * not allowed";
 413     return MethodMatcher::Unknown;
 414   }
 415   return (MethodMatcher::Mode)match;
 416 }
 417 
 418 static bool scan_line(const char * line,
 419                       char class_name[],  MethodMatcher::Mode* c_mode,
 420                       char method_name[], MethodMatcher::Mode* m_mode,
 421                       int* bytes_read, const char*& error_msg) {
 422   *bytes_read = 0;
 423   error_msg = NULL;
 424   for (uint i = 0; i < ARRAY_SIZE(patterns); i++) {
 425     if (2 == sscanf(line, patterns[i], class_name, method_name, bytes_read)) {
 426       *c_mode = check_mode(class_name, error_msg);
 427       *m_mode = check_mode(method_name, error_msg);
 428       return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown;
 429     }
 430   }
 431   return false;
 432 }
 433 
 434 
 435 
 436 void CompilerOracle::parse_from_line(char* line) {
 437   if (line[0] == '\0') return;
 438   if (line[0] == '#')  return;
 439 
 440   bool have_colon = (strstr(line, "::") != NULL);
 441   for (char* lp = line; *lp != '\0'; lp++) {
 442     // Allow '.' to separate the class name from the method name.
 443     // This is the preferred spelling of methods:
 444     //      exclude java/lang/String.indexOf(I)I
 445     // Allow ',' for spaces (eases command line quoting).
 446     //      exclude,java/lang/String.indexOf
 447     // For backward compatibility, allow space as separator also.
 448     //      exclude java/lang/String indexOf
 449     //      exclude,java/lang/String,indexOf
 450     // For easy cut-and-paste of method names, allow VM output format




 357   tty->print_cr("  exclude java/lang/StringBuffer.append");
 358   tty->print_cr("  compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;");
 359   tty->print_cr("  exclude java/lang/String*.*");
 360   tty->print_cr("  exclude *.toString");
 361 }
 362 
 363 
 364 // The characters allowed in a class or method name.  All characters > 0x7f
 365 // are allowed in order to handle obfuscated class files (e.g. Volano)
 366 #define RANGEBASE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_<>" \
 367         "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \
 368         "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \
 369         "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \
 370         "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \
 371         "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \
 372         "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \
 373         "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \
 374         "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
 375 
 376 #define RANGE0 "[*" RANGEBASE "]"

 377 #define RANGESLASH "[*" RANGEBASE "/]"
 378 
















 379 static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
 380   int match = MethodMatcher::Exact;
 381   while (name[0] == '*') {
 382     match |= MethodMatcher::Suffix;
 383     strcpy(name, name + 1);
 384   }
 385 
 386   if (strcmp(name, "*") == 0) return MethodMatcher::Any;
 387 
 388   size_t len = strlen(name);
 389   while (len > 0 && name[len - 1] == '*') {
 390     match |= MethodMatcher::Prefix;
 391     name[--len] = '\0';
 392   }
 393 
 394   if (strstr(name, "*") != NULL) {
 395     error_msg = "  Embedded * not allowed";
 396     return MethodMatcher::Unknown;
 397   }
 398   return (MethodMatcher::Mode)match;
 399 }
 400 
 401 static bool scan_line(const char * line,
 402                       char class_name[],  MethodMatcher::Mode* c_mode,
 403                       char method_name[], MethodMatcher::Mode* m_mode,
 404                       int* bytes_read, const char*& error_msg) {
 405   *bytes_read = 0;
 406   error_msg = NULL;
 407   if (2 == sscanf(line, "%*[ \t]%255" RANGESLASH "%*[ ]" "%255"  RANGE0 "%n", class_name, method_name, bytes_read)) {

 408     *c_mode = check_mode(class_name, error_msg);
 409     *m_mode = check_mode(method_name, error_msg);
 410     return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown;
 411   }

 412   return false;
 413 }
 414 
 415 
 416 
 417 void CompilerOracle::parse_from_line(char* line) {
 418   if (line[0] == '\0') return;
 419   if (line[0] == '#')  return;
 420 
 421   bool have_colon = (strstr(line, "::") != NULL);
 422   for (char* lp = line; *lp != '\0'; lp++) {
 423     // Allow '.' to separate the class name from the method name.
 424     // This is the preferred spelling of methods:
 425     //      exclude java/lang/String.indexOf(I)I
 426     // Allow ',' for spaces (eases command line quoting).
 427     //      exclude,java/lang/String.indexOf
 428     // For backward compatibility, allow space as separator also.
 429     //      exclude java/lang/String indexOf
 430     //      exclude,java/lang/String,indexOf
 431     // For easy cut-and-paste of method names, allow VM output format