This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: RFC: ugly workaround for PR 26390
Tom> I'll try to make a pass through some of the open PRs and see what
Tom> happens.
I took a look but didn't see anything else that this patch would fix.
(I might have missed something though... there are a lot of open front
end bugs.)
I'm checking this in.
Tom
Index: gcc/java/ChangeLog
from Tom Tromey <tromey@redhat.com>
PR java/26390:
* parse.y (find_most_specific_methods_list): Added 'class'
argument.
(lookup_method_invoke): Updated.
Index: libjava/ChangeLog
from Tom Tromey <tromey@redhat.com>
PR java/26390:
* testsuite/libjava.lang/pr26390.out: New file.
* testsuite/libjava.lang/pr26390.java: New file.
* sources.am, Makefile.in: Rebuilt.
* scripts/makemake.tcl: Compile gnu/java/awt/peer/swing.
Index: gcc/java/parse.y
===================================================================
--- gcc/java/parse.y (revision 112470)
+++ gcc/java/parse.y (working copy)
@@ -134,7 +134,7 @@
static int invocation_mode (tree, int);
static tree find_applicable_accessible_methods_list (int, tree, tree, tree);
static void search_applicable_methods_list (int, tree, tree, tree, tree *, tree *);
-static tree find_most_specific_methods_list (tree);
+static tree find_most_specific_methods_list (tree, tree);
static int argument_types_convertible (tree, tree);
static tree patch_invoke (tree, tree, tree);
static int maybe_use_access_method (int, tree *, tree *);
@@ -11249,7 +11249,7 @@
/* Find all candidates and then refine the list, searching for the
most specific method. */
list = find_applicable_accessible_methods_list (lc, class, name, atl);
- list = find_most_specific_methods_list (list);
+ list = find_most_specific_methods_list (list, class);
if (list && !TREE_CHAIN (list))
return TREE_VALUE (list);
@@ -11441,7 +11441,7 @@
/* 15.11.2.2 Choose the Most Specific Method */
static tree
-find_most_specific_methods_list (tree list)
+find_most_specific_methods_list (tree list, tree class)
{
int max = 0;
int abstract, candidates;
@@ -11464,8 +11464,23 @@
/* Compare arguments and location where methods where declared */
if (argument_types_convertible (method_v, current_v))
{
+ /* We have a rather odd special case here. The front
+ end doesn't properly implement inheritance, so we
+ work around it here. The idea is, if we are
+ comparing a method declared in a class to one
+ declared in an interface, and the invocation's
+ qualifying class is a class (and not an interface),
+ then we consider the method's class to be the
+ qualifying class of the invocation. This lets us
+ fake the result of ordinary inheritance. */
+ tree context_v = DECL_CONTEXT (current_v);
+ if (TYPE_INTERFACE_P (DECL_CONTEXT (method_v))
+ && ! TYPE_INTERFACE_P (context_v)
+ && ! TYPE_INTERFACE_P (class))
+ context_v = class;
+
if (valid_method_invocation_conversion_p
- (DECL_CONTEXT (method_v), DECL_CONTEXT (current_v)))
+ (DECL_CONTEXT (method_v), context_v))
{
int v = (DECL_SPECIFIC_COUNT (current_v) += 1);
max = (v > max ? v : max);
Index: libjava/scripts/makemake.tcl
===================================================================
--- libjava/scripts/makemake.tcl (revision 112470)
+++ libjava/scripts/makemake.tcl (working copy)
@@ -37,8 +37,7 @@
set package_map(gnu/test) ignore
set package_map(gnu/javax/swing/plaf/gtk) ignore
-# This package doesn't really work yet, and seems to trigger bug #26390
-set package_map(gnu/java/awt/peer/swing) ignore
+set package_map(gnu/java/awt/peer/swing) bc
set package_map(gnu/xml) bc
set package_map(javax/imageio) bc
Index: libjava/testsuite/libjava.lang/pr26390.out
===================================================================
Index: libjava/testsuite/libjava.lang/pr26390.java
===================================================================
--- libjava/testsuite/libjava.lang/pr26390.java (revision 0)
+++ libjava/testsuite/libjava.lang/pr26390.java (revision 0)
@@ -0,0 +1,45 @@
+public class pr26390
+{
+ public interface ComponentPeer {
+ public void setBounds();
+ }
+
+ public interface ContainerPeer extends ComponentPeer {
+ }
+
+ public interface WindowPeer extends ContainerPeer {
+ }
+
+ public interface FramePeer extends WindowPeer {
+ }
+
+ public static class SwingComponentPeer implements ComponentPeer {
+ public void setBounds() {
+ }
+ }
+
+ public static class SwingContainerPeer
+ extends SwingComponentPeer implements ContainerPeer
+ {
+ }
+
+ public static class SwingWindowPeer
+ extends SwingContainerPeer implements WindowPeer
+ {
+ }
+
+ public static class SwingFramePeer
+ extends SwingWindowPeer implements FramePeer
+ {
+ public void setBounds() {
+ super.setBounds();
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ SwingFramePeer s = new SwingFramePeer();
+ s.setBounds();
+ }
+}
+