Search in sources :

Example 81 with Member

use of java.lang.reflect.Member in project graal by oracle.

the class AccessorComputer method compute.

@Override
public Object compute(ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) {
    Member member = (Member) receiver;
    ReflectionSubstitution subst = ImageSingletons.lookup(ReflectionSubstitution.class);
    Class<?> proxyClass = subst.getProxyClass(member);
    if (proxyClass == null) {
        // should never happen, but better check for it here than segfault later
        throw VMError.shouldNotReachHere();
    }
    try {
        return UnsafeAccess.UNSAFE.allocateInstance(proxyClass);
    } catch (InstantiationException ex) {
        throw VMError.shouldNotReachHere(ex);
    }
}
Also used : Member(java.lang.reflect.Member)

Example 82 with Member

use of java.lang.reflect.Member in project graal by oracle.

the class ReflectionSubstitution method getSubstitution.

private ReflectionSubstitutionType getSubstitution(ResolvedJavaType original) {
    ReflectionSubstitutionType subst = getSubstitutionType(original);
    if (subst == null) {
        Member member = typeToMember.get(original);
        subst = new ReflectionSubstitutionType(original, member);
        addSubstitutionType(original, subst);
    }
    return subst;
}
Also used : Member(java.lang.reflect.Member)

Example 83 with Member

use of java.lang.reflect.Member in project narchy by automenta.

the class MethodFinder method findMostSpecificMemberIn.

/**
 * @param a List of Members (either all Constructors or all Methods)
 * @return the most specific of all Members in the list
 * @throws NoSuchMethodException if there is an ambiguity as to which is
 *                most specific
 */
private Member findMostSpecificMemberIn(final List<Member> memberList) throws NoSuchMethodException {
    List<Member> mostSpecificMembers = new ArrayList<>();
    for (Member member : memberList) {
        if (mostSpecificMembers.isEmpty()) {
            // First guy in is the most specific so far.
            mostSpecificMembers.add(member);
        } else {
            boolean moreSpecific = true;
            boolean lessSpecific = false;
            // set?
            for (Member moreSpecificMember : mostSpecificMembers) {
                if (!memberIsMoreSpecific(member, moreSpecificMember)) {
                    /*
                         * Can't be more specific than the whole set. Bail out,
                         * and mark whether member is less specific than the
                         * member under consideration. If it is less specific,
                         * it need not be added to the ambiguity set. This is no
                         * guarantee of not getting added to the ambiguity
                         * set...we're just not clever enough yet to make that
                         * assessment.
                         */
                    moreSpecific = false;
                    lessSpecific = memberIsMoreSpecific(moreSpecificMember, member);
                    break;
                }
            }
            if (moreSpecific) {
                // Member is the most specific now.
                mostSpecificMembers.clear();
                mostSpecificMembers.add(member);
            } else if (!lessSpecific) {
                // Add to ambiguity set if mutually unspecific.
                mostSpecificMembers.add(member);
            }
        }
    }
    if (mostSpecificMembers.size() > 1) {
        throw new NoSuchMethodException("Ambiguous request for member in " + this.clazz.getName() + " matching given args");
    }
    return mostSpecificMembers.get(0);
}
Also used : Member(java.lang.reflect.Member)

Example 84 with Member

use of java.lang.reflect.Member in project solr-document-store by DBCDK.

the class JmxMetrics method makeTimer.

@Produces
public Timer makeTimer(InjectionPoint ip) {
    Member member = ip.getMember();
    String variableName = member.getName();
    if (variableName.endsWith("Timer")) {
        int length = variableName.length() - "Timer".length();
        variableName = variableName.substring(0, length);
    }
    String name = MetricRegistry.name(member.getDeclaringClass(), variableName);
    return registry.timer(name);
}
Also used : Member(java.lang.reflect.Member) InjectionPoint(javax.enterprise.inject.spi.InjectionPoint) Produces(javax.enterprise.inject.Produces)

Example 85 with Member

use of java.lang.reflect.Member in project solr-document-store by DBCDK.

the class JmxMetrics method makeCounter.

@Produces
public Counter makeCounter(InjectionPoint ip) {
    Member member = ip.getMember();
    String variableName = member.getName();
    if (variableName.endsWith("Counter")) {
        int length = variableName.length() - "Counter".length();
        variableName = variableName.substring(0, length);
    }
    String name = MetricRegistry.name(member.getDeclaringClass(), variableName);
    return registry.counter(name);
}
Also used : Member(java.lang.reflect.Member) InjectionPoint(javax.enterprise.inject.spi.InjectionPoint) Produces(javax.enterprise.inject.Produces)

Aggregations

Member (java.lang.reflect.Member)135 Method (java.lang.reflect.Method)41 Field (java.lang.reflect.Field)30 ArrayList (java.util.ArrayList)13 AccessibleObject (java.lang.reflect.AccessibleObject)12 Type (java.lang.reflect.Type)12 Annotation (java.lang.annotation.Annotation)11 Constructor (java.lang.reflect.Constructor)10 TypeVariable (java.lang.reflect.TypeVariable)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 ParameterizedType (java.lang.reflect.ParameterizedType)7 Map (java.util.Map)7 MetaInfo (org.qi4j.api.common.MetaInfo)7 InjectionPoint (com.google.inject.spi.InjectionPoint)6 AnnotatedElement (java.lang.reflect.AnnotatedElement)6 LinkedHashSet (java.util.LinkedHashSet)6 Optional (org.qi4j.api.common.Optional)6 ValueConstraintsInstance (org.qi4j.runtime.composite.ValueConstraintsInstance)6 ValueConstraintsModel (org.qi4j.runtime.composite.ValueConstraintsModel)6 HashSet (java.util.HashSet)5