OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.incrementalinstall; | 5 package org.chromium.incrementalinstall; |
6 | 6 |
7 import java.lang.reflect.Array; | 7 import java.lang.reflect.Array; |
8 import java.lang.reflect.Constructor; | 8 import java.lang.reflect.Constructor; |
9 import java.lang.reflect.Field; | 9 import java.lang.reflect.Field; |
10 import java.lang.reflect.Method; | 10 import java.lang.reflect.Method; |
(...skipping 28 matching lines...) Expand all Loading... |
39 static Object getField(Object instance, String name) throws ReflectiveOperat
ionException { | 39 static Object getField(Object instance, String name) throws ReflectiveOperat
ionException { |
40 Field field = findField(instance, name); | 40 Field field = findField(instance, name); |
41 field.setAccessible(true); | 41 field.setAccessible(true); |
42 return field.get(instance); | 42 return field.get(instance); |
43 } | 43 } |
44 | 44 |
45 /** | 45 /** |
46 * Concatenates two arrays into a new array. The arrays must be of the same | 46 * Concatenates two arrays into a new array. The arrays must be of the same |
47 * type. | 47 * type. |
48 */ | 48 */ |
49 static Object[] concatArrays(Object[] left, Object[] right) { | 49 static Object[] concatArrays(Object[] arrType, Object[] left, Object[] right
) { |
50 Object[] result = (Object[]) Array.newInstance( | 50 Object[] result = (Object[]) Array.newInstance( |
51 left.getClass().getComponentType(), left.length + right.length); | 51 arrType.getClass().getComponentType(), left.length + right.lengt
h); |
52 System.arraycopy(left, 0, result, 0, left.length); | 52 System.arraycopy(left, 0, result, 0, left.length); |
53 System.arraycopy(right, 0, result, left.length, right.length); | 53 System.arraycopy(right, 0, result, left.length, right.length); |
54 return result; | 54 return result; |
55 } | 55 } |
56 | 56 |
57 /** | 57 /** |
58 * Invokes a method with zero or more parameters. For static methods, use th
e Class as the | 58 * Invokes a method with zero or more parameters. For static methods, use th
e Class as the |
59 * instance. | 59 * instance. |
60 */ | 60 */ |
61 static Object invokeMethod(Object instance, String name, Object... params) | 61 static Object invokeMethod(Object instance, String name, Object... params) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 133 } |
134 Class<?> rightClazz = right.getClass(); | 134 Class<?> rightClazz = right.getClass(); |
135 if (left.isPrimitive()) { | 135 if (left.isPrimitive()) { |
136 // TODO(agrieve): Fill in the rest as needed. | 136 // TODO(agrieve): Fill in the rest as needed. |
137 return left == boolean.class && rightClazz == Boolean.class | 137 return left == boolean.class && rightClazz == Boolean.class |
138 || left == int.class && rightClazz == Integer.class; | 138 || left == int.class && rightClazz == Integer.class; |
139 } | 139 } |
140 return left.isAssignableFrom(rightClazz); | 140 return left.isAssignableFrom(rightClazz); |
141 } | 141 } |
142 } | 142 } |
OLD | NEW |