hotspot/src/share/vm/classfile/klassFactory.hpp
author mgronlun
Tue, 08 Dec 2015 20:04:03 +0100
changeset 34666 1c7168ea0034
child 40016 bf6fcd467a7b
permissions -rw-r--r--
8140485: Class load and creation cleanup Reviewed-by: hseigel, coleenp, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
     1
/*
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
     2
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
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:
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    71
  static instanceKlassHandle create_from_stream(ClassFileStream* stream,
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    72
                                                Symbol* name,
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    73
                                                ClassLoaderData* loader_data,
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    74
                                                Handle protection_domain,
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    75
                                                const Klass* host_klass,
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    76
                                                GrowableArray<Handle>* cp_patches,
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    77
                                                TempNewSymbol* parsed_name,
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    78
                                                TRAPS);
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    79
};
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    80
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents:
diff changeset
    81
#endif // SHARE_VM_CLASSFILE_KLASSFACTORY_HPP