A licensee was seeing an assert in SymbolTable::basic_add fire. The
assert was:
assert(sym->equals((char*)name, len), "symbol must be properly initialized");
If you look at the code it seems clear that for the assert to fire that either
the compiler was broken or something similar. It certainly should not be a
failure that a licensee could induce in the port. The licensee tracked it
down to a dependency on whether char defaults to signed or unsigned. Apparently
their compiler is using unsigned as a default. Here is what licensee sent
in:
hotspot/src/share/vm/oops/symbolOopDesc.cpp
FUNCTION:
bool symbolOopDesc::equals(const char* str, int len) const {
int l = utf_length();
if(l != len) return false;
while (l-- > 0) {
if (str[l] != byte_at(l)) return false;
}
assert(l == -1, "we should be at the beginning");
return true;
}
str is of type const char
and the array in the object is a jbyte which is an 'signed char'
The function byte_at returns an 'int' so with gcc 3.3.3 the result of
byte_at(l) for a character value of 0x80 is 0xFFFFFF80 which does not match
the value in str[l] as it did not upcast it. I do not know the compiler
rules for casting of differing types but a simple (char)byte_at(l) solves
the problem.
assert was:
assert(sym->equals((char*)name, len), "symbol must be properly initialized");
If you look at the code it seems clear that for the assert to fire that either
the compiler was broken or something similar. It certainly should not be a
failure that a licensee could induce in the port. The licensee tracked it
down to a dependency on whether char defaults to signed or unsigned. Apparently
their compiler is using unsigned as a default. Here is what licensee sent
in:
hotspot/src/share/vm/oops/symbolOopDesc.cpp
FUNCTION:
bool symbolOopDesc::equals(const char* str, int len) const {
int l = utf_length();
if(l != len) return false;
while (l-- > 0) {
if (str[l] != byte_at(l)) return false;
}
assert(l == -1, "we should be at the beginning");
return true;
}
str is of type const char
and the array in the object is a jbyte which is an 'signed char'
The function byte_at returns an 'int' so with gcc 3.3.3 the result of
byte_at(l) for a character value of 0x80 is 0xFFFFFF80 which does not match
the value in str[l] as it did not upcast it. I do not know the compiler
rules for casting of differing types but a simple (char)byte_at(l) solves
the problem.