diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-08-24 17:24:44 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-08-24 17:24:44 +0000 |
commit | 5eebc41fc2d61e66d84f648fd6d59365facf185b (patch) | |
tree | b60d1cfd5772caf8f4b4422879feb1f039755a71 /libjava/defineclass.cc | |
parent | 14795d175a44e80fa9bed1c5ef99944645198bdd (diff) | |
download | gcc-5eebc41fc2d61e66d84f648fd6d59365facf185b.tar.gz |
* java/lang/reflect/Field.java (toString): Use
Method.appendClassName.
* java/lang/reflect/Constructor.java (toString): Use
Method.appendClassName.
* java/lang/reflect/Method.java: Reindented.
(appendClassName): New method.
(toString): Use it.
* defineclass.cc (handleMethod ): Initialize `throws' field of
method.
(read_one_method_attribute): Handle Exceptions attribute.
* java/lang/reflect/natMethod.cc (ClassClass): Removed.
(ObjectClass): Removed.
(getType): Compute `exception_types'.
* java/lang/Class.h (struct _Jv_Method): Added `throws' field.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45153 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/defineclass.cc')
-rw-r--r-- | libjava/defineclass.cc | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/libjava/defineclass.cc b/libjava/defineclass.cc index edf14cb098e..7ef51dc6e2b 100644 --- a/libjava/defineclass.cc +++ b/libjava/defineclass.cc @@ -526,10 +526,42 @@ void _Jv_ClassReader::read_one_method_attribute (int method_index) if (is_attribute_name (name, "Exceptions")) { - /* we ignore this for now */ - skip (length); + _Jv_Method *method = reinterpret_cast<_Jv_Method *> + (&def->methods[method_index]); + if (method->throws != NULL) + throw_class_format_error ("only one Exceptions attribute allowed per method"); + + int num_exceptions = read2u (); + // We use malloc here because the GC won't scan the method + // objects. FIXME this means a memory leak if we GC a class. + // (Currently we never do.) + _Jv_Utf8Const **exceptions = + (_Jv_Utf8Const **) _Jv_Malloc ((num_exceptions + 1) * sizeof (_Jv_Utf8Const *)); + + int out = 0; + _Jv_word *pool_data = def->constants.data; + for (int i = 0; i < num_exceptions; ++i) + { + try + { + int ndx = read2u (); + // JLS 2nd Ed. 4.7.5 requires that the tag not be 0. + if (ndx != 0) + { + check_tag (ndx, JV_CONSTANT_Class); + exceptions[out++] = pool_data[ndx].utf8; + } + } + catch (java::lang::Throwable *exc) + { + _Jv_Free (exceptions); + throw exc; + } + } + exceptions[out] = NULL; + method->throws = exceptions; } - + else if (is_attribute_name (name, "Code")) { int start_off = pos; @@ -1206,6 +1238,7 @@ void _Jv_ClassReader::handleMethod // intialize... method->ncode = 0; + method->throws = NULL; if (verify) { |