8010209: Better provision of factories
Reviewed-by: dcubed, ahgross
This commit is contained in:
parent
4a77df1972
commit
dc1533f6cf
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user