1.1 --- a/emul/compact/src/main/java/java/lang/SafeVarargs.java Tue Feb 26 14:55:55 2013 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,91 +0,0 @@
1.4 -/*
1.5 - * Copyright (c) 2010, 2011, 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;
1.30 -
1.31 -import java.lang.annotation.*;
1.32 -
1.33 -/**
1.34 - * A programmer assertion that the body of the annotated method or
1.35 - * constructor does not perform potentially unsafe operations on its
1.36 - * varargs parameter. Applying this annotation to a method or
1.37 - * constructor suppresses unchecked warnings about a
1.38 - * <i>non-reifiable</i> variable arity (vararg) type and suppresses
1.39 - * unchecked warnings about parameterized array creation at call
1.40 - * sites.
1.41 - *
1.42 - * <p> In addition to the usage restrictions imposed by its {@link
1.43 - * Target @Target} meta-annotation, compilers are required to implement
1.44 - * additional usage restrictions on this annotation type; it is a
1.45 - * compile-time error if a method or constructor declaration is
1.46 - * annotated with a {@code @SafeVarargs} annotation, and either:
1.47 - * <ul>
1.48 - * <li> the declaration is a fixed arity method or constructor
1.49 - *
1.50 - * <li> the declaration is a variable arity method that is neither
1.51 - * {@code static} nor {@code final}.
1.52 - *
1.53 - * </ul>
1.54 - *
1.55 - * <p> Compilers are encouraged to issue warnings when this annotation
1.56 - * type is applied to a method or constructor declaration where:
1.57 - *
1.58 - * <ul>
1.59 - *
1.60 - * <li> The variable arity parameter has a reifiable element type,
1.61 - * which includes primitive types, {@code Object}, and {@code String}.
1.62 - * (The unchecked warnings this annotation type suppresses already do
1.63 - * not occur for a reifiable element type.)
1.64 - *
1.65 - * <li> The body of the method or constructor declaration performs
1.66 - * potentially unsafe operations, such as an assignment to an element
1.67 - * of the variable arity parameter's array that generates an unchecked
1.68 - * warning. Some unsafe operations do not trigger an unchecked
1.69 - * warning. For example, the aliasing in
1.70 - *
1.71 - * <blockquote><pre>
1.72 - * @SafeVarargs // Not actually safe!
1.73 - * static void m(List<String>... stringLists) {
1.74 - * Object[] array = stringLists;
1.75 - * List<Integer> tmpList = Arrays.asList(42);
1.76 - * array[0] = tmpList; // Semantically invalid, but compiles without warnings
1.77 - * String s = stringLists[0].get(0); // Oh no, ClassCastException at runtime!
1.78 - * }
1.79 - * </pre></blockquote>
1.80 - *
1.81 - * leads to a {@code ClassCastException} at runtime.
1.82 - *
1.83 - * <p>Future versions of the platform may mandate compiler errors for
1.84 - * such unsafe operations.
1.85 - *
1.86 - * </ul>
1.87 - *
1.88 - * @jls 4.7 Reifiable Types
1.89 - * @jls 8.4.1 Formal Parameters
1.90 - */
1.91 -@Documented
1.92 -@Retention(RetentionPolicy.RUNTIME)
1.93 -@Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
1.94 -public @interface SafeVarargs {}