MCPcopy Create free account
hub / github.com/antlr/codebuff / newArray

Method newArray

corpus/java/training/guava/collect/Platform.java:39–47  ·  view source on GitHub ↗

Returns a new array of the given length with the same type as a reference array. @param reference any array of the desired type @param length the length of the new array

(T[] reference, int length)

Source from the content-addressed store, hash-verified

37 * @param length the length of the new array
38 */
39 static <T> T[] newArray(T[] reference, int length) {
40 Class<?> type = reference.getClass().getComponentType();
41
42 // the cast is safe because
43 // result.getClass() == reference.getClass().getComponentType()
44 @SuppressWarnings("unchecked")
45 T[] result = (T[]) Array.newInstance(type, length);
46 return result;
47 }
48
49 /**
50 * Configures the given map maker to use weak keys, if possible; does nothing

Callers 5

newArrayMethod · 0.95
newArrayMethod · 0.95
newArrayMethod · 0.95
newArrayMethod · 0.95
newArrayMethod · 0.95

Calls 2

getComponentTypeMethod · 0.45
newInstanceMethod · 0.45

Tested by

no test coverage detected