1 /* 2 * Copyright (c) 2012, 2013, 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 jdk.internal.vm.annotation; 27 28 import java.lang.annotation.*; 29 30 // Android-removed: HotSpot-specific implementation notes not relevant for Android. 31 /** 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 * conveys no additional information regarding change of the field's value, but 62 * still conveys information regarding change of additional components values if 63 * the type of the field is an array type (as described above). 64 * <p> 65 * It is (currently) undefined what happens if a field annotated as stable 66 * is given a third value (by explicitly updating a stable field, a component of 67 * a stable array, or a final stable field via reflection or other means). 68 * 69 * @implNote 70 * This annotation only takes effect for fields of classes loaded by the boot 71 * loader. Annoations on fields of classes loaded outside of the boot loader 72 * are ignored. 73 */ 74 @Target(ElementType.FIELD) 75 @Retention(RetentionPolicy.RUNTIME) 76 public @interface Stable { 77 } 78