1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
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 *
560
561 Klass* Klass::array_klass_impl(bool or_null, int rank, TRAPS) {
562 fatal("array_klass should be dispatched to InstanceKlass, ObjArrayKlass or TypeArrayKlass");
563 return NULL;
564 }
565
566
567 Klass* Klass::array_klass_impl(bool or_null, TRAPS) {
568 fatal("array_klass should be dispatched to InstanceKlass, ObjArrayKlass or TypeArrayKlass");
569 return NULL;
570 }
571
572 oop Klass::class_loader() const { return class_loader_data()->class_loader(); }
573
574 // In product mode, this function doesn't have virtual function calls so
575 // there might be some performance advantage to handling InstanceKlass here.
576 const char* Klass::external_name() const {
577 if (is_instance_klass()) {
578 const InstanceKlass* ik = static_cast<const InstanceKlass*>(this);
579 if (ik->is_anonymous()) {
580 intptr_t hash = 0;
581 if (ik->java_mirror() != NULL) {
582 // java_mirror might not be created yet, return 0 as hash.
583 hash = ik->java_mirror()->identity_hash();
584 }
585 char hash_buf[40];
586 sprintf(hash_buf, "/" UINTX_FORMAT, (uintx)hash);
587 size_t hash_len = strlen(hash_buf);
588
589 size_t result_len = name()->utf8_length();
590 char* result = NEW_RESOURCE_ARRAY(char, result_len + hash_len + 1);
591 name()->as_klass_external_name(result, (int) result_len + 1);
592 assert(strlen(result) == result_len, "");
593 strcpy(result + result_len, hash_buf);
594 assert(strlen(result) == result_len + hash_len, "");
595 return result;
596 }
597 }
598 if (name() == NULL) return "<unknown>";
599 return name()->as_klass_external_name();
600 }
601
602
603 const char* Klass::signature_name() const {
604 if (name() == NULL) return "<unknown>";
605 return name()->as_C_string();
606 }
607
608 // Unless overridden, modifier_flags is 0.
609 jint Klass::compute_modifier_flags(TRAPS) const {
610 return 0;
611 }
612
613 int Klass::atomic_incr_biased_lock_revocation_count() {
614 return (int) Atomic::add(1, &_biased_lock_revocation_count);
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
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 *
560
561 Klass* Klass::array_klass_impl(bool or_null, int rank, TRAPS) {
562 fatal("array_klass should be dispatched to InstanceKlass, ObjArrayKlass or TypeArrayKlass");
563 return NULL;
564 }
565
566
567 Klass* Klass::array_klass_impl(bool or_null, TRAPS) {
568 fatal("array_klass should be dispatched to InstanceKlass, ObjArrayKlass or TypeArrayKlass");
569 return NULL;
570 }
571
572 oop Klass::class_loader() const { return class_loader_data()->class_loader(); }
573
574 // In product mode, this function doesn't have virtual function calls so
575 // there might be some performance advantage to handling InstanceKlass here.
576 const char* Klass::external_name() const {
577 if (is_instance_klass()) {
578 const InstanceKlass* ik = static_cast<const InstanceKlass*>(this);
579 if (ik->is_anonymous()) {
580 char addr_buf[20];
581 jio_snprintf(addr_buf, 20, "/" INTPTR_FORMAT, p2i(ik));
582 size_t addr_len = strlen(addr_buf);
583 size_t name_len = name()->utf8_length();
584 char* result = NEW_RESOURCE_ARRAY(char, name_len + addr_len + 1);
585 name()->as_klass_external_name(result, (int) name_len + 1);
586 assert(strlen(result) == name_len, "");
587 strcpy(result + name_len, addr_buf);
588 assert(strlen(result) == name_len + addr_len, "");
589 return result;
590 }
591 }
592 if (name() == NULL) return "<unknown>";
593 return name()->as_klass_external_name();
594 }
595
596
597 const char* Klass::signature_name() const {
598 if (name() == NULL) return "<unknown>";
599 return name()->as_C_string();
600 }
601
602 // Unless overridden, modifier_flags is 0.
603 jint Klass::compute_modifier_flags(TRAPS) const {
604 return 0;
605 }
606
607 int Klass::atomic_incr_biased_lock_revocation_count() {
608 return (int) Atomic::add(1, &_biased_lock_revocation_count);
|