< prev index next >

src/hotspot/share/cds/classListWriter.cpp

Print this page
@@ -21,21 +21,24 @@
   * questions.
   *
   */
  
  #include "cds/cds_globals.hpp"
+ #include "cds/classListParser.hpp"
  #include "cds/classListWriter.hpp"
  #include "cds/lambdaFormInvokers.inline.hpp"
  #include "classfile/classFileStream.hpp"
  #include "classfile/classLoader.hpp"
  #include "classfile/classLoaderData.hpp"
  #include "classfile/classLoaderDataGraph.hpp"
  #include "classfile/moduleEntry.hpp"
+ #include "classfile/symbolTable.hpp"
  #include "classfile/systemDictionaryShared.hpp"
  #include "memory/resourceArea.hpp"
  #include "oops/constantPool.inline.hpp"
  #include "oops/instanceKlass.hpp"
+ #include "runtime/javaCalls.hpp"
  #include "runtime/mutexLocker.hpp"
  
  fileStream* ClassListWriter::_classlist_file = nullptr;
  
  void ClassListWriter::init() {

@@ -318,5 +321,52 @@
        }
      }
      stream->cr();
    }
  }
+ 
+ void ClassListWriter::write_loader_negative_lookup_cache_for(oop loader, const char* loader_type) {
+   TempNewSymbol method = SymbolTable::new_symbol("negativeLookupCacheContents");
+   TempNewSymbol signature = SymbolTable::new_symbol("()Ljava/lang/String;");
+ 
+   EXCEPTION_MARK;
+   HandleMark hm(THREAD);
+ 
+   JavaValue result(T_OBJECT);
+   JavaCalls::call_virtual(&result,
+                           Handle(THREAD, loader),
+                           loader->klass(),
+                           method,
+                           signature,
+                           CHECK);
+ 
+   if (HAS_PENDING_EXCEPTION) {
+     log_warning(cds)("Error during BuiltinClassLoader::negativeLookupCacheContents() call for %s loader", loader_type);
+     CLEAR_PENDING_EXCEPTION;
+     return;
+   } else if (result.get_oop() == nullptr) {
+     return;
+   }
+ 
+   ResourceMark rm;
+   const char* cache_contents = java_lang_String::as_utf8_string(result.get_oop());
+   log_debug(cds)("%s loader negative cache: %s", loader_type, cache_contents);
+ 
+   outputStream* stream = _classlist_file;
+   const size_t buffer_size = strlen(ClassListParser::LOADER_NEGATIVE_CACHE_TAG) + 1 /* for space*/
+                     + strlen(loader_type) + 1 /* for space */ + strlen(cache_contents) + 1 /* for null character */;
+   char* buffer = NEW_C_HEAP_ARRAY(char, buffer_size, mtInternal);
+   _classlist_file->set_scratch_buffer(buffer, buffer_size);
+   MutexLocker lock2(ClassListFile_lock, Mutex::_no_safepoint_check_flag);
+   stream->print("%s %s %s", ClassListParser::LOADER_NEGATIVE_CACHE_TAG, loader_type, cache_contents);
+   stream->cr();
+   _classlist_file->set_scratch_buffer(nullptr, 0);
+ }
+ 
+ void ClassListWriter::write_loader_negative_lookup_cache() {
+   if (!is_enabled()) {
+     return;
+   }
+ 
+   write_loader_negative_lookup_cache_for(SystemDictionary::java_platform_loader(), "platform");
+   write_loader_negative_lookup_cache_for(SystemDictionary::java_system_loader(), "app");
+ }
< prev index next >