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

Method set

classpath/java/lang/reflect/Array.java:48–95  ·  view source on GitHub ↗
(Object array, int index, Object value)

Source from the content-addressed store, hash-verified

46 }
47
48 public static void set(Object array, int index, Object value) {
49 String className = array.getClass().getName();
50 if (! className.startsWith("[")) {
51 throw new IllegalArgumentException();
52 }
53
54 switch (className.charAt(1)) {
55 case 'B':
56 ((byte[]) array)[index] = (Byte) value;
57 break;
58 case 'C':
59 ((char[]) array)[index] = (Character) value;
60 break;
61 case 'D':
62 ((double[]) array)[index] = (Double) value;
63 break;
64 case 'F':
65 ((float[]) array)[index] = (Float) value;
66 break;
67 case 'I':
68 ((int[]) array)[index] = (Integer) value;
69 break;
70 case 'J':
71 ((long[]) array)[index] = (Long) value;
72 break;
73 case 'S':
74 ((short[]) array)[index] = (Short) value;
75 break;
76 case 'Z':
77 ((boolean[]) array)[index] = (Boolean) value;
78 break;
79 case 'L':
80 case '[':
81 if (value == null
82 || array.getClass().getComponentType().isInstance(value))
83 {
84 ((Object[]) array)[index] = value;
85 } else {
86 throw new IllegalArgumentException
87 ("need " + array.getClass().getComponentType() +
88 ", got " + value.getClass().getName());
89 }
90 break;
91
92 default:
93 throw new Error();
94 }
95 }
96
97 public static native int getLength(Object array);
98

Callers 1

deserializeArrayMethod · 0.95

Calls 6

startsWithMethod · 0.95
charAtMethod · 0.95
isInstanceMethod · 0.80
getComponentTypeMethod · 0.80
getNameMethod · 0.65
getClassMethod · 0.45

Tested by

no test coverage detected