test/tools/javac/generics/T6751514.java

Thu, 25 Aug 2011 17:18:25 -0700

author
schien
date
Thu, 25 Aug 2011 17:18:25 -0700
changeset 1067
f497fac86cf9
parent 798
4868a36f6fd8
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8-b02 for changeset b3c059de2a61

mcimadamore@133 1 /*
ohair@798 2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
mcimadamore@133 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@133 4 *
mcimadamore@133 5 * This code is free software; you can redistribute it and/or modify it
mcimadamore@133 6 * under the terms of the GNU General Public License version 2 only, as
mcimadamore@133 7 * published by the Free Software Foundation.
mcimadamore@133 8 *
mcimadamore@133 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@133 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@133 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@133 12 * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@133 13 * accompanied this code).
mcimadamore@133 14 *
mcimadamore@133 15 * You should have received a copy of the GNU General Public License version
mcimadamore@133 16 * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@133 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@133 18 *
ohair@554 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 20 * or visit www.oracle.com if you need additional information or have any
ohair@554 21 * questions.
mcimadamore@133 22 */
mcimadamore@133 23
mcimadamore@133 24 /*
mcimadamore@133 25 * @test
mcimadamore@133 26 * @bug 6751514
mcimadamore@133 27 * @summary Unary post-increment with type variables crash javac during lowering
mcimadamore@133 28 * @author Maurizio Cimadamore
mcimadamore@133 29 */
mcimadamore@133 30
mcimadamore@133 31 public class T6751514 {
mcimadamore@133 32
mcimadamore@133 33 static class Foo<X> {
mcimadamore@133 34 X x;
mcimadamore@133 35 Foo (X x) {
mcimadamore@133 36 this.x = x;
mcimadamore@133 37 }
mcimadamore@133 38 }
mcimadamore@133 39
mcimadamore@133 40 static void test1(Foo<Integer> foo) {
mcimadamore@133 41 int start = foo.x;
mcimadamore@133 42 equals(foo.x += 1, start + 1);
mcimadamore@133 43 equals(foo.x++, start + 1);
mcimadamore@133 44 equals(++foo.x, start + 3);
mcimadamore@133 45 equals(foo.x--, start + 3);
mcimadamore@133 46 equals(foo.x -= 1, start + 1);
mcimadamore@133 47 equals(--foo.x, start);
mcimadamore@133 48 }
mcimadamore@133 49
mcimadamore@133 50 static void test2(Foo<Integer> foo) {
mcimadamore@133 51 int start = foo.x;
mcimadamore@133 52 equals((foo.x) += 1, start + 1);
mcimadamore@133 53 equals((foo.x)++, start + 1);
mcimadamore@133 54 equals(++(foo.x), start + 3);
mcimadamore@133 55 equals((foo.x)--, start + 3);
mcimadamore@133 56 equals((foo.x) -= 1, start + 1);
mcimadamore@133 57 equals(--(foo.x), start);
mcimadamore@133 58 }
mcimadamore@133 59
mcimadamore@133 60 static void test3(Foo<Integer> foo) {
mcimadamore@133 61 int start = foo.x;
mcimadamore@133 62 equals(((foo.x)) += 1, start + 1);
mcimadamore@133 63 equals(((foo.x))++, start + 1);
mcimadamore@133 64 equals(++((foo.x)), start + 3);
mcimadamore@133 65 equals(((foo.x))--, start + 3);
mcimadamore@133 66 equals(((foo.x)) -= 1, start + 1);
mcimadamore@133 67 equals(--((foo.x)), start);
mcimadamore@133 68 }
mcimadamore@133 69
mcimadamore@133 70 public static void main(String[] args) {
mcimadamore@133 71 test1(new Foo<Integer>(1));
mcimadamore@133 72 test2(new Foo<Integer>(1));
mcimadamore@133 73 test3(new Foo<Integer>(1));
mcimadamore@133 74 }
mcimadamore@133 75
mcimadamore@133 76 static void equals(int found, int req) {
mcimadamore@133 77 if (found != req) {
mcimadamore@133 78 throw new AssertionError("Error (expected: "+ req +
mcimadamore@133 79 " - found: " + found + ")");
mcimadamore@133 80 }
mcimadamore@133 81 }
jjg@525 82 }

mercurial