6999635: Multicatch: crash while compiling simple code with a multicatch parameter jdk7-b120

Mon, 15 Nov 2010 14:41:21 +0000

author
mcimadamore
date
Mon, 15 Nov 2010 14:41:21 +0000
changeset 747
1dd813a529cf
parent 746
a7ea58fa3e9a
child 748
621e096ca843
child 751
abaceae7c9f8

6999635: Multicatch: crash while compiling simple code with a multicatch parameter
Summary: missing erasure when computing stackmaps leads to assertion error
Reviewed-by: darcy

src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/jvm/Code.java file | annotate | diff | comparison | revisions
test/tools/javac/multicatch/Pos08.java file | annotate | diff | comparison | revisions
test/tools/javac/multicatch/Pos08eff_final.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Mon Nov 15 13:50:53 2010 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Mon Nov 15 14:41:21 2010 +0000
     1.3 @@ -993,7 +993,9 @@
     1.4      /** Enter an inner class into the `innerClasses' set/queue.
     1.5       */
     1.6      void enterInner(ClassSymbol c) {
     1.7 -        assert !c.type.isCompound();
     1.8 +        if (c.type.isCompound()) {
     1.9 +            throw new AssertionError("Unexpected intersection type: " + c.type);
    1.10 +        }
    1.11          try {
    1.12              c.complete();
    1.13          } catch (CompletionFailure ex) {
     2.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java	Mon Nov 15 13:50:53 2010 +0000
     2.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java	Mon Nov 15 14:41:21 2010 +0000
     2.3 @@ -1304,7 +1304,7 @@
     2.4          stackCount = 0;
     2.5          for (int i=0; i<state.stacksize; i++) {
     2.6              if (state.stack[i] != null) {
     2.7 -                frame.stack[stackCount++] = state.stack[i];
     2.8 +                frame.stack[stackCount++] = types.erasure(state.stack[i]);
     2.9              }
    2.10          }
    2.11  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/multicatch/Pos08.java	Mon Nov 15 14:41:21 2010 +0000
     3.3 @@ -0,0 +1,46 @@
     3.4 +/*
     3.5 + * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27 +/*
    3.28 + * @test
    3.29 + * @bug 6993963
    3.30 + * @summary Multicatch: crash while compiling simple code with a multicatch parameter
    3.31 + * @compile Pos08.java
    3.32 + */
    3.33 +
    3.34 +class Pos08 {
    3.35 +
    3.36 +    interface Foo {}
    3.37 +    static class X1 extends Exception implements Foo {}
    3.38 +    static class X2 extends Exception implements Foo {}
    3.39 +
    3.40 +    void m(boolean cond) {
    3.41 +        try {
    3.42 +            if (cond)
    3.43 +                throw new X1();
    3.44 +            else
    3.45 +                throw new X2();
    3.46 +        }
    3.47 +        catch (final X1 | X2 ex) {}
    3.48 +    }
    3.49 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/tools/javac/multicatch/Pos08eff_final.java	Mon Nov 15 14:41:21 2010 +0000
     4.3 @@ -0,0 +1,46 @@
     4.4 +/*
     4.5 + * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    4.23 + * or visit www.oracle.com if you need additional information or have any
    4.24 + * questions.
    4.25 + */
    4.26 +
    4.27 +/*
    4.28 + * @test
    4.29 + * @bug 6993963
    4.30 + * @summary Multicatch: crash while compiling simple code with a multicatch parameter
    4.31 + * @compile Pos08eff_final.java
    4.32 + */
    4.33 +
    4.34 +class Pos08eff_final {
    4.35 +
    4.36 +    interface Foo {}
    4.37 +    static class X1 extends Exception implements Foo {}
    4.38 +    static class X2 extends Exception implements Foo {}
    4.39 +
    4.40 +    void m(boolean cond) {
    4.41 +        try {
    4.42 +            if (cond)
    4.43 +                throw new X1();
    4.44 +            else
    4.45 +                throw new X2();
    4.46 +        }
    4.47 +        catch (X1 | X2 ex) {}
    4.48 +    }
    4.49 +}

mercurial