aboutsummaryrefslogtreecommitdiff
path: root/libjava/defineclass.cc
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2001-08-24 17:24:44 +0000
committerTom Tromey <tromey@gcc.gnu.org>2001-08-24 17:24:44 +0000
commit224b7b7b0c8a69e60e87a871a9ed828c99f389d8 (patch)
treeb60d1cfd5772caf8f4b4422879feb1f039755a71 /libjava/defineclass.cc
parent66b461ce02570f05b7ddd76e2de1a82f3a6618e3 (diff)
downloadgcc-224b7b7b0c8a69e60e87a871a9ed828c99f389d8.zip
gcc-224b7b7b0c8a69e60e87a871a9ed828c99f389d8.tar.gz
gcc-224b7b7b0c8a69e60e87a871a9ed828c99f389d8.tar.bz2
Field.java (toString): Use Method.appendClassName.
* 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. From-SVN: r45153
Diffstat (limited to 'libjava/defineclass.cc')
-rw-r--r--libjava/defineclass.cc39
1 files changed, 36 insertions, 3 deletions
diff --git a/libjava/defineclass.cc b/libjava/defineclass.cc
index edf14cb..7ef51dc 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)
{