Fri, 06 Dec 2019 12:42:29 +0100
8235243: handle VS2017 15.9 and VS2019 in abstract_vm_version
8235325: build failure on Linux after 8235243
Reviewed-by: dholmes, mdoerr
duke@435 | 1 | /* |
phh@9507 | 2 | * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "classfile/systemDictionary.hpp" |
stefank@2314 | 27 | #include "classfile/vmSymbols.hpp" |
stefank@2314 | 28 | #include "memory/resourceArea.hpp" |
stefank@2314 | 29 | #include "memory/universe.inline.hpp" |
coleenp@4037 | 30 | #include "oops/annotations.hpp" |
stefank@2314 | 31 | #include "oops/instanceKlass.hpp" |
jiangli@3803 | 32 | #include "oops/fieldStreams.hpp" |
stefank@2314 | 33 | #include "runtime/fieldDescriptor.hpp" |
stefank@2314 | 34 | #include "runtime/handles.inline.hpp" |
stefank@2314 | 35 | #include "runtime/signature.hpp" |
duke@435 | 36 | |
duke@435 | 37 | |
duke@435 | 38 | oop fieldDescriptor::loader() const { |
coleenp@4251 | 39 | return _cp->pool_holder()->class_loader(); |
duke@435 | 40 | } |
duke@435 | 41 | |
jiangli@3803 | 42 | Symbol* fieldDescriptor::generic_signature() const { |
jiangli@3879 | 43 | if (!has_generic_signature()) { |
jiangli@3879 | 44 | return NULL; |
jiangli@3879 | 45 | } |
jiangli@3879 | 46 | |
jiangli@3803 | 47 | int idx = 0; |
coleenp@4251 | 48 | InstanceKlass* ik = field_holder(); |
jiangli@3803 | 49 | for (AllFieldStream fs(ik); !fs.done(); fs.next()) { |
jiangli@3803 | 50 | if (idx == _index) { |
jiangli@3803 | 51 | return fs.generic_signature(); |
jiangli@3803 | 52 | } else { |
jiangli@3803 | 53 | idx ++; |
jiangli@3803 | 54 | } |
jiangli@3803 | 55 | } |
jiangli@3803 | 56 | assert(false, "should never happen"); |
jiangli@3803 | 57 | return NULL; |
jiangli@3803 | 58 | } |
jiangli@3803 | 59 | |
coleenp@4037 | 60 | AnnotationArray* fieldDescriptor::annotations() const { |
coleenp@4251 | 61 | InstanceKlass* ik = field_holder(); |
coleenp@4037 | 62 | Array<AnnotationArray*>* md = ik->fields_annotations(); |
duke@435 | 63 | if (md == NULL) |
duke@435 | 64 | return NULL; |
coleenp@4037 | 65 | return md->at(index()); |
duke@435 | 66 | } |
duke@435 | 67 | |
stefank@4393 | 68 | AnnotationArray* fieldDescriptor::type_annotations() const { |
stefank@4393 | 69 | InstanceKlass* ik = field_holder(); |
coleenp@4572 | 70 | Array<AnnotationArray*>* type_annos = ik->fields_type_annotations(); |
stefank@4393 | 71 | if (type_annos == NULL) |
stefank@4393 | 72 | return NULL; |
coleenp@4572 | 73 | return type_annos->at(index()); |
stefank@4393 | 74 | } |
stefank@4393 | 75 | |
duke@435 | 76 | constantTag fieldDescriptor::initial_value_tag() const { |
never@3137 | 77 | return constants()->tag_at(initial_value_index()); |
duke@435 | 78 | } |
duke@435 | 79 | |
duke@435 | 80 | jint fieldDescriptor::int_initial_value() const { |
never@3137 | 81 | return constants()->int_at(initial_value_index()); |
duke@435 | 82 | } |
duke@435 | 83 | |
duke@435 | 84 | jlong fieldDescriptor::long_initial_value() const { |
never@3137 | 85 | return constants()->long_at(initial_value_index()); |
duke@435 | 86 | } |
duke@435 | 87 | |
duke@435 | 88 | jfloat fieldDescriptor::float_initial_value() const { |
never@3137 | 89 | return constants()->float_at(initial_value_index()); |
duke@435 | 90 | } |
duke@435 | 91 | |
duke@435 | 92 | jdouble fieldDescriptor::double_initial_value() const { |
never@3137 | 93 | return constants()->double_at(initial_value_index()); |
duke@435 | 94 | } |
duke@435 | 95 | |
duke@435 | 96 | oop fieldDescriptor::string_initial_value(TRAPS) const { |
phh@9507 | 97 | return constants()->uncached_string_at(initial_value_index(), THREAD); |
duke@435 | 98 | } |
duke@435 | 99 | |
drchase@5732 | 100 | void fieldDescriptor::reinitialize(InstanceKlass* ik, int index) { |
drchase@5732 | 101 | if (_cp.is_null() || field_holder() != ik) { |
drchase@5732 | 102 | _cp = constantPoolHandle(Thread::current(), ik->constants()); |
drchase@5732 | 103 | // _cp should now reference ik's constant pool; i.e., ik is now field_holder. |
drchase@5732 | 104 | assert(field_holder() == ik, "must be already initialized to this class"); |
drchase@5732 | 105 | } |
never@3137 | 106 | FieldInfo* f = ik->field(index); |
never@3137 | 107 | assert(!f->is_internal(), "regular Java fields only"); |
duke@435 | 108 | |
never@3137 | 109 | _access_flags = accessFlags_from(f->access_flags()); |
never@3137 | 110 | guarantee(f->name_index() != 0 && f->signature_index() != 0, "bad constant pool index for fieldDescriptor"); |
duke@435 | 111 | _index = index; |
drchase@5732 | 112 | verify(); |
duke@435 | 113 | } |
duke@435 | 114 | |
duke@435 | 115 | #ifndef PRODUCT |
duke@435 | 116 | |
drchase@5732 | 117 | void fieldDescriptor::verify() const { |
drchase@5732 | 118 | if (_cp.is_null()) { |
drchase@5732 | 119 | assert(_index == badInt, "constructor must be called"); // see constructor |
drchase@5732 | 120 | } else { |
drchase@5732 | 121 | assert(_index >= 0, "good index"); |
drchase@5732 | 122 | assert(_index < field_holder()->java_fields_count(), "oob"); |
drchase@5732 | 123 | } |
drchase@5732 | 124 | } |
drchase@5732 | 125 | |
duke@435 | 126 | void fieldDescriptor::print_on(outputStream* st) const { |
never@3137 | 127 | access_flags().print_on(st); |
never@3137 | 128 | name()->print_value_on(st); |
duke@435 | 129 | st->print(" "); |
never@3137 | 130 | signature()->print_value_on(st); |
duke@435 | 131 | st->print(" @%d ", offset()); |
duke@435 | 132 | if (WizardMode && has_initial_value()) { |
duke@435 | 133 | st->print("(initval "); |
duke@435 | 134 | constantTag t = initial_value_tag(); |
duke@435 | 135 | if (t.is_int()) { |
duke@435 | 136 | st->print("int %d)", int_initial_value()); |
duke@435 | 137 | } else if (t.is_long()){ |
duke@435 | 138 | st->print_jlong(long_initial_value()); |
duke@435 | 139 | } else if (t.is_float()){ |
duke@435 | 140 | st->print("float %f)", float_initial_value()); |
duke@435 | 141 | } else if (t.is_double()){ |
duke@435 | 142 | st->print("double %lf)", double_initial_value()); |
duke@435 | 143 | } |
duke@435 | 144 | } |
duke@435 | 145 | } |
duke@435 | 146 | |
duke@435 | 147 | void fieldDescriptor::print_on_for(outputStream* st, oop obj) { |
duke@435 | 148 | print_on(st); |
duke@435 | 149 | BasicType ft = field_type(); |
jrose@1100 | 150 | jint as_int = 0; |
duke@435 | 151 | switch (ft) { |
duke@435 | 152 | case T_BYTE: |
duke@435 | 153 | as_int = (jint)obj->byte_field(offset()); |
duke@435 | 154 | st->print(" %d", obj->byte_field(offset())); |
duke@435 | 155 | break; |
duke@435 | 156 | case T_CHAR: |
jrose@1100 | 157 | as_int = (jint)obj->char_field(offset()); |
duke@435 | 158 | { |
duke@435 | 159 | jchar c = obj->char_field(offset()); |
duke@435 | 160 | as_int = c; |
duke@435 | 161 | st->print(" %c %d", isprint(c) ? c : ' ', c); |
duke@435 | 162 | } |
duke@435 | 163 | break; |
duke@435 | 164 | case T_DOUBLE: |
duke@435 | 165 | st->print(" %lf", obj->double_field(offset())); |
duke@435 | 166 | break; |
duke@435 | 167 | case T_FLOAT: |
duke@435 | 168 | as_int = obj->int_field(offset()); |
duke@435 | 169 | st->print(" %f", obj->float_field(offset())); |
duke@435 | 170 | break; |
duke@435 | 171 | case T_INT: |
jrose@1100 | 172 | as_int = obj->int_field(offset()); |
duke@435 | 173 | st->print(" %d", obj->int_field(offset())); |
duke@435 | 174 | break; |
duke@435 | 175 | case T_LONG: |
duke@435 | 176 | st->print(" "); |
duke@435 | 177 | st->print_jlong(obj->long_field(offset())); |
duke@435 | 178 | break; |
duke@435 | 179 | case T_SHORT: |
duke@435 | 180 | as_int = obj->short_field(offset()); |
duke@435 | 181 | st->print(" %d", obj->short_field(offset())); |
duke@435 | 182 | break; |
duke@435 | 183 | case T_BOOLEAN: |
duke@435 | 184 | as_int = obj->bool_field(offset()); |
duke@435 | 185 | st->print(" %s", obj->bool_field(offset()) ? "true" : "false"); |
duke@435 | 186 | break; |
duke@435 | 187 | case T_ARRAY: |
duke@435 | 188 | st->print(" "); |
jrose@1100 | 189 | NOT_LP64(as_int = obj->int_field(offset())); |
duke@435 | 190 | obj->obj_field(offset())->print_value_on(st); |
duke@435 | 191 | break; |
duke@435 | 192 | case T_OBJECT: |
duke@435 | 193 | st->print(" "); |
jrose@1100 | 194 | NOT_LP64(as_int = obj->int_field(offset())); |
duke@435 | 195 | obj->obj_field(offset())->print_value_on(st); |
duke@435 | 196 | break; |
duke@435 | 197 | default: |
duke@435 | 198 | ShouldNotReachHere(); |
duke@435 | 199 | break; |
duke@435 | 200 | } |
duke@435 | 201 | // Print a hint as to the underlying integer representation. This can be wrong for |
duke@435 | 202 | // pointers on an LP64 machine |
jrose@1100 | 203 | if (ft == T_LONG || ft == T_DOUBLE LP64_ONLY(|| !is_java_primitive(ft)) ) { |
duke@435 | 204 | st->print(" (%x %x)", obj->int_field(offset()), obj->int_field(offset()+sizeof(jint))); |
jrose@1100 | 205 | } else if (as_int < 0 || as_int > 9) { |
duke@435 | 206 | st->print(" (%x)", as_int); |
duke@435 | 207 | } |
duke@435 | 208 | } |
duke@435 | 209 | |
duke@435 | 210 | #endif /* PRODUCT */ |