src/hotspot/share/classfile/classLoaderExt.hpp
author coleenp
Thu, 10 Jan 2019 15:13:51 -0500
changeset 53244 9807daeb47c4
parent 52514 f4e3900c8d08
child 57898 5ddb746d45e0
permissions -rw-r--r--
8216167: Update include guards to reflect correct directories Summary: Use script and some manual fixup to fix directores names in include guards. Reviewed-by: lfoltan, eosterlund, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52514
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
     4
 *
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
     8
 *
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    13
 * accompanied this code).
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    14
 *
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    18
 *
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    21
 * questions.
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    22
 *
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    23
 */
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52514
diff changeset
    25
#ifndef SHARE_CLASSFILE_CLASSLOADEREXT_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52514
diff changeset
    26
#define SHARE_CLASSFILE_CLASSLOADEREXT_HPP
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    27
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    28
#include "classfile/classLoader.hpp"
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
    29
#include "classfile/moduleEntry.hpp"
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    30
#include "utilities/macros.hpp"
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    31
50039
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
    32
class ClassListParser;
34257
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 29199
diff changeset
    33
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    34
class ClassLoaderExt: public ClassLoader { // AllStatic
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    35
public:
52315
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    36
  static bool should_verify(int classpath_index) {
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    37
    CDS_ONLY(return (classpath_index >= _app_class_paths_start_index);)
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    38
    NOT_CDS(return false;)
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    39
  }
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    40
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    41
#if INCLUDE_CDS
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    42
private:
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    43
  enum SomeConstants {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    44
    max_classpath_index = 0x7fff
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    45
  };
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
    46
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    47
  static char* get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    48
  static void setup_app_search_path(); // Only when -Xshare:dump
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
    49
  static void process_module_table(ModuleEntryTable* met, TRAPS);
50039
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
    50
  static SharedPathsMiscInfo* shared_paths_misc_info() {
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
    51
    return (SharedPathsMiscInfo*)_shared_paths_misc_info;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    52
  }
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
    53
  // index of first app JAR in shared classpath entry table
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
    54
  static jshort _app_class_paths_start_index;
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
    55
  // index of first modular JAR in shared modulepath entry table
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
    56
  static jshort _app_module_paths_start_index;
51439
0517bd2a0eda 8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents: 50039
diff changeset
    57
  // the largest path index being used during CDS dump time
0517bd2a0eda 8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents: 50039
diff changeset
    58
  static jshort _max_used_path_index;
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
    59
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    60
  static bool _has_app_classes;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    61
  static bool _has_platform_classes;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    62
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    63
  static char* read_manifest(ClassPathEntry* entry, jint *manifest_size, bool clean_text, TRAPS);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    64
  static ClassPathEntry* find_classpath_entry_from_cache(const char* path, TRAPS);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    65
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    66
public:
52315
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    67
  static void process_jar_manifest(ClassPathEntry* entry, bool check_for_duplicates);
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    68
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    69
  // Called by JVMTI code to add boot classpath
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    70
  static void append_boot_classpath(ClassPathEntry* new_entry);
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    71
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    72
  static void setup_search_paths();
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    73
  static void setup_module_paths(TRAPS);
50426919edbb 8205327: Clean up #if INCLUDE_CDS in classLoaderExt.cpp and classLoaderExt.hpp
jiangli
parents: 51439
diff changeset
    74
47103
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46329
diff changeset
    75
  static char* read_manifest(ClassPathEntry* entry, jint *manifest_size, TRAPS) {
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    76
    // Remove all the new-line continuations (which wrap long lines at 72 characters, see
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    77
    // http://docs.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Manifest), so
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    78
    // that the manifest is easier to parse.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    79
    return read_manifest(entry, manifest_size, true, THREAD);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    80
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    81
  static char* read_raw_manifest(ClassPathEntry* entry, jint *manifest_size, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    82
    // Do not remove new-line continuations, so we can easily pass it as an argument to
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    83
    // java.util.jar.Manifest.getManifest() at run-time.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    84
    return read_manifest(entry, manifest_size, false, THREAD);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    85
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    86
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    87
  static void finalize_shared_paths_misc_info();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    88
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
    89
  static jshort app_class_paths_start_index() { return _app_class_paths_start_index; }
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
    90
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
    91
  static jshort app_module_paths_start_index() { return _app_module_paths_start_index; }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    92
51439
0517bd2a0eda 8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents: 50039
diff changeset
    93
  static jshort max_used_path_index() { return _max_used_path_index; }
0517bd2a0eda 8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents: 50039
diff changeset
    94
0517bd2a0eda 8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents: 50039
diff changeset
    95
  static void set_max_used_path_index(jshort used_index) {
0517bd2a0eda 8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents: 50039
diff changeset
    96
    _max_used_path_index = used_index;
0517bd2a0eda 8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents: 50039
diff changeset
    97
  }
0517bd2a0eda 8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents: 50039
diff changeset
    98
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
    99
  static void init_paths_start_index(jshort app_start) {
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
   100
    _app_class_paths_start_index = app_start;
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
   101
  }
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
   102
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
   103
  static void init_app_module_paths_start_index(jshort module_start) {
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
   104
    _app_module_paths_start_index = module_start;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   105
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   106
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   107
  static bool is_boot_classpath(int classpath_index) {
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49341
diff changeset
   108
    return classpath_index < _app_class_paths_start_index;
47103
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46329
diff changeset
   109
  }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   110
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   111
  static bool has_platform_or_app_classes() {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   112
    return _has_app_classes || _has_platform_classes;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   113
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   114
50039
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   115
  static void record_result(const s2 classpath_index,
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   116
                            InstanceKlass* result, TRAPS);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   117
  static InstanceKlass* load_class(Symbol* h_name, const char* path, TRAPS);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   118
  static void set_has_app_classes() {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   119
    _has_app_classes = true;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   120
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   121
  static void set_has_platform_classes() {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   122
    _has_platform_classes = true;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents: 47991
diff changeset
   123
  }
47103
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46329
diff changeset
   124
#endif
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
   125
};
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents:
diff changeset
   126
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52514
diff changeset
   127
#endif // SHARE_CLASSFILE_CLASSLOADEREXT_HPP