1879N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// The closure for GetLoadedClasses and GetClassLoaderClasses 0N/A // Since the SystemDictionary::classes_do callback 0N/A // doesn't pass a closureData pointer, 0N/A // we use a thread-local slot to hold a pointer to 0N/A // a stack allocated instance of this structure. 0N/A // Getting and setting the thread local pointer 0N/A // Public methods that get called within the scope of the closure 0N/A // Finally, the static methods that are the callbacks 0N/A // if initiating loader not null, just include the instance with 1 dimension 0N/A // if initiating loader not null, just include the instance with 1 dimension 0N/A // increment the count for the given basic type array class (and any 0N/A // multi-dimensional arrays). For example, for [B we check for 0N/A // [[B, [[[B, .. and the count is incremented for each one that exists. 0N/A // add the basic type array class and its multi-dimensional array classes to the list 0N/A // Since SystemDictionary::classes_do only takes a function pointer 0N/A // and doesn't call back with a closure data pointer, 0N/A // we can only pass static methods. 0N/A // To get a consistent list of classes we need MultiArray_lock to ensure 0N/A // array classes aren't created, and SystemDictionary_lock to ensure that 0N/A // classes aren't added to the system dictionary, 0N/A // First, count the classes 0N/A // Next, fill in the classes 0N/A // Drop the SystemDictionary_lock, so the results could be wrong from here, 0N/A // but we still have a snapshot. 0N/A // Since SystemDictionary::classes_do only takes a function pointer 0N/A // and doesn't call back with a closure data pointer, 0N/A // we can only pass static methods. 0N/A // To get a consistent list of classes we need MultiArray_lock to ensure 0N/A // array classes aren't created, and SystemDictionary_lock to ensure that 0N/A // classes aren't added to the system dictionary, 0N/A // First, count the classes in the system dictionary which have this loader recorded 0N/A // as an initiating loader. For basic type arrays this information is not recorded 0N/A // so GetClassLoaderClasses will return all of the basic type arrays. This is okay 0N/A // because the defining loader for basic type arrays is always the boot class loader 0N/A // and these classes are "visible" to all loaders. 0N/A // Next, fill in the classes 0N/A // Drop the SystemDictionary_lock, so the results could be wrong from here, 0N/A // but we still have a snapshot.