src/hotspot/share/classfile/classLoader.hpp
changeset 57898 5ddb746d45e0
parent 55524 b279ae9843b8
child 58447 319173c62caa
equal deleted inserted replaced
57897:e2e315f1aa63 57898:5ddb746d45e0
    45 template <typename T> class GrowableArray;
    45 template <typename T> class GrowableArray;
    46 
    46 
    47 class ClassPathEntry : public CHeapObj<mtClass> {
    47 class ClassPathEntry : public CHeapObj<mtClass> {
    48 private:
    48 private:
    49   ClassPathEntry* volatile _next;
    49   ClassPathEntry* volatile _next;
       
    50 protected:
       
    51   const char* copy_path(const char*path);
    50 public:
    52 public:
    51   ClassPathEntry* next() const;
    53   ClassPathEntry* next() const;
    52   virtual ~ClassPathEntry() {}
    54   virtual ~ClassPathEntry() {}
    53   void set_next(ClassPathEntry* next);
    55   void set_next(ClassPathEntry* next);
    54   virtual bool is_modules_image() const = 0;
    56   virtual bool is_modules_image() const { return false; }
    55   virtual bool is_jar_file() const = 0;
    57   virtual bool is_jar_file() const { return false; }
    56   // Is this entry created from the "Class-path" attribute from a JAR Manifest?
    58   // Is this entry created from the "Class-path" attribute from a JAR Manifest?
    57   virtual bool from_class_path_attr() const = 0;
    59   virtual bool from_class_path_attr() const { return false; }
    58   virtual const char* name() const = 0;
    60   virtual const char* name() const = 0;
    59   virtual JImageFile* jimage() const = 0;
    61   virtual JImageFile* jimage() const { return NULL; }
    60   virtual void close_jimage() = 0;
    62   virtual void close_jimage() {}
    61   // Constructor
    63   // Constructor
    62   ClassPathEntry() : _next(NULL) {}
    64   ClassPathEntry() : _next(NULL) {}
    63   // Attempt to locate file_name through this class path entry.
    65   // Attempt to locate file_name through this class path entry.
    64   // Returns a class file parsing stream if successfull.
    66   // Returns a class file parsing stream if successfull.
    65   virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0;
    67   virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0;
    71 
    73 
    72 class ClassPathDirEntry: public ClassPathEntry {
    74 class ClassPathDirEntry: public ClassPathEntry {
    73  private:
    75  private:
    74   const char* _dir;           // Name of directory
    76   const char* _dir;           // Name of directory
    75  public:
    77  public:
    76   bool is_modules_image() const { return false; }
       
    77   bool is_jar_file() const { return false;  }
       
    78   bool from_class_path_attr() const { return false; }
       
    79   const char* name() const { return _dir; }
    78   const char* name() const { return _dir; }
    80   JImageFile* jimage() const { return NULL; }
    79   ClassPathDirEntry(const char* dir) {
    81   void close_jimage() {}
    80     _dir = copy_path(dir);
    82   ClassPathDirEntry(const char* dir);
    81   }
    83   virtual ~ClassPathDirEntry() {}
    82   virtual ~ClassPathDirEntry() {}
    84   ClassFileStream* open_stream(const char* name, TRAPS);
    83   ClassFileStream* open_stream(const char* name, TRAPS);
    85 };
    84 };
    86 
       
    87 
    85 
    88 // Type definitions for zip file and zip file entry
    86 // Type definitions for zip file and zip file entry
    89 typedef void* jzfile;
    87 typedef void* jzfile;
    90 typedef struct {
    88 typedef struct {
    91   char *name;                   /* entry name */
    89   char *name;                   /* entry name */
   102  private:
   100  private:
   103   jzfile* _zip;              // The zip archive
   101   jzfile* _zip;              // The zip archive
   104   const char*   _zip_name;   // Name of zip archive
   102   const char*   _zip_name;   // Name of zip archive
   105   bool _from_class_path_attr; // From the "Class-path" attribute of a jar file
   103   bool _from_class_path_attr; // From the "Class-path" attribute of a jar file
   106  public:
   104  public:
   107   bool is_modules_image() const { return false; }
       
   108   bool is_jar_file() const { return true;  }
   105   bool is_jar_file() const { return true;  }
   109   bool from_class_path_attr() const { return _from_class_path_attr; }
   106   bool from_class_path_attr() const { return _from_class_path_attr; }
   110   const char* name() const { return _zip_name; }
   107   const char* name() const { return _zip_name; }
   111   JImageFile* jimage() const { return NULL; }
       
   112   void close_jimage() {}
       
   113   ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append, bool from_class_path_attr);
   108   ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append, bool from_class_path_attr);
   114   virtual ~ClassPathZipEntry();
   109   virtual ~ClassPathZipEntry();
   115   u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS);
   110   u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS);
   116   ClassFileStream* open_stream(const char* name, TRAPS);
   111   ClassFileStream* open_stream(const char* name, TRAPS);
   117   void contents_do(void f(const char* name, void* context), void* context);
   112   void contents_do(void f(const char* name, void* context), void* context);
   124   JImageFile* _jimage;
   119   JImageFile* _jimage;
   125   const char* _name;
   120   const char* _name;
   126   DEBUG_ONLY(static ClassPathImageEntry* _singleton;)
   121   DEBUG_ONLY(static ClassPathImageEntry* _singleton;)
   127 public:
   122 public:
   128   bool is_modules_image() const;
   123   bool is_modules_image() const;
   129   bool is_jar_file() const { return false; }
       
   130   bool from_class_path_attr() const { return false; }
       
   131   bool is_open() const { return _jimage != NULL; }
   124   bool is_open() const { return _jimage != NULL; }
   132   const char* name() const { return _name == NULL ? "" : _name; }
   125   const char* name() const { return _name == NULL ? "" : _name; }
   133   JImageFile* jimage() const { return _jimage; }
   126   JImageFile* jimage() const { return _jimage; }
   134   void close_jimage();
   127   void close_jimage();
   135   ClassPathImageEntry(JImageFile* jimage, const char* name);
   128   ClassPathImageEntry(JImageFile* jimage, const char* name);
   153   ClassPathEntry* module_first_entry() const { return _module_first_entry; }
   146   ClassPathEntry* module_first_entry() const { return _module_first_entry; }
   154   ModuleClassPathList(Symbol* module_name);
   147   ModuleClassPathList(Symbol* module_name);
   155   ~ModuleClassPathList();
   148   ~ModuleClassPathList();
   156   void add_to_list(ClassPathEntry* new_entry);
   149   void add_to_list(ClassPathEntry* new_entry);
   157 };
   150 };
   158 
       
   159 class SharedPathsMiscInfo;
       
   160 
   151 
   161 class ClassLoader: AllStatic {
   152 class ClassLoader: AllStatic {
   162  public:
   153  public:
   163   enum ClassLoaderType {
   154   enum ClassLoaderType {
   164     BOOT_LOADER = 1,      /* boot loader */
   155     BOOT_LOADER = 1,      /* boot loader */
   228   static ClassPathEntry* _first_append_entry;
   219   static ClassPathEntry* _first_append_entry;
   229   // Last entry in linked list of appended ClassPathEntry instances
   220   // Last entry in linked list of appended ClassPathEntry instances
   230   static ClassPathEntry* _last_append_entry;
   221   static ClassPathEntry* _last_append_entry;
   231 
   222 
   232   // Info used by CDS
   223   // Info used by CDS
   233   CDS_ONLY(static SharedPathsMiscInfo * _shared_paths_misc_info;)
       
   234 
       
   235   CDS_ONLY(static ClassPathEntry* _app_classpath_entries;)
   224   CDS_ONLY(static ClassPathEntry* _app_classpath_entries;)
   236   CDS_ONLY(static ClassPathEntry* _last_app_classpath_entry;)
   225   CDS_ONLY(static ClassPathEntry* _last_app_classpath_entry;)
   237   CDS_ONLY(static ClassPathEntry* _module_path_entries;)
   226   CDS_ONLY(static ClassPathEntry* _module_path_entries;)
   238   CDS_ONLY(static ClassPathEntry* _last_module_path_entry;)
   227   CDS_ONLY(static ClassPathEntry* _last_module_path_entry;)
   239   CDS_ONLY(static void setup_app_search_path(const char* class_path);)
   228   CDS_ONLY(static void setup_app_search_path(const char* class_path);)
   414       num_entries ++;
   403       num_entries ++;
   415       e = e->next();
   404       e = e->next();
   416     }
   405     }
   417     return num_entries;
   406     return num_entries;
   418   }
   407   }
   419   static void  finalize_shared_paths_misc_info();
       
   420   static int   get_shared_paths_misc_info_size();
       
   421   static void* get_shared_paths_misc_info();
       
   422   static bool  check_shared_paths_misc_info(void* info, int size, bool is_static);
       
   423   static void  exit_with_path_failure(const char* error, const char* message);
   408   static void  exit_with_path_failure(const char* error, const char* message);
   424   static char* skip_uri_protocol(char* source);
   409   static char* skip_uri_protocol(char* source);
   425   static void  record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS);
   410   static void  record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS);
   426 #endif
   411 #endif
   427   static JImageLocationRef jimage_find_resource(JImageFile* jf, const char* module_name,
   412   static JImageLocationRef jimage_find_resource(JImageFile* jf, const char* module_name,