Java Code Examples for java.lang.reflect.InvocationTargetException

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project arquillian-graphene, under directory /graphene-selenium/graphene-selenium-impl/src/main/java/org/jboss/arquillian/ajocado/command/.

Source file: CommandInterceptorProxyImpl.java

  32 
vote

/** 
 * <p> Proxies all the request on associated command processor. </p> <p> In case of  {@link CommandProcessor#doCommand(String,String[])} method, it also executes all associated interceptorsbefore performing the actual invocation of method. </p>
 */
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  Object result;
  try {
    if (interceptedMethods.contains(method.getName())) {
      String commandName=(String)args[0];
      String[] arguments=(String[])args[1];
      CommandContextImpl context=new CommandContextImpl(commandName,arguments,commandProcessor,method,interceptors.values());
      try {
        result=context.invoke();
      }
 catch (      CommandInterceptorException e) {
        throw new IllegalStateException("There was at least one interceptor which didn't call invoke()");
      }
catch (      Exception e) {
        throw new InvocationTargetException(e);
      }
    }
 else {
      result=method.invoke(commandProcessor,args);
    }
  }
 catch (  InvocationTargetException e) {
    throw e.getCause();
  }
catch (  Exception e) {
    throw new RuntimeException("unexpected invocation exception: " + e.getMessage());
  }
  return result;
}
 

Example 2

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.rds/src/com/amazonaws/eclipse/rds/.

Source file: ConfigureRDSDBConnectionRunnable.java

  31 
vote

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
  monitor.beginTask("Configuring database connection",10);
  openSecurityGroupIngress(new SubProgressMonitor(monitor,5));
  try {
    DriverInstance driverInstance=getDriver();
    IConnectionProfile connectionProfile=createConnectionProfile(driverInstance,new SubProgressMonitor(monitor,4));
    monitor.subTask("Connecting");
    RDSPlugin.connectAndReveal(connectionProfile);
    monitor.worked(1);
    completedSuccessfully=(connectionProfile.getConnectionState() == IConnectionProfile.CONNECTED_STATE);
  }
 catch (  Exception e) {
    throw new InvocationTargetException(e);
  }
 finally {
    monitor.done();
  }
}
 

Example 3

From project bamboo-sonar-integration, under directory /bamboo-sonar-web/src/main/java/com/marvelution/bamboo/plugins/sonar/web/proxy/.

Source file: OsgiServiceProxy.java

  31 
vote

/** 
 * {@inheritDoc}
 */
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  Class<?>[] argtypes;
  if (args != null && args.length > 0) {
    argtypes=new Class<?>[args.length];
    for (int index=0; index < args.length; index++) {
      argtypes[index]=bundle.loadClass(args[index].getClass().getName());
    }
  }
 else {
    argtypes=new Class[0];
  }
  Method actual=ReflectionUtils.findMethod(serviceClass,method.getName(),argtypes);
  if (actual != null) {
    return actual.invoke(service,args);
  }
 else {
    throw new InvocationTargetException(new Exception(),"Service '" + serviceClass + "' has no method with name: "+ method.getName());
  }
}
 

Example 4

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/.

Source file: PropertyValuesHolder.java

  30 
vote

/** 
 * Internal function (called from ObjectAnimator) to set up the setter and getter prior to running the animation. If the setter has not been manually set for this object, it will be derived automatically given the property name, target object, and types of values supplied. If no getter has been set, it will be supplied iff any of the supplied values was null. If there is a null value, then the getter (supplied or derived) will be called to set those null values to the current value of the property on the target object.
 * @param target The object on which the setter (and possibly getter) exist.
 */
