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:Main.java

public static Constructor<?> findConstructorBestMatch(Class<?> clazz, Class<?>... parameterTypes) {
    StringBuilder sb = new StringBuilder(clazz.getName());
    sb.append(getParametersString(parameterTypes));
    sb.append("#bestmatch");
    String fullConstructorName = sb.toString();

    if (constructorCache.containsKey(fullConstructorName)) {
        Constructor<?> constructor = constructorCache.get(fullConstructorName);
        if (constructor == null)
            throw new NoSuchMethodError(fullConstructorName);
        return constructor;
    }/*from  w ww  .jav  a2 s .  c  o m*/

    try {
        Constructor<?> constructor = findConstructorExact(clazz, parameterTypes);
        constructorCache.put(fullConstructorName, constructor);
        return constructor;
    } catch (NoSuchMethodError ignored) {
    }

    Constructor<?> bestMatch = null;
    Constructor<?>[] constructors = clazz.getDeclaredConstructors();
    for (Constructor<?> constructor : constructors) {
        // compare name and parameters
        //         if (ClassUtils.isAssignable(parameterTypes, constructor.getParameterTypes(), true)) {
        //             // get accessible version of method
        //               if (bestMatch == null || MemberUtils.compareParameterTypes(
        //                     constructor.getParameterTypes(),
        //                  bestMatch.getParameterTypes(),
        //                  parameterTypes) < 0) {
        //                  bestMatch = constructor;
        //               }
        //          }
    }

    if (bestMatch != null) {
        bestMatch.setAccessible(true);
        constructorCache.put(fullConstructorName, bestMatch);
        return bestMatch;
    } else {
        NoSuchMethodError e = new NoSuchMethodError(fullConstructorName);
        constructorCache.put(fullConstructorName, null);
        throw e;
    }
}

From source file:Main.java

public static Object clone(final Object obj) throws CloneNotSupportedException {
    if (obj == null) {
        return null;
    }/*ww w. j  a v a  2s  .c  om*/
    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();
    }
}

From source file:Main.java

/**
 * @since 4.3/*from   ww w  .j  a v a2s. co  m*/
 */
public static <T> T cloneObject(final T obj) throws CloneNotSupportedException {
    if (obj == null) {
        return null;
    }
    if (obj instanceof Cloneable) {
        final Class<?> clazz = obj.getClass();
        final Method m;
        try {
            m = clazz.getMethod("clone", (Class[]) null);
        } catch (final NoSuchMethodException ex) {
            throw new NoSuchMethodError(ex.getMessage());
        }
        try {
            @SuppressWarnings("unchecked")
            // OK because clone() preserves the class
            final T result = (T) m.invoke(obj, (Object[]) null);
            return result;
        } catch (final InvocationTargetException ex) {
            final Throwable cause = ex.getCause();
            if (cause instanceof CloneNotSupportedException) {
                throw ((CloneNotSupportedException) cause);
            } else {
                throw new Error("Unexpected exception", cause);
            }
        } catch (final IllegalAccessException ex) {
            throw new IllegalAccessError(ex.getMessage());
        }
    } else {
        throw new CloneNotSupportedException();
    }
}

From source file:Main.java

/**
 * @since 4.3//from  w w w  .  java2  s .  com
 */
public static <T> T cloneObject(final T obj) throws CloneNotSupportedException {
    if (obj == null) {
        return null;
    }
    if (obj instanceof Cloneable) {
        final Class<?> clazz = obj.getClass();
        final Method m;
        try {
            m = clazz.getMethod("clone", (Class<?>[]) null);
        } catch (final NoSuchMethodException ex) {
            throw new NoSuchMethodError(ex.getMessage());
        }
        try {
            @SuppressWarnings("unchecked")
            // OK because clone() preserves the class
            final T result = (T) m.invoke(obj, (Object[]) null);
            return result;
        } catch (final InvocationTargetException ex) {
            final Throwable cause = ex.getCause();
            if (cause instanceof CloneNotSupportedException) {
                throw ((CloneNotSupportedException) cause);
            } else {
                throw new Error("Unexpected exception", cause);
            }
        } catch (final IllegalAccessException ex) {
            throw new IllegalAccessError(ex.getMessage());
        }
    } else {
        throw new CloneNotSupportedException();
    }
}

From source file:com.ideabase.repository.core.dao.impl.ItemDAOJdbcImpl.java

public void updateItem(final Item pItem) {
    throw new NoSuchMethodError("this method is not yet implemented");
}

From source file:com.ideabase.repository.core.dao.impl.ItemDAOJdbcImpl.java

public void deleteItem(final Item pItem) {
    throw new NoSuchMethodError("this method is not yet implemented");
}

From source file:org.apache.ibatis.cache.TransactionalCacheManager.java

/**
 * ?//from  w  w  w. jav  a  2  s.c  om
 * @param ?
 * @return   ??
 * @throws CloneNotSupportedException
 */
@SuppressWarnings("unchecked")
public static <T> T cloneObject(T obj) throws CloneNotSupportedException {
    if (obj == null) {
        return null;
    }
    if (obj instanceof Cloneable) {//implement Cloneable?clone
        Class<? extends Object> clazz = obj.getClass();
        Method m;
        try {
            m = clazz.getMethod("clone", (Class[]) null);
        } catch (NoSuchMethodException ex) {
            throw new NoSuchMethodError(ex.getMessage());
        }
        try {
            Object result = m.invoke(obj, (Object[]) null);
            return (T) result;
        } catch (InvocationTargetException ex) {
            Throwable cause = ex.getCause();
            if (cause instanceof CloneNotSupportedException) {
                throw ((CloneNotSupportedException) cause);
            }
            throw new Error("Unexpected exception", cause);
        } catch (IllegalAccessException ex) {
            throw new IllegalAccessError(ex.getMessage());
        }
    }
    if (obj instanceof Serializable)//??????
        return (T) SerializationUtils.clone((Serializable) obj);
    throw new SerializationException();
}

From source file:com.ideabase.repository.core.dao.impl.ItemDAOJdbcImpl.java

public void deleteItemById(final Integer pId) {
    throw new NoSuchMethodError("this method is not yet implemented");
}

From source file:com.googlecode.arit.jul.HandlerResourceScanner.java

public HandlerResourceScanner() {
    LogManager logManager = LogManager.getLogManager();
    Class<? extends LogManager> clazz = logManager.getClass();
    try {//from w ww . j av a 2s. c  om
        // We only enable the plugin if the getLoggerNames method has not been overridden.
        // An overridden getLoggerNames method is an indication that the log manager maintains
        // multiple logger name spaces and that we need a specialized plugin. This is the
        // case for Tomcat's ClassLoaderLogManager. Note that WebSphere's WsLogManager
        // overrides getLogger, but not getLoggerNames.
        if (clazz.getMethod("getLoggerNames").getDeclaringClass().equals(LogManager.class)) {
            this.logManager = logManager;
        } else {
            this.logManager = null;
        }
    } catch (NoSuchMethodException ex) {
        throw new NoSuchMethodError(ex.getMessage());
    }
}

From source file:com.ideabase.repository.core.dao.impl.ItemDAOJdbcImpl.java

public List<Item> findItems(final Item pItem, final Integer pSkip, final Integer pMax) {
    throw new NoSuchMethodError("this method is not yet implemented");
}