65 * warning. Some unsafe operations do not trigger an unchecked
66 * warning. For example, the aliasing in
67 *
68 * <blockquote><pre>
69 * @SafeVarargs // Not actually safe!
70 * static void m(List<String>... stringLists) {
71 * Object[] array = stringLists;
72 * List<Integer> tmpList = Arrays.asList(42);
73 * array[0] = tmpList; // Semantically invalid, but compiles without warnings
74 * String s = stringLists[0].get(0); // Oh no, ClassCastException at runtime!
75 * }
76 * </pre></blockquote>
77 *
78 * leads to a {@code ClassCastException} at runtime.
79 *
80 * <p>Future versions of the platform may mandate compiler errors for
81 * such unsafe operations.
82 *
83 * </ul>
84 *
85 * @jls 4.7 Reifiable Types
86 * @jls 8.4.1 Formal Parameters
87 */
88 @Documented
89 @Retention(RetentionPolicy.RUNTIME)
90 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
91 public @interface SafeVarargs {}
|
65 * warning. Some unsafe operations do not trigger an unchecked
66 * warning. For example, the aliasing in
67 *
68 * <blockquote><pre>
69 * @SafeVarargs // Not actually safe!
70 * static void m(List<String>... stringLists) {
71 * Object[] array = stringLists;
72 * List<Integer> tmpList = Arrays.asList(42);
73 * array[0] = tmpList; // Semantically invalid, but compiles without warnings
74 * String s = stringLists[0].get(0); // Oh no, ClassCastException at runtime!
75 * }
76 * </pre></blockquote>
77 *
78 * leads to a {@code ClassCastException} at runtime.
79 *
80 * <p>Future versions of the platform may mandate compiler errors for
81 * such unsafe operations.
82 *
83 * </ul>
84 *
85 * @since 1.7
86 * @jls 4.7 Reifiable Types
87 * @jls 8.4.1 Formal Parameters
88 */
89 @Documented
90 @Retention(RetentionPolicy.RUNTIME)
91 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
92 public @interface SafeVarargs {}
|