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);
}
}
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;
}
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);
}
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);
}
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);
}
Aggregations