src/share/vm/classfile/sharedPathsMiscInfo.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File classpath.06 Sdiff src/share/vm/classfile

src/share/vm/classfile/sharedPathsMiscInfo.hpp

Print this page


   1 /*
   2  * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  47 // the archive file header. At run-time, this information is used only during initialization
  48 // (accessed using read() instead of mmap()), and is deallocated afterwards to save space.
  49 //
  50 // The SharedPathsMiscInfo class is used for both creating the the information (during
  51 // dumping time) and validation (at run time). Different constructors are used in the
  52 // two situations. See below.
  53 
  54 class SharedPathsMiscInfo : public CHeapObj<mtClass> {
  55 protected:
  56   char* _buf_start;
  57   char* _cur_ptr;
  58   char* _end_ptr;
  59   int   _buf_size;
  60   bool  _allocated;   // was _buf_start allocated by me?
  61   void ensure_size(size_t needed_bytes);
  62   void add_path(const char* path, int type);
  63 
  64   void write(const void* ptr, size_t size);
  65   bool read(void* ptr, size_t size);
  66 
  67   static void trace_class_path(const char* msg, const char* name = NULL) {
  68     ClassLoader::trace_class_path(tty, msg, name);
  69   }
  70 protected:
  71   static bool fail(const char* msg, const char* name = NULL);
  72   virtual bool check(jint type, const char* path);
  73 
  74 public:
  75   enum {
  76     INITIAL_BUF_SIZE = 128
  77   };
  78   // This constructor is used when creating the misc information (during dump)
  79   SharedPathsMiscInfo() {
  80     _buf_size = INITIAL_BUF_SIZE;
  81     _cur_ptr = _buf_start = NEW_C_HEAP_ARRAY(char, _buf_size, mtClass);
  82     _allocated = true;
  83   }
  84   // This constructor is used when validating the misc info (during run time)
  85   SharedPathsMiscInfo(char *buff, int size) {
  86     _cur_ptr = _buf_start = buff;
  87     _end_ptr = _buf_start + size;
  88     _buf_size = size;
  89     _allocated = false;


 127     return (os::write(fd, _buf_start, n) == (size_t)n);
 128   }
 129 
 130   // reading --
 131 
 132   enum {
 133     BOOT      = 1,
 134     NON_EXIST = 2,
 135     REQUIRED  = 3
 136   };
 137 
 138   virtual const char* type_name(int type) {
 139     switch (type) {
 140     case BOOT:      return "BOOT";
 141     case NON_EXIST: return "NON_EXIST";
 142     case REQUIRED:  return "REQUIRED";
 143     default:        ShouldNotReachHere(); return "?";
 144     }
 145   }
 146 
 147   virtual void print_path(outputStream* out, int type, const char* path) {


 148     switch (type) {
 149     case BOOT:
 150       out->print("Expecting -Dsun.boot.class.path=%s", path);
 151       break;
 152     case NON_EXIST:
 153       out->print("Expecting that %s does not exist", path);
 154       break;
 155     case REQUIRED:
 156       out->print("Expecting that file %s must exist and is not altered", path);
 157       break;
 158     default:
 159       ShouldNotReachHere();
 160     }
 161   }
 162 
 163   bool check();
 164   bool read_jint(jint *ptr) {
 165     return read(ptr, sizeof(jint));
 166   }
 167   bool read_long(long *ptr) {
   1 /*
   2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  47 // the archive file header. At run-time, this information is used only during initialization
  48 // (accessed using read() instead of mmap()), and is deallocated afterwards to save space.
  49 //
  50 // The SharedPathsMiscInfo class is used for both creating the the information (during
  51 // dumping time) and validation (at run time). Different constructors are used in the
  52 // two situations. See below.
  53 
  54 class SharedPathsMiscInfo : public CHeapObj<mtClass> {
  55 protected:
  56   char* _buf_start;
  57   char* _cur_ptr;
  58   char* _end_ptr;
  59   int   _buf_size;
  60   bool  _allocated;   // was _buf_start allocated by me?
  61   void ensure_size(size_t needed_bytes);
  62   void add_path(const char* path, int type);
  63 
  64   void write(const void* ptr, size_t size);
  65   bool read(void* ptr, size_t size);
  66 



  67 protected:
  68   static bool fail(const char* msg, const char* name = NULL);
  69   virtual bool check(jint type, const char* path);
  70 
  71 public:
  72   enum {
  73     INITIAL_BUF_SIZE = 128
  74   };
  75   // This constructor is used when creating the misc information (during dump)
  76   SharedPathsMiscInfo() {
  77     _buf_size = INITIAL_BUF_SIZE;
  78     _cur_ptr = _buf_start = NEW_C_HEAP_ARRAY(char, _buf_size, mtClass);
  79     _allocated = true;
  80   }
  81   // This constructor is used when validating the misc info (during run time)
  82   SharedPathsMiscInfo(char *buff, int size) {
  83     _cur_ptr = _buf_start = buff;
  84     _end_ptr = _buf_start + size;
  85     _buf_size = size;
  86     _allocated = false;


 124     return (os::write(fd, _buf_start, n) == (size_t)n);
 125   }
 126 
 127   // reading --
 128 
 129   enum {
 130     BOOT      = 1,
 131     NON_EXIST = 2,
 132     REQUIRED  = 3
 133   };
 134 
 135   virtual const char* type_name(int type) {
 136     switch (type) {
 137     case BOOT:      return "BOOT";
 138     case NON_EXIST: return "NON_EXIST";
 139     case REQUIRED:  return "REQUIRED";
 140     default:        ShouldNotReachHere(); return "?";
 141     }
 142   }
 143 
 144   virtual void print_path(int type, const char* path) {
 145     ResourceMark rm;
 146     outputStream* out = LogHandle(classpath)::info_stream();
 147     switch (type) {
 148     case BOOT:
 149       out->print("Expecting -Dsun.boot.class.path=%s", path);
 150       break;
 151     case NON_EXIST:
 152       out->print("Expecting that %s does not exist", path);
 153       break;
 154     case REQUIRED:
 155       out->print("Expecting that file %s must exist and is not altered", path);
 156       break;
 157     default:
 158       ShouldNotReachHere();
 159     }
 160   }
 161 
 162   bool check();
 163   bool read_jint(jint *ptr) {
 164     return read(ptr, sizeof(jint));
 165   }
 166   bool read_long(long *ptr) {
src/share/vm/classfile/sharedPathsMiscInfo.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File