summaryrefslogtreecommitdiffstats
path: root/libjava/defineclass.cc
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-07-29 17:12:54 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-07-29 17:12:54 +0000
commit378433550164faf6f571ca155c017b60f347053f (patch)
tree994095e34ee432cdb5d4b8668ece34c1c9ad7aba /libjava/defineclass.cc
parent8dec8e5f66929061b9cab6ef349b3238287db701 (diff)
downloadppe42-gcc-378433550164faf6f571ca155c017b60f347053f.tar.gz
ppe42-gcc-378433550164faf6f571ca155c017b60f347053f.zip
* defineclass.cc (handleField): Throw exception if field name is
duplicated. (handleMethod): Throw exception for duplicate method. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69928 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/defineclass.cc')
-rw-r--r--libjava/defineclass.cc37
1 files changed, 27 insertions, 10 deletions
diff --git a/libjava/defineclass.cc b/libjava/defineclass.cc
index 001fa0131f0..4cd4f4f1936 100644
--- a/libjava/defineclass.cc
+++ b/libjava/defineclass.cc
@@ -75,7 +75,7 @@ struct _Jv_ClassReader {
// allways on. You always want this as far as I can see, but it also
// controls weither identifiers and type descriptors/signatures are
// 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,
// it might be useful to turn off this verification for classes that
// come from a trusted source. However, for GCJ, trusted classes are
@@ -403,15 +403,15 @@ void _Jv_ClassReader::read_fields ()
int name_index = read2u ();
int descriptor_index = read2u ();
int attributes_count = read2u ();
-
+
check_tag (name_index, JV_CONSTANT_Utf8);
prepare_pool_entry (name_index, JV_CONSTANT_Utf8);
check_tag (descriptor_index, JV_CONSTANT_Utf8);
prepare_pool_entry (descriptor_index, JV_CONSTANT_Utf8);
-
+
handleField (i, access_flags, name_index, descriptor_index);
-
+
for (int j = 0; j < attributes_count; j++)
{
read_one_field_attribute (i);
@@ -1071,14 +1071,25 @@ void _Jv_ClassReader::handleField (int field_no,
field->nameIndex = name;
#endif
- if (verify)
- verify_identifier (field_name);
-
- // ignore flags we don't know about.
+ // Ignore flags we don't know about.
field->flags = flags & Modifier::ALL_FLAGS;
+ _Jv_Utf8Const* sig = pool_data[desc].utf8;
+
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
| Modifier::NATIVE
| Modifier::INTERFACE
@@ -1091,8 +1102,6 @@ void _Jv_ClassReader::handleField (int field_no,
throw_class_format_error ("erroneous field access flags");
}
- _Jv_Utf8Const* sig = pool_data[desc].utf8;
-
if (verify)
_Jv_VerifyFieldSignature (sig);
@@ -1233,6 +1242,14 @@ void _Jv_ClassReader::handleMethod
_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
| Modifier::TRANSIENT
| Modifier::INTERFACE))
OpenPOWER on IntegriCloud