hotspot/test/runtime/contended/DefaultValue.java
author chegar
Tue, 24 Nov 2015 11:49:44 +0000
changeset 34272 1b277b5ee6e3
parent 29678 dd2f3932c21e
child 36209 8db2a78cbc29
permissions -rw-r--r--
8140687: Move @Contended to the jdk.internal.vm.annotation package Reviewed-by: alanb, dholmes, psandoz, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17603
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 17603
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
17603
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
     4
 *
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
     7
 * published by the Free Software Foundation.
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
     8
 *
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    13
 * accompanied this code).
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    14
 *
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    18
 *
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    21
 * questions.
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    22
 */
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    23
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    24
import java.io.BufferedReader;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    25
import java.io.InputStreamReader;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    26
import java.lang.Class;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    27
import java.lang.String;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    28
import java.lang.System;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    29
import java.lang.management.ManagementFactory;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    30
import java.lang.management.RuntimeMXBean;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    31
import java.util.ArrayList;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    32
import java.util.List;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    33
import java.util.concurrent.CyclicBarrier;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    34
import java.util.regex.Matcher;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    35
import java.util.regex.Pattern;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    36
import java.lang.reflect.Field;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    37
import java.lang.reflect.Modifier;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    38
import sun.misc.Unsafe;
34272
1b277b5ee6e3 8140687: Move @Contended to the jdk.internal.vm.annotation package
chegar
parents: 29678
diff changeset
    39
import jdk.internal.vm.annotation.Contended;
17603
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    40
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    41
/*
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    42
 * @test
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    43
 * @bug     8014509
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    44
 * @summary \@Contended: explicit default value behaves differently from the implicit value
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    45
 *
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 17603
diff changeset
    46
 * @modules java.base/sun.misc
17603
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    47
 * @run main/othervm -XX:-RestrictContended DefaultValue
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    48
 */
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    49
public class DefaultValue {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    50
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    51
    private static final Unsafe U;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    52
    private static int ADDRESS_SIZE;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    53
    private static int HEADER_SIZE;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    54
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    55
    static {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    56
        // steal Unsafe
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    57
        try {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    58
            Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    59
            unsafe.setAccessible(true);
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    60
            U = (Unsafe) unsafe.get(null);
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    61
        } catch (NoSuchFieldException | IllegalAccessException e) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    62
            throw new IllegalStateException(e);
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    63
        }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    64
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    65
        // When running with CompressedOops on 64-bit platform, the address size
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    66
        // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    67
        // Try to guess the reference field size with this naive trick.
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    68
        try {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    69
            long off1 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj1"));
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    70
            long off2 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj2"));
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    71
            ADDRESS_SIZE = (int) Math.abs(off2 - off1);
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    72
            HEADER_SIZE = (int) Math.min(off1, off2);
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    73
        } catch (NoSuchFieldException e) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    74
            ADDRESS_SIZE = -1;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    75
        }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    76
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    77
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    78
    static class CompressedOopsClass {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    79
        public Object obj1;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    80
        public Object obj2;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    81
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    82
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    83
    public static boolean arePaddedPairwise(Class klass, String field1, String field2) throws Exception {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    84
        Field f1 = klass.getField(field1);
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    85
        Field f2 = klass.getField(field2);
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    86
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    87
        int diff = offset(f1) - offset(f2);
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    88
        if (diff < 0) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    89
            // f1 is first
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    90
            return (offset(f2) - (offset(f1) + getSize(f1))) > 64;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    91
        } else {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    92
            // f2 is first
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    93
            return (offset(f1) - (offset(f2) + getSize(f2))) > 64;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    94
        }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    95
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    96
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    97
    public static boolean sameLayout(Class klass1, Class klass2) throws Exception {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    98
        for (Field f1 : klass1.getDeclaredFields()) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
    99
            Field f2 = klass2.getDeclaredField(f1.getName());
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   100
            if (offset(f1) != offset(f2)) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   101
                return false;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   102
            }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   103
        }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   104
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   105
        for (Field f2 : klass1.getDeclaredFields()) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   106
            Field f1 = klass2.getDeclaredField(f2.getName());
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   107
            if (offset(f1) != offset(f2)) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   108
                return false;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   109
            }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   110
        }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   111
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   112
        return true;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   113
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   114
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   115
    public static boolean isStatic(Field field) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   116
        return Modifier.isStatic(field.getModifiers());
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   117
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   118
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   119
    public static int offset(Field field) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   120
        if (isStatic(field)) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   121
            return (int) U.staticFieldOffset(field);
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   122
        } else {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   123
            return (int) U.objectFieldOffset(field);
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   124
        }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   125
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   126
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   127
    public static int getSize(Field field) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   128
        Class type = field.getType();
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   129
        if (type == byte.class)    { return 1; }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   130
        if (type == boolean.class) { return 1; }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   131
        if (type == short.class)   { return 2; }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   132
        if (type == char.class)    { return 2; }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   133
        if (type == int.class)     { return 4; }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   134
        if (type == float.class)   { return 4; }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   135
        if (type == long.class)    { return 8; }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   136
        if (type == double.class)  { return 8; }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   137
        return ADDRESS_SIZE;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   138
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   139
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   140
    public static void main(String[] args) throws Exception {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   141
        boolean endResult = true;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   142
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   143
        if (!arePaddedPairwise(R1.class, "int1", "int2")) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   144
            System.err.println("R1 failed");
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   145
            endResult &= false;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   146
        }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   147
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   148
        if (!arePaddedPairwise(R2.class, "int1", "int2")) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   149
            System.err.println("R2 failed");
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   150
            endResult &= false;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   151
        }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   152
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   153
        if (!arePaddedPairwise(R3.class, "int1", "int2")) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   154
            System.err.println("R3 failed");
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   155
            endResult &= false;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   156
        }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   157
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   158
        System.out.println(endResult ? "Test PASSES" : "Test FAILS");
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   159
        if (!endResult) {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   160
           throw new Error("Test failed");
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   161
        }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   162
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   163
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   164
    public static class R1 {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   165
        @Contended
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   166
        public int int1;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   167
        @Contended
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   168
        public int int2;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   169
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   170
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   171
    public static class R2 {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   172
        @Contended("")
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   173
        public int int1;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   174
        @Contended("")
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   175
        public int int2;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   176
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   177
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   178
    public static class R3 {
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   179
        @Contended()
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   180
        public int int1;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   181
        @Contended()
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   182
        public int int2;
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   183
    }
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   184
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   185
}
30a72a5afcda 8014509: @Contended: explicit default value behaves differently from the implicit value
shade
parents:
diff changeset
   186