MCPcopy Create free account
hub / github.com/ReadyTalk/avian / newInstance

Method newInstance

classpath/java/lang/reflect/Array.java:101–129  ·  view source on GitHub ↗
(Class elementType, int length)

Source from the content-addressed store, hash-verified

99 private static native Object makeObjectArray(Class elementType, int length);
100
101 public static Object newInstance(Class elementType, int length) {
102 if (length < 0) {
103 throw new NegativeArraySizeException();
104 }
105
106 if (elementType.isPrimitive()) {
107 if (elementType.equals(boolean.class)) {
108 return new boolean[length];
109 } else if (elementType.equals(byte.class)) {
110 return new byte[length];
111 } else if (elementType.equals(char.class)) {
112 return new char[length];
113 } else if (elementType.equals(short.class)) {
114 return new short[length];
115 } else if (elementType.equals(int.class)) {
116 return new int[length];
117 } else if (elementType.equals(long.class)) {
118 return new long[length];
119 } else if (elementType.equals(float.class)) {
120 return new float[length];
121 } else if (elementType.equals(double.class)) {
122 return new double[length];
123 } else {
124 throw new IllegalArgumentException();
125 }
126 } else {
127 return makeObjectArray(elementType, length);
128 }
129 }
130}

Callers 3

deserializeArrayMethod · 0.95
copyOfMethod · 0.95
newProxyInstanceMethod · 0.45

Calls 3

makeObjectArrayMethod · 0.95
isPrimitiveMethod · 0.80
equalsMethod · 0.65

Tested by

no test coverage detected