6695838: javac does not detect cyclic inheritance involving static inner classes after import clause

Fri, 08 Aug 2008 15:16:25 +0100

author
mcimadamore
date
Fri, 08 Aug 2008 15:16:25 +0100
changeset 92
d635feaf3747
parent 90
6be961ee2290
child 93
30a415f8667f

6695838: javac does not detect cyclic inheritance involving static inner classes after import clause
Summary: Javac fails to detect some errors due to the order in which a class' static imports are entered
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/comp/MemberEnter.java file | annotate | diff | comparison | revisions
test/tools/javac/staticImport/6695838/T6695838.java file | annotate | diff | comparison | revisions
test/tools/javac/staticImport/6695838/a/Foo.java file | annotate | diff | comparison | revisions
test/tools/javac/staticImport/6695838/a/FooInterface.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Aug 05 17:07:13 2008 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri Aug 08 15:16:25 2008 +0100
     1.3 @@ -828,6 +828,9 @@
     1.4              // Save class environment for later member enter (2) processing.
     1.5              halfcompleted.append(env);
     1.6  
     1.7 +            // Mark class as not yet attributed.
     1.8 +            c.flags_field |= UNATTRIBUTED;
     1.9 +
    1.10              // If this is a toplevel-class, make sure any preceding import
    1.11              // clauses have been seen.
    1.12              if (c.owner.kind == PCK) {
    1.13 @@ -835,9 +838,6 @@
    1.14                  todo.append(env);
    1.15              }
    1.16  
    1.17 -            // Mark class as not yet attributed.
    1.18 -            c.flags_field |= UNATTRIBUTED;
    1.19 -
    1.20              if (c.owner.kind == TYP)
    1.21                  c.owner.complete();
    1.22  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/staticImport/6695838/T6695838.java	Fri Aug 08 15:16:25 2008 +0100
     2.3 @@ -0,0 +1,31 @@
     2.4 +/*
     2.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    2.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    2.24 + * have any questions.
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * @test
    2.29 + * @bug 6695838
    2.30 + * @summary javac does not detect cyclic inheritance involving static inner classes after import clause
    2.31 + * @author Maurizio Cimadamore
    2.32 + *
    2.33 + * @compile/fail a/FooInterface.java
    2.34 + */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/staticImport/6695838/a/Foo.java	Fri Aug 08 15:16:25 2008 +0100
     3.3 @@ -0,0 +1,29 @@
     3.4 +/*
     3.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    3.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    3.24 + * have any questions.
    3.25 + */
    3.26 +
    3.27 +package a;
    3.28 +
    3.29 +class Foo implements FooInterface {
    3.30 +    public static interface InnerInterface {}
    3.31 +}
    3.32 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/tools/javac/staticImport/6695838/a/FooInterface.java	Fri Aug 08 15:16:25 2008 +0100
     4.3 @@ -0,0 +1,29 @@
     4.4 +/*
     4.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + *
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.
    4.11 + *
    4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.15 + * version 2 for more details (a copy is included in the LICENSE file that
    4.16 + * accompanied this code).
    4.17 + *
    4.18 + * You should have received a copy of the GNU General Public License version
    4.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.21 + *
    4.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    4.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    4.24 + * have any questions.
    4.25 + */
    4.26 +
    4.27 +package a;
    4.28 +
    4.29 +import a.Foo.InnerInterface;
    4.30 +
    4.31 +public interface FooInterface extends Foo.InnerInterface {}
    4.32 +

mercurial