use of java.lang.reflect.Member in project roboguice by roboguice.
the class GraphvizGrapher method newImplementationNode.
@Override
protected void newImplementationNode(ImplementationNode node) {
NodeId nodeId = node.getId();
GraphvizNode gnode = new GraphvizNode(nodeId);
gnode.setStyle(NodeStyle.SOLID);
gnode.setHeaderBackgroundColor("#000000");
gnode.setHeaderTextColor("#ffffff");
gnode.setTitle(nameFactory.getClassName(nodeId.getKey()));
for (Member member : node.getMembers()) {
gnode.addField(portIdFactory.getPortId(member), nameFactory.getMemberName(member));
}
addNode(gnode);
}
use of java.lang.reflect.Member in project yyl_example by Relucent.
the class JaqueExample method property.
public static <T> void property(Property<T, ?> propertyRef) {
LambdaExpression<Function<T, ?>> parsed = LambdaExpression.parse(propertyRef);
// Use parsed Expression Tree...
Expression body = parsed.getBody();
Expression methodCall = body;
System.out.println("body:\n" + body);
// remove casts
while (methodCall instanceof UnaryExpression) {
methodCall = ((UnaryExpression) methodCall).getFirst();
}
// checks are omitted for brevity
MemberExpression invexp = (MemberExpression) ((InvocationExpression) methodCall).getTarget();
Member member = invexp.getMember();
System.out.println("member:\n" + member);
System.out.println();
}
use of java.lang.reflect.Member in project groovy by apache.
the class Java9 method checkCanSetAccessible.
/**
* This method may be used by a caller in class C to check whether to enable access to a member of declaring class D successfully
* if {@link Java8#checkCanSetAccessible(java.lang.reflect.AccessibleObject, java.lang.Class)} returns true and any of the following hold:
* <p>
* 1) C and D are in the same module.
* 2) The member is public and D is public in a package that the module containing D exports to at least the module containing C.
* 3) The member is protected static, D is public in a package that the module containing D exports to at least the module containing C, and C is a subclass of D.
* 4) D is in a package that the module containing D opens to at least the module containing C. All packages in unnamed and open modules are open to all modules and so this method always succeeds when D is in an unnamed or open module.
*
* @param accessibleObject the accessible object to check
* @param callerClass the class wishing to invoke {@code setAccessible}
* @return the check result
*/
@Override
public boolean checkCanSetAccessible(final AccessibleObject accessibleObject, final Class<?> callerClass) {
if (!super.checkCanSetAccessible(accessibleObject, callerClass))
return false;
if (callerClass == MethodHandle.class) {
// should not happen
throw new IllegalCallerException();
}
if (!(accessibleObject instanceof Member)) {
// should not happen
throw new IllegalArgumentException("accessibleObject should be a member of type: " + accessibleObject);
}
Member member = (Member) accessibleObject;
Class<?> declaringClass = member.getDeclaringClass();
Module declaringModule = declaringClass.getModule();
Module callerModule = callerClass.getModule();
if (!declaringModule.isNamed())
return true;
if (callerModule == declaringModule)
return true;
if (callerModule == Object.class.getModule())
return true;
return checkAccessible(callerClass, declaringClass, member.getModifiers(), true);
}
use of java.lang.reflect.Member in project wildfly by wildfly.
the class WeldResourceInjectionServices method resolveResource.
public Object resolveResource(InjectionPoint injectionPoint) {
final Member member = injectionPoint.getMember();
AnnotatedMember<?> annotatedMember;
if (injectionPoint.getAnnotated() instanceof AnnotatedField) {
annotatedMember = (AnnotatedField<?>) injectionPoint.getAnnotated();
} else {
annotatedMember = ((AnnotatedParameter<?>) injectionPoint.getAnnotated()).getDeclaringCallable();
}
if (!annotatedMember.isAnnotationPresent(Resource.class)) {
throw WeldLogger.ROOT_LOGGER.annotationNotFound(Resource.class, member);
}
if (member instanceof Method && ((Method) member).getParameterCount() != 1) {
throw WeldLogger.ROOT_LOGGER.injectionPointNotAJavabean((Method) member);
}
String name = getResourceName(injectionPoint);
for (ResourceInjectionResolver resolver : resourceResolvers) {
Object result = resolver.resolve(name);
if (result != null) {
return result;
}
}
try {
return context.lookup(name);
} catch (NamingException e) {
throw WeldLogger.ROOT_LOGGER.couldNotFindResource(name, injectionPoint.getMember().toString(), e);
}
}
use of java.lang.reflect.Member in project immutables by immutables.
the class ReflectionExtractor method extract.
@Override
@Nullable
public Object extract(Path path, Object instance) {
Objects.requireNonNull(path, "path");
Object result = instance;
for (Member member : path.members()) {
result = extractor.extract(member, result);
if (result == null) {
return null;
}
}
return result;
}
Aggregations