/** * {@inheritDoc} */ public boolean isSynthetic() { return method.isSynthetic(); }
private static boolean isEqualsDefined(Class<?> cls) { try { return !cls.getDeclaredMethod("equals", Object.class).isSynthetic(); } catch (NoSuchMethodException e) { return false; } }
@Override public boolean matches(final Method method) { return method.isSynthetic(); }
public boolean callMethodIsSynthetic(Method m) { return m.isSynthetic(); }
private static boolean isMatchesSafelyMethod(Method method) { return "matchesSafely".equals(method.getName()) && method.getParameterTypes().length == 1 && !method.isSynthetic(); }
private boolean _isIncludableMemberMethod(Method m) { if (Modifier.isStatic(m.getModifiers()) // Looks like generics can introduce hidden bridge and/or synthetic methods. // I don't think we want to consider those... || m.isSynthetic() || m.isBridge()) { return false; } // also, for now we have no use for methods with more than 2 arguments: // (2 argument methods for "any setter", fwtw) int pcount = m.getParameterTypes().length; return (pcount <= 2); }
/** * @param method The method to examine. * @return true if this method references the relevant type */ protected boolean canObtainExpectedTypeFrom(Method method) { return method.getName().equals(methodName) && method.getParameterTypes().length == expectedNumberOfParameters && !method.isSynthetic(); }
private static boolean isMatchesSafelyMethod(Method method) { return method.getName().equals("matchesSafely") && method.getParameterTypes().length == 1 && !method.isSynthetic(); }
private boolean _isIncludableMemberMethod(Method m) { if (Modifier.isStatic(m.getModifiers()) // Looks like generics can introduce hidden bridge and/or synthetic methods. // I don't think we want to consider those... || m.isSynthetic() || m.isBridge()) { return false; } // also, for now we have no use for methods with more than 2 arguments: // (2 argument methods for "any setter", fwtw) int pcount = m.getParameterTypes().length; return (pcount <= 2); }
/** * 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))); }
/** * @param method The method to examine. * @return true if this method references the relevant type */ protected boolean canObtainExpectedTypeFrom(Method method) { return method.getName().equals(methodName) && method.getParameterTypes().length == expectedNumberOfParameters && !method.isSynthetic(); }
public final static Set<Method> getInheritedPrivateMethod(Class<?> type) { Set<Method> result = new HashSet<>(); Class<?> i = type; while (i != null && i != Object.class) { for (Method m : i.getDeclaredMethods()) { if (!m.isSynthetic()) { result.add(m); } } i = i.getSuperclass(); } return result; }
/** * @param method The method to examine. * @return true if this method references the relevant type */ private boolean canObtainExpectedTypeFrom(Method method) { return method.getName().equals(methodName) && method.getParameterTypes().length == expectedNumberOfParameters && !method.isSynthetic(); }
private static ImmutableList<Method> getAnnotatedMethodsNotCached(Class<?> clazz) { Set<? extends Class<?>> supertypes = TypeToken.of(clazz).getTypes().rawTypes(); Map<MethodIdentifier, Method> identifiers = Maps.newHashMap(); for (Class<?> supertype : supertypes) { for (Method method : supertype.getDeclaredMethods()) { if (method.isAnnotationPresent(Subscribe.class) && !method.isSynthetic()) { // TODO(cgdecker): Should check for a generic parameter type and error out Class<?>[] parameterTypes = method.getParameterTypes(); checkArgument( parameterTypes.length == 1, "Method %s has @Subscribe annotation but has %s parameters." + "Subscriber methods must have exactly 1 parameter.", method, parameterTypes.length); MethodIdentifier ident = new MethodIdentifier(method); if (!identifiers.containsKey(ident)) { identifiers.put(ident, method); } } } } return ImmutableList.copyOf(identifiers.values()); }
private Method getAcceptMethod(Class<? extends StepdefBody> bodyClass) { List<Method> acceptMethods = new ArrayList<>(); for (Method method : bodyClass.getDeclaredMethods()) { if (!method.isBridge() && !method.isSynthetic() && "accept".equals(method.getName())) { acceptMethods.add(method); } } if (acceptMethods.size() != 1) { throw new IllegalStateException(format( "Expected single 'accept' method on body class, found '%s'", acceptMethods)); } return acceptMethods.get(0); }
/** * 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))); }
protected boolean _isIncludableMethod(Method m, MethodFilter filter) { if (filter != null && !filter.includeMethod(m)) { return false; } /* 07-Apr-2009, tatu: Looks like generics can introduce hidden * bridge and/or synthetic methods. I don't think we want to * consider those... */ if (m.isSynthetic() || m.isBridge()) { return false; } return true; }
private ImmutableList<Method> getVisibleMethods(Class<?> cls) { // Don't use cls.getPackage() because it does nasty things like reading // a file. String visiblePackage = Reflection.getPackageName(cls); ImmutableList.Builder<Method> builder = ImmutableList.builder(); for (Class<?> type : TypeToken.of(cls).getTypes().rawTypes()) { if (!Reflection.getPackageName(type).equals(visiblePackage)) { break; } for (Method method : type.getDeclaredMethods()) { if (!method.isSynthetic() && isVisible(method)) { builder.add(method); } } } return builder.build(); } }
/** * Returns whether the method given is a getter method we should serialize / * deserialize to the service. The method must begin with "get" or "is", * have no arguments, belong to a class that declares its table, and not be * marked ignored. */ private static boolean isRelevantGetter(Method m) { return (m.getName().startsWith("get") || m.getName().startsWith("is")) && m.getParameterTypes().length == 0 && ! (m.isBridge() || m.isSynthetic()) && isDocumentType(m.getDeclaringClass()) && !ReflectionUtils.getterOrFieldHasAnnotation(m, DynamoDBIgnore.class); }
private static ImmutableList<Method> getAnnotatedMethodsNotCached(Class<?> clazz) { Set<? extends Class<?>> supertypes = TypeToken.of(clazz).getTypes().rawTypes(); Map<MethodIdentifier, Method> identifiers = Maps.newHashMap(); for (Class<?> supertype : supertypes) { for (Method method : supertype.getDeclaredMethods()) { if (method.isAnnotationPresent(Subscribe.class) && !method.isSynthetic()) { // TODO(cgdecker): Should check for a generic parameter type and error out Class<?>[] parameterTypes = method.getParameterTypes(); checkArgument( parameterTypes.length == 1, "Method %s has @Subscribe annotation but has %s parameters." + "Subscriber methods must have exactly 1 parameter.", method, parameterTypes.length); MethodIdentifier ident = new MethodIdentifier(method); if (!identifiers.containsKey(ident)) { identifiers.put(ident, method); } } } } return ImmutableList.copyOf(identifiers.values()); }