8209138: Symbol constructor uses u1 as the element type of its name argument
Maske u1 the type for Symbol values and add a function to return it as a char. Reviewed-by: dholmes, coleenp
This commit is contained in:
parent
a3cd6a1a70
commit
221005a3d4
@ -399,8 +399,8 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
|
||||
|
||||
// Now we need to check the SystemDictionary
|
||||
Symbol* sym = name->get_symbol();
|
||||
if (sym->byte_at(0) == 'L' &&
|
||||
sym->byte_at(sym->utf8_length()-1) == ';') {
|
||||
if (sym->char_at(0) == 'L' &&
|
||||
sym->char_at(sym->utf8_length()-1) == ';') {
|
||||
// This is a name from a signature. Strip off the trimmings.
|
||||
// Call recursive to keep scope of strippedsym.
|
||||
TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
|
||||
@ -427,7 +427,7 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
|
||||
|
||||
// setup up the proper type to return on OOM
|
||||
ciKlass* fail_type;
|
||||
if (sym->byte_at(0) == '[') {
|
||||
if (sym->char_at(0) == '[') {
|
||||
fail_type = _unloaded_ciobjarrayklass;
|
||||
} else {
|
||||
fail_type = _unloaded_ciinstance_klass;
|
||||
@ -453,8 +453,8 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
|
||||
// we must build an array type around it. The CI requires array klasses
|
||||
// to be loaded if their element klasses are loaded, except when memory
|
||||
// is exhausted.
|
||||
if (sym->byte_at(0) == '[' &&
|
||||
(sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) {
|
||||
if (sym->char_at(0) == '[' &&
|
||||
(sym->char_at(1) == '[' || sym->char_at(1) == 'L')) {
|
||||
// We have an unloaded array.
|
||||
// Build it on the fly if the element class exists.
|
||||
TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
|
||||
|
@ -116,7 +116,7 @@ ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
|
||||
jobject loader, jobject protection_domain)
|
||||
: ciKlass(name, T_OBJECT)
|
||||
{
|
||||
assert(name->byte_at(0) != '[', "not an instance klass");
|
||||
assert(name->char_at(0) != '[', "not an instance klass");
|
||||
_init_state = (InstanceKlass::ClassState)0;
|
||||
_nonstatic_field_size = -1;
|
||||
_has_nonstatic_fields = false;
|
||||
@ -299,7 +299,7 @@ bool ciInstanceKlass::is_in_package_impl(const char* packagename, int len) {
|
||||
return false;
|
||||
|
||||
// Test for trailing '/'
|
||||
if ((char) name()->byte_at(len) != '/')
|
||||
if (name()->char_at(len) != '/')
|
||||
return false;
|
||||
|
||||
// Make sure it's not actually in a subpackage:
|
||||
|
@ -112,9 +112,9 @@ ciSymbol* ciObjArrayKlass::construct_array_name(ciSymbol* element_name,
|
||||
Symbol* base_name_sym = element_name->get_symbol();
|
||||
char* name;
|
||||
|
||||
if (base_name_sym->byte_at(0) == '[' ||
|
||||
(base_name_sym->byte_at(0) == 'L' && // watch package name 'Lxx'
|
||||
base_name_sym->byte_at(element_len-1) == ';')) {
|
||||
if (base_name_sym->char_at(0) == '[' ||
|
||||
(base_name_sym->char_at(0) == 'L' && // watch package name 'Lxx'
|
||||
base_name_sym->char_at(element_len-1) == ';')) {
|
||||
|
||||
int new_len = element_len + dimension + 1; // for the ['s and '\0'
|
||||
name = CURRENT_THREAD_ENV->name_buffer(new_len);
|
||||
|
@ -466,7 +466,7 @@ ciKlass* ciObjectFactory::get_unloaded_klass(ciKlass* accessing_klass,
|
||||
|
||||
// Two cases: this is an unloaded ObjArrayKlass or an
|
||||
// unloaded InstanceKlass. Deal with both.
|
||||
if (name->byte_at(0) == '[') {
|
||||
if (name->char_at(0) == '[') {
|
||||
// Decompose the name.'
|
||||
FieldArrayInfo fd;
|
||||
BasicType element_type = FieldType::get_array_info(name->get_symbol(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -68,14 +68,14 @@ const char* ciSymbol::as_quoted_ascii() {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ciSymbol::base
|
||||
const jbyte* ciSymbol::base() {
|
||||
const u1* ciSymbol::base() {
|
||||
GUARDED_VM_ENTRY(return get_symbol()->base();)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ciSymbol::byte_at
|
||||
int ciSymbol::byte_at(int i) {
|
||||
GUARDED_VM_ENTRY(return get_symbol()->byte_at(i);)
|
||||
// ciSymbol::char_at
|
||||
char ciSymbol::char_at(int i) {
|
||||
GUARDED_VM_ENTRY(return get_symbol()->char_at(i);)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -61,7 +61,7 @@ private:
|
||||
void print_impl(outputStream* st);
|
||||
|
||||
// This is public in Symbol* but private here, because the base can move:
|
||||
const jbyte* base();
|
||||
const u1* base();
|
||||
|
||||
// Make a ciSymbol from a C string (implementation).
|
||||
static ciSymbol* make_impl(const char* s);
|
||||
@ -77,8 +77,8 @@ public:
|
||||
// The text of the symbol as ascii with all non-printable characters quoted as \u####
|
||||
const char* as_quoted_ascii();
|
||||
|
||||
// Return the i-th utf8 byte, where i < utf8_length
|
||||
int byte_at(int i);
|
||||
// Return the i-th utf byte as a char, where i < utf8_length
|
||||
char char_at(int i);
|
||||
|
||||
// Tests if the symbol starts with the given prefix.
|
||||
bool starts_with(const char* prefix, int len) const;
|
||||
|
@ -655,7 +655,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
|
||||
"Illegal zero length constant pool entry at %d in class %s",
|
||||
name_index, CHECK);
|
||||
|
||||
if (sig->byte_at(0) == JVM_SIGNATURE_FUNC) {
|
||||
if (sig->char_at(0) == JVM_SIGNATURE_FUNC) {
|
||||
// Format check method name and signature
|
||||
verify_legal_method_name(name, CHECK);
|
||||
verify_legal_method_signature(name, sig, CHECK);
|
||||
@ -682,7 +682,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
|
||||
// CONSTANT_Dynamic's name and signature are verified above, when iterating NameAndType_info.
|
||||
// Need only to be sure signature is non-zero length and the right type.
|
||||
if (signature->utf8_length() == 0 ||
|
||||
signature->byte_at(0) == JVM_SIGNATURE_FUNC) {
|
||||
signature->char_at(0) == JVM_SIGNATURE_FUNC) {
|
||||
throwIllegalSignature("CONSTANT_Dynamic", name, signature, CHECK);
|
||||
}
|
||||
}
|
||||
@ -707,7 +707,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
|
||||
// Field name and signature are verified above, when iterating NameAndType_info.
|
||||
// Need only to be sure signature is non-zero length and the right type.
|
||||
if (signature->utf8_length() == 0 ||
|
||||
signature->byte_at(0) == JVM_SIGNATURE_FUNC) {
|
||||
signature->char_at(0) == JVM_SIGNATURE_FUNC) {
|
||||
throwIllegalSignature("Field", name, signature, CHECK);
|
||||
}
|
||||
}
|
||||
@ -716,7 +716,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
|
||||
// Method name and signature are verified above, when iterating NameAndType_info.
|
||||
// Need only to be sure signature is non-zero length and the right type.
|
||||
if (signature->utf8_length() == 0 ||
|
||||
signature->byte_at(0) != JVM_SIGNATURE_FUNC) {
|
||||
signature->char_at(0) != JVM_SIGNATURE_FUNC) {
|
||||
throwIllegalSignature("Method", name, signature, CHECK);
|
||||
}
|
||||
}
|
||||
@ -724,7 +724,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
|
||||
const unsigned int name_len = name->utf8_length();
|
||||
if (tag == JVM_CONSTANT_Methodref &&
|
||||
name_len != 0 &&
|
||||
name->byte_at(0) == '<' &&
|
||||
name->char_at(0) == '<' &&
|
||||
name != vmSymbols::object_initializer_name()) {
|
||||
classfile_parse_error(
|
||||
"Bad method name at constant pool index %u in class file %s",
|
||||
@ -942,7 +942,7 @@ void ClassFileParser::parse_interfaces(const ClassFileStream* const stream,
|
||||
|
||||
// Don't need to check legal name because it's checked when parsing constant pool.
|
||||
// But need to make sure it's not an array type.
|
||||
guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY,
|
||||
guarantee_property(unresolved_klass->char_at(0) != JVM_SIGNATURE_ARRAY,
|
||||
"Bad interface name in class file %s", CHECK);
|
||||
|
||||
// Call resolve_super so classcircularity is checked
|
||||
@ -3752,7 +3752,7 @@ const InstanceKlass* ClassFileParser::parse_super_class(ConstantPool* const cp,
|
||||
if (need_verify)
|
||||
is_array = super_klass->is_array_klass();
|
||||
} else if (need_verify) {
|
||||
is_array = (cp->klass_name_at(super_class_index)->byte_at(0) == JVM_SIGNATURE_ARRAY);
|
||||
is_array = (cp->klass_name_at(super_class_index)->char_at(0) == JVM_SIGNATURE_ARRAY);
|
||||
}
|
||||
if (need_verify) {
|
||||
guarantee_property(!is_array,
|
||||
@ -5379,7 +5379,7 @@ int ClassFileParser::verify_legal_method_signature(const Symbol* name,
|
||||
// The first non-signature thing better be a ')'
|
||||
if ((length > 0) && (*p++ == JVM_SIGNATURE_ENDFUNC)) {
|
||||
length--;
|
||||
if (name->utf8_length() > 0 && name->byte_at(0) == '<') {
|
||||
if (name->utf8_length() > 0 && name->char_at(0) == '<') {
|
||||
// All internal methods must return void
|
||||
if ((length == 1) && (p[0] == JVM_SIGNATURE_VOID)) {
|
||||
return args_size;
|
||||
@ -5796,7 +5796,7 @@ void ClassFileParser::prepend_host_package_name(const InstanceKlass* unsafe_anon
|
||||
void ClassFileParser::fix_unsafe_anonymous_class_name(TRAPS) {
|
||||
assert(_unsafe_anonymous_host != NULL, "Expected an unsafe anonymous class");
|
||||
|
||||
const jbyte* anon_last_slash = UTF8::strrchr(_class_name->base(),
|
||||
const jbyte* anon_last_slash = UTF8::strrchr((const jbyte*)_class_name->base(),
|
||||
_class_name->utf8_length(), '/');
|
||||
if (anon_last_slash == NULL) { // Unnamed package
|
||||
prepend_host_package_name(_unsafe_anonymous_host, CHECK);
|
||||
@ -6119,7 +6119,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream,
|
||||
// It has been checked when constant pool is parsed.
|
||||
// However, make sure it is not an array type.
|
||||
if (_need_verify) {
|
||||
guarantee_property(_class_name->byte_at(0) != JVM_SIGNATURE_ARRAY,
|
||||
guarantee_property(_class_name->char_at(0) != JVM_SIGNATURE_ARRAY,
|
||||
"Bad class name in class file %s",
|
||||
CHECK);
|
||||
}
|
||||
|
@ -478,8 +478,8 @@ private:
|
||||
#ifdef ASSERT
|
||||
assert(sym->utf8_length() == _len, "%s [%d,%d]", where, sym->utf8_length(), _len);
|
||||
for (int i = 0; i < _len; i++) {
|
||||
assert(sym->byte_at(i) == (jbyte) _name[i],
|
||||
"%s [%d,%d,%d]", where, i, sym->byte_at(i), _name[i]);
|
||||
assert(sym->char_at(i) == _name[i],
|
||||
"%s [%d,%d,%d]", where, i, sym->char_at(i), _name[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -2601,7 +2601,7 @@ Handle SystemDictionary::find_java_mirror_for_type(Symbol* signature,
|
||||
if (type->utf8_length() == 1) {
|
||||
|
||||
// It's a primitive. (Void has a primitive mirror too.)
|
||||
char ch = (char) type->byte_at(0);
|
||||
char ch = type->char_at(0);
|
||||
assert(is_java_primitive(char2type(ch)) || ch == 'V', "");
|
||||
return Handle(THREAD, find_java_mirror_for_type(ch));
|
||||
|
||||
|
@ -120,7 +120,7 @@ bool VerificationType::is_reference_assignable_from(
|
||||
VerificationType VerificationType::get_component(ClassVerifier *context, TRAPS) const {
|
||||
assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array");
|
||||
Symbol* component;
|
||||
switch (name()->byte_at(1)) {
|
||||
switch (name()->char_at(1)) {
|
||||
case 'Z': return VerificationType(Boolean);
|
||||
case 'B': return VerificationType(Byte);
|
||||
case 'C': return VerificationType(Char);
|
||||
|
@ -207,7 +207,7 @@ class VerificationType {
|
||||
bool is_check() const { return (_u._data & TypeQuery) == TypeQuery; }
|
||||
|
||||
bool is_x_array(char sig) const {
|
||||
return is_null() || (is_array() && (name()->byte_at(1) == sig));
|
||||
return is_null() || (is_array() && (name()->char_at(1) == sig));
|
||||
}
|
||||
bool is_int_array() const { return is_x_array('I'); }
|
||||
bool is_byte_array() const { return is_x_array('B'); }
|
||||
@ -223,10 +223,10 @@ class VerificationType {
|
||||
{ return is_object_array() || is_array_array(); }
|
||||
bool is_object() const
|
||||
{ return (is_reference() && !is_null() && name()->utf8_length() >= 1 &&
|
||||
name()->byte_at(0) != '['); }
|
||||
name()->char_at(0) != '['); }
|
||||
bool is_array() const
|
||||
{ return (is_reference() && !is_null() && name()->utf8_length() >= 2 &&
|
||||
name()->byte_at(0) == '['); }
|
||||
name()->char_at(0) == '['); }
|
||||
bool is_uninitialized() const
|
||||
{ return ((_u._data & Uninitialized) == Uninitialized); }
|
||||
bool is_uninitialized_this() const
|
||||
@ -322,7 +322,7 @@ class VerificationType {
|
||||
int dimensions() const {
|
||||
assert(is_array(), "Must be an array");
|
||||
int index = 0;
|
||||
while (name()->byte_at(index) == '[') index++;
|
||||
while (name()->char_at(index) == '[') index++;
|
||||
return index;
|
||||
}
|
||||
|
||||
|
@ -2809,7 +2809,7 @@ void ClassVerifier::verify_invoke_instructions(
|
||||
}
|
||||
}
|
||||
|
||||
if (method_name->byte_at(0) == '<') {
|
||||
if (method_name->char_at(0) == '<') {
|
||||
// Make sure <init> can only be invoked by invokespecial
|
||||
if (opcode != Bytecodes::_invokespecial ||
|
||||
method_name != vmSymbols::object_initializer_name()) {
|
||||
|
@ -212,7 +212,7 @@ void vmSymbols::serialize(SerializeClosure* soc) {
|
||||
BasicType vmSymbols::signature_type(const Symbol* s) {
|
||||
assert(s != NULL, "checking");
|
||||
if (s->utf8_length() == 1) {
|
||||
BasicType result = char2type(s->byte_at(0));
|
||||
BasicType result = char2type(s->char_at(0));
|
||||
if (is_java_primitive(result) || result == T_VOID) {
|
||||
assert(s == _type_signatures[result], "");
|
||||
return result;
|
||||
|
@ -435,8 +435,8 @@ C2V_VMENTRY(jobject, lookupType, (JNIEnv*, jobject, jstring jname, jclass access
|
||||
if (resolve) {
|
||||
resolved_klass = SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK_0);
|
||||
} else {
|
||||
if (class_name->byte_at(0) == 'L' &&
|
||||
class_name->byte_at(class_name->utf8_length()-1) == ';') {
|
||||
if (class_name->char_at(0) == 'L' &&
|
||||
class_name->char_at(class_name->utf8_length()-1) == ';') {
|
||||
// This is a name from a signature. Strip off the trimmings.
|
||||
// Call recursive to keep scope of strippedsym.
|
||||
TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1,
|
||||
|
@ -98,8 +98,8 @@ Klass* JVMCIEnv::get_klass_by_name_impl(Klass* accessing_klass,
|
||||
JVMCI_EXCEPTION_CONTEXT;
|
||||
|
||||
// Now we need to check the SystemDictionary
|
||||
if (sym->byte_at(0) == 'L' &&
|
||||
sym->byte_at(sym->utf8_length()-1) == ';') {
|
||||
if (sym->char_at(0) == 'L' &&
|
||||
sym->char_at(sym->utf8_length()-1) == ';') {
|
||||
// This is a name from a signature. Strip off the trimmings.
|
||||
// Call recursive to keep scope of strippedsym.
|
||||
TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
|
||||
@ -132,8 +132,8 @@ Klass* JVMCIEnv::get_klass_by_name_impl(Klass* accessing_klass,
|
||||
// we must build an array type around it. The CI requires array klasses
|
||||
// to be loaded if their element klasses are loaded, except when memory
|
||||
// is exhausted.
|
||||
if (sym->byte_at(0) == '[' &&
|
||||
(sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) {
|
||||
if (sym->char_at(0) == '[' &&
|
||||
(sym->char_at(1) == '[' || sym->char_at(1) == 'L')) {
|
||||
// We have an unloaded array.
|
||||
// Build it on the fly if the element class exists.
|
||||
TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
|
||||
|
@ -79,7 +79,7 @@ void Symbol::operator delete(void *p) {
|
||||
bool Symbol::starts_with(const char* prefix, int len) const {
|
||||
if (len > utf8_length()) return false;
|
||||
while (len-- > 0) {
|
||||
if (prefix[len] != (char) byte_at(len))
|
||||
if (prefix[len] != char_at(len))
|
||||
return false;
|
||||
}
|
||||
assert(len == -1, "we should be at the beginning");
|
||||
@ -117,7 +117,7 @@ char* Symbol::as_C_string(char* buf, int size) const {
|
||||
if (size > 0) {
|
||||
int len = MIN2(size - 1, utf8_length());
|
||||
for (int i = 0; i < len; i++) {
|
||||
buf[i] = byte_at(i);
|
||||
buf[i] = char_at(i);
|
||||
}
|
||||
buf[len] = '\0';
|
||||
}
|
||||
@ -311,7 +311,7 @@ void Symbol::print_value_on(outputStream* st) const {
|
||||
} else {
|
||||
st->print("'");
|
||||
for (int i = 0; i < utf8_length(); i++) {
|
||||
st->print("%c", byte_at(i));
|
||||
st->print("%c", char_at(i));
|
||||
}
|
||||
st->print("'");
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ class Symbol : public MetaspaceObj {
|
||||
// in high half word. length is the number of UTF8 characters in the symbol
|
||||
volatile uint32_t _length_and_refcount;
|
||||
short _identity_hash;
|
||||
jbyte _body[2];
|
||||
u1 _body[2];
|
||||
|
||||
enum {
|
||||
// max_symbol_length must fit into the top 16 bits of _length_and_refcount
|
||||
@ -128,7 +128,7 @@ class Symbol : public MetaspaceObj {
|
||||
return (int)heap_word_size(byte_size(length));
|
||||
}
|
||||
|
||||
void byte_at_put(int index, int value) {
|
||||
void byte_at_put(int index, u1 value) {
|
||||
assert(index >=0 && index < length(), "symbol index overflow");
|
||||
_body[index] = value;
|
||||
}
|
||||
@ -148,7 +148,7 @@ class Symbol : public MetaspaceObj {
|
||||
|
||||
public:
|
||||
// Low-level access (used with care, since not GC-safe)
|
||||
const jbyte* base() const { return &_body[0]; }
|
||||
const u1* base() const { return &_body[0]; }
|
||||
|
||||
int size() { return size(utf8_length()); }
|
||||
int byte_size() { return byte_size(utf8_length()); }
|
||||
@ -176,12 +176,16 @@ class Symbol : public MetaspaceObj {
|
||||
return (refcount() == PERM_REFCOUNT);
|
||||
}
|
||||
|
||||
int byte_at(int index) const {
|
||||
// Function char_at() returns the Symbol's selected u1 byte as a char type.
|
||||
//
|
||||
// Note that all multi-byte chars have the sign bit set on all their bytes.
|
||||
// No single byte chars have their sign bit set.
|
||||
char char_at(int index) const {
|
||||
assert(index >=0 && index < length(), "symbol index overflow");
|
||||
return base()[index];
|
||||
return (char)base()[index];
|
||||
}
|
||||
|
||||
const jbyte* bytes() const { return base(); }
|
||||
const u1* bytes() const { return base(); }
|
||||
|
||||
int utf8_length() const { return length(); }
|
||||
|
||||
@ -190,7 +194,7 @@ class Symbol : public MetaspaceObj {
|
||||
int l = utf8_length();
|
||||
if (l != len) return false;
|
||||
while (l-- > 0) {
|
||||
if (str[l] != (char) byte_at(l))
|
||||
if (str[l] != char_at(l))
|
||||
return false;
|
||||
}
|
||||
assert(l == -1, "we should be at the beginning");
|
||||
|
@ -853,7 +853,7 @@ ClassFieldMap* ClassFieldMap::create_map_of_static_fields(Klass* k) {
|
||||
if (!fld.access_flags().is_static()) {
|
||||
continue;
|
||||
}
|
||||
field_map->add(max_field_index - index, fld.signature()->byte_at(0), fld.offset());
|
||||
field_map->add(max_field_index - index, fld.signature()->char_at(0), fld.offset());
|
||||
}
|
||||
return field_map;
|
||||
}
|
||||
@ -879,7 +879,7 @@ ClassFieldMap* ClassFieldMap::create_map_of_instance_fields(oop obj) {
|
||||
if (fld.access_flags().is_static()) {
|
||||
continue;
|
||||
}
|
||||
field_map->add(max_field_index - index, fld.signature()->byte_at(0), fld.offset());
|
||||
field_map->add(max_field_index - index, fld.signature()->char_at(0), fld.offset());
|
||||
}
|
||||
|
||||
return field_map;
|
||||
|
@ -537,7 +537,7 @@ bool MethodHandles::is_basic_type_signature(Symbol* sig) {
|
||||
assert(vmSymbols::object_signature()->equals(OBJ_SIG), "");
|
||||
const int len = sig->utf8_length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
switch (sig->byte_at(i)) {
|
||||
switch (sig->char_at(i)) {
|
||||
case 'L':
|
||||
// only java/lang/Object is valid here
|
||||
if (sig->index_of_at(i, OBJ_SIG, OBJ_SIG_LEN) != i)
|
||||
@ -563,8 +563,8 @@ Symbol* MethodHandles::lookup_basic_type_signature(Symbol* sig, bool keep_last_a
|
||||
} else if (is_basic_type_signature(sig)) {
|
||||
sig->increment_refcount();
|
||||
return sig; // that was easy
|
||||
} else if (sig->byte_at(0) != '(') {
|
||||
BasicType bt = char2type(sig->byte_at(0));
|
||||
} else if (sig->char_at(0) != '(') {
|
||||
BasicType bt = char2type(sig->char_at(0));
|
||||
if (is_subword_type(bt)) {
|
||||
bsig = vmSymbols::int_signature();
|
||||
} else {
|
||||
@ -615,7 +615,7 @@ void MethodHandles::print_as_basic_type_signature_on(outputStream* st,
|
||||
int array = 0;
|
||||
bool prev_type = false;
|
||||
for (int i = 0; i < len; i++) {
|
||||
char ch = sig->byte_at(i);
|
||||
char ch = sig->char_at(i);
|
||||
switch (ch) {
|
||||
case '(': case ')':
|
||||
prev_type = false;
|
||||
@ -630,7 +630,7 @@ void MethodHandles::print_as_basic_type_signature_on(outputStream* st,
|
||||
{
|
||||
if (prev_type) st->put(',');
|
||||
int start = i+1, slash = start;
|
||||
while (++i < len && (ch = sig->byte_at(i)) != ';') {
|
||||
while (++i < len && (ch = sig->char_at(i)) != ';') {
|
||||
if (ch == '/' || ch == '.' || ch == '$') slash = i+1;
|
||||
}
|
||||
if (slash < i) start = slash;
|
||||
@ -638,7 +638,7 @@ void MethodHandles::print_as_basic_type_signature_on(outputStream* st,
|
||||
st->put('L');
|
||||
} else {
|
||||
for (int j = start; j < i; j++)
|
||||
st->put(sig->byte_at(j));
|
||||
st->put(sig->char_at(j));
|
||||
prev_type = true;
|
||||
}
|
||||
break;
|
||||
@ -975,7 +975,7 @@ int MethodHandles::find_MemberNames(Klass* k,
|
||||
}
|
||||
if (sig != NULL) {
|
||||
if (sig->utf8_length() == 0) return 0; // a match is not possible
|
||||
if (sig->byte_at(0) == '(')
|
||||
if (sig->char_at(0) == '(')
|
||||
match_flags &= ~(IS_FIELD | IS_TYPE);
|
||||
else
|
||||
match_flags &= ~(IS_CONSTRUCTOR | IS_METHOD);
|
||||
@ -1456,7 +1456,7 @@ JVM_ENTRY(void, MHN_copyOutBootstrapArguments(JNIEnv* env, jobject igcls,
|
||||
{
|
||||
Symbol* type = caller->constants()->signature_ref_at(bss_index_in_pool);
|
||||
Handle th;
|
||||
if (type->byte_at(0) == '(') {
|
||||
if (type->char_at(0) == '(') {
|
||||
th = SystemDictionary::find_method_handle_type(type, caller, CHECK);
|
||||
} else {
|
||||
th = SystemDictionary::find_java_mirror_for_type(type, caller, SignatureStream::NCDFError, CHECK);
|
||||
|
@ -103,7 +103,7 @@ char* NativeLookup::long_jni_name(const methodHandle& method) {
|
||||
st.print("__");
|
||||
// find ')'
|
||||
int end;
|
||||
for (end = 0; end < signature->utf8_length() && signature->byte_at(end) != ')'; end++);
|
||||
for (end = 0; end < signature->utf8_length() && signature->char_at(end) != ')'; end++);
|
||||
// skip first '('
|
||||
mangle_name_on(&st, signature, 1, end);
|
||||
return st.as_string();
|
||||
@ -288,7 +288,7 @@ address NativeLookup::lookup_critical_entry(const methodHandle& method) {
|
||||
|
||||
Symbol* signature = method->signature();
|
||||
for (int end = 0; end < signature->utf8_length(); end++) {
|
||||
if (signature->byte_at(end) == 'L') {
|
||||
if (signature->char_at(end) == 'L') {
|
||||
// Don't allow object types
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1451,7 +1451,7 @@ void Deoptimization::load_class_by_index(const constantPoolHandle& constant_pool
|
||||
Symbol* symbol = constant_pool->symbol_at(index);
|
||||
|
||||
// class name?
|
||||
if (symbol->byte_at(0) != '(') {
|
||||
if (symbol->char_at(0) != '(') {
|
||||
Handle protection_domain (THREAD, constant_pool->pool_holder()->protection_domain());
|
||||
SystemDictionary::resolve_or_null(symbol, class_loader, protection_domain, CHECK);
|
||||
return;
|
||||
|
@ -32,21 +32,21 @@
|
||||
#include "runtime/signature.hpp"
|
||||
|
||||
BasicType FieldType::basic_type(Symbol* signature) {
|
||||
return char2type(signature->byte_at(0));
|
||||
return char2type(signature->char_at(0));
|
||||
}
|
||||
|
||||
// Check if it is a valid array signature
|
||||
bool FieldType::is_valid_array_signature(Symbol* sig) {
|
||||
assert(sig->utf8_length() > 1, "this should already have been checked");
|
||||
assert(sig->byte_at(0) == '[', "this should already have been checked");
|
||||
assert(sig->char_at(0) == '[', "this should already have been checked");
|
||||
// The first character is already checked
|
||||
int i = 1;
|
||||
int len = sig->utf8_length();
|
||||
// First skip all '['s
|
||||
while(i < len - 1 && sig->byte_at(i) == '[') i++;
|
||||
while(i < len - 1 && sig->char_at(i) == '[') i++;
|
||||
|
||||
// Check type
|
||||
switch(sig->byte_at(i)) {
|
||||
switch(sig->char_at(i)) {
|
||||
case 'B': // T_BYTE
|
||||
case 'C': // T_CHAR
|
||||
case 'D': // T_DOUBLE
|
||||
@ -59,7 +59,7 @@ bool FieldType::is_valid_array_signature(Symbol* sig) {
|
||||
return (i + 1 == len);
|
||||
case 'L':
|
||||
// If it is an object, the last character must be a ';'
|
||||
return sig->byte_at(len - 1) == ';';
|
||||
return sig->char_at(len - 1) == ';';
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -70,7 +70,7 @@ BasicType FieldType::get_array_info(Symbol* signature, FieldArrayInfo& fd, TRAPS
|
||||
assert(basic_type(signature) == T_ARRAY, "must be array");
|
||||
int index = 1;
|
||||
int dim = 1;
|
||||
while (signature->byte_at(index) == '[') {
|
||||
while (signature->char_at(index) == '[') {
|
||||
index++;
|
||||
dim++;
|
||||
}
|
||||
|
@ -58,14 +58,14 @@ class FieldType: public AllStatic {
|
||||
static BasicType basic_type(Symbol* signature);
|
||||
|
||||
// Testing
|
||||
static bool is_array(Symbol* signature) { return signature->utf8_length() > 1 && signature->byte_at(0) == '[' && is_valid_array_signature(signature); }
|
||||
static bool is_array(Symbol* signature) { return signature->utf8_length() > 1 && signature->char_at(0) == '[' && is_valid_array_signature(signature); }
|
||||
|
||||
static bool is_obj(Symbol* signature) {
|
||||
int sig_length = signature->utf8_length();
|
||||
// Must start with 'L' and end with ';'
|
||||
return (sig_length >= 2 &&
|
||||
(signature->byte_at(0) == 'L') &&
|
||||
(signature->byte_at(sig_length - 1) == ';'));
|
||||
(signature->char_at(0) == 'L') &&
|
||||
(signature->char_at(sig_length - 1) == ';'));
|
||||
}
|
||||
|
||||
// Parse field and extract array information. Works for T_ARRAY only.
|
||||
|
@ -50,7 +50,7 @@ SignatureIterator::SignatureIterator(Symbol* signature) {
|
||||
}
|
||||
|
||||
void SignatureIterator::expect(char c) {
|
||||
if (_signature->byte_at(_index) != c) fatal("expecting %c", c);
|
||||
if (_signature->char_at(_index) != c) fatal("expecting %c", c);
|
||||
_index++;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ int SignatureIterator::parse_type() {
|
||||
// work (stack underflow for some tests) - this seems to be a VC++ 6.0
|
||||
// compiler bug (was problem - gri 4/27/2000).
|
||||
int size = -1;
|
||||
switch(_signature->byte_at(_index)) {
|
||||
switch(_signature->char_at(_index)) {
|
||||
case 'B': do_byte (); if (_parameter_index < 0 ) _return_type = T_BYTE;
|
||||
_index++; size = T_BYTE_size ; break;
|
||||
case 'C': do_char (); if (_parameter_index < 0 ) _return_type = T_CHAR;
|
||||
@ -83,7 +83,7 @@ int SignatureIterator::parse_type() {
|
||||
case 'L':
|
||||
{ int begin = ++_index;
|
||||
Symbol* sig = _signature;
|
||||
while (sig->byte_at(_index++) != ';') ;
|
||||
while (sig->char_at(_index++) != ';') ;
|
||||
do_object(begin, _index);
|
||||
}
|
||||
if (_parameter_index < 0 ) _return_type = T_OBJECT;
|
||||
@ -92,11 +92,11 @@ int SignatureIterator::parse_type() {
|
||||
case '[':
|
||||
{ int begin = ++_index;
|
||||
Symbol* sig = _signature;
|
||||
while (sig->byte_at(_index) == '[') {
|
||||
while (sig->char_at(_index) == '[') {
|
||||
_index++;
|
||||
}
|
||||
if (sig->byte_at(_index) == 'L') {
|
||||
while (sig->byte_at(_index++) != ';') ;
|
||||
if (sig->char_at(_index) == 'L') {
|
||||
while (sig->char_at(_index++) != ';') ;
|
||||
} else {
|
||||
_index++;
|
||||
}
|
||||
@ -137,7 +137,7 @@ void SignatureIterator::iterate_parameters() {
|
||||
_index = 0;
|
||||
_parameter_index = 0;
|
||||
expect('(');
|
||||
while (_signature->byte_at(_index) != ')') _parameter_index += parse_type();
|
||||
while (_signature->char_at(_index) != ')') _parameter_index += parse_type();
|
||||
expect(')');
|
||||
_parameter_index = 0;
|
||||
}
|
||||
@ -217,8 +217,8 @@ void SignatureIterator::iterate_returntype() {
|
||||
// Need to skip over each type in the signature's argument list until a
|
||||
// closing ')' is found., then get the return type. We cannot just scan
|
||||
// for the first ')' because ')' is a legal character in a type name.
|
||||
while (sig->byte_at(_index) != ')') {
|
||||
switch(sig->byte_at(_index)) {
|
||||
while (sig->char_at(_index) != ')') {
|
||||
switch(sig->char_at(_index)) {
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
@ -234,17 +234,17 @@ void SignatureIterator::iterate_returntype() {
|
||||
break;
|
||||
case 'L':
|
||||
{
|
||||
while (sig->byte_at(_index++) != ';') ;
|
||||
while (sig->char_at(_index++) != ';') ;
|
||||
}
|
||||
break;
|
||||
case '[':
|
||||
{
|
||||
int begin = ++_index;
|
||||
while (sig->byte_at(_index) == '[') {
|
||||
while (sig->char_at(_index) == '[') {
|
||||
_index++;
|
||||
}
|
||||
if (sig->byte_at(_index) == 'L') {
|
||||
while (sig->byte_at(_index++) != ';') ;
|
||||
if (sig->char_at(_index) == 'L') {
|
||||
while (sig->char_at(_index++) != ';') ;
|
||||
} else {
|
||||
_index++;
|
||||
}
|
||||
@ -269,7 +269,7 @@ void SignatureIterator::iterate() {
|
||||
_parameter_index = 0;
|
||||
_index = 0;
|
||||
expect('(');
|
||||
while (_signature->byte_at(_index) != ')') _parameter_index += parse_type();
|
||||
while (_signature->char_at(_index) != ')') _parameter_index += parse_type();
|
||||
expect(')');
|
||||
// Parse return type
|
||||
_parameter_index = -1;
|
||||
@ -304,20 +304,20 @@ void SignatureStream::next_non_primitive(int t) {
|
||||
case 'L': {
|
||||
_type = T_OBJECT;
|
||||
Symbol* sig = _signature;
|
||||
while (sig->byte_at(_end++) != ';');
|
||||
while (sig->char_at(_end++) != ';');
|
||||
break;
|
||||
}
|
||||
case '[': {
|
||||
_type = T_ARRAY;
|
||||
Symbol* sig = _signature;
|
||||
char c = sig->byte_at(_end);
|
||||
while ('0' <= c && c <= '9') c = sig->byte_at(_end++);
|
||||
while (sig->byte_at(_end) == '[') {
|
||||
char c = sig->char_at(_end);
|
||||
while ('0' <= c && c <= '9') c = sig->char_at(_end++);
|
||||
while (sig->char_at(_end) == '[') {
|
||||
_end++;
|
||||
c = sig->byte_at(_end);
|
||||
while ('0' <= c && c <= '9') c = sig->byte_at(_end++);
|
||||
c = sig->char_at(_end);
|
||||
while ('0' <= c && c <= '9') c = sig->char_at(_end++);
|
||||
}
|
||||
switch(sig->byte_at(_end)) {
|
||||
switch(sig->char_at(_end)) {
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
@ -327,7 +327,7 @@ void SignatureStream::next_non_primitive(int t) {
|
||||
case 'S':
|
||||
case 'Z':_end++; break;
|
||||
default: {
|
||||
while (sig->byte_at(_end++) != ';');
|
||||
while (sig->char_at(_end++) != ';');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -353,8 +353,8 @@ Symbol* SignatureStream::as_symbol(TRAPS) {
|
||||
int begin = _begin;
|
||||
int end = _end;
|
||||
|
||||
if ( _signature->byte_at(_begin) == 'L'
|
||||
&& _signature->byte_at(_end-1) == ';') {
|
||||
if ( _signature->char_at(_begin) == 'L'
|
||||
&& _signature->char_at(_end-1) == ';') {
|
||||
begin++;
|
||||
end--;
|
||||
}
|
||||
@ -394,15 +394,15 @@ Symbol* SignatureStream::as_symbol_or_null() {
|
||||
int begin = _begin;
|
||||
int end = _end;
|
||||
|
||||
if ( _signature->byte_at(_begin) == 'L'
|
||||
&& _signature->byte_at(_end-1) == ';') {
|
||||
if ( _signature->char_at(_begin) == 'L'
|
||||
&& _signature->char_at(_end-1) == ';') {
|
||||
begin++;
|
||||
end--;
|
||||
}
|
||||
|
||||
char* buffer = NEW_RESOURCE_ARRAY(char, end - begin);
|
||||
for (int index = begin; index < end; index++) {
|
||||
buffer[index - begin] = _signature->byte_at(index);
|
||||
buffer[index - begin] = _signature->char_at(index);
|
||||
}
|
||||
Symbol* result = SymbolTable::probe(buffer, end - begin);
|
||||
return result;
|
||||
|
@ -378,7 +378,7 @@ class SignatureStream : public StackObj {
|
||||
}
|
||||
|
||||
_begin = _end;
|
||||
int t = sig->byte_at(_begin);
|
||||
int t = sig->char_at(_begin);
|
||||
switch (t) {
|
||||
case 'B': _type = T_BYTE; break;
|
||||
case 'C': _type = T_CHAR; break;
|
||||
@ -405,8 +405,8 @@ class SignatureStream : public StackObj {
|
||||
enum FailureMode { ReturnNull, CNFException, NCDFError };
|
||||
Klass* as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
|
||||
oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
|
||||
const jbyte* raw_bytes() { return _signature->bytes() + _begin; }
|
||||
int raw_length() { return _end - _begin; }
|
||||
const u1* raw_bytes() { return _signature->bytes() + _begin; }
|
||||
int raw_length() { return _end - _begin; }
|
||||
|
||||
// return same as_symbol except allocation of new symbols is avoided.
|
||||
Symbol* as_symbol_or_null();
|
||||
|
@ -329,8 +329,8 @@ typedef PaddedEnd<ObjectMonitor> PaddedObjectMonitor;
|
||||
nonstatic_field(ObjArrayKlass, _bottom_klass, Klass*) \
|
||||
volatile_nonstatic_field(Symbol, _length_and_refcount, unsigned int) \
|
||||
nonstatic_field(Symbol, _identity_hash, short) \
|
||||
unchecked_nonstatic_field(Symbol, _body, sizeof(jbyte)) /* NOTE: no type */ \
|
||||
nonstatic_field(Symbol, _body[0], jbyte) \
|
||||
unchecked_nonstatic_field(Symbol, _body, sizeof(u1)) /* NOTE: no type */ \
|
||||
nonstatic_field(Symbol, _body[0], u1) \
|
||||
nonstatic_field(TypeArrayKlass, _max_length, jint) \
|
||||
\
|
||||
/***********************/ \
|
||||
|
@ -696,7 +696,7 @@ void DumperSupport:: write_header(DumpWriter* writer, hprofTag tag, u4 len) {
|
||||
|
||||
// returns hprof tag for the given type signature
|
||||
hprofTag DumperSupport::sig2tag(Symbol* sig) {
|
||||
switch (sig->byte_at(0)) {
|
||||
switch (sig->char_at(0)) {
|
||||
case JVM_SIGNATURE_CLASS : return HPROF_NORMAL_OBJECT;
|
||||
case JVM_SIGNATURE_ARRAY : return HPROF_NORMAL_OBJECT;
|
||||
case JVM_SIGNATURE_BYTE : return HPROF_BYTE;
|
||||
@ -821,7 +821,7 @@ u4 DumperSupport::instance_size(Klass* k) {
|
||||
for (FieldStream fld(ik, false, false); !fld.eos(); fld.next()) {
|
||||
if (!fld.access_flags().is_static()) {
|
||||
Symbol* sig = fld.signature();
|
||||
switch (sig->byte_at(0)) {
|
||||
switch (sig->char_at(0)) {
|
||||
case JVM_SIGNATURE_CLASS :
|
||||
case JVM_SIGNATURE_ARRAY : size += oopSize; break;
|
||||
|
||||
@ -889,7 +889,7 @@ void DumperSupport::dump_static_fields(DumpWriter* writer, Klass* k) {
|
||||
writer->write_u1(sig2tag(sig)); // type
|
||||
|
||||
// value
|
||||
dump_field_value(writer, sig->byte_at(0), ik->java_mirror(), fld.offset());
|
||||
dump_field_value(writer, sig->char_at(0), ik->java_mirror(), fld.offset());
|
||||
}
|
||||
}
|
||||
|
||||
@ -925,7 +925,7 @@ void DumperSupport::dump_instance_fields(DumpWriter* writer, oop o) {
|
||||
for (FieldStream fld(ik, false, false); !fld.eos(); fld.next()) {
|
||||
if (!fld.access_flags().is_static()) {
|
||||
Symbol* sig = fld.signature();
|
||||
dump_field_value(writer, sig->byte_at(0), o, fld.offset());
|
||||
dump_field_value(writer, sig->char_at(0), o, fld.offset());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -57,7 +57,7 @@ import sun.jvm.hotspot.debugger.*;
|
||||
|
||||
FIXME: among other things, this interface is not sufficient to
|
||||
describe fields which are themselves arrays (like Symbol's
|
||||
jbyte _body[1]). */
|
||||
u1 _body[1]). */
|
||||
public interface Field {
|
||||
/** Get the name of this field */
|
||||
public String getName();
|
||||
|
Loading…
x
Reference in New Issue
Block a user