coleenp@4037: /* coleenp@4037: * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. coleenp@4037: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. coleenp@4037: * coleenp@4037: * This code is free software; you can redistribute it and/or modify it coleenp@4037: * under the terms of the GNU General Public License version 2 only, as coleenp@4037: * published by the Free Software Foundation. coleenp@4037: * coleenp@4037: * This code is distributed in the hope that it will be useful, but WITHOUT coleenp@4037: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or coleenp@4037: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License coleenp@4037: * version 2 for more details (a copy is included in the LICENSE file that coleenp@4037: * accompanied this code). coleenp@4037: * coleenp@4037: * You should have received a copy of the GNU General Public License version coleenp@4037: * 2 along with this work; if not, write to the Free Software Foundation, coleenp@4037: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. coleenp@4037: * coleenp@4037: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA coleenp@4037: * or visit www.oracle.com if you need additional information or have any coleenp@4037: * questions. coleenp@4037: * coleenp@4037: */ coleenp@4037: coleenp@4037: #ifndef SHARE_VM_OOPS_METADATA_HPP coleenp@4037: #define SHARE_VM_OOPS_METADATA_HPP coleenp@4037: coleenp@4037: #include "utilities/exceptions.hpp" coleenp@4037: #include "utilities/globalDefinitions.hpp" coleenp@4037: #include "utilities/ostream.hpp" coleenp@4037: coleenp@4037: // This is the base class for an internal Class related metadata coleenp@4037: class Metadata : public MetaspaceObj { coleenp@4037: // Debugging hook to check that the metadata has not been deleted. coleenp@4037: NOT_PRODUCT(int _valid;) coleenp@4037: public: coleenp@4037: NOT_PRODUCT(Metadata() { _valid = 0; }) coleenp@4037: NOT_PRODUCT(bool is_valid() const volatile { return _valid == 0; }) coleenp@4037: coleenp@4037: int identity_hash() { return (int)(uintptr_t)this; } coleenp@4037: coleenp@4037: // Rehashing support for tables containing pointers to this coleenp@4037: unsigned int new_hash(jint seed) { ShouldNotReachHere(); return 0; } coleenp@4037: coleenp@4037: virtual bool is_klass() const volatile { return false; } coleenp@4037: virtual bool is_method() const volatile { return false; } coleenp@4037: virtual bool is_methodData() const volatile { return false; } coleenp@4037: virtual bool is_constantPool() const volatile { return false; } coleenp@4037: coleenp@4037: virtual const char* internal_name() const = 0; coleenp@4037: coleenp@4037: void print() const { print_on(tty); } coleenp@4037: void print_value() const { print_value_on(tty); } coleenp@4037: coleenp@4037: void print_maybe_null() const { print_on_maybe_null(tty); } coleenp@4037: void print_on_maybe_null(outputStream* st) const { coleenp@4037: if (this == NULL) coleenp@4037: st->print("NULL"); coleenp@4037: else coleenp@4037: print_on(tty); coleenp@4037: } coleenp@4037: void print_value_on_maybe_null(outputStream* st) const { coleenp@4037: if (this == NULL) coleenp@4037: st->print("NULL"); coleenp@4037: else coleenp@4037: print_value_on(tty); coleenp@4037: } coleenp@4037: coleenp@4037: virtual void print_on(outputStream* st) const; // First level print coleenp@4037: virtual void print_value_on(outputStream* st) const = 0; // Second level print coleenp@4037: coleenp@4037: char* print_value_string() const; coleenp@4037: coleenp@4037: // Used to keep metadata alive during class redefinition coleenp@4037: // Can't assert because is called for delete functions (as an assert) coleenp@4037: virtual bool on_stack() const { return false; } coleenp@4037: virtual void set_on_stack(const bool value); coleenp@4037: coleenp@4037: // Set on_stack bit, so that the metadata is not cleared coleenp@4037: // during class redefinition. This is a virtual call because only methods coleenp@4037: // and constant pools need to be set, but someday instanceKlasses might also. coleenp@4037: static void mark_on_stack(Metadata* m) { m->set_on_stack(true); } coleenp@4037: }; coleenp@4037: coleenp@4037: #endif // SHARE_VM_OOPS_METADATA_HPP