本文整理了Java中java.lang.NoSuchMethodError.<init>()
方法的一些代码示例,展示了NoSuchMethodError.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NoSuchMethodError.<init>()
方法的具体详情如下:
包路径:java.lang.NoSuchMethodError
类名称:NoSuchMethodError
方法名:<init>
[英]Constructs a new NoSuchMethodError that includes the current stack trace.
[中]构造包含当前堆栈跟踪的新NoSuchMethodError。
代码示例来源:origin: jenkinsci/jenkins
private static Method init() {
try {
Method m = ClassLoader.class.getDeclaredMethod("findResource", String.class);
m.setAccessible(true);
return m;
} catch (NoSuchMethodException e) {
throw (Error)new NoSuchMethodError().initCause(e);
}
}
}
代码示例来源:origin: wildfly/wildfly
public Constructor<T> run() {
try {
return clazz.getDeclaredConstructor(paramTypes);
} catch (NoSuchMethodException e) {
throw new NoSuchMethodError(e.getMessage());
}
}
代码示例来源:origin: org.mockito/mockito-core
/**
* Returns the type of {@link ArgumentMatcher#matches(Object)} of the given
* {@link ArgumentMatcher} implementation.
*/
private static Class<?> getArgumentType(ArgumentMatcher<?> argumentMatcher) {
Method[] methods = argumentMatcher.getClass().getMethods();
for (Method method : methods) {
if (isMatchesMethod(method)) {
return method.getParameterTypes()[0];
}
}
throw new NoSuchMethodError("Method 'matches(T)' not found in ArgumentMatcher: " + argumentMatcher + " !\r\n Please file a bug with this stack trace at: https://github.com/mockito/mockito/issues/new ");
}
代码示例来源:origin: wildfly/wildfly
public Constructor<OptionalDataException> run() {
try {
final Constructor<OptionalDataException> constructor = OptionalDataException.class.getDeclaredConstructor(boolean.class);
constructor.setAccessible(true);
return constructor;
} catch (NoSuchMethodException e) {
throw new NoSuchMethodError(e.getMessage());
}
}
});
代码示例来源:origin: robovm/robovm
private static Method findCallback(Class<?> cls, String methodName) {
for (Method m : cls.getDeclaredMethods()) {
if (m.getName().equals(methodName)) {
return m;
}
}
throw new NoSuchMethodError(methodName);
}
代码示例来源:origin: google/j2objc
public FastMethod getMethod(String name, Class[] parameterTypes) {
try {
return getMethod(type.getMethod(name, parameterTypes));
} catch (NoSuchMethodException e) {
throw new NoSuchMethodError(e.getMessage());
}
}
代码示例来源:origin: google/j2objc
public FastConstructor getConstructor(Class[] parameterTypes) {
try {
return getConstructor(type.getConstructor(parameterTypes));
} catch (NoSuchMethodException e) {
throw new NoSuchMethodError(e.getMessage());
}
}
代码示例来源:origin: micronaut-projects/micronaut-core
private static NoSuchMethodError newNoSuchConstructorInternalError(Class declaringType, Class[] argumentTypes) {
Stream<String> stringStream = Arrays.stream(argumentTypes).map(Class::getSimpleName);
String argsAsText = stringStream.collect(Collectors.joining(","));
return new NoSuchMethodError("Micronaut constructor " + declaringType.getName() + "(" + argsAsText + ") not found. Most likely reason for this issue is that you are running a newer version of Micronaut with code compiled against an older version. Please recompile the offending classes");
}
}
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* @param declaringType The declaring type
* @param name The method name
* @param argumentTypes The argument types
* @return A {@link NoSuchMethodError}
*/
public static NoSuchMethodError newNoSuchMethodError(Class declaringType, String name, Class[] argumentTypes) {
Stream<String> stringStream = Arrays.stream(argumentTypes).map(Class::getSimpleName);
String argsAsText = stringStream.collect(Collectors.joining(","));
return new NoSuchMethodError("Required method " + name + "(" + argsAsText + ") not found for class: " + declaringType.getName() + ". Most likely cause of this error is that an unsupported or older version of a dependency is present on the classpath. Check your classpath, and ensure the incompatible classes are not present and/or recompile classes as necessary.");
}
代码示例来源:origin: micronaut-projects/micronaut-core
private static NoSuchMethodError newNoSuchMethodInternalError(Class declaringType, String name, Class[] argumentTypes) {
Stream<String> stringStream = Arrays.stream(argumentTypes).map(Class::getSimpleName);
String argsAsText = stringStream.collect(Collectors.joining(","));
return new NoSuchMethodError("Micronaut method " + declaringType.getName() + "." + name + "(" + argsAsText + ") not found. Most likely reason for this issue is that you are running a newer version of Micronaut with code compiled against an older version. Please recompile the offending classes");
}
代码示例来源:origin: org.easymock/easymock
public FastMethod getMethod(String name, Class[] parameterTypes) {
try {
return getMethod(type.getMethod(name, parameterTypes));
} catch (NoSuchMethodException e) {
throw new NoSuchMethodError(e.getMessage());
}
}
代码示例来源:origin: org.easymock/easymock
public FastConstructor getConstructor(Class[] parameterTypes) {
try {
return getConstructor(type.getConstructor(parameterTypes));
} catch (NoSuchMethodException e) {
throw new NoSuchMethodError(e.getMessage());
}
}
代码示例来源:origin: cglib/cglib
public FastMethod getMethod(String name, Class[] parameterTypes) {
try {
return getMethod(type.getMethod(name, parameterTypes));
} catch (NoSuchMethodException e) {
throw new NoSuchMethodError(e.getMessage());
}
}
代码示例来源:origin: cglib/cglib
public FastConstructor getConstructor(Class[] parameterTypes) {
try {
return getConstructor(type.getConstructor(parameterTypes));
} catch (NoSuchMethodException e) {
throw new NoSuchMethodError(e.getMessage());
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Due to the return type change in {@link Executable} in 1.377, the caller needs a special precaution now.
* @param e Executable
* @return Discovered subtask
*/
public static @Nonnull SubTask getParentOf(@Nonnull Executable e)
throws Error, RuntimeException {
try {
return e.getParent();
} catch (AbstractMethodError ignored) { // will fallback to a private implementation
try {
Method m = e.getClass().getMethod("getParent");
m.setAccessible(true);
return (SubTask) m.invoke(e);
} catch (IllegalAccessException x) {
throw (Error)new IllegalAccessError().initCause(x);
} catch (NoSuchMethodException x) {
throw (Error)new NoSuchMethodError().initCause(x);
} catch (InvocationTargetException x) {
Throwable y = x.getTargetException();
if (y instanceof Error) throw (Error)y;
if (y instanceof RuntimeException) throw (RuntimeException)y;
throw new Error(x);
}
}
}
代码示例来源:origin: google/guava
private Method getMethod(String methodName, Object... arguments) throws Exception {
METHODS:
for (Method method : lockLikeObject.getClass().getMethods()) {
Class<?>[] parameterTypes = method.getParameterTypes();
if (method.getName().equals(methodName) && (parameterTypes.length == arguments.length)) {
for (int i = 0; i < arguments.length; i++) {
if (!parameterTypes[i].isAssignableFrom(arguments[i].getClass())) {
continue METHODS;
}
}
return method;
}
}
throw new NoSuchMethodError(methodName);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void stopCannotResume() {
OnNextFailureStrategy strategy = OnNextFailureStrategy.stop();
assertThat(strategy.test(new IllegalStateException(), null))
.isFalse();
assertThat(strategy.test(new NoSuchMethodError(), null))
.isFalse();
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
@Test
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void testDoesNotThrowIfAskedToGetManagerForFragmentPreJellyBeanMr1() {
Util.setSdkVersionInt(Build.VERSION_CODES.JELLY_BEAN);
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
android.app.Fragment fragment = new android.app.Fragment();
activity.getFragmentManager().beginTransaction().add(fragment, "test").commit();
android.app.Fragment spyFragment = Mockito.spy(fragment);
when(spyFragment.getChildFragmentManager()).thenThrow(new NoSuchMethodError());
assertNotNull(retriever.get(spyFragment));
}
代码示例来源:origin: bumptech/glide
@Test
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void testDoesNotThrowIfAskedToGetManagerForActivityPreJellYBeanMr1() {
Util.setSdkVersionInt(Build.VERSION_CODES.JELLY_BEAN);
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
Activity spyActivity = Mockito.spy(activity);
when(spyActivity.isDestroyed()).thenThrow(new NoSuchMethodError());
assertNotNull(retriever.get(spyActivity));
}
代码示例来源:origin: reactor/reactor-core
@Test
public void stopProcessWithFatal() {
OnNextFailureStrategy strategy = OnNextFailureStrategy.stop();
Throwable exception = new NoSuchMethodError("foo");
assertThatExceptionOfType(NoSuchMethodError.class)
.isThrownBy(() -> strategy.process(exception, null, Context.empty()))
.satisfies(e -> assertThat(e)
.hasMessage("foo")
.hasNoSuppressedExceptions());
}
内容来源于网络,如有侵权,请联系作者删除!