1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/rt/emul/compact/src/main/java/java/lang/invoke/Stable.java Sat Aug 09 11:11:13 2014 +0200
1.3 @@ -0,0 +1,73 @@
1.4 +/*
1.5 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1.7 + *
1.8 + * This code is free software; you can redistribute it and/or modify it
1.9 + * under the terms of the GNU General Public License version 2 only, as
1.10 + * published by the Free Software Foundation. Oracle designates this
1.11 + * particular file as subject to the "Classpath" exception as provided
1.12 + * by Oracle in the LICENSE file that accompanied this code.
1.13 + *
1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1.17 + * version 2 for more details (a copy is included in the LICENSE file that
1.18 + * accompanied this code).
1.19 + *
1.20 + * You should have received a copy of the GNU General Public License version
1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1.23 + *
1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1.25 + * or visit www.oracle.com if you need additional information or have any
1.26 + * questions.
1.27 + */
1.28 +
1.29 +package java.lang.invoke;
1.30 +
1.31 +import java.lang.annotation.*;
1.32 +
1.33 +/**
1.34 + * A field may be annotated as stable if all of its component variables
1.35 + * changes value at most once.
1.36 + * A field's value counts as its component value.
1.37 + * If the field is typed as an array, then all the non-null components
1.38 + * of the array, of depth up to the rank of the field's array type,
1.39 + * also count as component values.
1.40 + * By extension, any variable (either array or field) which has annotated
1.41 + * as stable is called a stable variable, and its non-null or non-zero
1.42 + * value is called a stable value.
1.43 + * <p>
1.44 + * Since all fields begin with a default value of null for references
1.45 + * (resp., zero for primitives), it follows that this annotation indicates
1.46 + * that the first non-null (resp., non-zero) value stored in the field
1.47 + * will never be changed.
1.48 + * <p>
1.49 + * If the field is not of an array type, there are no array elements,
1.50 + * then the value indicated as stable is simply the value of the field.
1.51 + * If the dynamic type of the field value is an array but the static type
1.52 + * is not, the components of the array are <em>not</em> regarded as stable.
1.53 + * <p>
1.54 + * If the field is an array type, then both the field value and
1.55 + * all the components of the field value (if the field value is non-null)
1.56 + * are indicated to be stable.
1.57 + * If the field type is an array type with rank {@code N > 1},
1.58 + * then each component of the field value (if the field value is non-null),
1.59 + * is regarded as a stable array of rank {@code N-1}.
1.60 + * <p>
1.61 + * Fields which are declared {@code final} may also be annotated as stable.
1.62 + * Since final fields already behave as stable values, such an annotation
1.63 + * indicates no additional information, unless the type of the field is
1.64 + * an array type.
1.65 + * <p>
1.66 + * It is (currently) undefined what happens if a field annotated as stable
1.67 + * is given a third value. In practice, if the JVM relies on this annotation
1.68 + * to promote a field reference to a constant, it may be that the Java memory
1.69 + * model would appear to be broken, if such a constant (the second value of the field)
1.70 + * is used as the value of the field even after the field value has changed.
1.71 + */
1.72 +/* package-private */
1.73 +@Target(ElementType.FIELD)
1.74 +@Retention(RetentionPolicy.RUNTIME)
1.75 +@interface Stable {
1.76 +}