src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java
changeset 58836 31ec3e55fa3d
parent 52334 a181612f0715
child 58837 2bfbb50dd97d
child 58863 c16ac7a2eba4
equal deleted inserted replaced
58831:b026a43e1809 58836:31ec3e55fa3d
     1 /*
     1 /*
     2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
     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.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   253 
   253 
   254     synchronized void setStaleMetadata() {
   254     synchronized void setStaleMetadata() {
   255         staleMetadata = true;
   255         staleMetadata = true;
   256     }
   256     }
   257 
   257 
   258     // Lock around setOutput ensures that other threads dosn't
   258     // Lock around setOutput ensures that other threads don't
   259     // emit event after setOutput and unregister the event class, before a call
   259     // emit events after setOutput and unregister the event class, before a call
   260     // to storeDescriptorInJVM
   260     // to storeDescriptorInJVM
   261     synchronized void setOutput(String filename) {
   261     synchronized void setOutput(String filename) {
       
   262         if (staleMetadata) {
       
   263             storeDescriptorInJVM();
       
   264         }
   262         jvm.setOutput(filename);
   265         jvm.setOutput(filename);
   263 
   266 
   264         unregisterUnloaded();
   267         unregisterUnloaded();
   265         if (unregistered) {
   268         if (unregistered) {
   266             staleMetadata = typeLibrary.clearUnregistered();
   269             if (typeLibrary.clearUnregistered()) {
       
   270                 storeDescriptorInJVM();
       
   271             }
   267             unregistered = false;
   272             unregistered = false;
   268         }
       
   269         if (staleMetadata) {
       
   270             storeDescriptorInJVM();
       
   271         }
   273         }
   272     }
   274     }
   273 
   275 
   274     private void unregisterUnloaded() {
   276     private void unregisterUnloaded() {
   275         long unloaded = jvm.getUnloadedEventClassCount();
   277         long unloaded = jvm.getUnloadedEventClassCount();