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 *
23 */
24
25 #ifndef SHARE_VM_MEMORY_METADATAFACTORY_HPP
26 #define SHARE_VM_MEMORY_METADATAFACTORY_HPP
27
28 #include "utilities/array.hpp"
29 #include "utilities/exceptions.hpp"
30 #include "utilities/globalDefinitions.hpp"
31
32 class MetadataFactory : AllStatic {
33 public:
34 template <typename T>
35 static Array<T>* new_array(ClassLoaderData* loader_data, int length, TRAPS) {
36 // The "true" argument is because all metadata arrays are read only when
37 // dumped to the shared archive
38 return new (loader_data, length, /*read_only*/true, THREAD) Array<T>(length);
39 }
40
41 template <typename T>
42 static Array<T>* new_array(ClassLoaderData* loader_data, int length, T value, TRAPS) {
43 Array<T>* array = new_array<T>(loader_data, length, CHECK_NULL);
44 for (int i = 0; i < length; i++) {
45 array->at_put(i, value);
46 }
47 return array;
|
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 *
23 */
24
25 #ifndef SHARE_VM_MEMORY_METADATAFACTORY_HPP
26 #define SHARE_VM_MEMORY_METADATAFACTORY_HPP
27
28 #include "classfile/classLoaderData.hpp"
29 #include "utilities/array.hpp"
30 #include "utilities/exceptions.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33 class MetadataFactory : AllStatic {
34 public:
35 template <typename T>
36 static Array<T>* new_array(ClassLoaderData* loader_data, int length, TRAPS) {
37 // The "true" argument is because all metadata arrays are read only when
38 // dumped to the shared archive
39 return new (loader_data, length, /*read_only*/true, THREAD) Array<T>(length);
40 }
41
42 template <typename T>
43 static Array<T>* new_array(ClassLoaderData* loader_data, int length, T value, TRAPS) {
44 Array<T>* array = new_array<T>(loader_data, length, CHECK_NULL);
45 for (int i = 0; i < length; i++) {
46 array->at_put(i, value);
47 }
48 return array;
|