sunchao commented on a change in pull request #2341:
URL: https://github.com/apache/hadoop/pull/2341#discussion_r495478153
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ReflectionUtils.java
##########
@@ -124,15 +124,29 @@ private static void setJobConf(Object theObject,
Configuration conf) {
*/
@SuppressWarnings("unchecked")
public static <T> T newInstance(Class<T> theClass, Configuration conf) {
+ return newInstance(theClass, conf, EMPTY_ARRAY);
+ }
+
+ /** Create an object for the given class and initialize it from conf
+ *
+ * @param theClass class of which an object is created
+ * @param conf Configuration
+ * @param argsType the types of the arguments
+ * @param values the values of the arguments
+ * @return a new object
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T newInstance(Class<T> theClass, Configuration conf,
Review comment:
Could you add a test in `TestReflectionUtils`?
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ReflectionUtils.java
##########
@@ -124,15 +124,29 @@ private static void setJobConf(Object theObject,
Configuration conf) {
*/
@SuppressWarnings("unchecked")
public static <T> T newInstance(Class<T> theClass, Configuration conf) {
+ return newInstance(theClass, conf, EMPTY_ARRAY);
+ }
+
+ /** Create an object for the given class and initialize it from conf
+ *
+ * @param theClass class of which an object is created
+ * @param conf Configuration
+ * @param argsType the types of the arguments
+ * @param values the values of the arguments
+ * @return a new object
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T newInstance(Class<T> theClass, Configuration conf,
+ Class<?>[] argsType, Object ... values) {
Review comment:
nit: `argsType` -> `argTypes`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]