File tree Expand file tree Collapse file tree 4 files changed +29
-7
lines changed
Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,14 @@ public Object[] array() {
128128 return copyOf (a , a .length );
129129 }
130130
131- @ SuppressWarnings ("unchecked" )
131+ /**
132+ * To be removed in future release:
133+ * affectation of the result of this method to a non generic array
134+ * will result in runtime error (ClassCastException).
135+ *
136+ * @deprecated use {@link #array(Class)}
137+ */
138+ @ Deprecated
132139 public A [] toJavaArray () {
133140 return (A []) array ();
134141 }
Original file line number Diff line number Diff line change @@ -211,7 +211,14 @@ public final Object[] toArrayObject() {
211211 return a ;
212212 }
213213
214- @ SuppressWarnings ("unchecked" )
214+ /**
215+ * To be removed in future release:
216+ * affectation of the result of this method to a non generic array
217+ * will result in runtime error (ClassCastException).
218+ *
219+ * @deprecated use {@link #array(Class)}
220+ */
221+ @ Deprecated
215222 public final A [] toJavaArray () {
216223 return (A []) toArrayObject ();
217224 }
Original file line number Diff line number Diff line change @@ -916,7 +916,14 @@ public final Option<A> toOption() {
916916 return isEmpty () ? Option .<A >none () : some (head ());
917917 }
918918
919- @ SuppressWarnings ({"unchecked" , "UnnecessaryFullyQualifiedName" })
919+ /**
920+ * To be removed in future release:
921+ * affectation of the result of this method to a non generic array
922+ * will result in runtime error (ClassCastException).
923+ *
924+ * @deprecated use {@link #array(Class)}
925+ */
926+ @ Deprecated
920927 public final A [] toJavaArray () {
921928 final A [] array = (A []) new Object [length ()];
922929 int i = 0 ;
Original file line number Diff line number Diff line change 33import org .junit .Test ;
44
55import static org .hamcrest .CoreMatchers .equalTo ;
6+ import static org .hamcrest .CoreMatchers .instanceOf ;
67import static org .junit .Assert .assertThat ;
78
89/**
1112public class ArrayTest {
1213
1314 @ Test
14- public void toJavaArray () {
15- final int max = 3 ;
16- List < Integer > list = List . range ( 1 , max + 1 );
17- assertThat (list .toArray ().toJavaArray ( ), equalTo ( list . toJavaArray () ));
15+ public void array_is_safe () {
16+ List < Integer > list = List . range ( 1 , 2 ) ;
17+
18+ assertThat (list .toArray ().array ( Integer []. class ), instanceOf ( Integer []. class ));
1819 }
1920
2021}
You can’t perform that action at this time.
0 commit comments