Example usage for java.lang NoSuchMethodError NoSuchMethodError

List of usage examples for java.lang NoSuchMethodError NoSuchMethodError

Introduction

In this page you can find the example usage for java.lang NoSuchMethodError NoSuchMethodError.

Prototype

public NoSuchMethodError(String s) 

Source Link

Document

Constructs a NoSuchMethodError with the specified detail message.

Usage

From source file:com.ideabase.repository.core.jmx.impl.LuceneIndexAdministrationBean.java

/**
 * {@inheritDoc}//from  w  w  w .  j a va 2  s  .c o m
 */
@ManagedOperation(description = "Rebuild lucene index")
public boolean rebuildIndics() {
    LOG.debug("Rebuilding lucene index.");
    throw new NoSuchMethodError("This method wasn't implemented yet.");
    /*try {
      // remove all existing index.
      final LuceneIndexTemplate template = getLuceneIndexTemplate();
      removeIndics(template);
            
      // rebuild all index
      rebuildIndics(template);
            
      // invoke optimize
      optimizeIndics();
      return true;
    } catch (Exception e) {
      LOG.warn("Exception raised during rebuilding the index", e);
    }
    return false;*/
}

From source file:reactor.js.core.JavaScriptObject.java

@Override
public Object call(Object thiz, Object... args) {
    if (!hasProperty("apply")) {
        throw new NoSuchMethodError(this + " does not have a property 'apply' so cannot be invoked.");
    }/* w  w  w .jav  a2 s.com*/
    Object apply = getProperty("apply");
    if (apply instanceof ScriptFunction) {
        return ScriptRuntime.apply((ScriptFunction) apply, thiz, args);
    } else if (apply instanceof JSObject) {
        return ((JSObject) apply).call(thiz, args);
    } else {
        throw new IllegalArgumentException("Cannot invoke an instance of " + apply);
    }
}

From source file:com.ideabase.repository.core.jmx.impl.LuceneIndexAdministrationBean.java

/**
 * {@inheritDoc}/* w ww  .j  a v a  2  s. c  om*/
 */
@ManagedOperation(description = "Create indics based on current repository items.")
public boolean createIndics() {
    /*try {
      rebuildIndics(getLuceneIndexTemplate());
      return true;
    } catch (Exception e) {
      LOG.warn("Create index has been failed", e);
    }
    return false;*/
    throw new NoSuchMethodError("This method wasn't implemented yet.");
}

From source file:org.xmlactions.pager.actions.CodeAction.java

public String getClas() {

    Validate.notNull(getCall());/*from  w  w  w .  j  a va 2s.c o  m*/
    int pos = getCall().lastIndexOf('.');
    if (pos >= 0) {
        return getCall().substring(0, pos);
    }
    throw new NoSuchMethodError("Unable to find method in [" + getCall() + "]");
}

From source file:it.unibo.alchemist.language.protelis.util.ReflectionUtils.java

private static Method loadBestMethod(final Class<?> clazz, final String methodName, final Class<?>[] argClass) {
    Objects.requireNonNull(clazz, "The class on which the method will be invoked can not be null.");
    Objects.requireNonNull(methodName, "Method name can not be null.");
    Objects.requireNonNull(argClass, "Method arguments can not be null.");
    /*//from  ww  w  .  ja  v a 2 s  . c om
     * If there is a matching method, return it
     */
    try {
        return clazz.getMethod(methodName, argClass);
    } catch (NoSuchMethodException | SecurityException e) {
        /*
         * Look it up on the cache
         */
        /*
         * Deal with Java method overloading scoring methods
         */
        final Method[] candidates = clazz.getMethods();
        final List<Pair<Integer, Method>> lm = new ArrayList<>(candidates.length);
        for (final Method m : candidates) {
            // TODO: Workaround for different Method API
            if (m.getParameterTypes().length == argClass.length && methodName.equals(m.getName())) {
                final Class<?>[] params = m.getParameterTypes();
                int p = 0;
                boolean compatible = true;
                for (int i = 0; compatible && i < argClass.length; i++) {
                    final Class<?> expected = params[i];
                    if (expected.isAssignableFrom(argClass[i])) {
                        /*
                         * No downcast required, there is compatibility
                         */
                        p++;
                    } else if (!PrimitiveUtils.classIsNumber(expected)) {
                        compatible = false;
                    }
                }
                if (compatible) {
                    lm.add(new Pair<>(p, m));
                }
            }
        }
        /*
         * Find best
         */
        if (lm.size() > 0) {
            Pair<Integer, Method> max = lm.get(0);
            for (Pair<Integer, Method> cPair : lm) {
                if (cPair.getFirst().compareTo(max.getFirst()) > 0) {
                    max = cPair;
                }
            }
            return max.getSecond();
        }
    }
    List<Class<?>> list = new ArrayList<>();
    for (Class<?> c : argClass) {
        list.add(c);
    }
    final String argType = list.toString();
    throw new NoSuchMethodError(
            methodName + "/" + argClass.length + argType + " does not exist in " + clazz + ".");
}

