1 /* 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.invoke; 27 28 import java.lang.annotation.*; 29 30 /** 31 * Internal marker for some fields in the JSR 292 implementation. 32 * A field may be annotated as stable if all of its component variables 33 * changes value at most once. 34 * A field's value counts as its component value. 35 * If the field is typed as an array, then all the non-null components 36 * of the array, of depth up to the rank of the field's array type, 37 * also count as component values. 38 * By extension, any variable (either array or field) which has annotated 39 * as stable is called a stable variable, and its non-null or non-zero 40 * value is called a stable value. 41 * <p> 42 * Since all fields begin with a default value of null for references 43 * (resp., zero for primitives), it follows that this annotation indicates 44 * that the first non-null (resp., non-zero) value stored in the field 45 * will never be changed. 46 * <p> 47 * If the field is not of an array type, there are no array elements, 48 * then the value indicated as stable is simply the value of the field. 49 * If the dynamic type of the field value is an array but the static type 50 * is not, the components of the array are <em>not</em> regarded as stable. 51 * <p> 52 * If the field is an array type, then both the field value and 53 * all the components of the field value (if the field value is non-null) 54 * are indicated to be stable. 55 * If the field type is an array type with rank {@code N > 1}, 56 * then each component of the field value (if the field value is non-null), 57 * is regarded as a stable array of rank {@code N-1}. 58 * <p> 59 * Fields which are declared {@code final} may also be annotated as stable. 60 * Since final fields already behave as stable values, such an annotation 61 * indicates no additional information, unless the type of the field is 62 * an array type. 63 * <p> 64 * It is (currently) undefined what happens if a field annotated as stable 65 * is given a third value. In practice, if the JVM relies on this annotation 66 * to promote a field reference to a constant, it may be that the Java memory 67 * model would appear to be broken, if such a constant (the second value of the field) 68 * is used as the value of the field even after the field value has changed. 69 */ 70 public 71 @Target(ElementType.FIELD) 72 @Retention(RetentionPolicy.RUNTIME) 73 @interface Stable { 74 }