本文整理汇总了Java中java.lang.reflect.Method.isBridge方法的典型用法代码示例。如果您正苦于以下问题:Java Method.isBridge方法的具体用法?Java Method.isBridge怎么用?Java Method.isBridge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.reflect.Method
的用法示例。
在下文中一共展示了Method.isBridge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canMap
import java.lang.reflect.Method; //导入方法依赖的package包/类
private boolean canMap(Method method, boolean inherited) {
if (method.getName().matches("^(get|is).+") == false) {
return false;
} else if (method.getParameterTypes().length != 0) {
return false;
} else if (method.isBridge() || method.isSynthetic()) {
return false;
} else if (method.getDeclaringClass() == Object.class) {
return false;
} else if (!inherited && method.getDeclaringClass() != this.clazz &&
StandardAnnotationMaps.of(method.getDeclaringClass()).attributeType() == null) {
return false;
} else {
return true;
}
}
示例2: findAnnotatedMethods
import java.lang.reflect.Method; //导入方法依赖的package包/类
/**
* Find methods that are tagged with a given annotation somewhere in the hierarchy
*/
public static Collection<Method> findAnnotatedMethods(Class<?> type, Class<? extends Annotation> annotation)
{
List<Method> result = new ArrayList<>();
// gather all publicly available methods
// this returns everything, even if it's declared in a parent
for (Method method : type.getMethods()) {
// skip methods that are used internally by the vm for implementing covariance, etc
if (method.isSynthetic() || method.isBridge() || isStatic(method.getModifiers())) {
continue;
}
// look for annotations recursively in super-classes or interfaces
Method managedMethod = findAnnotatedMethod(
type,
annotation,
method.getName(),
method.getParameterTypes());
if (managedMethod != null) {
result.add(managedMethod);
}
}
return result;
}
示例3: getMethod
import java.lang.reflect.Method; //导入方法依赖的package包/类
private static Method getMethod(Class theClass, String propertyName) {
Method[] methods = theClass.getDeclaredMethods();
Method.setAccessible( methods, true );
for ( Method method : methods ) {
// if the method has parameters, skip it
if ( method.getParameterTypes().length != 0 ) {
continue;
}
// if the method is a "bridge", skip it
if ( method.isBridge() ) {
continue;
}
final String methodName = method.getName();
if ( methodName.equals( propertyName ) ) {
return method;
}
}
return null;
}
示例4: populateHandlerConfiguration
import java.lang.reflect.Method; //导入方法依赖的package包/类
private static void populateHandlerConfiguration(Class<?> handler) {
Class<?> publicInterface = getPublicInterface(handler);
if (publicInterface != null) {
Method[] methods = publicInterface.getMethods();
for (Method method : methods) {
if (publicInterface.equals(method.getDeclaringClass()) && !method.isBridge()
&& "execute".equals(method.getName())) {
if (method.getParameterTypes().length == 1) {
MusterServiceConfiguration annotation = publicInterface.getAnnotation(com.github.dmozzy.muster.api.MusterServiceConfiguration.class);
functionHandlers.put(annotation.name(),
new PublicIntferfaceReference((Class<? extends MusterService<?, ?>>) handler,
method.getParameterTypes()[0], method.getReturnType(), annotation.service(),
annotation.name(), annotation.idempotency()));
}
}
}
}
Class<?>[] classes = handler.getClasses();
for (Class<?> clazz : classes) {
populateHandlerConfiguration(clazz);
}
}
示例5: loadAnnotatedMethods
import java.lang.reflect.Method; //导入方法依赖的package包/类
/**
* Load all methods annotated with {@link OnGuiCreated} into their respective caches for the
* specified class.
*/
private static void loadAnnotatedMethods(Class<?> listenerClass, Set<Method> methods) {
for (Method method : listenerClass.getDeclaredMethods()) {
// The compiler sometimes creates synthetic bridge methods as part of the
// type erasure process. As of JDK8 these methods now include the same
// annotations as the original declarations. They should be ignored for
// subscribe/produce.
if (method.isBridge()) {
continue;
}
if (method.isAnnotationPresent(OnGuiCreated.class)) {
Class<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes.length != 0) {
throw new IllegalArgumentException("Method " + method + " has @OnGuiCreated annotation but requires "
+ parameterTypes.length + " arguments. Methods must require zero arguments.");
}
//if ((method.getModifiers() & Modifier.PUBLIC) == 0) {
// throw new IllegalArgumentException("Method " + method + " has @OnGuiCreated annotation but is not 'public'.");
//}
methods.add(method);
}
}
METHODS_ON_GUI_CREATED_CACHE.put(listenerClass, methods);
}
示例6: findAnnotatedMethods
import java.lang.reflect.Method; //导入方法依赖的package包/类
private static EventComposite findAnnotatedMethods(Object listenerClass, Set<EventSubscriber> subscriberMethods,
CompositeDisposable compositeDisposable) {
for (Method method : listenerClass.getClass().getDeclaredMethods()) {
if (method.isBridge()) {
continue;
}
if (method.isAnnotationPresent(Subscribe.class)) {
Class<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes.length != 1) {
throw new IllegalArgumentException("Method " + method + " has @Subscribe annotation but requires " + parameterTypes
.length + " arguments. Methods must require a single argument.");
}
Class<?> parameterClazz = parameterTypes[0];
if ((method.getModifiers() & Modifier.PUBLIC) == 0) {
throw new IllegalArgumentException("Method " + method + " has @EventSubscribe annotation on " + parameterClazz + " " +
"but is not 'public'.");
}
Subscribe annotation = method.getAnnotation(Subscribe.class);
ThreadMode thread = annotation.threadMode();
EventSubscriber subscriberEvent = new EventSubscriber(listenerClass, method, thread);
if (!subscriberMethods.contains(subscriberEvent)) {
subscriberMethods.add(subscriberEvent);//添加事件订阅者
compositeDisposable.add(subscriberEvent.getDisposable());//管理订阅,方便取消订阅
}
}
}
return new EventComposite(compositeDisposable, listenerClass, subscriberMethods);
}
示例7: getReturnType
import java.lang.reflect.Method; //导入方法依赖的package包/类
private <T, R> Class<R> getReturnType(Class<? extends MusterService<T, R>> publicInterface) {
if (publicInterface != null) {
Method[] methods = publicInterface.getMethods();
for (Method method : methods) {
if (publicInterface.equals(method.getDeclaringClass()) && !method.isBridge()
&& "execute".equals(method.getName())) {
if (method.getParameterTypes().length == 1) {
return (Class<R>) method.getReturnType();
}
}
}
}
return null;
}
示例8: isProperty
import java.lang.reflect.Method; //导入方法依赖的package包/类
public static boolean isProperty(Member m) {
if ( m instanceof Method ) {
Method method = (Method) m;
return !method.isSynthetic()
&& !method.isBridge()
&& !Modifier.isStatic( method.getModifiers() )
&& method.getParameterTypes().length == 0
&& ( method.getName().startsWith( "get" ) || method.getName().startsWith( "is" ) );
}
else {
return !Modifier.isTransient( m.getModifiers() ) && !m.isSynthetic();
}
}
示例9: isBridgeMethod
import java.lang.reflect.Method; //导入方法依赖的package包/类
public boolean isBridgeMethod(Method method) {
return method.isBridge();
}
示例10: matches
import java.lang.reflect.Method; //导入方法依赖的package包/类
@Override
public boolean matches(Method method) {
return !method.isBridge();
}
示例11: matches
import java.lang.reflect.Method; //导入方法依赖的package包/类
@Override
public boolean matches(Method method) {
return (!method.isBridge() && method.getDeclaringClass() != Object.class);
}
示例12: isHandler
import java.lang.reflect.Method; //导入方法依赖的package包/类
public boolean isHandler(Method method) {
return findAnnotation(method) != null &&
!method.isBridge() &&
!method.isSynthetic();
}
示例13: registerEvents
import java.lang.reflect.Method; //导入方法依赖的package包/类
public void registerEvents(Listener listener, Plugin plugin) {
if (!plugin.isEnabled()) {
throw new PluginException("Plugin attempted to register " + listener.getClass().getName() + " while not enabled");
}
Map<Class<? extends Event>, Set<RegisteredListener>> ret = new HashMap<>();
Set<Method> methods;
try {
Method[] publicMethods = listener.getClass().getMethods();
Method[] privateMethods = listener.getClass().getDeclaredMethods();
methods = new HashSet<>(publicMethods.length + privateMethods.length, 1.0f);
Collections.addAll(methods, publicMethods);
Collections.addAll(methods, privateMethods);
} catch (NoClassDefFoundError e) {
plugin.getLogger().error("Plugin " + plugin.getDescription().getFullName() + " has failed to register events for " + listener.getClass() + " because " + e.getMessage() + " does not exist.");
return;
}
for (final Method method : methods) {
final EventHandler eh = method.getAnnotation(EventHandler.class);
if (eh == null) continue;
if (method.isBridge() || method.isSynthetic()) {
continue;
}
final Class<?> checkClass;
if (method.getParameterTypes().length != 1 || !Event.class.isAssignableFrom(checkClass = method.getParameterTypes()[0])) {
plugin.getLogger().error(plugin.getDescription().getFullName() + " attempted to register an invalid EventHandler method signature \"" + method.toGenericString() + "\" in " + listener.getClass());
continue;
}
final Class<? extends Event> eventClass = checkClass.asSubclass(Event.class);
method.setAccessible(true);
for (Class<?> clazz = eventClass; Event.class.isAssignableFrom(clazz); clazz = clazz.getSuperclass()) {
// This loop checks for extending deprecated events
if (clazz.getAnnotation(Deprecated.class) != null) {
if (Boolean.valueOf(String.valueOf(this.server.getConfig("settings.deprecated-verbpse", true)))) {
this.server.getLogger().warning(this.server.getLanguage().translateString("nukkit.plugin.deprecatedEvent", plugin.getName(), clazz.getName(), listener.getClass().getName() + "." + method.getName() + "()"));
}
break;
}
}
EventExecutor executor = EventExecutor.create(method, eventClass);
this.registerEvent(eventClass, listener, eh.priority(), executor, plugin, eh.ignoreCancelled());
}
}
示例14: getLambdaPayloadClass
import java.lang.reflect.Method; //导入方法依赖的package包/类
private Class getLambdaPayloadClass(Class functionClass) {
Class payloadClass = null;
for (Method method : functionClass.getDeclaredMethods())
if (method.getName().equals("handleRequest") && !method.isSynthetic() && !method.isBridge())
payloadClass = method.getParameterTypes()[0];
return payloadClass;
}
示例15: isUserLevelMethod
import java.lang.reflect.Method; //导入方法依赖的package包/类
/**
* Determine whether the given method is declared by the user or at least pointing to
* a user-declared method.
* <p>Checks {@link Method#isSynthetic()} (for implementation methods) as well as the
* {@code GroovyObject} interface (for interface methods; on an implementation class,
* implementations of the {@code GroovyObject} methods will be marked as synthetic anyway).
* Note that, despite being synthetic, bridge methods ({@link Method#isBridge()}) are considered
* as user-level methods since they are eventually pointing to a user-declared generic method.
* @param method the method to check
* @return {@code true} if the method can be considered as user-declared; [@code false} otherwise
*/
public static boolean isUserLevelMethod(Method method) {
Assert.notNull(method, "Method must not be null");
return (method.isBridge() || (!method.isSynthetic() && !isGroovyObjectMethod(method)));
}