* Patch: FYI: fix signatures of anonymous class constructors
@ 2005-12-06 1:58 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2005-12-06 1:58 UTC (permalink / raw)
To: Gcc Patch List; +Cc: Java Patch List
I'm checking this in on the 4.0 branch, the 4.1 branch, and the trunk.
This fixes a bug reported to the Red Hat bugzilla. The test case is
included below. The bug is that we can end up with invalid
constructor signatures in some cases.
I looked at a couple other approaches, but this seemed simplest.
I think this never noticed this before because the old verifier did
check the validity of signatures.
Tom
Index: gcc/java/ChangeLog
from Tom Tromey <tromey@redhat.com>
* parse.y (patch_new_array_init): Don't set length on array.
Index: libjava/ChangeLog
from Tom Tromey <tromey@redhat.com>
* testsuite/libjava.compile/rh174912.java: New file.
Index: gcc/java/parse.y
===================================================================
--- gcc/java/parse.y (revision 108077)
+++ gcc/java/parse.y (working copy)
@@ -14857,8 +14857,12 @@
/* Create a new type. We can't reuse the one we have here by
patching its dimension because it originally is of dimension -1
- hence reused by gcc. This would prevent triangular arrays. */
- type = build_java_array_type (element_type, length);
+ hence reused by gcc. This would prevent triangular arrays.
+ Note that we don't pass the length here. If we do that then the
+ length will end up in the signature of this type, and hence in
+ the signature of the anonymous constructor -- but this is not a
+ valid java signature. */
+ type = build_java_array_type (element_type, -1);
TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
TREE_TYPE (node) = promote_type (type);
TREE_CONSTANT (init) = all_constant;
Index: libjava/testsuite/libjava.compile/rh174912.java
===================================================================
--- libjava/testsuite/libjava.compile/rh174912.java (revision 0)
+++ libjava/testsuite/libjava.compile/rh174912.java (revision 0)
@@ -0,0 +1,17 @@
+// Derived from Red Hat bugzilla 174912
+// https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=174912
+// The bug is that the anonymous class constructor here will end up
+// with a bogus '[3C' in its signature.
+
+public class rh174912 {
+ public rh174912(char[][] args) { }
+
+ public Object m() {
+ return new rh174912(new char[][] { "hi".toCharArray(),
+ "bob".toCharArray(),
+ "and joe".toCharArray() }) {
+ };
+ }
+
+ public static void main(String[] args) { }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-12-06 1:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-06 1:58 Patch: FYI: fix signatures of anonymous class constructors Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).