< prev index next >

src/hotspot/share/compiler/methodMatcher.cpp

Print this page


   1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 220     return MethodMatcher::Any;
 221   }
 222 
 223   if (strstr(name, "*") != NULL) {
 224     error_msg = " Embedded * not allowed";
 225     return MethodMatcher::Unknown;
 226   }
 227   return (MethodMatcher::Mode)match;
 228 }
 229 
 230 // Skip any leading spaces
 231 void skip_leading_spaces(char*& line, int* total_bytes_read ) {
 232   int bytes_read = 0;
 233   sscanf(line, "%*[ \t]%n", &bytes_read);
 234   if (bytes_read > 0) {
 235     line += bytes_read;
 236     *total_bytes_read += bytes_read;
 237   }
 238 }
 239 




 240 void MethodMatcher::parse_method_pattern(char*& line, const char*& error_msg, MethodMatcher* matcher) {
 241   MethodMatcher::Mode c_match;
 242   MethodMatcher::Mode m_match;
 243   char class_name[256] = {0};
 244   char method_name[256] = {0};
 245   char sig[1024] = {0};
 246   int bytes_read = 0;
 247   int total_bytes_read = 0;
 248 
 249   assert(error_msg == NULL, "Dont call here with error_msg already set");
 250 
 251   if (!MethodMatcher::canonicalize(line, error_msg)) {
 252     assert(error_msg != NULL, "Message must be set if parsing failed");
 253     return;
 254   }
 255 
 256   skip_leading_spaces(line, &total_bytes_read);
 257 
 258   if (2 == sscanf(line, "%255" RANGESLASH "%*[ ]" "%255"  RANGE0 "%n", class_name, method_name, &bytes_read)) {
 259     c_match = check_mode(class_name, error_msg);


 289       sig[0] = '(';
 290       // scan the rest
 291       if (1 == sscanf(line, "%1022[[);/" RANGEBASE "]%n", sig+1, &bytes_read)) {
 292         if (strchr(sig, '*') != NULL) {
 293           error_msg = " Wildcard * not allowed in signature";
 294           return;
 295         }
 296         line += bytes_read;
 297       }
 298       signature = SymbolTable::new_symbol(sig, CHECK);
 299     }
 300     Symbol* c_name = SymbolTable::new_symbol(class_name, CHECK);
 301     Symbol* m_name = SymbolTable::new_symbol(method_name, CHECK);
 302 
 303     matcher->init(c_name, c_match, m_name, m_match, signature);
 304     return;
 305   } else {
 306     error_msg = "Could not parse method pattern";
 307   }
 308 }



 309 
 310 bool MethodMatcher::matches(const methodHandle& method) const {
 311   Symbol* class_name  = method->method_holder()->name();
 312   Symbol* method_name = method->name();
 313   Symbol* signature = method->signature();
 314 
 315   if (match(class_name, this->class_name(), _class_mode) &&
 316       match(method_name, this->method_name(), _method_mode) &&
 317       ((this->signature() == NULL) || match(signature, this->signature(), Prefix))) {
 318     return true;
 319   }
 320   return false;
 321 }
 322 
 323 void MethodMatcher::print_symbol(outputStream* st, Symbol* h, Mode mode) {
 324   if (mode == Suffix || mode == Substring || mode == Any) {
 325     st->print("*");
 326   }
 327   if (mode != Any) {
 328     h->print_utf8_on(st);


   1 /*
   2  * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 220     return MethodMatcher::Any;
 221   }
 222 
 223   if (strstr(name, "*") != NULL) {
 224     error_msg = " Embedded * not allowed";
 225     return MethodMatcher::Unknown;
 226   }
 227   return (MethodMatcher::Mode)match;
 228 }
 229 
 230 // Skip any leading spaces
 231 void skip_leading_spaces(char*& line, int* total_bytes_read ) {
 232   int bytes_read = 0;
 233   sscanf(line, "%*[ \t]%n", &bytes_read);
 234   if (bytes_read > 0) {
 235     line += bytes_read;
 236     *total_bytes_read += bytes_read;
 237   }
 238 }
 239 
 240 #ifdef _MSC_VER
 241 #pragma warning(push)
 242 #pragma warning(disable : 4819)
 243 #endif
 244 void MethodMatcher::parse_method_pattern(char*& line, const char*& error_msg, MethodMatcher* matcher) {
 245   MethodMatcher::Mode c_match;
 246   MethodMatcher::Mode m_match;
 247   char class_name[256] = {0};
 248   char method_name[256] = {0};
 249   char sig[1024] = {0};
 250   int bytes_read = 0;
 251   int total_bytes_read = 0;
 252 
 253   assert(error_msg == NULL, "Dont call here with error_msg already set");
 254 
 255   if (!MethodMatcher::canonicalize(line, error_msg)) {
 256     assert(error_msg != NULL, "Message must be set if parsing failed");
 257     return;
 258   }
 259 
 260   skip_leading_spaces(line, &total_bytes_read);
 261 
 262   if (2 == sscanf(line, "%255" RANGESLASH "%*[ ]" "%255"  RANGE0 "%n", class_name, method_name, &bytes_read)) {
 263     c_match = check_mode(class_name, error_msg);


 293       sig[0] = '(';
 294       // scan the rest
 295       if (1 == sscanf(line, "%1022[[);/" RANGEBASE "]%n", sig+1, &bytes_read)) {
 296         if (strchr(sig, '*') != NULL) {
 297           error_msg = " Wildcard * not allowed in signature";
 298           return;
 299         }
 300         line += bytes_read;
 301       }
 302       signature = SymbolTable::new_symbol(sig, CHECK);
 303     }
 304     Symbol* c_name = SymbolTable::new_symbol(class_name, CHECK);
 305     Symbol* m_name = SymbolTable::new_symbol(method_name, CHECK);
 306 
 307     matcher->init(c_name, c_match, m_name, m_match, signature);
 308     return;
 309   } else {
 310     error_msg = "Could not parse method pattern";
 311   }
 312 }
 313 #ifdef _MSC_VER
 314 #pragma warning(pop)
 315 #endif
 316 
 317 bool MethodMatcher::matches(const methodHandle& method) const {
 318   Symbol* class_name  = method->method_holder()->name();
 319   Symbol* method_name = method->name();
 320   Symbol* signature = method->signature();
 321 
 322   if (match(class_name, this->class_name(), _class_mode) &&
 323       match(method_name, this->method_name(), _method_mode) &&
 324       ((this->signature() == NULL) || match(signature, this->signature(), Prefix))) {
 325     return true;
 326   }
 327   return false;
 328 }
 329 
 330 void MethodMatcher::print_symbol(outputStream* st, Symbol* h, Mode mode) {
 331   if (mode == Suffix || mode == Substring || mode == Any) {
 332     st->print("*");
 333   }
 334   if (mode != Any) {
 335     h->print_utf8_on(st);


< prev index next >