/* Take pointer to a string. Skip over the longest part of the string that *couldbetakenasafieldname.Allow'/'ifslash_okayisJNI_TRUE. * *Returnapointertojustpastthefieldname.ReturnNULLifnofieldname *atallwasfound,orinthecaseofslash_okaybeingtrue,wesaw *consecutiveslashes(meaningwewerelookingforaqualifiedpathbut *foundsomethingthatwasbadly-formed).
*/ staticchar *
skip_over_fieldname(char *name, jboolean slash_okay, unsignedint length)
{ char *p;
unicode ch;
unicode last_ch = 0; int valid = 1; /* last_ch == 0 implies we are looking at the first char. */ for (p = name; p != name + length; last_ch = ch) { char *old_p = p;
ch = *p; if (ch < 128) {
p++; if (isJvmIdentifier(ch)) { continue;
}
} else { char *tmp_p = p;
ch = next_utf2unicode(&tmp_p, &valid); if (valid == 0) return0;
p = tmp_p; if (isJvmIdentifier(ch)) { continue;
}
}
/* Take pointer to a string. Skip over the longest part of the string that *couldbetakenasafieldsignature.Allow"void"ifvoid_okay. * *Returnapointertojustpastthesignature.ReturnNULLifnolegal *signatureisfound.
*/
staticchar *
skip_over_field_signature(char *name, jboolean void_okay, unsignedint length)
{ unsignedint array_dim = 0; for (;length > 0;) { switch (name[0]) { case JVM_SIGNATURE_VOID: if (!void_okay) return0; /* FALL THROUGH */ case JVM_SIGNATURE_BOOLEAN: case JVM_SIGNATURE_BYTE: case JVM_SIGNATURE_CHAR: case JVM_SIGNATURE_SHORT: case JVM_SIGNATURE_INT: case JVM_SIGNATURE_FLOAT: case JVM_SIGNATURE_LONG: case JVM_SIGNATURE_DOUBLE: return name + 1;
case JVM_SIGNATURE_CLASS: { /* Skip over the classname, if one is there. */ char *p =
skip_over_fieldname(name + 1, JNI_TRUE, --length); /* The next character better be a semicolon. */ if (p && p - name - 1 > 0 && p[0] == ';') return p + 1; return0;
}
case JVM_SIGNATURE_ARRAY:
array_dim++; /* JVMS 2nd ed. 4.10 */ /* The number of dimensions in an array is limited to 255 ... */ if (array_dim > 255) { return0;
} /* The rest of what's there better be a legal signature. */
name++;
length--;
void_okay = JNI_FALSE; break;
default: return0;
}
} return0;
}
/* Determine if the specified name is legal *UTFnameforaclassname. * *Notethatthisroutineexpectstheinternalformofqualifiedclasses: *thedotsshouldhavebeenreplacedbyslashes.
*/
jboolean verifyClassname(char *name, jboolean allowArrayClass)
{
size_t s = strlen(name);
assert(s <= UINT_MAX); unsignedint length = (unsignedint)s; char *p;
if (length > 0 && name[0] == JVM_SIGNATURE_ARRAY) { if (!allowArrayClass) { return JNI_FALSE;
} else { /* Everything that's left better be a field signature */
p = skip_over_field_signature(name, JNI_FALSE, length);
}
} else { /* skip over the fieldname. Slashes are okay */
p = skip_over_fieldname(name, JNI_TRUE, length);
} return (p != 0 && p - name == (ptrdiff_t)length);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.