提交 5ee8b1cf 编写于 作者: J jbachorik

8010209: Better provision of factories

Reviewed-by: dcubed, ahgross
上级 5c03611b
......@@ -154,20 +154,25 @@ public abstract class ProviderSkeleton implements InvocationHandler, Provider {
* @return always null, if the method is a user-defined probe
*/
public Object invoke(Object proxy, Method method, Object[] args) {
if (method.getDeclaringClass() != providerType) {
Class declaringClass = method.getDeclaringClass();
// not a provider subtype's own method
if (declaringClass != providerType) {
try {
return method.invoke(this, args);
// delegate only to methods declared by
// com.sun.tracing.Provider or java.lang.Object
if (declaringClass == Provider.class ||
declaringClass == Object.class) {
return method.invoke(this, args);
} else {
assert false;
}
} catch (IllegalAccessException e) {
assert false;
} catch (InvocationTargetException e) {
assert false;
}
} else if (active) {
ProbeSkeleton p = probes.get(method);
if (p != null) {
// Skips argument check -- already done by javac
p.uncheckedTrigger(args);
}
} else {
triggerProbe(method, args);
}
return null;
}
......@@ -252,4 +257,14 @@ public abstract class ProviderSkeleton implements InvocationHandler, Provider {
}
return ret;
}
protected void triggerProbe(Method method, Object[] args) {
if (active) {
ProbeSkeleton p = probes.get(method);
if (p != null) {
// Skips argument check -- already done by javac
p.uncheckedTrigger(args);
}
}
}
}
......@@ -151,19 +151,8 @@ class DTraceProvider extends ProviderSkeleton {
// directly. So this method should never get invoked. We also wire up the
// DTraceProbe.uncheckedTrigger() method to call the proxy method instead
// of doing the work itself.
public Object invoke(Object proxy, Method method, Object[] args) {
if (method.getDeclaringClass() != providerType) {
try {
return method.invoke(this, args);
} catch (IllegalAccessException e) {
assert false;
} catch (InvocationTargetException e) {
assert false;
}
} else if (active) {
assert false : "This method should have been overridden by the JVM";
}
return null;
protected void triggerProbe(Method method, Object[] args) {
assert false : "This method should have been overridden by the JVM";
}
public String getProviderName() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册