Java Code Examples for java.lang.reflect.Method

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 agile, under directory /agile-apps/agile-app-search/src/main/java/org/headsupdev/agile/app/search/.

Source file: Search.java

  21 
vote

private Project getProjectFromResult(Object[] result){
  if (result[1] instanceof Project) {
    return (Project)result[1];
  }
 else {
    try {
      Method getProject=result[1].getClass().getMethod("getProject");
      return (Project)getProject.invoke(result[1]);
    }
 catch (    Exception e) {
      return StoredProject.getDefault();
    }
  }
}
 

Example 2

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/widget/.

Source file: SearchView.java

  19 
vote

private void forceSuggestionQuery(){
  try {
    Method before=SearchAutoComplete.class.getMethod("doBeforeTextChanged");
    Method after=SearchAutoComplete.class.getMethod("doAfterTextChanged");
    before.setAccessible(true);
    after.setAccessible(true);
    before.invoke(mQueryTextView);
    after.invoke(mQueryTextView);
  }
 catch (  Exception e) {
  }
}
 

Example 3

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

Source file: ConfigurationMetadata.java

  19 
vote

/** 
 * Find methods that are tagged with a given annotation somewhere in the hierarchy
 * @param configClass the class to analyze
 * @return a map that associates a concrete method to the actual method tagged(which may belong to a different class in class hierarchy)
 */
private static Collection<Method> findAnnotatedMethods(Class<?> configClass,Class<? extends java.lang.annotation.Annotation> annotation){
  List<Method> result=new ArrayList<Method>();
  for (  Method method : configClass.getMethods()) {
    if (method.isSynthetic() || method.isBridge() || Modifier.isStatic(method.getModifiers())) {
      continue;
    }
    Method managedMethod=findAnnotatedMethod(configClass,annotation,method.getName(),method.getParameterTypes());
    if (managedMethod != null) {
      result.add(managedMethod);
    }
  }
  return result;
}
 

Example 4

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

Source file: AirTunesCrytography.java

  19 
vote

/** 
 * Sets the padding of a  {@link javax.crypto.CipherSpi} instance.Like  {@link #getCipher(String)}, we're accessing a private API here, so me must work around the access restrictions
 * @param cipherSpi the {@link javax.crypto.CipherSpi} instance
 * @param padding the padding to set
 * @throws Throwable if {@link javax.crypto.CipherSpi#engineSetPadding} throws
 */
private static void cipherSpiSetPadding(final CipherSpi cipherSpi,final String padding) throws Throwable {
  final Method engineSetPadding=getMethod(cipherSpi.getClass(),"engineSetPadding",String.class);
  engineSetPadding.setAccessible(true);
  try {
    engineSetPadding.invoke(cipherSpi,padding);
  }
 catch (  final InvocationTargetException e) {
    throw e.getCause();
  }
}
 

Example 5

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

Source file: ActiveJdbcInstrumentationPlugin.java

  18 
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 6

From project activemq-apollo, under directory /apollo-util/src/main/scala/org/apache/activemq/apollo/util/.

Source file: IntrospectionSupport.java

  18 
vote

public static Class<?> getPropertyType(Object target,String name){
  Class<?> clazz=target.getClass();
  Method setter=findSetterMethod(clazz,name);
  if (setter == null) {
    return null;
  }
  return setter.getParameterTypes()[0];
}
 

Example 7

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

Source file: DataBrowser.java

  18 
vote

DataBrowser(RemoteConnection remote) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException {
  Class<?> jmxTarget=Class.forName("org.neo4j.remote.transports.JmxTarget");
  Method connect=jmxTarget.getMethod("connectGraphDatabase",RemoteConnection.class);
  try {
    this.graphDb=(GraphDatabaseService)connect.invoke(null,remote);
  }
 catch (  InvocationTargetException e) {
    throw launderRuntimeException(e.getTargetException());
  }
}
 

Example 8

From project aerogear-controller, under directory /src/main/java/org/jboss/aerogear/controller/router/.

Source file: DefaultRouter.java

  18 
vote

private void invokeErrorRoute(final Route errorRoute,final Throwable t) throws ServletException {
  try {
    final Method targetMethod=errorRoute.getTargetMethod();
    if (targetMethod.getParameterTypes().length == 0) {
      targetMethod.invoke(getController(errorRoute));
    }
 else {
      targetMethod.invoke(getController(errorRoute),t);
    }
  }
 catch (  final Exception e) {
    throw new ServletException(e.getMessage(),e);
  }
}
 

Example 9

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

Source file: PeriodicSyncTest.java

  18 
vote

@SmallTest public void testPeriodicSyncMethodAvailable() throws Exception {
  Method m=AccountAuthenticatorService.methodContentResolver_addPeriodicSync;
  boolean expectPeriodicSyncAvailable=Build.VERSION.SDK_INT >= FROYO;
  Log.d(TAG,"Expect Periodic-Sync available : " + expectPeriodicSyncAvailable + " method="+ m);
  if (expectPeriodicSyncAvailable) {
    assertThat("Required period sync method",m,notNullValue());
    assertThat(m.getName(),is("addPeriodicSync"));
  }
 else {
    assertThat(m,nullValue());
  }
}
 

Example 10

From project agorava-core, under directory /agorava-core-impl/src/main/java/org/agorava/core/oauth/.

Source file: SimpleOAuthAppSettingsBuilder.java

  18 
vote

/** 
 * This reflection method tries to call a field setter in the builder from its name It's useful when settings are reading from a text source.
 * @param k     name of the param
 * @param value value to set in the param
 * @throws AgoravaException if the setter can't be found or invoked
 */
void invokeSetter(String k,String value){
  Method setter;
  Class<? extends OAuthAppSettingsBuilder> clazz=this.getClass();
  try {
    setter=clazz.getMethod(k,String.class);
    setter.invoke(this,value);
  }
 catch (  Exception e) {
    throw new AgoravaException("Unable to invoke setter for " + k + " in class "+ clazz,e);
  }
}
 

Example 11

From project AirCastingAndroidClient, under directory /src/main/java/ioio/lib/android/bluetooth/.

Source file: BluetoothIOIOConnection.java

  18 
vote

public static BluetoothSocket createSocket(final BluetoothDevice device) throws IOException {
  BluetoothSocket socket=null;
  try {
    Method m=device.getClass().getMethod("createRfcommSocket",int.class);
    socket=(BluetoothSocket)m.invoke(device,1);
  }
 catch (  NoSuchMethodException ignore) {
    socket=device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
  }
catch (  Exception ignore) {
  }
  return socket;
}
 

Example 12

From project akubra, under directory /akubra-fs/src/test/java/org/akubraproject/fs/.

Source file: TestFSBlobThreaded.java

  18 
vote

private static CodePosition getDirExistsCodePosition() throws Exception {
  ClassInstrumentation instr=Instrumentation.getClassInstrumentation(FSBlob.class);
  Method makeParentDirs=FSBlob.class.getDeclaredMethod("makeParentDirs",File.class);
  Method exists=File.class.getDeclaredMethod("exists");
  CodePosition position=instr.afterCall(makeParentDirs,exists);
  return position;
}
 

Example 13

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

Source file: PureJavaReflectionProvider.java

  18 
vote

public void invokeMethod(Object object,String methodName,Object value,Class definedIn){
  try {
    Method method=object.getClass().getMethod(methodName,new Class[]{value.getClass()});
    method.invoke(object,new Object[]{value});
  }
 catch (  Exception e) {
    throw new ObjectAccessException("Could not invoke " + object.getClass() + "."+ methodName,e);
  }
}
 

Example 14

From project android-bankdroid, under directory /src/com/liato/bankdroid/.

Source file: Helpers.java

  18 
vote

static public void setActivityAnimation(Activity activity,int in,int out){
  try {
    Method method=Activity.class.getMethod("overridePendingTransition",new Class[]{int.class,int.class});
    method.invoke(activity,in,out);
  }
 catch (  Exception e) {
  }
}
 

Example 15

From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/twitter/extpack/winterwell/jtwitter/.

Source file: OAuthSignpostClient.java

  18 
vote

/** 
 * <p> <i>Convenience method for desktop apps only - does not work in Android</i> </p> Opens a popup dialog asking the user to enter the verification code. (you would then call  {@link #setAuthorizationCode(String)}). This is only relevant when using out-of-band instead of a callback-url. This is a convenience method -- you will probably want to build your own UI around this. <p> <i>This method requires Swing. It will not work on Android devices!</i>
 * @param question e.g. "Please enter the authorisation code from Twitter"
 * @return
 */
public static String askUser(String question){
  try {
    Class<?> JOptionPaneClass=Class.forName("javax.swing.JOptionPane");
    Method showInputDialog=JOptionPaneClass.getMethod("showInputDialog",Object.class);
    return (String)showInputDialog.invoke(null,question);
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
 

Example 16

From project AndroidCommon, under directory /src/com/asksven/android/common/privateapiproxies/.

Source file: BatteryStatsProxy.java

  18 
vote

/** 
 * Collect the UidStats using reflection and store them  
 */
@SuppressWarnings("unchecked") private void collectUidStats(){
  try {
    Method method=m_ClassDefinition.getMethod("getUidStats");
    m_uidStats=(SparseArray<? extends Object>)method.invoke(m_Instance);
  }
 catch (  IllegalArgumentException e) {
    Log.e("TAG","An exception occured in collectUidStats(). Message: " + e.getMessage() + ", cause: "+ e.getCause().getMessage());
    throw e;
  }
catch (  Exception e) {
    m_uidStats=null;
  }
}
 

Example 17

From project Android_1, under directory /org.eclipse.ecf.android/src/org/eclipse/ecf/android/.

Source file: SharedObjectMsg.java

  18 
vote

public static Method searchForMethod(Method meths[],String meth,Class args[]){
  for (int i=0; i < meths.length; i++) {
    Method test=meths[i];
    if (test.getName().equals(meth)) {
      if (test.getParameterTypes().length == args.length)       return test;
    }
  }
  return null;
}
 

Example 18

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

Source file: LegacyMatcherProvider.java

  18 
vote

@SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  Map<MethodSerializationWrapper,ArgumentsMatcher> map=(Map<MethodSerializationWrapper,ArgumentsMatcher>)stream.readObject();
  matchers=new HashMap<Method,ArgumentsMatcher>(map.size());
  for (  Map.Entry<MethodSerializationWrapper,ArgumentsMatcher> entry : map.entrySet()) {
    try {
      Method method=entry.getKey().getMethod();
      matchers.put(method,entry.getValue());
    }
 catch (    NoSuchMethodException e) {
      throw new IOException(e.toString());
    }
  }
}
 

Example 19

From project ant4eclipse, under directory /org.ant4eclipse.ant.jdt/src/org/ant4eclipse/ant/jdt/.

Source file: JdtCompilerTask.java

  18 
vote

/** 
 * {@inheritDoc}
 */
@Override public void execute() throws BuildException {
  super.setCompiler(EcjCompilerAdapter.class.getName());
  super.setIncludeantruntime(false);
  try {
    Method addAdapterMethod=getClass().getMethod("add",CompilerAdapter.class);
    addAdapterMethod.invoke(this,getOrCreateCompilerAdapter());
  }
 catch (  Exception ex) {
  }
  super.execute();
}
 

Example 20

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

Source file: PropertyValuesHolder.java

  17 
vote

/** 
 * Returns the setter or getter requested. This utility function checks whether the requested method exists in the propertyMapMap cache. If not, it calls another utility function to request the Method from the targetClass directly.
 * @param targetClass The Class on which the requested method should exist.
 * @param propertyMapMap The cache of setters/getters derived so far.
 * @param prefix "set" or "get", for the setter or getter.
 * @param valueType The type of parameter passed into the method (null for getter).
 * @return Method the method associated with mPropertyName.
 */
private Method setupSetterOrGetter(Class targetClass,HashMap<Class,HashMap<String,Method>> propertyMapMap,String prefix,Class valueType){
  Method setterOrGetter=null;
  try {
    mPropertyMapLock.writeLock().lock();
    HashMap<String,Method> propertyMap=propertyMapMap.get(targetClass);
    if (propertyMap != null) {
      setterOrGetter=propertyMap.get(mPropertyName);
    }
    if (setterOrGetter == null) {
      setterOrGetter=getPropertyFunction(targetClass,prefix,valueType);
      if (propertyMap == null) {
        propertyMap=new HashMap<String,Method>();
        propertyMapMap.put(targetClass,propertyMap);
      }
      propertyMap.put(mPropertyName,setterOrGetter);
    }
  }
  finally {
    mPropertyMapLock.writeLock().unlock();
  }
  return setterOrGetter;
}
 

Example 21

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

Source file: Webserver.java

  17 
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 22

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

Source file: PropertyValuesHolder.java

  17 
vote

/** 
 * Returns the setter or getter requested. This utility function checks whether the requested method exists in the propertyMapMap cache. If not, it calls another utility function to request the Method from the targetClass directly.
 * @param targetClass The Class on which the requested method should exist.
 * @param propertyMapMap The cache of setters/getters derived so far.
 * @param prefix "set" or "get", for the setter or getter.
 * @param valueType The type of parameter passed into the method (null for getter).
 * @return Method the method associated with mPropertyName.
 */
private Method setupSetterOrGetter(Class targetClass,HashMap<Class,HashMap<String,Method>> propertyMapMap,String prefix,Class valueType){
  Method setterOrGetter=null;
  try {
    mPropertyMapLock.writeLock().lock();
    HashMap<String,Method> propertyMap=propertyMapMap.get(targetClass);
    if (propertyMap != null) {
      setterOrGetter=propertyMap.get(mPropertyName);
    }
    if (setterOrGetter == null) {
      setterOrGetter=getPropertyFunction(targetClass,prefix,valueType);
      if (propertyMap == null) {
        propertyMap=new HashMap<String,Method>();
        propertyMapMap.put(targetClass,propertyMap);
      }
      propertyMap.put(mPropertyName,setterOrGetter);
    }
  }
  finally {
    mPropertyMapLock.writeLock().unlock();
  }
  return setterOrGetter;
}
 

Example 23

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

Source file: AntlibTypeInfo.java

  17 
vote

private static TaskMethods processTaskMethods(Class<? extends Task> taskClass){
  IntrospectionHelper helper=IntrospectionHelper.getHelper(taskClass);
  TaskMethods taskMethods=new TaskMethods(taskClass);
  for (Enumeration en=helper.getAttributes(); en.hasMoreElements(); ) {
    String attributeName=(String)en.nextElement();
    taskMethods.add(new TaskSetter(attributeName,helper.getAttributeType(attributeName)));
  }
  for (Enumeration en=helper.getNestedElements(); en.hasMoreElements(); ) {
    String elementName=(String)en.nextElement();
    Method elementMethod=helper.getElementMethod(elementName);
    if (elementMethod.getName().startsWith("add") && elementMethod.getParameterTypes().length == 1) {
      taskMethods.add(new TaskAdder(elementName,helper.getElementType(elementName)));
    }
 else {
      taskMethods.add(new TaskCreator(elementName,helper.getElementType(elementName)));
    }
  }
  for (  Object methodObj : helper.getExtensionPoints()) {
    Method method=(Method)methodObj;
    if (method.getName().equals("add") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == ResourceCollection.class) {
      taskMethods.add(new CustomTaskMethod(ResourceCollection.class,"resources",method));
      break;
    }
  }
  return taskMethods;
}
 

Example 24

From project aether-core, under directory /aether-connector-wagon/src/main/java/org/eclipse/aether/connector/wagon/.

Source file: WagonRepositoryConnector.java

  17 
vote

private void connectWagon(Wagon wagon) throws Exception {
  if (!headers.isEmpty()) {
    try {
      Method setHttpHeaders=wagon.getClass().getMethod("setHttpHeaders",Properties.class);
      setHttpHeaders.invoke(wagon,headers);
    }
 catch (    NoSuchMethodException e) {
    }
catch (    Exception e) {
      logger.debug("Could not set user agent for wagon " + wagon.getClass().getName() + ": "+ e);
    }
  }
  int connectTimeout=ConfigUtils.getInteger(session,ConfigurationProperties.DEFAULT_CONNECT_TIMEOUT,ConfigurationProperties.CONNECT_TIMEOUT);
  int requestTimeout=ConfigUtils.getInteger(session,ConfigurationProperties.DEFAULT_REQUEST_TIMEOUT,ConfigurationProperties.REQUEST_TIMEOUT);
  wagon.setTimeout(Math.max(Math.max(connectTimeout,requestTimeout),0));
  wagon.setInteractive(ConfigUtils.getBoolean(session,ConfigurationProperties.DEFAULT_INTERACTIVE,ConfigurationProperties.INTERACTIVE));
  Object configuration=ConfigUtils.getObject(session,null,PROP_CONFIG + "." + repository.getId());
  if (configuration != null && wagonConfigurator != null) {
    try {
      wagonConfigurator.configure(wagon,configuration);
    }
 catch (    Exception e) {
      String msg="Could not apply configuration for " + repository.getId() + " to wagon "+ wagon.getClass().getName()+ ":"+ e.getMessage();
      if (logger.isDebugEnabled()) {
        logger.warn(msg,e);
      }
 else {
        logger.warn(msg);
      }
    }
  }
  wagon.connect(wagonRepo,wagonAuth,wagonProxy);
}
 

Example 25

From project agraph-java-client, under directory /src/test/.

Source file: TestRunner.java

  17 
vote

static List<Method> methodsAnnotated(Class clazz,Class<? extends Annotation> annotationClass){
  List<Method> r=new ArrayList<Method>();
  List<Class> classes=getSupers(clazz);
  for (  Class c : classes) {
    Method[] methods=c.getDeclaredMethods();
    for (int i=0; i < methods.length; i++) {
      Method m=methods[i];
      Annotation anno=m.getAnnotation(annotationClass);
      if (anno != null) {
        r.add(m);
      }
    }
  }
  return r;
}
 

Example 26

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

Source file: AbstractAjahDao.java

  17 
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 27

From project alljoyn_java, under directory /src/org/alljoyn/bus/.

Source file: BusAttachment.java

  17 
vote

/** 
 * Registers a public method to receive a signal from specific objects emitting it. Once registered, the method of the object will receive the signal specified from objects implementing the interface.
 * @param ifaceName the interface name of the signal
 * @param signalName the member name of the signal
 * @param obj the object receiving the signal
 * @param handlerMethod the signal handler method
 * @param source the object path of the emitter of the signal
 * @return OK if the register is succesful
 */
public Status registerSignalHandler(String ifaceName,String signalName,Object obj,Method handlerMethod,String source){
  Status status=registerNativeSignalHandler(ifaceName,signalName,obj,handlerMethod,source);
  if (status == Status.BUS_NO_SUCH_INTERFACE) {
    try {
      Class<?> iface=Class.forName(ifaceName);
      InterfaceDescription desc=new InterfaceDescription();
      status=desc.create(this,iface);
      if (status == Status.OK) {
        ifaceName=InterfaceDescription.getName(iface);
        try {
          Method signal=iface.getMethod(signalName,handlerMethod.getParameterTypes());
          signalName=InterfaceDescription.getName(signal);
        }
 catch (        NoSuchMethodException ex) {
        }
        status=registerNativeSignalHandler(ifaceName,signalName,obj,handlerMethod,source);
      }
    }
 catch (    ClassNotFoundException ex) {
      BusException.log(ex);
      status=Status.BUS_NO_SUCH_INTERFACE;
    }
catch (    AnnotationBusException ex) {
      BusException.log(ex);
      status=Status.BAD_ANNOTATION;
    }
  }
  return status;
}
 

Example 28

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

Source file: PropertyValuesHolder.java

  17 
vote

/** 
 * Returns the setter or getter requested. This utility function checks whether the requested method exists in the propertyMapMap cache. If not, it calls another utility function to request the Method from the targetClass directly.
 * @param targetClass The Class on which the requested method should exist.
 * @param propertyMapMap The cache of setters/getters derived so far.
 * @param prefix "set" or "get", for the setter or getter.
 * @param valueType The type of parameter passed into the method (null for getter).
 * @return Method the method associated with mPropertyName.
 */
private Method setupSetterOrGetter(Class targetClass,HashMap<Class,HashMap<String,Method>> propertyMapMap,String prefix,Class valueType){
  Method setterOrGetter=null;
  try {
    mPropertyMapLock.writeLock().lock();
    HashMap<String,Method> propertyMap=propertyMapMap.get(targetClass);
    if (propertyMap != null) {
      setterOrGetter=propertyMap.get(mPropertyName);
    }
    if (setterOrGetter == null) {
      setterOrGetter=getPropertyFunction(targetClass,prefix,valueType);
      if (propertyMap == null) {
        propertyMap=new HashMap<String,Method>();
        propertyMapMap.put(targetClass,propertyMap);
      }
      propertyMap.put(mPropertyName,setterOrGetter);
    }
  }
  finally {
    mPropertyMapLock.writeLock().unlock();
  }
  return setterOrGetter;
}
 

Example 29

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

Source file: CloneUtils.java

  17 
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 30

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

Source file: CUtilities.java

  17 
vote

/** 
 * a universal isEmpty check that can handle arrays,  {@link Collection}s,  {@link Map}s,  {@link CharSequence} or objects.
 * @param object Array, {@link Collection},  {@link Map}s,  {@link CharSequence} or object.
 * @return true if the passed object is an array, {@link Collection},  {@link Map}, or  {@link CharSequence} that is null or contains no elements.For other objects return true if the object is not null. if the objects is a single object (that is not an array, collection, map) then true is return if the object is null. TODO (Any or All? which is better?)
 */
public static boolean isEmpty(Object object){
  if (object == null) {
    return true;
  }
 else   if (object instanceof Map<?,?>) {
    return ((Map<?,?>)object).isEmpty();
  }
 else   if (object instanceof Collection<?>) {
    return ((Collection<?>)object).isEmpty();
  }
 else   if (object.getClass().isArray()) {
    return ((Object[])object).length == 0;
  }
 else   if (object instanceof CharSequence) {
    return ((CharSequence)object).length() == 0;
  }
 else {
    Method empty;
    try {
      empty=object.getClass().getMethod("isEmpty",new Class<?>[0]);
      return (Boolean)empty.invoke(object);
    }
 catch (    NoSuchMethodException e) {
    }
catch (    IllegalArgumentException e) {
    }
catch (    IllegalAccessException e) {
      throw new ApplicationIllegalStateException(e);
    }
catch (    InvocationTargetException e) {
      throw new ApplicationIllegalStateException(e);
    }
    return false;
  }
}
 

Example 31

From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/page/.

Source file: BibleView.java

  17 
vote

/** 
 * enter text selection mode
 */
@Override public void selectAndCopyText(LongPressControl longPressControl){
  Log.d(TAG,"enter text selection mode");
  if (CommonUtils.isJellyBeanPlus()) {
    Log.d(TAG,"keycode Enter for JB+");
    KeyEvent enterEvent=new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_ENTER,0,0);
    longPressControl.ignoreNextLongPress();
    enterEvent.dispatch(this);
  }
 else {
    try {
      Log.d(TAG,"selectText for ICS");
      WebView.class.getMethod("selectText").invoke(this);
    }
 catch (    Exception e1) {
      try {
        Log.d(TAG,"emulateShiftHeld");
        Method m=WebView.class.getMethod("emulateShiftHeld",(Class[])null);
        m.invoke(this,(Object[])null);
      }
 catch (      Exception e2) {
        Log.d(TAG,"shiftPressEvent");
        KeyEvent shiftPressEvent=new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
        shiftPressEvent.dispatch(this);
      }
    }
  }
}
 

Example 32

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

Source file: PropertyValuesHolder.java

  17 
vote

/** 
 * Returns the setter or getter requested. This utility function checks whether the requested method exists in the propertyMapMap cache. If not, it calls another utility function to request the Method from the targetClass directly.
 * @param targetClass The Class on which the requested method should exist.
 * @param propertyMapMap The cache of setters/getters derived so far.
 * @param prefix "set" or "get", for the setter or getter.
 * @param valueType The type of parameter passed into the method (null for getter).
 * @return Method the method associated with mPropertyName.
 */
private Method setupSetterOrGetter(Class targetClass,HashMap<Class,HashMap<String,Method>> propertyMapMap,String prefix,Class valueType){
  Method setterOrGetter=null;
  try {
    mPropertyMapLock.writeLock().lock();
    HashMap<String,Method> propertyMap=propertyMapMap.get(targetClass);
    if (propertyMap != null) {
      setterOrGetter=propertyMap.get(mPropertyName);
    }
    if (setterOrGetter == null) {
      setterOrGetter=getPropertyFunction(targetClass,prefix,valueType);
      if (propertyMap == null) {
        propertyMap=new HashMap<String,Method>();
        propertyMapMap.put(targetClass,propertyMap);
      }
      propertyMap.put(mPropertyName,setterOrGetter);
    }
  }
  finally {
    mPropertyMapLock.writeLock().unlock();
  }
  return setterOrGetter;
}
 

Example 33

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

Source file: PropertyValuesHolder.java

  17 
vote

/** 
 * Returns the setter or getter requested. This utility function checks whether the requested method exists in the propertyMapMap cache. If not, it calls another utility function to request the Method from the targetClass directly.
 * @param targetClass The Class on which the requested method should exist.
 * @param propertyMapMap The cache of setters/getters derived so far.
 * @param prefix "set" or "get", for the setter or getter.
 * @param valueType The type of parameter passed into the method (null for getter).
 * @return Method the method associated with mPropertyName.
 */
private Method setupSetterOrGetter(Class targetClass,HashMap<Class,HashMap<String,Method>> propertyMapMap,String prefix,Class valueType){
  Method setterOrGetter=null;
  try {
    mPropertyMapLock.writeLock().lock();
    HashMap<String,Method> propertyMap=propertyMapMap.get(targetClass);
    if (propertyMap != null) {
      setterOrGetter=propertyMap.get(mPropertyName);
    }
    if (setterOrGetter == null) {
      setterOrGetter=getPropertyFunction(targetClass,prefix,valueType);
      if (propertyMap == null) {
        propertyMap=new HashMap<String,Method>();
        propertyMapMap.put(targetClass,propertyMap);
      }
      propertyMap.put(mPropertyName,setterOrGetter);
    }
  }
  finally {
    mPropertyMapLock.writeLock().unlock();
  }
  return setterOrGetter;
}
 

Example 34

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

Source file: FFXIEQSettings.java

  17 
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 35

From project android-tether, under directory /src/og/android/tether/system/.

Source file: BluetoothService_cupcake.java

  17 
vote

@SuppressWarnings("unchecked") private Object callBluetoothMethod(String methodName){
  Object manager=this.application.getSystemService("bluetooth");
  Class c=manager.getClass();
  Object returnValue=null;
  if (c == null) {
  }
 else {
    try {
      Method enable=c.getMethod(methodName);
      enable.setAccessible(true);
      returnValue=enable.invoke(manager);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  return returnValue;
}
 

Example 36

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

Source file: AnnotationHelper.java

  17 
vote

@SuppressWarnings("unchecked") public <T>T extractAnnotationParameter(Element element,Class<? extends Annotation> target,String methodName){
  Annotation annotation=element.getAnnotation(target);
  Method method;
  try {
    method=annotation.getClass().getMethod(methodName);
    return (T)method.invoke(annotation);
  }
 catch (  InvocationTargetException e) {
    if (e.getCause() instanceof MirroredTypeException) {
      MirroredTypeException cause=(MirroredTypeException)e.getCause();
      return (T)cause.getTypeMirror();
    }
 else {
      throw new RuntimeException(e);
    }
  }
catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
 

Example 37

From project androidquery, under directory /src/com/androidquery/util/.

Source file: AQUtility.java

  17 
vote

private static Object invokeMethod(Object handler,String callback,boolean fallback,Class<?>[] cls,Class<?>[] cls2,Object... params) throws Exception {
  if (handler == null || callback == null)   return null;
  Method method=null;
  try {
    if (cls == null)     cls=new Class[0];
    method=handler.getClass().getMethod(callback,cls);
    return method.invoke(handler,params);
  }
 catch (  NoSuchMethodException e) {
  }
  try {
    if (fallback) {
      if (cls2 == null) {
        method=handler.getClass().getMethod(callback);
        return method.invoke(handler);
      }
 else {
        method=handler.getClass().getMethod(callback,cls2);
        return method.invoke(handler,params);
      }
    }
  }
 catch (  NoSuchMethodException e) {
  }
  return null;
}
 

Example 38

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

Source file: PropertyValuesHolder.java

  17 
vote

/** 
 * Returns the setter or getter requested. This utility function checks whether the requested method exists in the propertyMapMap cache. If not, it calls another utility function to request the Method from the targetClass directly.
 * @param targetClass The Class on which the requested method should exist.
 * @param propertyMapMap The cache of setters/getters derived so far.
 * @param prefix "set" or "get", for the setter or getter.
 * @param valueType The type of parameter passed into the method (null for getter).
 * @return Method the method associated with mPropertyName.
 */
private Method setupSetterOrGetter(Class targetClass,HashMap<Class,HashMap<String,Method>> propertyMapMap,String prefix,Class valueType){
  Method setterOrGetter=null;
  try {
    mPropertyMapLock.writeLock().lock();
    HashMap<String,Method> propertyMap=propertyMapMap.get(targetClass);
    if (propertyMap != null) {
      setterOrGetter=propertyMap.get(mPropertyName);
    }
    if (setterOrGetter == null) {
      setterOrGetter=getPropertyFunction(targetClass,prefix,valueType);
      if (propertyMap == null) {
        propertyMap=new HashMap<String,Method>();
        propertyMapMap.put(targetClass,propertyMap);
      }
      propertyMap.put(mPropertyName,setterOrGetter);
    }
  }
  finally {
    mPropertyMapLock.writeLock().unlock();
  }
  return setterOrGetter;
}
 

Example 39

From project android_5, under directory /src/aarddict/android/.

Source file: N2EpdController.java

  17 
vote

public static void exitA2Mode(){
  System.err.println("aarddict::exitA2Mode");
  vCurrentNode=0;
  try {
    Class epdControllerClass=Class.forName("android.hardware.EpdController");
    Class epdControllerRegionClass=Class.forName("android.hardware.EpdController$Region");
    Class epdControllerRegionParamsClass=Class.forName("android.hardware.EpdController$RegionParams");
    Class epdControllerWaveClass=Class.forName("android.hardware.EpdController$Wave");
    Object[] waveEnums=null;
    if (epdControllerWaveClass.isEnum()) {
      waveEnums=epdControllerWaveClass.getEnumConstants();
    }
    Object[] regionEnums=null;
    if (epdControllerRegionClass.isEnum()) {
      regionEnums=epdControllerRegionClass.getEnumConstants();
    }
    Constructor RegionParamsConstructor=epdControllerRegionParamsClass.getConstructor(new Class[]{Integer.TYPE,Integer.TYPE,Integer.TYPE,Integer.TYPE,epdControllerWaveClass,Integer.TYPE});
    Object localRegionParams=RegionParamsConstructor.newInstance(new Object[]{0,0,600,800,waveEnums[3],16});
    Method epdControllerSetRegionMethod=epdControllerClass.getMethod("setRegion",new Class[]{String.class,epdControllerRegionClass,epdControllerRegionParamsClass});
    epdControllerSetRegionMethod.invoke(null,new Object[]{"aarddicteadingView",regionEnums[2],localRegionParams});
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Example 40

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

Source file: Communication.java

  17 
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 41

From project android_external_guava, under directory /src/com/google/common/base/internal/.

Source file: Finalizer.java

  17 
vote

/** 
 * Cleans up a single reference. Catches and logs all throwables.
 */
private void cleanUp(Reference<?> reference) throws ShutDown {
  Method finalizeReferentMethod=getFinalizeReferentMethod();
  do {
    reference.clear();
    if (reference == frqReference) {
      throw new ShutDown();
    }
    try {
      finalizeReferentMethod.invoke(reference);
    }
 catch (    Throwable t) {
      logger.log(Level.SEVERE,"Error cleaning up after reference.",t);
    }
  }
 while ((reference=queue.poll()) != null);
}
 

Example 42

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/util/.

Source file: FileUtils.java

  17 
vote

/** 
 * Native helper method, returns whether the current process has execute privilages.
 * @param a File
 * @return returns TRUE if the current process has execute privilages.
 */
public static boolean canExecute(File mContextFile){
  try {
    Method m=File.class.getMethod("canExecute",new Class[]{});
    Boolean result=(Boolean)m.invoke(mContextFile);
    return result;
  }
 catch (  Exception e) {
    if (libLoadSuccess) {
      return access(mContextFile.getPath(),X_OK);
    }
 else {
      return false;
    }
  }
}
 

Example 43

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

Source file: HttpClientFactory.java

  17 
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 44

From project android_packages_apps_phone, under directory /src/com/android/phone/sip/.

Source file: SipEditor.java

  17 
vote

private void loadPreferencesFromProfile(SipProfile p){
  if (p != null) {
    Log.v(TAG,"Edit the existing profile : " + p.getProfileName());
    try {
      Class profileClass=SipProfile.class;
      for (      PreferenceKey key : PreferenceKey.values()) {
        Method meth=profileClass.getMethod(GET_METHOD_PREFIX + getString(key.text),(Class[])null);
        if (key == PreferenceKey.SendKeepAlive) {
          boolean value=((Boolean)meth.invoke(p,(Object[])null)).booleanValue();
          key.setValue(getString(value ? R.string.sip_always_send_keepalive : R.string.sip_system_decide));
        }
 else {
          Object value=meth.invoke(p,(Object[])null);
          key.setValue((value == null) ? "" : value.toString());
        }
      }
      checkIfDisplayNameSet();
    }
 catch (    Exception e) {
      Log.e(TAG,"Can not load pref from profile",e);
    }
  }
 else {
    Log.v(TAG,"Edit a new profile");
    for (    PreferenceKey key : PreferenceKey.values()) {
      key.preference.setOnPreferenceChangeListener(this);
      if (key.initValue != 0) {
        key.setValue(getString(key.initValue));
      }
    }
    mDisplayNameSet=false;
  }
}
 

Example 45

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

Source file: SamsungAppWidgetInfo.java

  17 
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 46

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

Source file: AnnisBaseRunner.java

  17 
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 47

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

Source file: FlexPilotLocatingElementHandler.java

  15 
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 48

From project amsterdam, under directory /src/main/java/com/unicodecollective/amsterdam/.

Source file: CallSpecs.java

  15 
vote

public static CallSpec methodMatching(String regex){
  final Pattern methodPattern=Pattern.compile(regex);
  return new CallSpec(){
    @Override public boolean matches(    Method method,    Object[] args){
      return methodPattern.matcher(method.getName()).find();
    }
  }
;
}
 

Example 49

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

Source file: ServiceForegroundCompat.java

  15 
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 50

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/compat/.

Source file: CompatUtils.java

  15 
vote

public static Method getMethod(Class<?> targetClass,String name,Class<?>... parameterTypes){
  if (targetClass == null || TextUtils.isEmpty(name))   return null;
  try {
    return targetClass.getMethod(name,parameterTypes);
  }
 catch (  SecurityException e) {
  }
catch (  NoSuchMethodException e) {
  }
  return null;
}
 

Example 51

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

Source file: DroidDoc.java

  15 
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 52

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

Source file: CompatUtils.java

  15 
vote

public static Method getMethod(Class<?> targetClass,String name,Class<?>... parameterTypes){
  if (targetClass == null || TextUtils.isEmpty(name))   return null;
  try {
    return targetClass.getMethod(name,parameterTypes);
  }
 catch (  SecurityException e) {
  }
catch (  NoSuchMethodException e) {
  }
  return null;
}