src/hotspot/share/classfile/javaAssertions.cpp
changeset 58722 cba8afa5cfed
parent 49036 bc92debe57e4
equal deleted inserted replaced
58720:ae0af9fb3dbb 58722:cba8afa5cfed
    77   // when copying to java in createJavaAssertionStatusDirectives, but that
    77   // when copying to java in createJavaAssertionStatusDirectives, but that
    78   // should happen only once.  Alternative would require that
    78   // should happen only once.  Alternative would require that
    79   // JVM_DesiredAssertionStatus pass the external_name() to
    79   // JVM_DesiredAssertionStatus pass the external_name() to
    80   // JavaAssertion::enabled(), but that is done once per loaded class.
    80   // JavaAssertion::enabled(), but that is done once per loaded class.
    81   for (int i = 0; i < len; ++i) {
    81   for (int i = 0; i < len; ++i) {
    82     if (name_copy[i] == '.') name_copy[i] = '/';
    82     if (name_copy[i] == JVM_SIGNATURE_DOT) name_copy[i] = JVM_SIGNATURE_SLASH;
    83   }
    83   }
    84 
    84 
    85   if (TraceJavaAssertions) {
    85   if (TraceJavaAssertions) {
    86     tty->print_cr("JavaAssertions: adding %s %s=%d",
    86     tty->print_cr("JavaAssertions: adding %s %s=%d",
    87       head == &_classes ? "class" : "package",
    87       head == &_classes ? "class" : "package",
   133   // it was created by prepending successive items from the command line).
   133   // it was created by prepending successive items from the command line).
   134   int index;
   134   int index;
   135   for (index = len - 1; p != 0; p = p->next(), --index) {
   135   for (index = len - 1; p != 0; p = p->next(), --index) {
   136     assert(index >= 0, "length does not match list");
   136     assert(index >= 0, "length does not match list");
   137     Handle s = java_lang_String::create_from_str(p->name(), CHECK);
   137     Handle s = java_lang_String::create_from_str(p->name(), CHECK);
   138     s = java_lang_String::char_converter(s, '/', '.', CHECK);
   138     s = java_lang_String::char_converter(s, JVM_SIGNATURE_SLASH, JVM_SIGNATURE_DOT, CHECK);
   139     names->obj_at_put(index, s());
   139     names->obj_at_put(index, s());
   140     enabled->bool_at_put(index, p->enabled());
   140     enabled->bool_at_put(index, p->enabled());
   141   }
   141   }
   142   assert(index == -1, "length does not match list");
   142   assert(index == -1, "length does not match list");
   143 }
   143 }
   161 
   161 
   162   // Find the length of the "most-specific" package in classname.  If classname
   162   // Find the length of the "most-specific" package in classname.  If classname
   163   // does not include a package, length will be 0 which will match items for the
   163   // does not include a package, length will be 0 which will match items for the
   164   // default package (from options "-ea:..."  or "-da:...").
   164   // default package (from options "-ea:..."  or "-da:...").
   165   size_t len = strlen(classname);
   165   size_t len = strlen(classname);
   166   for (/* empty */; len > 0 && classname[len] != '/'; --len) /* empty */;
   166   for (/* empty */; len > 0 && classname[len] != JVM_SIGNATURE_SLASH; --len) /* empty */;
   167 
   167 
   168   do {
   168   do {
   169     assert(len == 0 || classname[len] == '/', "not a package name");
   169     assert(len == 0 || classname[len] == JVM_SIGNATURE_SLASH, "not a package name");
   170     for (OptionList* p = _packages; p != 0; p = p->next()) {
   170     for (OptionList* p = _packages; p != 0; p = p->next()) {
   171       if (strncmp(p->name(), classname, len) == 0 && p->name()[len] == '\0') {
   171       if (strncmp(p->name(), classname, len) == 0 && p->name()[len] == '\0') {
   172         return p;
   172         return p;
   173       }
   173       }
   174     }
   174     }
   175 
   175 
   176     // Find the length of the next package, taking care to avoid decrementing
   176     // Find the length of the next package, taking care to avoid decrementing
   177     // past 0 (len is unsigned).
   177     // past 0 (len is unsigned).
   178     while (len > 0 && classname[--len] != '/') /* empty */;
   178     while (len > 0 && classname[--len] != JVM_SIGNATURE_SLASH) /* empty */;
   179   } while (len > 0);
   179   } while (len > 0);
   180 
   180 
   181   return 0;
   181   return 0;
   182 }
   182 }
   183 
   183