src/hotspot/share/classfile/klassFactory.hpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46329 hotspot/src/share/vm/classfile/klassFactory.hpp@53ccc37bda19
child 48157 7c4d43c26352
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
     1
/*
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 41182
diff changeset
     2
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
     3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
     4
*
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
     5
* This code is free software; you can redistribute it and/or modify it
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
     6
* under the terms of the GNU General Public License version 2 only, as
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
     7
* published by the Free Software Foundation.
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
     8
*
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
     9
* This code is distributed in the hope that it will be useful, but WITHOUT
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    11
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    12
* version 2 for more details (a copy is included in the LICENSE file that
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    13
* accompanied this code).
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    14
*
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    15
* You should have received a copy of the GNU General Public License version
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    16
* 2 along with this work; if not, write to the Free Software Foundation,
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    18
*
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    20
* or visit www.oracle.com if you need additional information or have any
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    21
* questions.
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    22
*
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    23
*/
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    24
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    25
#ifndef SHARE_VM_CLASSFILE_KLASSFACTORY_HPP
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    26
#define SHARE_VM_CLASSFILE_KLASSFACTORY_HPP
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    27
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    28
#include "memory/allocation.inline.hpp"
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    29
#include "runtime/handles.hpp"
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    30
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    31
class ClassFileStream;
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    32
class ClassLoaderData;
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    33
template <typename>
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    34
class GrowableArray;
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    35
class Klass;
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    36
class Symbol;
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    37
class TempNewSymbol;
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    38
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    39
/*
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    40
 * KlassFactory is an interface to implementations of the following mapping/function:
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    41
 *
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    42
 * Summary: create a VM internal runtime representation ("Klass")
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    43
            from a bytestream (classfile).
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    44
 *
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    45
 * Input:  a named bytestream in the Java class file format (see JVMS, chapter 4).
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    46
 * Output: a VM runtime representation of a Java class
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    47
 *
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    48
 * Pre-conditions:
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    49
 *   a non-NULL ClassFileStream* // the classfile bytestream
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    50
 *   a non-NULL Symbol*          // the name of the class
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    51
 *   a non-NULL ClassLoaderData* // the metaspace allocator
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    52
 *   (no pending exceptions)
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    53
 *
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    54
 * Returns:
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    55
 *   if the returned value is non-NULL, that value is an indirection (pointer/handle)
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    56
 *   to a Klass. The caller will not have a pending exception.
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    57
 *
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    58
 *   On broken invariants and/or runtime errors the returned value will be
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    59
 *   NULL (or a NULL handle) and the caller *might* now have a pending exception.
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    60
 *
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    61
 */
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    62
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    63
class KlassFactory : AllStatic {
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    64
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    65
  // approved clients
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    66
  friend class ClassLoader;
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    67
  friend class ClassLoaderExt;
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    68
  friend class SystemDictionary;
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    69
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    70
 private:
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 41182
diff changeset
    71
  static InstanceKlass* create_from_stream(ClassFileStream* stream,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 41182
diff changeset
    72
                                           Symbol* name,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 41182
diff changeset
    73
                                           ClassLoaderData* loader_data,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 41182
diff changeset
    74
                                           Handle protection_domain,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 41182
diff changeset
    75
                                           const InstanceKlass* host_klass,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 41182
diff changeset
    76
                                           GrowableArray<Handle>* cp_patches,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 41182
diff changeset
    77
                                           TRAPS);
41182
dbd59c1da636 8078644: CDS needs to support JVMTI CFLH
jiangli
parents: 40923
diff changeset
    78
 public:
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 41182
diff changeset
    79
  static InstanceKlass* check_shared_class_file_load_hook(
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 41182
diff changeset
    80
                                          InstanceKlass* ik,
41182
dbd59c1da636 8078644: CDS needs to support JVMTI CFLH
jiangli
parents: 40923
diff changeset
    81
                                          Symbol* class_name,
dbd59c1da636 8078644: CDS needs to support JVMTI CFLH
jiangli
parents: 40923
diff changeset
    82
                                          Handle class_loader,
dbd59c1da636 8078644: CDS needs to support JVMTI CFLH
jiangli
parents: 40923
diff changeset
    83
                                          Handle protection_domain, TRAPS);
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    84
};
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    85
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    86
#endif // SHARE_VM_CLASSFILE_KLASSFACTORY_HPP