From source file:org.xmlactions.pager.actions.CodeAction.java

public String getMethod() {

    Validate.notNull(getCall(), "Missing method name for call attribute");
    int pos = getCall().lastIndexOf('.');
    if (pos >= 0) {
        return getCall().substring(pos + 1);
    }/* ww  w.j a  v  a  2s.co m*/
    throw new NoSuchMethodError("Unable to find method in [" + getCall() + "]");
}

From source file:com.ebaotech.salesplatform.commons.helper.SimpleSharedPreferences.java

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@Override//from  www. j a  v a  2 s.co  m
public void apply() throws NoSuchMethodError {
    initAndEdit();
    try {
        mEditor.apply();
    } catch (final NoSuchMethodError e) {
        throw new NoSuchMethodError("\n ======================================== \nError : "
                + "This method is supported only from API-9 { i.e only above GINGERBREAD }"
                + " \n ======================================== \n");
    }
}

From source file:com.jaliansystems.activeMQLite.impl.ObjectRepository.java

/**
 * Invoke a method on a local object./*from w ww . java2  s  . c  om*/
 * 
 * @param message
 *            the message received.
 * @param client
 *            the repository client.
 * @return the return value from the method invocation.
 * @throws Exception
 *             the exception
 */
public Object invoke(JMSLiteMessage message, RepositoryClient client) throws Exception {
    ObjectHandle handle = (ObjectHandle) message.read();
    String methodName = (String) message.read();
    Object[] args = (Object[]) message.read();

    Object object = getObject(handle);
    if (object == null)
        throw new IllegalArgumentException("Could not find local object: " + handle);
    if (client != null && args != null)
        for (int i = 0; i < args.length; i++) {
            if (args[i] != null && args[i] instanceof ObjectHandle)
                args[i] = lookupHandle((ObjectHandle) args[i], client);
        }
    Method method = findMethod(object, methodName, args);
    if (method == null)
        throw new NoSuchMethodError(
                "Could not find method: " + methodName + " on Object of type " + object.getClass().getName());
    Object rval = method.invoke(object, args);
    Class<?> rtype = method.getReturnType();
    if (rtype.isInterface() && exportedInterfaces.contains(rtype) && rval != null) {
        rval = createHandle(rval, rtype);
    }
    return rval;
}

From source file:org.jenkinsci.plugins.workflow.cps.DSL.java

/**
 * Executes the {@link Step} implementation specified by the name argument.
 *
 * @return//from   www . j  a v a2 s.  c  om
 *      If the step completes execution synchronously, the result will be
 *      returned. Otherwise this method {@linkplain Continuable#suspend(Object) suspends}.
 */
@Override
@CpsVmThreadOnly
public Object invokeMethod(String name, Object args) {
    try {
        if (exec == null)
            exec = (CpsFlowExecution) handle.get();
    } catch (IOException e) {
        throw new GroovyRuntimeException(e);
    }

    if (functions == null) {
        functions = new TreeMap<>();
        while (StepDescriptor.all().isEmpty()) {
            LOGGER.warning("Jenkins does not seem to be fully started yet, waiting");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException x) {
                throw new GroovyRuntimeException(x);
            }
        }
        for (StepDescriptor d : StepDescriptor.all()) {
            functions.put(d.getFunctionName(), d);
        }
    }
    final StepDescriptor sd = functions.get(name);
    if (sd != null) {
        return invokeStep(sd, args);
    }
    if (SymbolLookup.get().findDescriptor(Describable.class, name) != null) {
        return invokeDescribable(name, args);
    }

    Set<String> symbols = new TreeSet<>();
    Set<String> globals = new TreeSet<>();
    // TODO SymbolLookup only lets us find a particular symbol, not enumerate them
    try {
        for (Class<?> e : Index.list(Symbol.class, Jenkins.getActiveInstance().pluginManager.uberClassLoader,
                Class.class)) {
            if (Descriptor.class.isAssignableFrom(e)) {
                symbols.addAll(SymbolLookup.getSymbolValue(e));
            }
        }
        Queue.Executable executable = exec.getOwner().getExecutable();
        for (GlobalVariable var : GlobalVariable.forRun(executable instanceof Run ? (Run) executable : null)) {
            globals.add(var.getName());
        }
    } catch (IOException x) {
        Logger.getLogger(DSL.class.getName()).log(Level.WARNING, null, x);
    }
    // TODO probably this should be throwing a subtype of groovy.lang.MissingMethodException
    throw new NoSuchMethodError("No such DSL method '" + name + "' found among steps " + functions.keySet()
            + " or symbols " + symbols + " or globals " + globals);
}

From source file:com.antsdb.saltedfish.util.UberUtil.java

@SuppressWarnings("unchecked")
public static <T> T clone(final T obj) throws CloneNotSupportedException {
    if (obj == null) {
        return null;
    }/*  ww w .ja  v  a 2  s  . c  o  m*/
    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 (T) 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();
    }
}