src/hotspot/share/oops/reflectionAccessorImplKlassHelper.cpp
author coleenp
Wed, 24 Jul 2019 10:22:11 -0400
changeset 57511 00ae3b739184
parent 53838 c8c9bd65c198
permissions -rw-r--r--
8228485: JVM crashes when bootstrap method for condy triggers loading of class whose static initializer throws exception Summary: Add case for JVM_CONSTANT_Dynamic in error_message function. Reviewed-by: dholmes, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50572
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
     1
/*
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
     3
 * Copyright (c) 2018, SAP SE. All rights reserved.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
     5
 *
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
     8
 * published by the Free Software Foundation.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
     9
 *
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    14
 * accompanied this code).
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    15
 *
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    19
 *
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    22
 * questions.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    23
 *
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    24
 */
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    25
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    26
#include "precompiled.hpp"
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    27
#include "classfile/systemDictionary.hpp"
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    28
#include "memory/resourceArea.hpp"
53838
c8c9bd65c198 8219229: Make ConstantPool::tag_at and release_tag_at_put inlineable
redestad
parents: 50572
diff changeset
    29
#include "oops/constantPool.hpp"
50572
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    30
#include "oops/reflectionAccessorImplKlassHelper.hpp"
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    31
#include "utilities/constantTag.hpp"
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    32
#include "utilities/debug.hpp"
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    33
#include "utilities/globalDefinitions.hpp"
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    34
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    35
// This code extracts name of target class, method and signature from the constant pool of a class
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    36
// assumed to be of type jdk/internal/reflect/Generated{SerializationConstructor|Constructor|Method}AccessorXXX.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    37
// Since this may be affected by bitrot if these classes change, extra care is taken to make the
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    38
// release build of this coding robust.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    39
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    40
// We extract target class name, method name and sig from the constant pool of the Accessor class.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    41
// This is an excerpt of the Constant pool (see jdk/internal/reflect/MethodAccessorGenerator.java:)
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    42
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    43
// (^  = Only present if generating SerializationConstructorAccessor)
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    44
// 1    [UTF-8] [This class's name]
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    45
// 2    [CONSTANT_Class_info] for above
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    46
// 3    [UTF-8] "jdk/internal/reflect/{MethodAccessorImpl,ConstructorAccessorImpl,SerializationConstructorAccessorImpl}"
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    47
// 4    [CONSTANT_Class_info] for above
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    48
// 5    [UTF-8] [Target class's name]
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    49
// 6    [CONSTANT_Class_info] for above
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    50
// 7^   [UTF-8] [Serialization: Class's name in which to invoke constructor]
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    51
// 8^   [CONSTANT_Class_info] for above
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    52
// 9    [UTF-8] target method or constructor name
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    53
// 10   [UTF-8] target method or constructor signature
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    54
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    55
// Note that these strings are found at slightly different slots depending on the class type:
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    56
// - MethodAccessorImpl, ConstructoreAccessorImpl: slots 5, 7 and 8.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    57
// - SerializationConstructorAccessorImpl: slots 5, 9 and 10.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    58
// Unfortunately SerializationConstructorAccessorImpl is a child of ConstructoreAccessorImpl and there
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    59
//  is no easy way to tell them apart. So we examine parent class name.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    60
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    61
enum cpi_slots {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    62
  cpi_slot_parent_class_name = 3,
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    63
  cpi_slot_target_class_name = 5,
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    64
  cpi_slot_target_method_name = 7,
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    65
  cpi_slot_target_method_name_sca = 9, // SerializationConstructorAccessor case, see above
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    66
  cpi_slot_target_method_sig = 8,
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    67
  cpi_slot_target_method_sig_sca = 10  // SerializationConstructorAccessor case, see above
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    68
};
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    69
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    70
// Returns a string, resource-area allocated, from an UTF8 slot in the constant pool in the
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    71
// given Klass*.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    72
static const char* get_string_from_cp_with_checks(const InstanceKlass* k, int cpi) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    73
  const char* s = NULL;
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    74
  const ConstantPool* const cp = k->constants();
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    75
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    76
  assert(cp != NULL, "No cp?");
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    77
  assert(cp->is_within_bounds(cpi), "Unexpected constant pool layout for \"%s\", child class of Generated{Method|Constructor}AccessorImplXXX"
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    78
         " (cpi %d out of bounds for [0..%d)).", k->external_name(), cpi, cp->length());
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    79
  assert(cp->tag_at(cpi).is_utf8(), "Unexpected constant pool layout for \"%s\", child class of Generated{Method|Constructor}AccessorImplXXX"
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    80
         " (no UTF8 at cpi %d (%u)).", k->external_name(), cpi, cp->tag_at(cpi).value());
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    81
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    82
  // Be nice in release: lets not crash, just return NULL.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    83
  if (cp != NULL && cp->is_within_bounds(cpi) && cp->tag_at(cpi).is_utf8()) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    84
    s = cp->symbol_at(cpi)->as_C_string();
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    85
  }
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    86
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    87
  return s;
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    88
}
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    89
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    90
// helper, returns true if class name of given class matches a given prefix
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    91
static bool classname_matches_prefix(const Klass* k, const char* prefix) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    92
  const char* classname = k->external_name();
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    93
  if (classname != NULL) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    94
    if (::strncmp(classname, prefix, strlen(prefix)) == 0) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    95
      return true;
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    96
    }
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    97
  }
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    98
  return false;
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
    99
}
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   100
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   101
// Returns true if k is of type jdk/internal/reflect/GeneratedMethodAccessorXXX.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   102
bool ReflectionAccessorImplKlassHelper::is_generated_method_accessor(const InstanceKlass* k) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   103
  return k->super() == SystemDictionary::reflect_MethodAccessorImpl_klass() &&
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   104
         classname_matches_prefix(k, "jdk.internal.reflect.GeneratedMethodAccessor");
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   105
}
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   106
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   107
// Returns true if k is of type jdk/internal/reflect/GeneratedConstructorAccessorXXX.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   108
bool ReflectionAccessorImplKlassHelper::is_generated_constructor_accessor(const InstanceKlass* k) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   109
  return k->super() == SystemDictionary::reflect_ConstructorAccessorImpl_klass() &&
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   110
         classname_matches_prefix(k, "jdk.internal.reflect.GeneratedConstructorAccessor");
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   111
}
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   112
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   113
// Returns true if k is of type jdk/internal/reflect/GeneratedSerializationConstructorAccessorXXX.
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   114
bool ReflectionAccessorImplKlassHelper::is_generated_method_serialization_constructor_accessor(const InstanceKlass* k) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   115
  // GeneratedSerializationConstructorAccessor is not a direct subclass of ConstructorAccessorImpl
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   116
  const Klass* sk = k->super();
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   117
  if (sk != NULL && sk->super() == SystemDictionary::reflect_ConstructorAccessorImpl_klass() &&
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   118
      classname_matches_prefix(k, "jdk.internal.reflect.GeneratedSerializationConstructorAccessor")) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   119
    return true;
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   120
  }
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   121
  return false;
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   122
}
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   123
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   124
const char* ReflectionAccessorImplKlassHelper::get_target_class_name(const InstanceKlass* k) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   125
  return get_string_from_cp_with_checks(k, cpi_slot_target_class_name);
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   126
}
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   127
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   128
const char* ReflectionAccessorImplKlassHelper::get_target_method_name(const InstanceKlass* k) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   129
  const int target_method_name_cpi =
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   130
      is_generated_method_serialization_constructor_accessor(k) ? cpi_slot_target_method_name_sca : cpi_slot_target_method_name;
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   131
  return get_string_from_cp_with_checks(k, target_method_name_cpi);
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   132
}
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   133
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   134
const char* ReflectionAccessorImplKlassHelper::get_target_method_signature(const InstanceKlass* k) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   135
  const int target_method_name_cpi =
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   136
      is_generated_method_serialization_constructor_accessor(k) ? cpi_slot_target_method_sig_sca : cpi_slot_target_method_sig;
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   137
  return get_string_from_cp_with_checks(k, target_method_name_cpi);
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   138
}
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   139
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   140
// Returns true if this is either one of jdk/internal/reflect/Generated{SerializationConstructor|Constructor|Method}AccessorXXX
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   141
// and it is safe to call print_invocation_target(k)
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   142
bool ReflectionAccessorImplKlassHelper::is_generated_accessor(const Klass* k) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   143
  if (k != NULL && k->is_instance_klass()) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   144
    const InstanceKlass* ik = InstanceKlass::cast(k);
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   145
    if (ik->is_initialized()) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   146
      return is_generated_method_accessor(ik) ||
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   147
             is_generated_constructor_accessor(ik) ||
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   148
             is_generated_method_serialization_constructor_accessor(ik);
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   149
    }
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   150
  }
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   151
  return false;
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   152
}
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   153
void ReflectionAccessorImplKlassHelper::print_invocation_target(outputStream* out, Klass* k) {
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   154
  assert(ReflectionAccessorImplKlassHelper::is_generated_accessor(k), "Invariant");
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   155
  InstanceKlass* ik = InstanceKlass::cast(k);
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   156
  ResourceMark rm;
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   157
  const char* target_class_name = ReflectionAccessorImplKlassHelper::get_target_class_name(ik);
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   158
  const char* target_method_name = ReflectionAccessorImplKlassHelper::get_target_method_name(ik);
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   159
  const char* target_method_signature = ReflectionAccessorImplKlassHelper::get_target_method_signature(ik);
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   160
  out->print("%s::%s %s",
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   161
      target_class_name != NULL ? target_class_name : "?",
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   162
      target_method_name != NULL ? target_method_name : "?",
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   163
      target_method_signature != NULL ? target_method_signature : "?");
6d4332f746ad 8203343: VM.{metaspace|classloaders|classhierarchy...} jcmd should show invocation targets for Generated{Method|Constructor}AccessorImpl classes
stuefe
parents:
diff changeset
   164
}