defineclass.cc (handleField): Throw exception if field name is duplicated.
* defineclass.cc (handleField): Throw exception if field name is duplicated. (handleMethod): Throw exception for duplicate method. From-SVN: r69928
This commit is contained in:
parent
b33ab7a9b0
commit
a47c20a77a
2 changed files with 33 additions and 10 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2003-07-29 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* defineclass.cc (handleField): Throw exception if field name is
|
||||||
|
duplicated.
|
||||||
|
(handleMethod): Throw exception for duplicate method.
|
||||||
|
|
||||||
2003-07-29 Tom Tromey <tromey@redhat.com>
|
2003-07-29 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* gnu/gcj/convert/natIconv.cc (write): Handle case where
|
* gnu/gcj/convert/natIconv.cc (write): Handle case where
|
||||||
|
|
|
@ -75,7 +75,7 @@ struct _Jv_ClassReader {
|
||||||
// allways on. You always want this as far as I can see, but it also
|
// allways on. You always want this as far as I can see, but it also
|
||||||
// controls weither identifiers and type descriptors/signatures are
|
// controls weither identifiers and type descriptors/signatures are
|
||||||
// verified as legal. This could be somewhat more expensive since it
|
// verified as legal. This could be somewhat more expensive since it
|
||||||
// will call Characher.isJavaIdentifier{Start,Part} for each character
|
// will call Character.isJavaIdentifier{Start,Part} for each character
|
||||||
// in any identifier (field name or method name) it comes by. Thus,
|
// in any identifier (field name or method name) it comes by. Thus,
|
||||||
// it might be useful to turn off this verification for classes that
|
// it might be useful to turn off this verification for classes that
|
||||||
// come from a trusted source. However, for GCJ, trusted classes are
|
// come from a trusted source. However, for GCJ, trusted classes are
|
||||||
|
@ -1071,14 +1071,25 @@ void _Jv_ClassReader::handleField (int field_no,
|
||||||
field->nameIndex = name;
|
field->nameIndex = name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (verify)
|
// Ignore flags we don't know about.
|
||||||
verify_identifier (field_name);
|
|
||||||
|
|
||||||
// ignore flags we don't know about.
|
|
||||||
field->flags = flags & Modifier::ALL_FLAGS;
|
field->flags = flags & Modifier::ALL_FLAGS;
|
||||||
|
|
||||||
|
_Jv_Utf8Const* sig = pool_data[desc].utf8;
|
||||||
|
|
||||||
if (verify)
|
if (verify)
|
||||||
{
|
{
|
||||||
|
verify_identifier (field_name);
|
||||||
|
|
||||||
|
for (int i = 0; i < field_no; ++i)
|
||||||
|
{
|
||||||
|
if (_Jv_equalUtf8Consts (field_name, def->fields[i].name)
|
||||||
|
&& _Jv_equalUtf8Consts (sig,
|
||||||
|
// We know the other fields are
|
||||||
|
// unresolved.
|
||||||
|
(_Jv_Utf8Const *) def->fields[i].type))
|
||||||
|
throw_class_format_error ("duplicate field name");
|
||||||
|
}
|
||||||
|
|
||||||
if (field->flags & (Modifier::SYNCHRONIZED
|
if (field->flags & (Modifier::SYNCHRONIZED
|
||||||
| Modifier::NATIVE
|
| Modifier::NATIVE
|
||||||
| Modifier::INTERFACE
|
| Modifier::INTERFACE
|
||||||
|
@ -1091,8 +1102,6 @@ void _Jv_ClassReader::handleField (int field_no,
|
||||||
throw_class_format_error ("erroneous field access flags");
|
throw_class_format_error ("erroneous field access flags");
|
||||||
}
|
}
|
||||||
|
|
||||||
_Jv_Utf8Const* sig = pool_data[desc].utf8;
|
|
||||||
|
|
||||||
if (verify)
|
if (verify)
|
||||||
_Jv_VerifyFieldSignature (sig);
|
_Jv_VerifyFieldSignature (sig);
|
||||||
|
|
||||||
|
@ -1233,6 +1242,14 @@ void _Jv_ClassReader::handleMethod
|
||||||
|
|
||||||
_Jv_VerifyMethodSignature (method->signature);
|
_Jv_VerifyMethodSignature (method->signature);
|
||||||
|
|
||||||
|
for (int i = 0; i < mth_index; ++i)
|
||||||
|
{
|
||||||
|
if (_Jv_equalUtf8Consts (method->name, def->methods[i].name)
|
||||||
|
&& _Jv_equalUtf8Consts (method->signature,
|
||||||
|
def->methods[i].signature))
|
||||||
|
throw_class_format_error ("duplicate method");
|
||||||
|
}
|
||||||
|
|
||||||
if (method->accflags & (Modifier::VOLATILE
|
if (method->accflags & (Modifier::VOLATILE
|
||||||
| Modifier::TRANSIENT
|
| Modifier::TRANSIENT
|
||||||
| Modifier::INTERFACE))
|
| Modifier::INTERFACE))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue