Invokes a method safely on a Object regardless of accessibility (Unless not allowed with security settings).

@param obj
@param aMethod
@param log
@throws Exception
358235
private static void safeInvokeMethod(Object obj, Method aMethod, Logger log)
      throws Exception {
    boolean accessible = aMethod.isAccessible();
    try {
      if(!accessible) {
        aMethod.setAccessible(true);
      }
      if(Modifier.isStatic(aMethod.getModifiers())) {
        log.debug("Invoking static method: {}", aMethod);
        aMethod.invoke(null);
      } else {
        log.debug("Invoking method {} on object instance {}", aMethod, obj);
        aMethod.invoke(obj);
      }
    } finally {
      if(!accessible) {
        aMethod.setAccessible(accessible);
      }
    }
  }
382416
public static void logRuntimeException(Logger log, String exceptionMessage,
            String method, Object... params) {
        handleException(log, newRunTimeException(exceptionMessage), method,
                params);
    }
549588
public Object invoke (Object object, String methodName, Class[] paramTypes, Object... args) {
		return invoke(object, getIndex(methodName, paramTypes), args);
	}
1229197
@Override
  public void _log (final int nLevel, @Nonnull final Object aMsg, @Nullable final Throwable aThrowable)
  {
    // >= 7
    if (nLevel >= ERROR)
    {
      if (m_aLogger.isErrorEnabled ())
      {
        if (aMsg != null)
          m_aLogger.error ("{}", aMsg, aThrowable);
        else
          m_aLogger.error (BLA, aThrowable);
      }
    }
    else
      // >= 5
      if (nLevel >= WARN)
      {
        if (m_aLogger.isWarnEnabled ())
        {
          if (aMsg != null)
            m_aLogger.warn ("{}", aMsg, aThrowable);
          else
            m_aLogger.warn (BLA, aThrowable);
        }
      }
      else
        // >= 3
        if (nLevel >= INFO)
        {
          if (m_aLogger.isInfoEnabled ())
          {
            if (aMsg != null)
              m_aLogger.info ("{}", aMsg, aThrowable);
            else
              m_aLogger.info (BLA, aThrowable);
          }
        }
        else
          // >= 1
          if (nLevel >= DEBUG)
          {
            if (m_aLogger.isDebugEnabled ())
            {
              if (aMsg != null)
                m_aLogger.debug ("{}", aMsg, aThrowable);
              else
                m_aLogger.debug (BLA, aThrowable);
            }
          }
          else
          {
            // < 1
            if (m_aLogger.isTraceEnabled ())
            {
              if (aMsg != null)
                m_aLogger.trace ("{}", aMsg, aThrowable);
              else
                m_aLogger.trace (BLA, aThrowable);
            }
          }
  }
878193
@Override
	public Object intercept(Object object, Method method, Object[] args,
			MethodProxy methodProxy) throws Throwable {
		Method delegateMethod = delegateClass.getMethod(method.getName(),
				method.getParameterTypes());
		if ("registerBeanDefinition".equals(method.getName())) {
			if (beanDefinitionMap.containsKey(args[0])) {
				List<BeanDefinition> definitions = beanDefinitionMap
						.get(args[0]);
				definitions.add((BeanDefinition) args[1]);
			} else {
				List<BeanDefinition> beanDefinitions = new ArrayList<BeanDefinition>();
				beanDefinitions.add((BeanDefinition) args[1]);
				beanDefinitionMap.put((String) args[0], beanDefinitions);
			}
		}
		return delegateMethod.invoke(delegate, args);
	}
799947
public static Object executeMethod(Object object, MethodCallFact methodCallFact)
   throws Exception
   {
	if (object == null)
	   throw new RequiredException("object");
	
	if (methodCallFact == null)
	   throw new RequiredException("methodCallFact");
	
	return executeMethod(object, methodCallFact.getMethodName(),methodCallFact.getArguments());
   }
297964
@Nonnull
  public JSInvocation staticInvoke (@Nullable final AbstractJSClass aType, @Nonnull final JSMethod aMethod)
  {
    final JSInvocation aInvocation = new JSInvocation (aType, aMethod);
    return addStatement (aInvocation);
  }
