mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cache JavaMethod instances with annotation cache within
This commit is contained in:
@@ -604,7 +604,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
|
||||
invocation = myInvocationCache.getInvocation(method);
|
||||
if (invocation != null) return invocation;
|
||||
|
||||
JavaMethod javaMethod = JavaMethod.getMethod(getRawType(), method);
|
||||
JavaMethod javaMethod = myInvocationCache.getInternedMethod(method);
|
||||
invocation = myGenericInfo.createInvocation(javaMethod);
|
||||
if (invocation != null) {
|
||||
myInvocationCache.putInvocation(method, invocation);
|
||||
|
||||
@@ -24,6 +24,12 @@ public class InvocationCache {
|
||||
return ourCoreInvocations.get(new JavaMethodSignature(key));
|
||||
}
|
||||
};
|
||||
private final Map<Method, JavaMethod> myJavaMethods = new ConcurrentFactoryMap<Method, JavaMethod>() {
|
||||
@Override
|
||||
protected JavaMethod create(Method key) {
|
||||
return JavaMethod.getMethod(myType, key);
|
||||
}
|
||||
};
|
||||
private final Map<JavaMethod, Boolean> myGetters = new ConcurrentFactoryMap<JavaMethod, Boolean>() {
|
||||
@Override
|
||||
protected Boolean create(JavaMethod key) {
|
||||
@@ -167,6 +173,10 @@ public class InvocationCache {
|
||||
return myInvocations.get(method);
|
||||
}
|
||||
|
||||
public JavaMethod getInternedMethod(Method method) {
|
||||
return myJavaMethods.get(method);
|
||||
}
|
||||
|
||||
public void putInvocation(Method method, Invocation invocation) {
|
||||
myInvocations.put(method, invocation);
|
||||
}
|
||||
|
||||
@@ -65,8 +65,9 @@ public class StaticGenericInfoBuilder {
|
||||
myClass = aClass;
|
||||
|
||||
final Set<JavaMethod> methods = new THashSet<JavaMethod>();
|
||||
InvocationCache invocationCache = DomApplicationComponent.getInstance().getInvocationCache(myClass);
|
||||
for (final Method method : ReflectionCache.getMethods(myClass)) {
|
||||
methods.add(JavaMethod.getMethod(myClass, method));
|
||||
methods.add(invocationCache.getInternedMethod(method));
|
||||
}
|
||||
for (final JavaMethod method : methods) {
|
||||
if (DomImplUtil.isGetter(method) && method.getAnnotation(NameValue.class) != null) {
|
||||
@@ -80,11 +81,10 @@ public class StaticGenericInfoBuilder {
|
||||
if (implClass != null) {
|
||||
for (Method method : ReflectionCache.getMethods(implClass)) {
|
||||
final int modifiers = method.getModifiers();
|
||||
if (!Modifier.isAbstract(modifiers) && !Modifier.isVolatile(modifiers)) {
|
||||
final JavaMethodSignature signature = new JavaMethodSignature(method);
|
||||
if (signature.findMethod(myClass) != null) {
|
||||
methods.remove(JavaMethod.getMethod(myClass, signature));
|
||||
}
|
||||
if (!Modifier.isAbstract(modifiers) &&
|
||||
!Modifier.isVolatile(modifiers) &&
|
||||
new JavaMethodSignature(method).findMethod(myClass) != null) {
|
||||
methods.remove(invocationCache.getInternedMethod(method));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user