This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: 1.5 class reading fixes
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 11 Jul 2005 10:44:57 -0600
- Subject: [gcjx] Patch: FYI: 1.5 class reading fixes
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This fixes a few bugs in 1.5 class reading and writing.
- we weren't handling the argument types for a method correctly
- the throws specification in a Signature is optional; now we
correctly handle this when reading, and we omit this if possible
when writing
- ACC_SUPER must be set for enums
- we now properly handle parameterized member classes in signatures
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* model/throwsclause.cc (get_signature): Return empty string if
no parameterized types seen.
* bytecode/classreader.cc (parse_signature): Handle case where
exceptions are elided. Clear current_method_arguments before
parsing method signature.
(parse_self): Require ACC_SUPER for enums.
* bytecode/signature.cc (parse_ref_type): Exit loop if inner class
is parameterized.
Index: bytecode/classreader.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/classreader.cc,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 classreader.cc
--- bytecode/classreader.cc 8 Mar 2005 23:26:27 -0000 1.1.2.10
+++ bytecode/classreader.cc 11 Jul 2005 16:47:02 -0000
@@ -571,11 +571,20 @@
std::list<ref_type_variable> type_parameters;
ref_forwarding_type return_type;
- current_exceptions.clear ();
+ std::list<ref_forwarding_type> new_exceptions;
+
+ current_method_arguments.clear ();
parser.parse_method_signature (current_method_arguments,
type_parameters,
return_type,
- current_exceptions);
+ new_exceptions);
+
+ // A compiler may elide the exceptions if they are not generic.
+ if (! new_exceptions.empty ())
+ current_exceptions = new_exceptions;
+
+ // FIXME: could check that the generic signature is compatible
+ // with the erased type.
// A couple things we discover about the method are actually
// handled in parse_method. Others we can easily set here.
@@ -951,12 +960,8 @@
result->set_superclass (super);
}
- // ACC_SUPER doesn't make sense for enums, but is required for
- // ordinary classes.
- if ((access_flags & ACC_ENUM) == 0)
- must_set |= ACC_SUPER;
- else
- must_not_set |= ACC_SUPER;
+ // Require ACC_SUPER for enums as well as ordinary classes.
+ must_set |= ACC_SUPER;
must_not_set |= ACC_ANNOTATION;
if ((access_flags & ACC_ABSTRACT) != 0
Index: bytecode/signature.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/signature.cc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 signature.cc
--- bytecode/signature.cc 13 Feb 2005 03:24:29 -0000 1.1.2.2
+++ bytecode/signature.cc 11 Jul 2005 16:47:02 -0000
@@ -182,7 +182,7 @@
std::list<std::string> ids;
std::string::const_iterator start = it;
- while (it != done && *it != '.' && *it != ';')
+ while (it != done && *it != '.' && *it != ';' && *it != '<')
++it;
result = new model_forwarding_inner (where,
Index: model/throwsclause.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/throwsclause.cc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 throwsclause.cc
--- model/throwsclause.cc 13 Jan 2005 03:18:36 -0000 1.1.2.1
+++ model/throwsclause.cc 11 Jul 2005 16:47:02 -0000
@@ -1,6 +1,6 @@
// Represent a method's 'throws' clause.
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
@@ -172,12 +172,18 @@
std::string
model_throws_clause::get_signature ()
{
+ bool seen_generic = false;
std::string result;
for (std::list<ref_forwarding_type>::const_iterator i = decls.begin ();
i != decls.end ();
++i)
- result += "^" + (*i)->type ()->get_signature ();
- return result;
+ {
+ model_type *t = (*i)->type ();
+ if (t->erasure () != t)
+ seen_generic = true;
+ result += "^" + t->get_signature ();
+ }
+ return seen_generic ? result : "";
}
void