405970
@Override
  public Object invoke(Object[] argv) throws Throwable {
    if (handle == null) {
      throw new IllegalStateException(
          "Default method handler invoked before proxy has been bound.");
    }
    return handle.invokeWithArguments(argv);
  }
1221287
public static Object invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
			final Object[] args) {
		Method method = getAccessibleMethod(obj, methodName, parameterTypes);
		if (method == null) {
			throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
		}

		try {
			return method.invoke(obj, args);
		} catch (Exception e) {
			throw convertReflectionExceptionToUnchecked(e);
		}
	}
641293
public static void setAccessible(AccessibleObject... objs) {
    AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
      AccessibleObject.setAccessible(objs, true);
      return null;
    });
  }
694566
public static void notNull(final Object obj, final String message) throws IllegalArgumentException {
        if (obj == null) {
            throw new IllegalArgumentException(message);
        }
    }
288277
public void error(Object o) {
        if (o instanceof Throwable) {
            logger.error(o, (Throwable) o);
        } else {
            logger.error(o);
        }
    }
918865
@Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
    {
        if (constructed)
        {

            String methodName = method.getName();
            int params = args.length;

            if (params == 0)
            {
                if (isUninitialized() && method.equals(getIdentifierMethod))
                {
                    return getIdentifier();
                }

                else if ("getKunderaLazyInitializer".equals(methodName))
                {
                    return this;
                }
            }

            Object target = getImplementation();

            String[] strArr = entityName.split("#");
            String fieldName = strArr[1];

            if (owner != null)
            {
                EntityMetadata m = KunderaMetadataManager.getEntityMetadata(persistenceDelegator.getKunderaMetadata(),
                        owner.getClass());
                Relation r = m.getRelation(fieldName);
                if (r != null)
                {
                    PropertyAccessorHelper.set(owner, r.getProperty(), target);
                }
                if (r.getBiDirectionalField() != null && method.getReturnType().equals(m.getEntityClazz()))
                {
                    PropertyAccessorHelper.set(target, r.getBiDirectionalField(), owner);
                }

            }

            try
            {
                final Object returnValue;
                if (method.isAccessible())
                {
                    if (!method.getDeclaringClass().isInstance(target))
                    {
                        throw new ClassCastException(target.getClass().getName());
                    }
                    returnValue = method.invoke(target, args);
                }
                else
                {
                    if (!method.isAccessible())
                    {
                        method.setAccessible(true);
                    }
                    returnValue = method.invoke(target, args);
                }
                return ((returnValue == target) ? proxy : returnValue);
            }
            catch (InvocationTargetException ite)
            {
                throw new LazyInitializationException(ite);
            }
        }
        else
        {
            // while constructor is running
            throw new LazyInitializationException("unexpected case hit, method=" + method.getName());
        }

    }
1046709
public static Object invokeMethod(Object obj, Method method, Object... params) {
        try {
            method.setAccessible(true);
            return method.invoke(obj, params);
        }
        catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException ex) {
            throw new RuntimeException(ex);
        }
    }
530191
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
        throws Throwable {
        if (Object.class.equals(method.getDeclaringClass())) {
            return proxy.invokeSuper(obj, args);
        }

        List<WebElement> realElements = new ArrayList<>(locator.findElements());
        return getObject(realElements, method, args);
    }
455586
public void log(Throwable exception) {
		if (exception instanceof CoreException) {
			getILog().log(new Status(IStatus.ERROR, PLUGIN_ID,
					exception.getMessage(),
					exception.getCause()));
		} else if (exception != null) {
			getILog().log(new Status(IStatus.ERROR, PLUGIN_ID,
					exception.getMessage(), exception));
		} else {
			getILog().log(new Status(IStatus.ERROR, PLUGIN_ID,
					"Internal Error", exception));   //$NON-NLS-1$
		}
	}
1023648
protected void registerLoggedException(Throwable exception) {
		SpringBootExceptionHandler handler = getSpringBootExceptionHandler();
		if (handler != null) {
			handler.registerLoggedException(exception);
		}
	}