@@ -0,0 +1,2277 @@
+/*%0A * Copyright 2012, Facebook, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.facebook.LinkBench.util;%0A%0Aimport java.lang.reflect.Constructor;%0A%0A/**%0A * Utility methods for dynamic loading of classes%0A */%0Apublic class ClassLoadUtil %7B%0A%0A  private static final Class%3C?%3E%5B%5D EMPTY_ARRAY = new Class%5B%5D%7B%7D;%0A%0A  /**%0A   * Load a class by name.%0A   * @param name the class name.%0A   * @return the class object.%0A   * @throws ClassNotFoundException if the class is not found.%0A   */%0A  public static Class%3C?%3E getClassByName(String name)%0A                            throws ClassNotFoundException %7B%0A    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();%0A    return Class.forName(name, true, classLoader);%0A  %7D%0A%0A  /** Create an object for the given class and initialize it from conf%0A   *%0A   * @param theClass class of which an object is created%0A   * @param expected the expected parent class or interface%0A   * @return a new object%0A   */%0A  public static %3CT%3E T newInstance(Class%3C?%3E theClass, Class%3CT%3E expected) %7B%0A    T result;%0A    try %7B%0A      if (!expected.isAssignableFrom(theClass)) %7B%0A        throw new Exception(%22Specified class %22 + theClass.getName() + %22%22 +%0A            %22does not extend/implement %22 + expected.getName());%0A      %7D%0A      Class%3C? extends T%3E clazz = (Class%3C? extends T%3E)theClass;%0A      Constructor%3C? extends T%3E meth = clazz.getDeclaredConstructor(EMPTY_ARRAY);%0A      meth.setAccessible(true);%0A      result = meth.newInstance();%0A    %7D catch (Exception e) %7B%0A      throw new RuntimeException(e);%0A    %7D%0A    return result;%0A  %7D%0A%0A  public static %3CT%3E T newInstance(String className, Class%3CT%3E expected)%0A                                        throws ClassNotFoundException %7B%0A    return newInstance(getClassByName(className), expected);%0A  %7D%0A%7D%0A

Create ClassLoadUtil.java