void setupSetterAndGetter(Object target){
  Class targetClass=target.getClass();
  if (mSetter == null) {
    setupSetter(targetClass);
  }
  for (  Keyframe kf : mKeyframeSet.mKeyframes) {
    if (!kf.hasValue()) {
      if (mGetter == null) {
        setupGetter(targetClass);
      }
      try {
        kf.setValue(mGetter.invoke(target));
      }
 catch (      InvocationTargetException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
catch (      IllegalAccessException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
    }
  }
}
 

Example 5

From project amplafi-sworddance, under directory /src/main/java/com/sworddance/beans/.

Source file: ProxyMapperImpl.java

  30 
vote

/** 
 * @param method
 * @param args
 * @param actualObject
 * @return
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 */
private Object doInvoke(Method method,Object[] args) throws IllegalAccessException, InvocationTargetException {
  O actualObject;
  if ((method.getModifiers() & Modifier.STATIC) != Modifier.STATIC) {
    actualObject=getRealObject(true,"need object to call a non-static method ",this," method=",method,"(",join(args),")");
  }
 else {
    actualObject=null;
  }
  try {
    return method.invoke(actualObject,args);
  }
 catch (  RuntimeException e) {
    throw new InvocationTargetException(e,this + " method=" + method+ "("+ join(args)+ ")");
  }
}
 

Example 6

From project aunit, under directory /junit/src/main/java/com/toolazydogs/aunit/internal/.

Source file: AntlrTestMethod.java

  30 
vote

/** 
 * {@inheritDoc} Starts the test container, installs the test bundle and executes the test within the container.
 */
public void invoke(Object test) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
  final String fullTestName=name + "(" + testMethod.getName()+ ")";
  LOG.info("Starting test " + fullTestName);
  LOG.finest("Execute test [" + name + "]");
  try {
    LOG.info("Starting test " + fullTestName);
    ((CallableTestMethod)test).call();
    LOG.info("Test " + fullTestName + " ended successfully");
  }
 catch (  InstantiationException e) {
    throw new InvocationTargetException(e);
  }
catch (  ClassNotFoundException e) {
    throw new InvocationTargetException(e);
  }
}
 

Example 7

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/www/http/.

Source file: Webserver.java

  29 
vote

private void initSSLAttrs(){
  if (socket.getClass().getName().indexOf("SSLSocket") > 0) {
    try {
      sslAttributes=new Hashtable<String,Object>();
      Object sslSession=socket.getClass().getMethod("getSession",Utils.EMPTY_CLASSES).invoke(socket,Utils.EMPTY_OBJECTS);
      if (sslSession != null) {
        sslAttributes.put("javax.net.ssl.session",sslSession);
        Method m=sslSession.getClass().getMethod("getCipherSuite",Utils.EMPTY_CLASSES);
        m.setAccessible(true);
        sslAttributes.put("javax.net.ssl.cipher_suite",m.invoke(sslSession,Utils.EMPTY_OBJECTS));
        m=sslSession.getClass().getMethod("getPeerCertificates",Utils.EMPTY_CLASSES);
        m.setAccessible(true);
        sslAttributes.put("javax.net.ssl.peer_certificates",m.invoke(sslSession,Utils.EMPTY_OBJECTS));
      }
    }
 catch (    IllegalAccessException iae) {
      sslAttributes=null;
    }
catch (    NoSuchMethodException nsme) {
      sslAttributes=null;
    }
catch (    InvocationTargetException ite) {
    }
catch (    IllegalArgumentException iae) {
    }
  }
}
 

Example 8

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/.

Source file: PropertyValuesHolder.java

  29 
vote

/** 
 * Internal function (called from ObjectAnimator) to set up the setter and getter prior to running the animation. If the setter has not been manually set for this object, it will be derived automatically given the property name, target object, and types of values supplied. If no getter has been set, it will be supplied iff any of the supplied values was null. If there is a null value, then the getter (supplied or derived) will be called to set those null values to the current value of the property on the target object.
 * @param target The object on which the setter (and possibly getter) exist.
 */
void setupSetterAndGetter(Object target){
  Class targetClass=target.getClass();
  if (mSetter == null) {
    setupSetter(targetClass);
  }
  for (  Keyframe kf : mKeyframeSet.mKeyframes) {
    if (!kf.hasValue()) {
      if (mGetter == null) {
        setupGetter(targetClass);
      }
      try {
        kf.setValue(mGetter.invoke(target));
      }
 catch (      InvocationTargetException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
catch (      IllegalAccessException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
    }
  }
}
 

Example 9

From project Aardvark, under directory /aardvark-core/src/main/java/gw/vark/typeloader/.

Source file: AntlibTypeInfo.java

  29 
vote

@Override void invoke(Task taskInstance,Object arg,IntrospectionHelper helper){
  for (  Object argListArg : (List)arg) {
    try {
      helper.getElementMethod(_helperKey).invoke(taskInstance,argListArg);
    }
 catch (    IllegalAccessException e) {
      throw GosuExceptionUtil.forceThrow(e);
    }
catch (    InvocationTargetException e) {
      throw GosuExceptionUtil.forceThrow(e);
    }
  }
}
 

Example 10

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/nineoldandroids/animation/.

Source file: PropertyValuesHolder.java

  29 
vote

/** 
 * Internal function (called from ObjectAnimator) to set up the setter and getter prior to running the animation. If the setter has not been manually set for this object, it will be derived automatically given the property name, target object, and types of values supplied. If no getter has been set, it will be supplied iff any of the supplied values was null. If there is a null value, then the getter (supplied or derived) will be called to set those null values to the current value of the property on the target object.
 * @param target The object on which the setter (and possibly getter) exist.
 */
void setupSetterAndGetter(Object target){
  Class targetClass=target.getClass();
  if (mSetter == null) {
    setupSetter(targetClass);
  }
  for (  Keyframe kf : mKeyframeSet.mKeyframes) {
    if (!kf.hasValue()) {
      if (mGetter == null) {
        setupGetter(targetClass);
      }
      try {
        kf.setValue(mGetter.invoke(target));
      }
 catch (      InvocationTargetException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
catch (      IllegalAccessException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
    }
  }
}
 

Example 11

From project activejdbc, under directory /activejdbc-instrumentation/src/main/java/org/javalite/instrumentation/.

Source file: ActiveJdbcInstrumentationPlugin.java

  29 
vote

private void instrument(String instrumentationDirectory) throws MalformedURLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
  if (!new File(instrumentationDirectory).exists()) {
    getLog().info("Instrumentation: directory " + instrumentationDirectory + " does not exist, skipping");
    return;
  }
  ClassLoader realmLoader=getClass().getClassLoader();
  URL outDir=new File(instrumentationDirectory).toURL();
  Method addUrlMethod=realmLoader.getClass().getSuperclass().getDeclaredMethod("addURL",URL.class);
  addUrlMethod.setAccessible(true);
  addUrlMethod.invoke(realmLoader,outDir);
  Instrumentation instrumentation=new Instrumentation();
  instrumentation.setOutputDirectory(instrumentationDirectory);
  instrumentation.instrument();
}
 

Example 12

From project addis, under directory /application/src/test/java/org/drugis/addis/util/jaxb/.

Source file: NetworkMetaAnalysisConverterTest.java

  29 
vote

@Test public void testConvertNetworkMetaAnalysis() throws Exception, InstantiationException, InvocationTargetException, NoSuchMethodException {
  Domain domain=new DomainImpl();
  ExampleData.initDefaultData(domain);
  String name="CGI network meta-analysis";
  MetaAnalysisWithStudies ma=d_jaxbConverterTest.buildNetworkMetaAnalysis(name);
  List<Study> studies=new ArrayList<Study>();
  for (  org.drugis.addis.entities.data.Study study : ma.d_studies) {
    Study studyEnt=JAXBConvertor.convertStudy(study,domain);
    domain.getStudies().add(studyEnt);
    studies.add(studyEnt);
  }
  TreatmentDefinition combi=TreatmentDefinition.createTrivial(Arrays.asList(ExampleData.buildDrugFluoxetine(),ExampleData.buildDrugSertraline()));
  TreatmentDefinition parox=TreatmentDefinition.createTrivial(ExampleData.buildDrugParoxetine());
  TreatmentDefinition sertr=TreatmentDefinition.createTrivial(ExampleData.buildDrugSertraline());
  SortedSet<TreatmentDefinition> alternatives=new TreeSet<TreatmentDefinition>();
  alternatives.add(combi);
  alternatives.add(parox);
  alternatives.add(sertr);
  Map<Study,Map<TreatmentDefinition,Arm>> armMap=new HashMap<Study,Map<TreatmentDefinition,Arm>>();
  Map<TreatmentDefinition,Arm> study1map=new HashMap<TreatmentDefinition,Arm>();
  study1map.put(combi,studies.get(0).getArms().get(0));
  study1map.put(sertr,studies.get(0).getArms().get(1));
  armMap.put(studies.get(0),study1map);
  Map<TreatmentDefinition,Arm> study2map=new HashMap<TreatmentDefinition,Arm>();
  study2map.put(parox,studies.get(1).getArms().get(0));
  study2map.put(sertr,studies.get(1).getArms().get(1));
  armMap.put(studies.get(1),study2map);
  Map<TreatmentDefinition,Arm> study3map=new HashMap<TreatmentDefinition,Arm>();
  study3map.put(sertr,studies.get(2).getArms().get(0));
  study3map.put(parox,studies.get(2).getArms().get(1));
  study3map.put(combi,studies.get(2).getArms().get(2));
  armMap.put(studies.get(2),study3map);
  Collections.sort(studies);
  NetworkMetaAnalysis expected=new NetworkMetaAnalysis(name,ExampleData.buildIndicationDepression(),ExampleData.buildEndpointCgi(),studies,alternatives,armMap);
  assertEntityEquals(expected,NetworkMetaAnalysisConverter.load(ma.d_nwma,domain));
  assertEquals(ma.d_nwma,NetworkMetaAnalysisConverter.save(expected));
}
 

Example 13

From project advanced, under directory /management/src/main/java/org/neo4j/management/impl/.

Source file: BeanProxy.java

  29 
vote

@Override <T>T makeProxy(MBeanServerConnection mbs,Class<T> beanType,ObjectName name){
  try {
    return beanType.cast(newMXBeanProxy.invoke(null,mbs,name,beanType));
  }
 catch (  InvocationTargetException exception) {
    throw launderRuntimeException(exception.getTargetException());
  }
catch (  Exception exception) {
    throw new UnsupportedOperationException("Creating Management Bean proxies requires Java 1.6",exception);
  }
}
 

Example 14

From project agit, under directory /agit/src/main/java/com/madgag/agit/sync/.

Source file: AccountAuthenticatorService.java

  29 
vote

private static void addPeriodicSyncIfSupported(Account account,long pollPeriodInSeconds){
  if (methodContentResolver_addPeriodicSync == null) {
    return;
  }
  try {
    methodContentResolver_addPeriodicSync.invoke(null,account,AGIT_PROVIDER_AUTHORITY,new Bundle(),pollPeriodInSeconds);
  }
 catch (  InvocationTargetException ite) {
    Throwable cause=ite.getCause();
    if (cause instanceof RuntimeException) {
      throw (RuntimeException)cause;
    }
 else     if (cause instanceof Error) {
      throw (Error)cause;
    }
 else {
      throw new RuntimeException(ite);
    }
  }
catch (  IllegalAccessException ie) {
    Log.e(TAG,"Unexpected exception adding periodic sync",ie);
  }
}
 

Example 15

From project Agot-Java, under directory /src/main/java/got/ui/update/.

Source file: Util.java

  29 
vote

public static void runInSwingEventThread(final Runnable r){
  if (SwingUtilities.isEventDispatchThread()) {
    r.run();
  }
 else {
    try {
      SwingUtilities.invokeAndWait(r);
    }
 catch (    final InterruptedException e) {
      throw new IllegalStateException(e);
    }
catch (    final InvocationTargetException e) {
      throw new IllegalStateException(e);
    }
  }
}
 

Example 16

From project Aion-Extreme, under directory /AE-go_GameServer/src/com/aionemu/gameserver/model/quests/.

Source file: ConditionFactory.java

  29 
vote

public static QuestCondition newCondition(String name,NamedNodeMap attr) throws QuestEngineException {
  try {
    if (conditions.containsKey(name)) {
      Constructor con=conditions.get(name).getConstructor(new Class<?>[]{NamedNodeMap.class});
      return (QuestCondition)con.newInstance(new Object[]{attr});
    }
  }
 catch (  InstantiationException ex) {
    throw new QuestEngineException("Error on QuestCondition \"" + name + "\".",ex);
  }
catch (  IllegalAccessException ex) {
    throw new QuestEngineException("Error on QuestCondition \"" + name + "\".",ex);
  }
catch (  IllegalArgumentException ex) {
    throw new QuestEngineException("Error on QuestCondition \"" + name + "\".",ex);
  }
catch (  InvocationTargetException ex) {
    throw new QuestEngineException("Error on QuestCondition \"" + name + "\".",ex);
  }
catch (  NoSuchMethodException ex) {
    throw new QuestEngineException("Error on QuestCondition \"" + name + "\".",ex);
  }
catch (  SecurityException ex) {
    throw new QuestEngineException("Error on QuestCondition \"" + name + "\".",ex);
  }
  throw new QuestEngineException("Unhandled QuestCondition \"" + name + "\".");
}
 

Example 17

From project airlift, under directory /bootstrap/src/main/java/io/airlift/bootstrap/.

Source file: LifeCycleManager.java

  29 
vote

private void startInstance(Object obj) throws IllegalAccessException, InvocationTargetException {
  log.debug("Starting %s",obj.getClass().getName());
  LifeCycleMethods methods=methodsMap.get(obj.getClass());
  for (  Method postConstruct : methods.methodsFor(PostConstruct.class)) {
    log.debug("\t%s()",postConstruct.getName());
    postConstruct.invoke(obj);
  }
}
 

Example 18

From project AirReceiver, under directory /src/main/java/org/phlo/AirReceiver/.

Source file: AirTunesCrytography.java

  29 
vote

/** 
 * Creates a  {@link javax.crypto.Cipher} instance from a {@link javax.crypto.CipherSpi}.
 * @param cipherSpi the {@link javax.cyrpto.CipherSpi} instance
 * @param transformation the transformation cipherSpi was obtained for
 * @return a {@link javax.crypto.Cipher} instance
 * @throws Throwable in case of an error
 */
private static Cipher getCipher(final CipherSpi cipherSpi,final String transformation) throws Throwable {
  final Class<Cipher> cipherClass=Cipher.class;
  final Constructor<Cipher> cipherConstructor=cipherClass.getDeclaredConstructor(CipherSpi.class,String.class);
  cipherConstructor.setAccessible(true);
  try {
    return cipherConstructor.newInstance(cipherSpi,transformation);
  }
 catch (  final InvocationTargetException e) {
    throw e.getCause();
  }
}
 

Example 19

From project ajah, under directory /ajah-spring-jdbc/src/main/java/com/ajah/spring/jdbc/.

Source file: AbstractAjahDao.java

  29 
vote

private void propSet(final T entity,final PropertyDescriptor prop,final Object value){
  try {
    final Method setter=prop.getWriteMethod();
    if (setter == null) {
      throw new IllegalArgumentException("No setter found for " + prop.getName());
    }
    setter.invoke(entity,value);
  }
 catch (  final IllegalAccessException e) {
    log.log(Level.SEVERE,prop.getName() + ": " + e.getMessage(),e);
  }
catch (  final IllegalArgumentException e) {
    log.log(Level.SEVERE,prop.getName() + ": " + e.getMessage(),e);
  }
catch (  final InvocationTargetException e) {
    log.log(Level.SEVERE,prop.getName() + ": " + e.getMessage(),e);
  }
}
 

Example 20

From project alljoyn_java, under directory /samples/android/simple/wfd_service/src/org/alljoyn/bus/samples/wfdsimpleservice/.

Source file: WifiDirectAutoAccept.java

  29 
vote

/** 
 * Call WifiP2pManager.setDialogListener() using reflection. Passing null for the listener parameter will deregister any previous listener and cause the WiFi P2P framework to revert to system handling of P2P group formation. If the method is not available at runtime, no action is taken. WifiP2pManager.setDialogListener() exists in Android API 16, but not in earlier APIs.
 */
private void setDialogListener(Object listener){
  if (dialogListenerMethod == null) {
    return;
  }
  try {
    dialogListenerMethod.invoke(manager,channel,listener);
  }
 catch (  IllegalAccessException ex) {
    Log.d(TAG,ex.getClass().getName());
  }
catch (  InvocationTargetException ex) {
    Log.d(TAG,ex.getClass().getName());
  }
}
 

Example 21

From project ALP, under directory /workspace/alp-flexpilot/src/main/java/com/lohika/alp/flexpilot/pagefactory/.

Source file: FlexPilotLocatingElementHandler.java

  29 
vote

public Object invoke(Object object,Method method,Object[] objects) throws Throwable {
  FlexElement element=locator.findElement();
  if ("getWrappedElement".equals(method.getName())) {
    return element;
  }
  try {
    return method.invoke(element,objects);
  }
 catch (  InvocationTargetException e) {
    Throwable t=e.getCause();
    throw t;
  }
}
 

Example 22

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/.

Source file: PropertyValuesHolder.java

  29 
vote

/** 
 * Internal function (called from ObjectAnimator) to set up the setter and getter prior to running the animation. If the setter has not been manually set for this object, it will be derived automatically given the property name, target object, and types of values supplied. If no getter has been set, it will be supplied iff any of the supplied values was null. If there is a null value, then the getter (supplied or derived) will be called to set those null values to the current value of the property on the target object.
 * @param target The object on which the setter (and possibly getter) exist.
 */
void setupSetterAndGetter(Object target){
  Class targetClass=target.getClass();
  if (mSetter == null) {
    setupSetter(targetClass);
  }
  for (  Keyframe kf : mKeyframeSet.mKeyframes) {
    if (!kf.hasValue()) {
      if (mGetter == null) {
        setupGetter(targetClass);
      }
      try {
        kf.setValue(mGetter.invoke(target));
      }
 catch (      InvocationTargetException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
catch (      IllegalAccessException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
    }
  }
}
 

Example 23

From project amber, under directory /oauth-2.0/common/src/main/java/org/apache/amber/oauth2/common/utils/.

Source file: OAuthUtils.java

  29 
vote

public static Object instantiateClassWithParameters(Class clazz,Class[] paramsTypes,Object[] paramValues) throws OAuthSystemException {
  try {
    if (paramsTypes != null && paramValues != null) {
      if (!(paramsTypes.length == paramValues.length)) {
        throw new IllegalArgumentException("Number of types and values must be equal");
      }
      if (paramsTypes.length == 0 && paramValues.length == 0) {
        return clazz.newInstance();
      }
      Constructor clazzConstructor=clazz.getConstructor(paramsTypes);
      return clazzConstructor.newInstance(paramValues);
    }
    return clazz.newInstance();
  }
 catch (  NoSuchMethodException e) {
    throw new OAuthSystemException(e);
  }
catch (  InstantiationException e) {
    throw new OAuthSystemException(e);
  }
catch (  IllegalAccessException e) {
    throw new OAuthSystemException(e);
  }
catch (  InvocationTargetException e) {
    throw new OAuthSystemException(e);
  }
}
 

Example 24

From project AmDroid, under directory /httpclientandroidlib/src/ch/boye/httpclientandroidlib/client/utils/.

Source file: CloneUtils.java

  29 
vote

public static Object clone(final Object obj) throws CloneNotSupportedException {
  if (obj == null) {
    return null;
  }
  if (obj instanceof Cloneable) {
    Class<?> clazz=obj.getClass();
    Method m;
    try {
      m=clazz.getMethod("clone",(Class[])null);
    }
 catch (    NoSuchMethodException ex) {
      throw new NoSuchMethodError(ex.getMessage());
    }
    try {
      return m.invoke(obj,(Object[])null);
    }
 catch (    InvocationTargetException ex) {
      Throwable cause=ex.getCause();
      if (cause instanceof CloneNotSupportedException) {
        throw ((CloneNotSupportedException)cause);
      }
 else {
        throw new Error("Unexpected exception",cause);
      }
    }
catch (    IllegalAccessException ex) {
      throw new IllegalAccessError(ex.getMessage());
    }
  }
 else {
    throw new CloneNotSupportedException();
  }
}
 

Example 25

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/bean/.

Source file: PureJavaReflectionProvider.java

  29 
vote

public Object newInstance(Class type){
  try {
    Constructor[] constructors=type.getDeclaredConstructors();
    for (int i=0; i < constructors.length; i++) {
      if (constructors[i].getParameterTypes().length == 0) {
        if (!Modifier.isPublic(constructors[i].getModifiers())) {
          constructors[i].setAccessible(true);
        }
        return constructors[i].newInstance(new Object[0]);
      }
    }
    if (Serializable.class.isAssignableFrom(type)) {
      return instantiateUsingSerialization(type);
    }
 else {
      throw new ObjectAccessException("Cannot construct " + type.getName() + " as it does not have a no-args constructor");
    }
  }
 catch (  InstantiationException e) {
    throw new ObjectAccessException("Cannot construct " + type.getName(),e);
  }
catch (  IllegalAccessException e) {
    throw new ObjectAccessException("Cannot construct " + type.getName(),e);
  }
catch (  InvocationTargetException e) {
    if (e.getTargetException() instanceof RuntimeException) {
      throw (RuntimeException)e.getTargetException();
    }
 else     if (e.getTargetException() instanceof Error) {
      throw (Error)e.getTargetException();
    }
 else {
      throw new ObjectAccessException("Constructor for " + type.getName() + " threw an exception",e.getTargetException());
    }
  }
}
 

Example 26

From project anadix, under directory /anadix-api/src/main/java/org/anadix/factories/.

Source file: ObjectFactory.java

  29 
vote

/** 
 * Creates a new instance of given class using constructor accepting given parameters
 * @param clazz - class to create a new instance of
 * @param initargs - arguments to constructor
 * @return new instance of given class
 * @throws Exception - if anything goes wrong
 */
private static <T>T instantiate(Class<T> clazz,Object... initargs) throws InstantiationException {
  try {
    Object o=getConstructor(clazz,initargs).newInstance(initargs);
    return clazz.cast(o);
  }
 catch (  IllegalAccessException ex) {
    throw newInstantiationException(clazz.getName(),ex);
  }
catch (  IllegalArgumentException ex) {
    throw newInstantiationException(clazz.getName(),ex);
  }
catch (  InvocationTargetException ex) {
    throw newInstantiationException(clazz.getName(),ex);
  }
}
 

Example 27

From project and-bible, under directory /AndBible/src/org/apache/commons/lang/.

Source file: StringUtils.java

  29 
vote

/** 
 * <p>Removes diacritics (~= accents) from a string. The case will not be altered.</p> <p>For instance, '&agrave;' will be replaced by 'a'.</p> <p>Note that ligatures will be left as is.</p> <p>This method will use the first available implementation of: Java 6's  {@link java.text.Normalizer}, Java 1.3&ndash;1.5's  {@code sun.text.Normalizer}</p> <pre> StringUtils.stripAccents(null)                = null StringUtils.stripAccents("")                  = "" StringUtils.stripAccents("control")           = "control" StringUtils.stripAccents("&ecute;clair")      = "eclair" </pre>
 * @param input String to be stripped
 * @return input text with diacritics removed
 * @since 3.0
 */
public static String stripAccents(CharSequence input){
  if (input == null) {
    return null;
  }
  try {
    String result=null;
    if (java6Available) {
      result=removeAccentsJava6(input);
    }
 else     if (sunAvailable) {
      result=removeAccentsSUN(input);
    }
 else {
      throw new UnsupportedOperationException("The stripAccents(CharSequence) method requires at least Java 1.6 or a Sun JVM");
    }
    return result;
  }
 catch (  IllegalArgumentException iae) {
    throw new RuntimeException("IllegalArgumentException occurred",iae);
  }
catch (  IllegalAccessException iae) {
    throw new RuntimeException("IllegalAccessException occurred",iae);
  }
catch (  InvocationTargetException ite) {
    throw new RuntimeException("InvocationTargetException occurred",ite);
  }
catch (  SecurityException se) {
    throw new RuntimeException("SecurityException occurred",se);
  }
}
 

Example 28

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/.

Source file: PropertyValuesHolder.java

  29 
vote

/** 
 * Internal function (called from ObjectAnimator) to set up the setter and getter prior to running the animation. If the setter has not been manually set for this object, it will be derived automatically given the property name, target object, and types of values supplied. If no getter has been set, it will be supplied iff any of the supplied values was null. If there is a null value, then the getter (supplied or derived) will be called to set those null values to the current value of the property on the target object.
 * @param target The object on which the setter (and possibly getter) exist.
 */
void setupSetterAndGetter(Object target){
  Class targetClass=target.getClass();
  if (mSetter == null) {
    setupSetter(targetClass);
  }
  for (  Keyframe kf : mKeyframeSet.mKeyframes) {
    if (!kf.hasValue()) {
      if (mGetter == null) {
        setupGetter(targetClass);
      }
      try {
        kf.setValue(mGetter.invoke(target));
      }
 catch (      InvocationTargetException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
catch (      IllegalAccessException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
    }
  }
}
 

Example 29

From project android-animation-backport, under directory /animation-backport/src/backports/animation/.

Source file: PropertyValuesHolder.java

  29 
vote

/** 
 * Internal function (called from ObjectAnimator) to set up the setter and getter prior to running the animation. If the setter has not been manually set for this object, it will be derived automatically given the property name, target object, and types of values supplied. If no getter has been set, it will be supplied iff any of the supplied values was null. If there is a null value, then the getter (supplied or derived) will be called to set those null values to the current value of the property on the target object.
 * @param target The object on which the setter (and possibly getter) exist.
 */
void setupSetterAndGetter(Object target){
  if (mProperty != null) {
    try {
      Object testValue=mProperty.get(target);
      for (      Keyframe kf : mKeyframeSet.mKeyframes) {
        if (!kf.hasValue()) {
          kf.setValue(mProperty.get(target));
        }
      }
      return;
    }
 catch (    ClassCastException e) {
      Log.e("PropertyValuesHolder","No such property (" + mProperty.getName() + ") on target object "+ target+ ". Trying reflection instead");
      mProperty=null;
    }
  }
  Class targetClass=target.getClass();
  if (mSetter == null) {
    setupSetter(targetClass);
  }
  for (  Keyframe kf : mKeyframeSet.mKeyframes) {
    if (!kf.hasValue()) {
      if (mGetter == null) {
        setupGetter(targetClass);
      }
      try {
        kf.setValue(mGetter.invoke(target));
      }
 catch (      InvocationTargetException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
catch (      IllegalAccessException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
    }
  }
}
 

Example 30

From project android-client, under directory /xwiki-android-core/src/org/xwiki/android/context/.

Source file: XWikiApplicationContext.java

  29 
vote

public FileStoreManager getFileStoreManager(){
  FileStoreManager fsm=null;
  try {
    Constructor<FileStoreManagerImpl> con=FileStoreManagerImpl.class.getDeclaredConstructor(XWikiApplicationContext.class);
    con.setAccessible(true);
    fsm=con.newInstance(this);
  }
 catch (  SecurityException e) {
    e.printStackTrace();
  }
catch (  NoSuchMethodException e) {
    e.printStackTrace();
  }
catch (  IllegalArgumentException e) {
    e.printStackTrace();
  }
catch (  InstantiationException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
catch (  InvocationTargetException e) {
    e.printStackTrace();
  }
  return fsm;
}
 

Example 31

From project android-client_1, under directory /src/com/googlecode/asmack/connection/impl/.

Source file: ZLibOutputStream.java

  29 
vote

/** 
 * Flush the given stream, preferring Java7 FLUSH_SYNC if available.
 * @throws IOException In case of a lowlevel exception.
 */
@Override public void flush() throws IOException {
  if (!SUPPORTED) {
    super.flush();
    return;
  }
  int count=0;
  if (!def.needsInput()) {
    do {
      count=def.deflate(buf,0,buf.length);
      out.write(buf,0,count);
    }
 while (count > 0);
    out.flush();
  }
  try {
    do {
      count=(Integer)method.invoke(def,buf,0,buf.length,2);
      out.write(buf,0,count);
    }
 while (count > 0);
  }
 catch (  IllegalArgumentException e) {
    throw new IOException("Can't flush");
  }
catch (  IllegalAccessException e) {
    throw new IOException("Can't flush");
  }
catch (  InvocationTargetException e) {
    throw new IOException("Can't flush");
  }
  super.flush();
}
 

Example 32

From project Android-FFXIEQ, under directory /ffxieq/src/com/github/kanata3249/ffxieq/android/db/.

Source file: FFXIEQSettings.java

  29 
vote

private void dataChanged(){
  if (mBackupManager != null) {
    try {
      Method method=mBackupManager.getClass().getMethod("dataChanged",(Class[])null);
      method.invoke(mBackupManager,(Object[])null);
    }
 catch (    IllegalArgumentException e) {
    }
catch (    SecurityException e) {
    }
catch (    IllegalAccessException e) {
    }
catch (    InvocationTargetException e) {
    }
catch (    NoSuchMethodException e) {
    }
  }
}
 

Example 33

From project android-inject, under directory /src/test/java/com/teamcodeflux/android/inject/.

Source file: AndroidInjectTest.java

  29 
vote

@Test(expected=InvocationTargetException.class) public void shouldNotAllowInstantiationUsingReflection() throws Exception {
  Constructor defaultConstructor=AndroidInject.class.getDeclaredConstructors()[0];
  defaultConstructor.setAccessible(true);
  defaultConstructor.newInstance((Object[])null);
  fail("Should not be allowed");
}
 

Example 34

From project android-sdk, under directory /src/test/java/com/mobeelizer/mobile/android/.

Source file: MobeelizerDefinitionManagerTest.java

  29 
vote

private void checkModelHasAccess(final String role,final MobeelizerCredential createAllowed,final MobeelizerCredential updateAllowed,final MobeelizerCredential readAllowed,final MobeelizerCredential deleteAllowed,final boolean hasAccess){
  MobeelizerModelDefinition model=mock(MobeelizerModelDefinition.class);
  MobeelizerModelCredentialsDefinition credentials1=mock(MobeelizerModelCredentialsDefinition.class);
  when(credentials1.getRole()).thenReturn(role);
  when(credentials1.getCreateAllowed()).thenReturn(createAllowed);
  when(credentials1.getUpdateAllowed()).thenReturn(updateAllowed);
  when(credentials1.getReadAllowed()).thenReturn(readAllowed);
  when(credentials1.getDeleteAllowed()).thenReturn(deleteAllowed);
  Set<MobeelizerModelCredentialsDefinition> credentials=new HashSet<MobeelizerModelCredentialsDefinition>();
  credentials.add(credentials1);
  when(model.getCredentials()).thenReturn(credentials);
  MobeelizerModelCredentialsDefinition actualCredentials;
  try {
    actualCredentials=(MobeelizerModelCredentialsDefinition)modelHasAccess.invoke(definitionManager,model,"role");
  }
 catch (  IllegalArgumentException e) {
    throw new IllegalStateException(e.getMessage(),e);
  }
catch (  IllegalAccessException e) {
    throw new IllegalStateException(e.getMessage(),e);
  }
catch (  InvocationTargetException e) {
    throw new IllegalStateException(e.getMessage(),e);
  }
  if (hasAccess) {
    assertSame(credentials1,actualCredentials);
  }
 else {
    assertNull(actualCredentials);
  }
}
 

Example 35

From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/compat/.

Source file: ServiceForegroundCompat.java

  29 
vote

private void invokeMethod(Object receiver,Method method,Object... args){
  try {
    method.invoke(receiver,args);
  }
 catch (  IllegalAccessException e) {
    Log.w("ServiceCompat","Unable to invoke method",e);
  }
catch (  InvocationTargetException e) {
    Log.w("ServiceCompat","Method threw exception",e.getCause());
  }
}
 

Example 36

From project android-thaiime, under directory /common/src/com/android/common/.

Source file: SharedPreferencesCompat.java

  29 
vote

public static void apply(SharedPreferences.Editor editor){
  if (sApplyMethod != null) {
    try {
      sApplyMethod.invoke(editor);
      return;
    }
 catch (    InvocationTargetException unused) {
    }
catch (    IllegalAccessException unused) {
    }
  }
  editor.commit();
}
 

Example 37

From project androidannotations, under directory /AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/api/sharedpreferences/.

Source file: SharedPreferencesCompat.java

  29 
vote

public static void apply(SharedPreferences.Editor editor){
  if (sApplyMethod != null) {
    try {
      sApplyMethod.invoke(editor);
      return;
    }
 catch (    InvocationTargetException unused) {
    }
catch (    IllegalAccessException unused) {
    }
  }
  editor.commit();
}
 

Example 38

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/provider/.

Source file: BookStoreFactory.java

  29 
vote

private static void addStore(Context context,XmlResourceParser parser,AttributeSet attrs,HashMap<String,BooksStore> stores){
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.BookStore);
  final String name=a.getString(R.styleable.BookStore_name);
  if (TextUtils.isEmpty(name)) {
    throw new InflateException(parser.getPositionDescription() + ": A store must have a name");
  }
  final String label=a.getString(R.styleable.BookStore_label);
  if (TextUtils.isEmpty(label)) {
    throw new InflateException(parser.getPositionDescription() + ": A store must have a label");
  }
  final String storeClass=a.getString(R.styleable.BookStore_storeClass);
  if (TextUtils.isEmpty(name)) {
    throw new InflateException(parser.getPositionDescription() + ": A store must have a class");
  }
  a.recycle();
  try {
    Class<?> klass=Class.forName(storeClass);
    Constructor<?> constructor=klass.getDeclaredConstructor(String.class,String.class);
    constructor.setAccessible(true);
    BooksStore store=(BooksStore)constructor.newInstance(name,label);
    stores.put(name,store);
  }
 catch (  ClassNotFoundException e) {
  }
catch (  NoSuchMethodException e) {
    throw new InflateException(parser.getPositionDescription() + ": The book store " + storeClass+ " does not have a matching constructor");
  }
catch (  IllegalAccessException e) {
    throw new InflateException(parser.getPositionDescription() + ": Could not create the " + "book store",e);
  }
catch (  InvocationTargetException e) {
    throw new InflateException(parser.getPositionDescription() + ": Could not create the " + "book store",e);
  }
catch (  InstantiationException e) {
    throw new InflateException(parser.getPositionDescription() + ": Could not create the " + "book store",e);
  }
}
 

Example 39

From project AndroidSensorLogger, under directory /libraries/opencsv-2.3-src-with-libs/opencsv-2.3/src/au/com/bytecode/opencsv/bean/.

Source file: CsvToBean.java

  29 
vote

protected T processLine(MappingStrategy<T> mapper,String[] line) throws IllegalAccessException, InvocationTargetException, InstantiationException, IntrospectionException {
  T bean=mapper.createBean();
  for (int col=0; col < line.length; col++) {
    PropertyDescriptor prop=mapper.findDescriptor(col);
    if (null != prop) {
      String value=checkForTrim(line[col],prop);
      Object obj=convertValue(value,prop);
      prop.getWriteMethod().invoke(bean,obj);
    }
  }
  return bean;
}
 

Example 40

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/nineoldandroids/animation/.

Source file: PropertyValuesHolder.java

  29 
vote

/** 
 * Internal function (called from ObjectAnimator) to set up the setter and getter prior to running the animation. If the setter has not been manually set for this object, it will be derived automatically given the property name, target object, and types of values supplied. If no getter has been set, it will be supplied iff any of the supplied values was null. If there is a null value, then the getter (supplied or derived) will be called to set those null values to the current value of the property on the target object.
 * @param target The object on which the setter (and possibly getter) exist.
 */
void setupSetterAndGetter(Object target){
  Class targetClass=target.getClass();
  if (mSetter == null) {
    setupSetter(targetClass);
  }
  for (  Keyframe kf : mKeyframeSet.mKeyframes) {
    if (!kf.hasValue()) {
      if (mGetter == null) {
        setupGetter(targetClass);
      }
      try {
        kf.setValue(mGetter.invoke(target));
      }
 catch (      InvocationTargetException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
catch (      IllegalAccessException e) {
        Log.e("PropertyValuesHolder",e.toString());
      }
    }
  }
}
 

Example 41

From project android_8, under directory /src/com/defuzeme/communication/.

Source file: Communication.java

  29 
vote

@Override protected Void doInBackground(Void... params){
  StreamObject object=null;
  Method method=null;
  while (true) {
    try {
      Thread.sleep(100);
      if (DefuzeMe._requests.size() > 0) {
        object=DefuzeMe._requests.remove(0);
        method=Receive.class.getMethod(object.event,StreamObject.class);
        method.invoke(Communication.Receive,object);
      }
    }
 catch (    InterruptedException exception) {
      Log.e(this.getClass().getName(),exception.toString());
    }
catch (    SecurityException exception) {
      Log.e(this.getClass().getName(),exception.toString());
    }
catch (    NoSuchMethodException exception) {
      Log.e(this.getClass().getName(),exception.toString());
    }
catch (    IllegalArgumentException exception) {
      Log.e(this.getClass().getName(),exception.toString());
    }
catch (    IllegalAccessException exception) {
      Log.e(this.getClass().getName(),exception.toString());
    }
catch (    InvocationTargetException exception) {
      Log.e(this.getClass().getName(),exception.toString());
    }
  }
}
 

Example 42

From project android_build, under directory /tools/droiddoc/src/.

Source file: DroidDoc.java

  29 
vote

public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  String methodName=method.getName();
  if (args != null) {
    if (methodName.equals("compareTo") || methodName.equals("equals") || methodName.equals("overrides")|| methodName.equals("subclassOf")) {
      args[0]=unwrap(args[0]);
    }
  }
  if (methodName.equals("getRawCommentText")) {
    return filterComment((String)method.invoke(target,args));
  }
  if (proxy instanceof Type && methodName.equals("toString")) {
    return ((String)method.invoke(target,args)).replace("&","&amp;");
  }
  try {
    return filterHidden(method.invoke(target,args),method.getReturnType());
  }
 catch (  InvocationTargetException e) {
    throw e.getTargetException();
  }
}
 

Example 43

From project android_external_easymock, under directory /src/org/easymock/internal/.

Source file: Result.java

  29 
vote

public static Result createDelegatingResult(final Object value){
class DelegatingAnswer implements IAnswer<Object>, Serializable {
    private static final long serialVersionUID=-5699326678580460103L;
    public Object answer() throws Throwable {
      Invocation invocation=LastControl.getCurrentInvocation();
      try {
        return invocation.getMethod().invoke(value,invocation.getArguments());
      }
 catch (      IllegalArgumentException e) {
        throw new IllegalArgumentException("Delegation to object [" + String.valueOf(value) + "] is not implementing the mocked method ["+ invocation.getMethod()+ "]",e);
      }
catch (      InvocationTargetException e) {
        throw e.getCause();
      }
    }
    @Override public String toString(){
      return "Delegated to " + value;
    }
  }
  return new Result(new DelegatingAnswer(),false);
}
 

Example 44

From project android_external_guava, under directory /src/com/google/common/util/concurrent/.

Source file: SimpleTimeLimiter.java

  29 
vote

public <T>T newProxy(final T target,Class<T> interfaceType,final long timeoutDuration,final TimeUnit timeoutUnit){
  checkNotNull(target);
  checkNotNull(interfaceType);
  checkNotNull(timeoutUnit);
  checkArgument(timeoutDuration > 0,"bad timeout: " + timeoutDuration);
  checkArgument(interfaceType.isInterface(),"interfaceType must be an interface type");
  final Set<Method> interruptibleMethods=findInterruptibleMethods(interfaceType);
  InvocationHandler handler=new InvocationHandler(){
    public Object invoke(    Object obj,    final Method method,    final Object[] args) throws Throwable {
      Callable<Object> callable=new Callable<Object>(){
        public Object call() throws Exception {
          try {
            return method.invoke(target,args);
          }
 catch (          InvocationTargetException e) {
            Throwables.throwCause(e,false);
            throw new AssertionError("can't get here");
          }
        }
      }
;
      return callWithTimeout(callable,timeoutDuration,timeoutUnit,interruptibleMethods.contains(method));
    }
  }
;
  return newProxy(interfaceType,handler);
}
 

Example 45

From project android_frameworks_ex, under directory /common/java/com/android/common/.

Source file: SharedPreferencesCompat.java

  29 
vote

public static void apply(SharedPreferences.Editor editor){
  if (sApplyMethod != null) {
    try {
      sApplyMethod.invoke(editor);
      return;
    }
 catch (    InvocationTargetException unused) {
    }
catch (    IllegalAccessException unused) {
    }
  }
  editor.commit();
}
 

Example 46

From project android_packages_apps_Exchange, under directory /tests/src/com/android/exchange/adapter/.

Source file: SyncAdapterTestCase.java

  29 
vote

protected T getTestSyncAdapter(Class<T> klass){
  EasSyncService service=getTestService();
  Constructor<T> c;
  try {
    c=klass.getDeclaredConstructor(new Class[]{EasSyncService.class});
    return c.newInstance(service);
  }
 catch (  SecurityException e) {
  }
catch (  NoSuchMethodException e) {
  }
catch (  IllegalArgumentException e) {
  }
catch (  InstantiationException e) {
  }
catch (  IllegalAccessException e) {
  }
catch (  InvocationTargetException e) {
  }
  return null;
}
 

Example 47

From project android_packages_apps_Gallery2, under directory /gallerycommon/src/com/android/gallery3d/common/.

Source file: HttpClientFactory.java

  29 
vote

/** 
 * Creates an HttpClient with the specified userAgent string.
 * @param userAgent the userAgent string
 * @return the client
 */
public static HttpClient newHttpClient(String userAgent){
  try {
    Class<?> clazz=Class.forName("android.net.http.AndroidHttpClient");
    Method newInstance=clazz.getMethod("newInstance",String.class);
    Object instance=newInstance.invoke(null,userAgent);
    HttpClient client=(HttpClient)instance;
    HttpParams params=client.getParams();
    params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,HttpVersion.HTTP_1_1);
    ConnManagerParams.setTimeout(params,60 * 1000);
    return client;
  }
 catch (  InvocationTargetException e) {
    throw new RuntimeException(e);
  }
catch (  ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
catch (  NoSuchMethodException e) {
    throw new RuntimeException(e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}
 

Example 48

From project android_packages_apps_TouchWiz30Launcher, under directory /src/com/sec/android/app/twlauncher/.

Source file: SamsungAppWidgetInfo.java

  29 
vote

public void fireOnPause(Context context){
  Class class1;
  class1=null;
  break MISSING_BLOCK_LABEL_2;
  while (true) {
    do     return;
 while (state != 1 || context == null || !(context instanceof ActivityGroup) || widgetId == -1);
    Activity activity=((ActivityGroup)context).getLocalActivityManager().getActivity(Integer.toString(widgetId));
    if (activity != null) {
      Class aclass[]=activity.getClass().getInterfaces();
      for (int i=0; i < aclass.length; i++)       if (aclass[i].toString().equals(com / sec / android/ touchwiz/ appwidget/ IWidgetObserver.toString()))       class1=aclass[i];
      if (class1 != null)       try {
        Method method=class1.getMethod("fireOnPause",null);
        if (method != null) {
          state=2;
          method.invoke(activity,null);
        }
      }
 catch (      SecurityException securityexception) {
        securityexception.printStackTrace();
      }
catch (      NoSuchMethodException nosuchmethodexception) {
        nosuchmethodexception.printStackTrace();
      }
catch (      IllegalArgumentException illegalargumentexception) {
        illegalargumentexception.printStackTrace();
      }
catch (      IllegalAccessException illegalaccessexception) {
        illegalaccessexception.printStackTrace();
      }
catch (      InvocationTargetException invocationtargetexception) {
        invocationtargetexception.printStackTrace();
      }
    }
  }
}
 

Example 49

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/compat/.

Source file: SharedPreferencesCompat.java

  29 
vote

public static void apply(SharedPreferences.Editor editor){
  if (sApplyMethod != null) {
    try {
      sApplyMethod.invoke(editor);
      return;
    }
 catch (    InvocationTargetException unused) {
    }
catch (    IllegalAccessException unused) {
    }
  }
  editor.commit();
}
 

Example 50

From project ANNIS, under directory /annis-service/src/main/java/annis/.

Source file: AnnisBaseRunner.java

  29 
vote

protected void runCommand(String command,String args){
  String methodName="do" + command.substring(0,1).toUpperCase() + command.substring(1);
  log.debug("looking for: " + methodName);
  try {
    long start=new Date().getTime();
    Method commandMethod=getClass().getMethod(methodName,String.class);
    commandMethod.invoke(this,args);
    System.out.println("Time: " + (new Date().getTime() - start) + " ms");
    if (history != null) {
      history.flush();
    }
  }
 catch (  InvocationTargetException e) {
    Throwable cause=e.getCause();
    try {
      throw cause;
    }
 catch (    AnnisQLSyntaxException ee) {
      error(ee.getMessage());
    }
catch (    Throwable ee) {
      log.error("Uncaught exception: ",ee);
      error("Uncaught Exception: " + ee.getMessage());
    }
  }
catch (  IllegalAccessException e) {
    log.error("BUG: IllegalAccessException should never be thrown",e);
    throw new AnnisRunnerException("BUG: can't access method: " + methodName,e);
  }
catch (  SecurityException e) {
    log.error("BUG: SecurityException should never be thrown",e);
    error(e);
  }
catch (  NoSuchMethodException e) {
    throw new UsageException("don't know how to do: " + command);
  }
catch (  IOException e) {
    log.error("IOException was thrown",e);
  }
}
 

Example 51

From project apb, under directory /modules/apb/src/apb/processors/.

Source file: ExcludeDoclet.java

  29 
vote

public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  if (args != null) {
    String methodName=method.getName();
    if ("compareTo".equals(methodName) || "equals".equals(methodName) || "overrides".equals(methodName)|| "subclassOf".equals(methodName)) {
      args[0]=unwrap(args[0]);
    }
  }
  try {
    return process(method.invoke(target,args),method.getReturnType());
  }
 catch (  InvocationTargetException e) {
    throw e.getTargetException();
  }
}
 

Example 52

From project appdriver, under directory /android/src/com/google/android/testing/nativedriver/server/.

Source file: RootSearchScope.java

  29 
vote

protected View[] getTopLevelViews(){
  try {
    Class<?> wmClass=getWindowManagerImplClass();
    Object wm=wmClass.getDeclaredMethod("getDefault").invoke(null);
    Field views=wmClass.getDeclaredField("mViews");
    views.setAccessible(true);
synchronized (wm) {
      return ((View[])views.get(wm)).clone();
    }
  }
 catch (  ClassNotFoundException exception) {
    throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception);
  }
catch (  NoSuchMethodException exception) {
    throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception);
  }
catch (  NoSuchFieldException exception) {
    throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception);
  }
catch (  IllegalArgumentException exception) {
    throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception);
  }
catch (  InvocationTargetException exception) {
    throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception);
  }
catch (  SecurityException exception) {
    throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception);
  }
catch (  IllegalAccessException exception) {
    throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception);
  }
}
 

Example 53

From project appengine-java-mapreduce, under directory /java/src/com/google/appengine/tools/mapreduce/impl/handlers/.

Source file: MapperContextImpl.java

  29 
vote

@Override public <T extends Pool>T getPool(PoolKey<T> key){
  @SuppressWarnings("unchecked") T pool=(T)pools.get(key);
  if (pool == null) {
    Class<? extends T> implClass=key.implClass;
    try {
      pool=implClass.getConstructor().newInstance();
    }
 catch (    InstantiationException e) {
      throw new RuntimeException("Can't instantiate pool " + implClass,e);
    }
catch (    IllegalAccessException e) {
      throw new RuntimeException("Can't instantiate pool " + implClass,e);
    }
catch (    InvocationTargetException e) {
      throw new RuntimeException("Can't instantiate pool " + implClass,e);
    }
catch (    NoSuchMethodException e) {
      throw new RuntimeException("Can't instantiate pool " + implClass,e);
    }
    pools.put(key,pool);
  }
  return pool;
}
 

Example 54

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/util/.

Source file: ReflectionUtils.java

  29 
vote

public static Object tryInvoke(Object target,String methodName,Class<?>[] argTypes,Object... args){
  try {
    return target.getClass().getMethod(methodName,argTypes).invoke(target,args);
  }
 catch (  NoSuchMethodException e) {
  }
catch (  IllegalAccessException e) {
  }
catch (  InvocationTargetException e) {
  }
  return null;
}
 

Example 55

From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/factories/.

Source file: ElementFactory.java

  29 
vote

/** 
 * @param elementId Element's id
 * @param args The arguments (in the correct order) to create the element (the constructor with those arguments in this order MUST exist).
 * @return The element created
 * @throws ElementCreationException Thrown if there is some problem during the method invoke
 */
public Element createElement(String elementId,Object... args) throws ElementCreationException {
  ElementEPLoader loader=new ElementEPLoader();
  Element element=null;
  Class<? extends Element> elementClass=loader.getElementClass(elementId);
  if (elementClass != null) {
    try {
      Constructor<? extends Element> constructor=getMatchableConstructor(elementClass,args);
      element=constructor.newInstance(args);
    }
 catch (    IllegalArgumentException e) {
      throw new ElementCreationException(Messages.bind(Messages.ElementFactory_WrongNumberArguments,elementId),e);
    }
catch (    NoSuchMethodException e) {
      throw new ElementCreationException(Messages.bind(Messages.ElementFactory_WrongArgument,elementId),e);
    }
catch (    InstantiationException e) {
      throw new ElementCreationException(Messages.bind(Messages.ElementFactory_NonBuildableObject,elementId),e);
    }
catch (    SecurityException e) {
      throw new ElementCreationException(Messages.bind(Messages.ElementFactory_MissingPlugins,elementId),e);
    }
catch (    IllegalAccessException e) {
      throw new ElementCreationException(Messages.bind(Messages.ElementFactory_MissingPlugins,elementId),e);
    }
catch (    InvocationTargetException e) {
      throw new ElementCreationException(Messages.bind(Messages.ElementFactory_InvalidConstructor,elementId),e);
    }
  }
  return element;
}
 

Example 56

From project ardverk-dht, under directory /components/core/src/main/java/org/ardverk/dht/codec/bencode/.

Source file: MessageInputStream.java

  29 
vote

private static <T extends Enum<T>>T readEnum(Class<T> clazz,String method,Class<?> type,Object value) throws IOException {
  try {
    Method m=clazz.getMethod(method,type);
    return clazz.cast(m.invoke(null,value));
  }
 catch (  NoSuchMethodException|SecurityException|IllegalAccessException|IllegalArgumentException|InvocationTargetException e) {
    throw new IOException(e.getClass().getSimpleName(),e);
  }
}
 

Example 57

From project Arecibo, under directory /alert-data-support/src/main/java/com/ning/arecibo/alert/confdata/dao/.

Source file: ConfDataDAO.java

  29 
vote

private <T extends ConfDataObject>Integer performDAOOperation(final String bashMethodName,final T data) throws ConfDataDAOException {
  try {
    final String[] classTokenized=data.getClass().getName().split("\\.");
    final Method method=dao.getClass().getMethod(bashMethodName + classTokenized[classTokenized.length - 1],data.getClass());
    return (Integer)method.invoke(dao,data);
  }
 catch (  RuntimeException e) {
    log.warn(e);
    throw new ConfDataDAOException("Problem inserting data:",e);
  }
catch (  NoSuchMethodException e) {
    log.warn(e);
    throw new ConfDataDAOException("Problem inserting data:",e);
  }
catch (  InvocationTargetException e) {
    log.warn(e);
    throw new ConfDataDAOException("Problem inserting data:",e);
  }
catch (  IllegalAccessException e) {
    log.warn(e);
    throw new ConfDataDAOException("Problem inserting data:",e);
  }
}
 

Example 58

From project arkadiko, under directory /src/com/liferay/arkadiko/.

Source file: AKServiceTrackerInvocationHandler.java

  29 
vote

/** 
 * Invoke.
 * @param proxy the proxy
 * @param method the method
 * @param arguments the arguments
 * @return the object
 * @throws Throwable the throwable
 */
public Object invoke(Object proxy,Method method,Object[] arguments) throws Throwable {
  if (_currentService == null) {
    Class<?> returnType=method.getReturnType();
    if (returnType.equals(Void.TYPE)) {
      _methodQueue.push(new MethodInvocation(method,arguments));
      return null;
    }
    throw new IllegalStateException("called too early!");
  }
  try {
    return method.invoke(_currentService,arguments);
  }
 catch (  InvocationTargetException ite) {
    throw ite.getCause();
  }
catch (  Exception e) {
    throw e;
  }
}
 

Example 59

From project arquillian-container-gae, under directory /gae-embedded/src/main/java/org/jboss/arquillian/container/appengine/embedded/hack/.

Source file: DevAppServerFactoryHack.java

  29 
vote

private static DevAppServer createDevAppServer(Object[] ctorArgs){
  ClassLoader loader=DevAppServerClassLoaderExposed.newClassLoader(DevAppServerFactory.class.getClassLoader());
  DevAppServer devAppServer;
  try {
    Class<?> devAppServerClass=Class.forName("com.google.appengine.tools.development.DevAppServerImpl",true,loader);
    Constructor<?> cons=devAppServerClass.getConstructor(DEV_APPSERVER_CTOR_ARG_TYPES);
    cons.setAccessible(true);
    devAppServer=(DevAppServer)cons.newInstance(ctorArgs);
  }
 catch (  Exception e) {
    Throwable t=e;
    if (e instanceof InvocationTargetException) {
      t=e.getCause();
    }
    throw new RuntimeException("Unable to create a DevAppServer",t);
  }
  System.setSecurityManager(new CustomSecurityManager(devAppServer));
  return devAppServer;
}
 

Example 60

From project arquillian-container-openshift, under directory /openshift-express/src/main/java/org/jboss/arquillian/container/openshift/express/.

Source file: ServletUtils.java

  29 
vote

@SuppressWarnings({"unchecked","rawtypes"}) private static String getServletName(Class<?> clazz){
  if (!isWebServletAnnotationOnClasspath()) {
    return applyArquillianHook(clazz.getSimpleName());
  }
  Class webServlet=forName(WEB_SERVLET_ANNOTATION_CLASS_NAME);
  if (clazz.isAnnotationPresent(webServlet)) {
    Object webServletAnnon=clazz.getAnnotation(webServlet);
    Method nameMethod=SecurityActions.getMethod(webServlet,"name");
    if (nameMethod != null) {
      String servletName=null;
      try {
        servletName=(String)nameMethod.invoke(webServletAnnon);
      }
 catch (      IllegalArgumentException e) {
      }
catch (      IllegalAccessException e) {
      }
catch (      InvocationTargetException e) {
      }
      if (servletName != null && servletName.length() != 0) {
        return servletName;
      }
    }
  }
  return applyArquillianHook(clazz.getSimpleName());
}
 

Example 61

From project arquillian-container-weld, under directory /weld-ee-embedded-1.1/src/main/java/org/jboss/arquillian/container/weld/ee/embedded_1_1/mock/.

Source file: ServiceLoader.java

  29 
vote

private S prepareInstance(Class<? extends S> serviceClass){
  try {
    Constructor<? extends S> constructor=serviceClass.getDeclaredConstructor();
    constructor.setAccessible(true);
    return constructor.newInstance();
  }
 catch (  NoClassDefFoundError e) {
    log.log(WARNING,"Could not instantiate service class " + serviceClass.getName(),e);
    return null;
  }
catch (  InvocationTargetException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e.getCause());
  }
catch (  IllegalArgumentException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  InstantiationException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  SecurityException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  NoSuchMethodException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
}
 

Example 62

From project arquillian-core, under directory /container/test-spi/src/main/java/org/jboss/arquillian/container/test/spi/util/.

Source file: ServiceLoader.java

  29 
vote

public S createInstance(String line) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, NoClassDefFoundError, InstantiationException, IllegalAccessException {
  try {
    Class<?> clazz=loader.loadClass(line);
    Class<? extends S> serviceClass;
    try {
      serviceClass=clazz.asSubclass(expectedType);
    }
 catch (    ClassCastException e) {
      throw new IllegalStateException("Service " + line + " does not implement expected type "+ expectedType.getName());
    }
    Constructor<? extends S> constructor=serviceClass.getConstructor();
    if (!constructor.isAccessible()) {
      constructor.setAccessible(true);
    }
    return constructor.newInstance();
  }
 catch (  NoClassDefFoundError e) {
    throw e;
  }
catch (  InstantiationException e) {
    throw e;
  }
catch (  IllegalAccessException e) {
    throw e;
  }
}
 

Example 63

From project arquillian-extension-drone, under directory /drone-webdriver/src/main/java/org/jboss/arquillian/drone/webdriver/factory/.

Source file: SecurityActions.java

  29 
vote

/** 
 * Create a new instance by finding a constructor that matches the argumentTypes signature using the arguments for instantiation.
 * @param className Full classname of class to create
 * @param argumentTypes The constructor argument types
 * @param arguments The constructor arguments
 * @return a new instance
 * @throws IllegalArgumentException if className, argumentTypes, or arguments are null
 * @throws RuntimeException if any exceptions during creation
 * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
 * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
 */
static <T>T newInstance(final String className,final Class<?>[] argumentTypes,final Object[] arguments,final Class<T> expectedType){
  if (className == null) {
    throw new IllegalArgumentException("ClassName must be specified");
  }
  if (argumentTypes == null) {
    throw new IllegalArgumentException("ArgumentTypes must be specified. Use empty array if no arguments");
  }
  if (arguments == null) {
    throw new IllegalArgumentException("Arguments must be specified. Use empty array if no arguments");
  }
  final Object obj;
  try {
    final Class<?> implClass=getClass(className);
    Constructor<?> constructor=getConstructor(implClass,argumentTypes);
    obj=constructor.newInstance(arguments);
  }
 catch (  NoSuchMethodException e) {
    throw new IllegalStateException("Unable to find a constructor for implementation class " + getConstructorName(className,argumentTypes) + ". Please make sure that you haven't misconfigured Arquillian Drone, "+ "e.g. you set an implementationClass which does not match the field/parameter type in your code.");
  }
catch (  IllegalArgumentException e) {
    throw new IllegalStateException("Unable to instantiate a " + className + ". Please make sure that you haven't misconfigured Arquillian Drone, "+ "e.g. you set an implementationClass which does not match the field/parameter type in your code.",e);
  }
catch (  InstantiationException e) {
    throw new IllegalStateException("Unable to instantiate a " + className + ". Please make sure that you haven't misconfigured Arquillian Drone, "+ "e.g. you set an implementationClass which does not match the field/parameter type in your code.",e);
  }
catch (  IllegalAccessException e) {
    throw new IllegalStateException("Unable to instantiate a " + className + " instance, access refused by SecurityManager.",e);
  }
catch (  InvocationTargetException e) {
    throw new RuntimeException("Unable to instantiate Drone via " + getConstructorName(className,argumentTypes),e.getCause());
  }
  try {
    return expectedType.cast(obj);
  }
 catch (  final ClassCastException cce) {
    throw new ClassCastException("Unable to instantiate " + expectedType.getName() + " instance. Constructed object was type of "+ obj.getClass().getName()+ ", which is not compatible. Please make sure you haven't misconfigured Arquillian Drone.");
  }
}
 

Example 64

From project arquillian-extension-spring, under directory /arquillian-service-integration-spring-inject/src/main/java/org/jboss/arquillian/spring/integration/inject/container/.

Source file: XmlRemoteApplicationContextProducer.java

  29 
vote

/** 
 * <p>Creates new instance of  {@link org.springframework.context.ApplicationContext}.</p>
 * @param applicationContextClass the class of application context
 * @param locations               the locations from which load the configuration files
 * @return the created {@link org.springframework.context.ApplicationContext} instance
 */
private <T extends ApplicationContext>ApplicationContext createInstance(Class<T> applicationContextClass,String[] locations){
  try {
    Constructor<T> ctor=applicationContextClass.getConstructor(String[].class);
    return ctor.newInstance((Object)locations);
  }
 catch (  NoSuchMethodException e) {
    throw new RuntimeException("Could not create instance of " + applicationContextClass.getName() + ", no appropriate constructor found.",e);
  }
catch (  InvocationTargetException e) {
    throw new RuntimeException("Could not create instance of " + applicationContextClass.getName(),e);
  }
catch (  InstantiationException e) {
    throw new RuntimeException("Could not create instance of " + applicationContextClass.getName(),e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException("Could not create instance of " + applicationContextClass.getName(),e);
  }
}
 

Example 65

From project arquillian-extension-warp, under directory /impl/src/main/java/org/jboss/arquillian/warp/impl/server/test/.

Source file: LifecycleTestDriver.java

  29 
vote

@Override public void invoke(Object... parameters) throws Throwable {
  try {
    method.invoke(instance,parameters);
  }
 catch (  InvocationTargetException e) {
    throw e.getCause();
  }
}
 

Example 66

From project arquillian-rusheye, under directory /rusheye-impl/src/main/java/org/jboss/rusheye/parser/.

Source file: ConfigurationCompiler.java

  29 
vote

Object evaluate(Method thisMethod,Object[] args) throws Throwable {
  for (  Configuration configuration : customConfigurations) {
    Perception perception=configuration.getPerception();
    if (perception != null) {
      Object result;
      try {
        result=thisMethod.invoke(perception,args);
      }
 catch (      InvocationTargetException e) {
        throw e.getTargetException();
      }
      if (result != null) {
        return result;
      }
    }
  }
  return null;
}
 

Example 67

From project arquillian-weld-embedded-1.1, under directory /src/main/java/org/jboss/arquillian/container/weld/ee/embedded_1_1/mock/.

Source file: ServiceLoader.java

  29 
vote

private S prepareInstance(Class<? extends S> serviceClass){
  try {
    Constructor<? extends S> constructor=serviceClass.getDeclaredConstructor();
    constructor.setAccessible(true);
    return constructor.newInstance();
  }
 catch (  NoClassDefFoundError e) {
    log.log(WARNING,"Could not instantiate service class " + serviceClass.getName(),e);
    return null;
  }
catch (  InvocationTargetException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e.getCause());
  }
catch (  IllegalArgumentException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  InstantiationException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  SecurityException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  NoSuchMethodException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
}
 

Example 68

From project arquillian_deprecated, under directory /containers/weld-ee-embedded-1.1/src/main/java/org/jboss/arquillian/container/weld/ee/embedded_1_1/mock/.

Source file: ServiceLoader.java

  29 
vote

private S prepareInstance(Class<? extends S> serviceClass){
  try {
    Constructor<? extends S> constructor=serviceClass.getDeclaredConstructor();
    constructor.setAccessible(true);
    return constructor.newInstance();
  }
 catch (  NoClassDefFoundError e) {
    log.log(WARNING,"Could not instantiate service class " + serviceClass.getName(),e);
    return null;
  }
catch (  InvocationTargetException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e.getCause());
  }
catch (  IllegalArgumentException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  InstantiationException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  SecurityException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
catch (  NoSuchMethodException e) {
    throw new RuntimeException("Error instantiating " + serviceClass,e);
  }
}
 

Example 69

From project artifactory-plugin, under directory /src/main/java/org/jfrog/hudson/util/.

Source file: IssuesTrackerHelper.java

  29 
vote

private Set<String> manuallyCollectIssues(AbstractBuild build,Pattern issuePattern) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
  Class<?> jiraUpdaterClass=Class.forName("hudson.plugins.jira.Updater");
  Method findIssueIdsRecursive=jiraUpdaterClass.getDeclaredMethod("findIssueIdsRecursive",AbstractBuild.class,Pattern.class,BuildListener.class);
  findIssueIdsRecursive.setAccessible(true);
  return (Set<String>)findIssueIdsRecursive.invoke(null,build,issuePattern,new StreamBuildListener(new NullOutputStream()));
}
 

Example 70

From project artimate, under directory /artimate-demo/src/main/java/com/jdotsoft/jarloader/.

Source file: JarClassLoader.java

  29 
vote

/** 
 * Invokes main() method on class with provided parameters.
 * @param sClass class name in form "MyClass" for default packageor "com.abc.MyClass" for class in some package
 * @param args arguments for the main() method or null.
 * @throws Throwable wrapper for many exceptions thrown while<p>(1) main() method lookup: ClassNotFoundException, SecurityException, NoSuchMethodException <p>(2) main() method launch: IllegalArgumentException, IllegalAccessException (disabled) <p>(3) Actual cause of InvocationTargetException See {@link http://java.sun.com/developer/Books/javaprogramming/JAR/api/jarclassloader.html}and {@link http://java.sun.com/developer/Books/javaprogramming/JAR/api/example-1dot2/JarClassLoader.java}
 */
public void invokeMain(String sClass,String[] args) throws Throwable {
  Class<?> clazz=loadClass(sClass);
  logInfo(LogArea.CONFIG,"Launch: %s.main(); Loader: %s",sClass,clazz.getClassLoader());
  Method method=clazz.getMethod("main",new Class<?>[]{String[].class});
  boolean bValidModifiers=false;
  boolean bValidVoid=false;
  if (method != null) {
    method.setAccessible(true);
    int nModifiers=method.getModifiers();
    bValidModifiers=Modifier.isPublic(nModifiers) && Modifier.isStatic(nModifiers);
    Class<?> clazzRet=method.getReturnType();
    bValidVoid=(clazzRet == void.class);
  }
  if (method == null || !bValidModifiers || !bValidVoid) {
    throw new NoSuchMethodException("The main() method in class \"" + sClass + "\" not found.");
  }
  try {
    method.invoke(null,(Object)args);
  }
 catch (  InvocationTargetException e) {
    throw e.getTargetException();
  }
}
 

Example 71

From project as3-commons-jasblocks, under directory /src/test/java/org/as3commons/asblocks/impl/.

Source file: TestAS3FragmentParser.java

  29 
vote

private static void assertParseMethodFailsFor(String methodName,String input) throws Exception {
  Method meth=AS3FragmentParser.class.getMethod(methodName,new Class[]{String.class});
  try {
    meth.invoke(null,new Object[]{input});
    fail(methodName + "(\"" + input+ "\") should fail");
  }
 catch (  InvocationTargetException e) {
  }
}
 

Example 72

From project AsmackService, under directory /src/com/googlecode/asmack/connection/impl/.

Source file: ZLibOutputStream.java

  29 
vote

/** 
 * Flush the given stream, preferring Java7 FLUSH_SYNC if available.
 * @throws IOException In case of a lowlevel exception.
 */
@Override public void flush() throws IOException {
  if (!SUPPORTED) {
    super.flush();
    return;
  }
  int count=0;
  if (!def.needsInput()) {
    do {
      count=def.deflate(buf,0,buf.length);
      out.write(buf,0,count);
    }
 while (count > 0);
    out.flush();
  }
  try {
    do {
      count=(Integer)method.invoke(def,buf,0,buf.length,2);
      out.write(buf,0,count);
    }
 while (count > 0);
  }
 catch (  IllegalArgumentException e) {
    throw new IOException("Can't flush");
  }
catch (  IllegalAccessException e) {
    throw new IOException("Can't flush");
  }
catch (  InvocationTargetException e) {
    throw new IOException("Can't flush");
  }
  super.flush();
}
 

Example 73

From project asterisk-java, under directory /src/main/java/org/asteriskjava/util/.

Source file: ReflectionUtil.java

  29 
vote

/** 
 * Creates a new instance of the given class. The class is loaded using the current thread's context class loader and instantiated using its default constructor.
 * @param s fully qualified name of the class to instantiate.
 * @return the new instance or <code>null</code> on failure.
 */
public static Object newInstance(String s){
  final ClassLoader classLoader=Thread.currentThread().getContextClassLoader();
  try {
    Class<?> clazz=classLoader.loadClass(s);
    Constructor<?> constructor=clazz.getConstructor();
    return constructor.newInstance();
  }
 catch (  ClassNotFoundException e) {
    return null;
  }
catch (  IllegalAccessException e) {
    return null;
  }
catch (  InstantiationException e) {
    return null;
  }
catch (  NoSuchMethodException e) {
    return null;
  }
catch (  InvocationTargetException e) {
    return null;
  }
}
 

Example 74

From project atlas, under directory /src/main/java/com/ning/atlas/.

Source file: AtlasInstaller.java

  29 
vote

@SuppressWarnings("unchecked") @JsonAnyGetter public Map<?,?> getProperties() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
  Map<?,?> map=mapper.convertValue(host,Map.class);
  map.remove("children");
  map.putAll(attributes);
  return map;
}
 

Example 75

From project atlassian-rest-cli, under directory /rest-cli-runner/src/main/java/com/galeoconsulting/leonardinius/api/impl/.

Source file: ChainingClassLoader.java

  29 
vote

private Class<?> callFindClass(ClassLoader classloader,String name) throws ClassNotFoundException {
  try {
    return (Class<?>)MethodsHolder.findClassMethod.invoke(classloader,name);
  }
 catch (  IllegalAccessException e) {
    throw new AssertionError(e);
  }
catch (  InvocationTargetException e) {
    if (e.getTargetException() instanceof ClassNotFoundException) {
      throw (ClassNotFoundException)e.getTargetException();
    }
    throw new AssertionError(e);
  }
}
 

Example 76

From project AudioBox.fm-JavaLib, under directory /audiobox.fm-core/src/main/java/fm/audiobox/configurations/.

Source file: DefaultFactory.java

  29 
vote

@Override public IEntity getEntity(String tagName,IConfiguration configuration){
  IEntity entity=null;
  if (!this.containsEntity(tagName)) {
    log.warn("No IEntity found under key: " + tagName);
    return null;
  }
  Class<? extends IEntity> klass=getEntityByTag(tagName);
  try {
    Constructor<? extends IEntity> constructor=klass.getConstructor(IConfiguration.class);
    entity=constructor.newInstance(configuration);
  }
 catch (  SecurityException e) {
    log.error("SecurityException while instantiating IEntity under key: " + tagName,e);
  }
catch (  NoSuchMethodException e) {
    log.error("NoSuchMethodException while instantiating IEntity under key: " + tagName,e);
  }
catch (  IllegalArgumentException e) {
    log.error("IllegalArgumentException while instantiating IEntity under key: " + tagName,e);
  }
catch (  InstantiationException e) {
    log.error("InstantiationException while instantiating IEntity under key: " + tagName,e);
  }
catch (  IllegalAccessException e) {
    log.error("IllegalAccessException while instantiating IEntity under key: " + tagName,e);
  }
catch (  InvocationTargetException e) {
    log.error("InvocationTargetException while instantiating IEntity under key: " + tagName,e);
  }
  return entity;
}
 

Example 77

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/corecomponents/.

Source file: DataResultViewerTable.java

  29 
vote

private static Object[][] getRowValues(Node node,int rows){
  int maxRows=Math.min(rows,node.getChildren().getNodesCount());
  Object[][] objs=new Object[maxRows][];
  for (int i=0; i < maxRows; i++) {
    PropertySet[] props=node.getChildren().getNodeAt(i).getPropertySets();
    if (props.length == 0)     continue;
    Property[] property=props[0].getProperties();
    objs[i]=new Object[property.length];
    for (int j=0; j < property.length; j++) {
      try {
        objs[i][j]=property[j].getValue();
      }
 catch (      IllegalAccessException ignore) {
        objs[i][j]="n/a";
      }
catch (      InvocationTargetException ignore) {
        objs[i][j]="n/a";
      }
    }
  }
  return objs;
}
 

Example 78

From project avro, under directory /lang/java/avro/src/main/java/org/apache/avro/reflect/.

Source file: ReflectDatumReader.java

  29 
vote

private Object readString(Decoder in,Class c) throws IOException {
  String value=(String)readString(null,in);
  if (c != null)   try {
    return c.getConstructor(String.class).newInstance(value);
  }
 catch (  NoSuchMethodException e) {
    throw new AvroRuntimeException(e);
  }
catch (  InstantiationException e) {
    throw new AvroRuntimeException(e);
  }
catch (  IllegalAccessException e) {
    throw new AvroRuntimeException(e);
  }
catch (  InvocationTargetException e) {
    throw new AvroRuntimeException(e);
  }
  return value;
}
 

Example 79

From project aws-tasks, under directory /src/test/java/datameer/awstasks/testsupport/junit/.

Source file: CheckBeforeRunner.java

  29 
vote

private Exception execute(Object target,Method checkMethod){
  Exception exception=null;
  boolean reThrow=true;
  try {
    checkMethod.invoke(target);
  }
 catch (  IllegalArgumentException e) {
    exception=e;
  }
catch (  IllegalAccessException e) {
    exception=e;
  }
catch (  InvocationTargetException e) {
    exception=(Exception)e.getCause();
    reThrow=false;
  }
  if (exception != null && reThrow) {
    throw new RuntimeException(exception);
  }
  return exception;
}
 

Example 80

From project azkaban, under directory /azkaban-common/src/java/azkaban/common/utils/.

Source file: Utils.java

  29 
vote

/** 
 * Call the named method
 * @param obj The object to call the method on
 * @param c The class of the object
 * @param name The name of the method
 * @param args The method arguments
 * @return The result of the method
 */
public static Object callMethod(Object obj,Class<?> c,String name,Class<?>[] classes,Object[] args){
  try {
    Method m=getMethod(c,name,classes);
    return m.invoke(obj,args);
  }
 catch (  InvocationTargetException e) {
    throw getCause(e);
  }
catch (  IllegalAccessException e) {
    throw new IllegalStateException(e);
  }
}
 

Example 81

From project BDSup2Sub, under directory /src/main/java/bdsup2sub/gui/support/.

Source file: Progress.java

  29 
vote

public void setProgress(final int val){
  try {
    SwingUtilities.invokeAndWait(new Runnable(){
      @Override public void run(){
        jProgressBar.setValue(val);
        jProgressBar.repaint();
      }
    }
);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
catch (  InvocationTargetException e) {
    e.printStackTrace();
  }
}
 

Example 82

From project BeeQueue, under directory /src/org/beequeue/proxy/.

Source file: MethodInterceptor.java

  29 
vote

public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  Object result=null;
  Throwable failure=null;
  beforeInvocation(method,args);
  try {
    result=onInvoke(method,args);
    return result;
  }
 catch (  InvocationTargetException e) {
    failure=onFailure(method,args,e);
    throw failure;
  }
 finally {
    afterInvocation(method,args,result,failure);
  }
}
 

Example 83

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/wizards/.

Source file: NewProjectWizard.java

  29 
vote

/** 
 * {@inheritDoc}
 */
@Override protected void execute(final IProgressMonitor m) throws CoreException, InvocationTargetException, InterruptedException {
  try {
    createProject(m);
    status=Status.OK_STATUS;
  }
 catch (  CoreException ce) {
    status=ce.getStatus();
  }
}
 

Example 84

From project big-data-plugin, under directory /shims/hive-jdbc/test-src/org/apache/hadoop/hive/jdbc/.

Source file: HiveDriverTest.java

  29 
vote

@Test public void getActiveDriver_exception_in_getHiveJdbcDriver(){
  HadoopShim shim=new MockHadoopShim(){
    public java.sql.Driver getHiveJdbcDriver(){
      throw new RuntimeException();
    }
  }
;
  HiveDriver d=new HiveDriver(getMockUtil(shim));
  try {
    d.getActiveDriver();
    fail("Expected exception");
  }
 catch (  SQLException ex) {
    assertEquals(InvocationTargetException.class,ex.getCause().getClass());
    assertEquals("Unable to load Hive JDBC driver for the currently active Hadoop configuration",ex.getMessage());
  }
}
 

Example 85

From project Binaural-Beats, under directory /src/com/ihunda/android/binauralbeat/.

Source file: DefaultProgramsBuilder.java

  29 
vote

public static Program getProgram(ProgramMeta pm,Context context){
  try {
    return (Program)pm.getMethod().invoke(null,new Program(pm.getName()));
  }
 catch (  IllegalArgumentException e) {
    throw new RuntimeException(e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
catch (  InvocationTargetException e) {
    throw new RuntimeException(e);
  }
}
 

Example 86

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/lib/opencsv-2.1/src/au/com/bytecode/opencsv/bean/.

Source file: CsvToBean.java

  29 
vote

protected T processLine(MappingStrategy<T> mapper,String[] line) throws IllegalAccessException, InvocationTargetException, InstantiationException, IntrospectionException {
  T bean=mapper.createBean();
  for (int col=0; col < line.length; col++) {
    String value=line[col];
    PropertyDescriptor prop=mapper.findDescriptor(col);
    if (null != prop) {
      Object obj=convertValue(value,prop);
      prop.getWriteMethod().invoke(bean,obj);
    }
  }
  return bean;
}
 

Example 87

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/editor/.

Source file: SenecaJobEditor.java

  29 
vote

private void saveSDFile(List<IMolecule> mols,String jobTitle) throws BioclipseException, InvocationTargetException {
  IStructuredSelection virtualselection=new StructuredSelection(net.bioclipse.core.Activator.getVirtualProject());
  String filename=WizardHelper.findUnusedFileName(virtualselection,"Seneca_" + jobTitle,".sdf");
  final IFile sdfile=net.bioclipse.core.Activator.getVirtualProject().getFile(filename);
  net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager().saveSDFile(sdfile,mols,new BioclipseUIJob<Void>(){
    @Override public void runInUI(){
      net.bioclipse.ui.business.Activator.getDefault().getUIManager().open(sdfile);
    }
  }
);
}
 

Example 88

From project BioMAV, under directory /Behavior/src/nl/ru/ai/projects/parrot/biomav/editor/.

Source file: BehaviorVertex.java

  29 
vote

@SuppressWarnings({"rawtypes","unchecked"}) public State initState(BehaviorArray behaviors){
  Class stateClass=FSM_STATES.get(selectedBehaviorState);
  try {
    Constructor c=stateClass.getConstructor(BehaviorArray.class);
    State result=(State)c.newInstance(behaviors);
    result.addStateListener(this);
    return result;
  }
 catch (  NoSuchMethodException e) {
    e.printStackTrace();
  }
catch (  SecurityException e) {
    e.printStackTrace();
  }
catch (  InstantiationException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
catch (  IllegalArgumentException e) {
    e.printStackTrace();
  }
catch (  InvocationTargetException e) {
    e.printStackTrace();
  }
  return null;
}
 

Example 89

From project blacktie, under directory /jatmibroker-xatmi/src/main/java/org/jboss/narayana/blacktie/jatmibroker/xatmi/impl/.

Source file: ConnectionImpl.java

  29 
vote

/** 
 * Allocate a new buffer
 * @param type The type of the buffer
 * @param subtype The subtype of the buffer
 * @return The new buffer
 * @throws ConnectionException If the buffer was unknown or invalid.
 * @throws ConfigurationException
 */
public Buffer tpalloc(String type,String subtype) throws ConnectionException, ConfigurationException {
  if (type == null) {
    throw new ConnectionException(ConnectionImpl.TPEINVAL,"No type provided");
  }
 else {
    log.debug("Initializing a new: " + type);
    try {
      Class clazz=Class.forName(getClass().getPackage().getName() + "." + type+ "_Impl");
      Constructor ctor=clazz.getConstructor(String.class);
      return (Buffer)ctor.newInstance(subtype);
    }
 catch (    InvocationTargetException t) {
      if (t.getCause() instanceof ConfigurationException) {
        throw ((ConfigurationException)t.getCause());
      }
      throw new ConnectionException(ConnectionImpl.TPENOENT,"Type was not known: " + type,t);
    }
catch (    Throwable t) {
      throw new ConnectionException(ConnectionImpl.TPENOENT,"Type was not known: " + type,t);
    }
  }
}