< prev index next >

src/hotspot/share/memory/allocation.cpp

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

@@ -83,10 +83,18 @@
                                   MetaspaceObj::Type type) throw() {
    assert(!Thread::current()->is_Java_thread(), "only allowed by non-Java thread");
    return Metaspace::allocate(loader_data, word_size, type);
  }
  
+ 
+ // Work-around -- see JDK-8331086
+ void* MetaspaceObj::operator new(size_t size, MEMFLAGS flags) throw() {
+   void* p = AllocateHeap(size, flags, CALLER_PC);
+   memset(p, 0, size);
+   return p;
+ }
+ 
  bool MetaspaceObj::is_valid(const MetaspaceObj* p) {
    // Weed out obvious bogus values first without traversing metaspace
    if ((size_t)p < os::min_page_size()) {
      return false;
    } else if (!is_aligned((address)p, sizeof(MetaWord))) {
< prev index next >