annotate src/hotspot/share/classfile/classListParser.hpp @ 54526:ee29b516a36a

revert changes
author jlaskey
date Wed, 23 Jan 2019 16:09:20 -0400
parents 3009ca99de32
children
rev   line source
iklam@34257 1 /*
coleenp@54304 2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
iklam@34257 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
iklam@34257 4 *
iklam@34257 5 * This code is free software; you can redistribute it and/or modify it
iklam@34257 6 * under the terms of the GNU General Public License version 2 only, as
iklam@34257 7 * published by the Free Software Foundation.
iklam@34257 8 *
iklam@34257 9 * This code is distributed in the hope that it will be useful, but WITHOUT
iklam@34257 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
iklam@34257 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
iklam@34257 12 * version 2 for more details (a copy is included in the LICENSE file that
iklam@34257 13 * accompanied this code).
iklam@34257 14 *
iklam@34257 15 * You should have received a copy of the GNU General Public License version
iklam@34257 16 * 2 along with this work; if not, write to the Free Software Foundation,
iklam@34257 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
iklam@34257 18 *
iklam@34257 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
iklam@34257 20 * or visit www.oracle.com if you need additional information or have any
iklam@34257 21 * questions.
iklam@34257 22 *
iklam@34257 23 */
iklam@34257 24
coleenp@54304 25 #ifndef SHARE_CLASSFILE_CLASSLISTPARSER_HPP
coleenp@54304 26 #define SHARE_CLASSFILE_CLASSLISTPARSER_HPP
iklam@34257 27
iklam@34257 28 #include "utilities/exceptions.hpp"
iklam@34257 29 #include "utilities/globalDefinitions.hpp"
iklam@53599 30 #include "utilities/growableArray.hpp"
iklam@53599 31 #include "utilities/hashtable.inline.hpp"
iklam@48354 32
iklam@53599 33 class ID2KlassTable : public KVHashtable<int, InstanceKlass*, mtInternal> {
iklam@48354 34 public:
iklam@53599 35 ID2KlassTable() : KVHashtable<int, InstanceKlass*, mtInternal>(1987) {}
iklam@48354 36 };
iklam@34257 37
iklam@34257 38 class ClassListParser : public StackObj {
iklam@34257 39 enum {
iklam@48354 40 _unspecified = -999,
iklam@48354 41
iklam@34257 42 // Max number of bytes allowed per line in the classlist.
iklam@48354 43 // Theoretically Java class names could be 65535 bytes in length. Also, an input line
iklam@48354 44 // could have a very long path name up to JVM_MAXPATHLEN bytes in length. In reality,
iklam@34257 45 // 4K bytes is more than enough.
iklam@34257 46 _max_allowed_line_len = 4096,
iklam@34257 47 _line_buf_extra = 10, // for detecting input too long
iklam@34257 48 _line_buf_size = _max_allowed_line_len + _line_buf_extra
iklam@34257 49 };
iklam@34257 50
iklam@48354 51 static ClassListParser* _instance; // the singleton.
iklam@34257 52 const char* _classlist_file;
iklam@34257 53 FILE* _file;
iklam@34257 54
iklam@48354 55 ID2KlassTable _id2klass_table;
iklam@48354 56
iklam@48354 57 // The following field contains information from the *current* line being
iklam@48354 58 // parsed.
iklam@48354 59 char _line[_line_buf_size]; // The buffer that holds the current line. Some characters in
iklam@48354 60 // the buffer may be overwritten by '\0' during parsing.
iklam@48354 61 int _line_len; // Original length of the input line.
iklam@48354 62 int _line_no; // Line number for current line being parsed
iklam@48354 63 const char* _class_name;
iklam@48354 64 int _id;
iklam@48354 65 int _super;
iklam@48354 66 GrowableArray<int>* _interfaces;
iklam@48354 67 bool _interfaces_specified;
iklam@48354 68 const char* _source;
iklam@48354 69
iklam@48354 70 bool parse_int_option(const char* option_name, int* value);
iklam@48354 71 InstanceKlass* load_class_from_source(Symbol* class_name, TRAPS);
iklam@48354 72 ID2KlassTable *table() {
iklam@48354 73 return &_id2klass_table;
iklam@48354 74 }
iklam@48354 75 InstanceKlass* lookup_class_by_id(int id);
iklam@48354 76 void print_specified_interfaces();
iklam@48354 77 void print_actual_interfaces(InstanceKlass *ik);
iklam@34257 78 public:
iklam@34257 79 ClassListParser(const char* file);
iklam@34257 80 ~ClassListParser();
iklam@48354 81
iklam@48354 82 static ClassListParser* instance() {
iklam@48354 83 return _instance;
iklam@48354 84 }
iklam@34257 85 bool parse_one_line();
iklam@48354 86 char* _token;
iklam@48354 87 void error(const char* msg, ...);
iklam@48354 88 void parse_int(int* value);
iklam@48354 89 bool try_parse_int(int* value);
iklam@48354 90 bool skip_token(const char* option_name);
iklam@48354 91 void skip_whitespaces();
iklam@48354 92 void skip_non_whitespaces();
iklam@48354 93
iklam@48354 94 bool is_id_specified() {
iklam@48354 95 return _id != _unspecified;
iklam@48354 96 }
iklam@48354 97 bool is_super_specified() {
iklam@48354 98 return _super != _unspecified;
iklam@48354 99 }
iklam@48354 100 bool are_interfaces_specified() {
iklam@48354 101 return _interfaces->length() > 0;
iklam@48354 102 }
iklam@48354 103 int id() {
iklam@48354 104 assert(is_id_specified(), "do not query unspecified id");
iklam@48354 105 return _id;
iklam@48354 106 }
iklam@48354 107 int super() {
iklam@48354 108 assert(is_super_specified(), "do not query unspecified super");
iklam@48354 109 return _super;
iklam@48354 110 }
iklam@48354 111 void check_already_loaded(const char* which, int id) {
iklam@48354 112 if (_id2klass_table.lookup(id) == NULL) {
iklam@48354 113 error("%s id %d is not yet loaded", which, id);
iklam@48354 114 }
iklam@48354 115 }
iklam@34257 116
iklam@34257 117 const char* current_class_name() {
iklam@48354 118 return _class_name;
iklam@34257 119 }
iklam@48354 120
ccheung@48654 121 Klass* load_current_class(TRAPS);
iklam@48354 122
iklam@48354 123 bool is_loading_from_source();
iklam@48354 124
iklam@48354 125 // Look up the super or interface of the current class being loaded
iklam@48354 126 // (in this->load_current_class()).
iklam@48354 127 InstanceKlass* lookup_super_for_current_class(Symbol* super_name);
iklam@48354 128 InstanceKlass* lookup_interface_for_current_class(Symbol* interface_name);
iklam@34257 129 };
coleenp@54304 130 #endif // SHARE_CLASSFILE_CLASSLISTPARSER_HPP