6611449: Internal Error thrown during generic method/constructor invocation

Tue, 04 Mar 2008 12:14:13 +0000

author
mcimadamore
date
Tue, 04 Mar 2008 12:14:13 +0000
changeset 5
b45f8d4794b7
parent 4
3c2d13c42e0a
child 6
40813968849e

6611449: Internal Error thrown during generic method/constructor invocation
Summary: type-inference should fail since lub is not defined for primitive types
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/code/Types.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Infer.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/inference/6611449/T6611449.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/inference/6611449/T6611449.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Mar 03 16:03:53 2008 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Mar 04 12:14:13 2008 +0000
     1.3 @@ -2483,7 +2483,7 @@
     1.4                  break;
     1.5              default:
     1.6                  if (t.isPrimitive())
     1.7 -                    return syms.botType;
     1.8 +                    return syms.errType;
     1.9              }
    1.10          }
    1.11          switch (boundkind) {
     2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Mon Mar 03 16:03:53 2008 +0000
     2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Mar 04 12:14:13 2008 +0000
     2.3 @@ -194,14 +194,14 @@
     2.4              if (that.lobounds.isEmpty())
     2.5                  that.inst = syms.botType;
     2.6              else if (that.lobounds.tail.isEmpty())
     2.7 -                that.inst = that.lobounds.head;
     2.8 +                that.inst = that.lobounds.head.isPrimitive() ? syms.errType : that.lobounds.head;
     2.9              else {
    2.10                  that.inst = types.lub(that.lobounds);
    2.11 -                if (that.inst == null)
    2.12 +            }
    2.13 +            if (that.inst == null || that.inst == syms.errType)
    2.14                      throw ambiguousNoInstanceException
    2.15                          .setMessage("no.unique.minimal.instance.exists",
    2.16                                      that.qtype, that.lobounds);
    2.17 -            }
    2.18              // VGJ: sort of inlined maximizeInst() below.  Adding
    2.19              // bounds can cause lobounds that are above hibounds.
    2.20              if (that.hibounds.isEmpty())
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/generics/inference/6611449/T6611449.java	Tue Mar 04 12:14:13 2008 +0000
     3.3 @@ -0,0 +1,46 @@
     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 +/**
    3.28 + * @test
    3.29 + * @bug 6611449
    3.30 + * @summary Internal Error thrown during generic method/constructor invocation
    3.31 + * @compile/fail/ref=T6611449.out -XDstdout -XDrawDiagnostics T6611449.java
    3.32 + */
    3.33 +public class T6611449<S> {
    3.34 +
    3.35 +    T6611449() {this(1);}
    3.36 +
    3.37 +    <T extends S> T6611449(T t1) {this(t1, 1);}
    3.38 +
    3.39 +    <T extends S> T6611449(T t1, T t2) {}
    3.40 +
    3.41 +    <T extends S> void m(T t1) {}
    3.42 +
    3.43 +    <T extends S> void m(T t1, T t2) {}
    3.44 +
    3.45 +    void test() {
    3.46 +        m1(1);
    3.47 +        m2(1, 1);
    3.48 +    }
    3.49 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/tools/javac/generics/inference/6611449/T6611449.out	Tue Mar 04 12:14:13 2008 +0000
     4.3 @@ -0,0 +1,5 @@
     4.4 +T6611449.java:32:17: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (int), , (- compiler.misc.kindname.class), T6611449<S>
     4.5 +T6611449.java:34:35: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (T,int), , (- compiler.misc.kindname.class), T6611449<S>
     4.6 +T6611449.java:43:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.method), m1, (int), , (- compiler.misc.kindname.class), T6611449<S>
     4.7 +T6611449.java:44:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.method), m2, (int,int), , (- compiler.misc.kindname.class), T6611449<S>
     4.8 +4 errors

mercurial