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
|
* @return always null, if the method is a user-defined probe
|
||||||
*/
|
*/
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) {
|
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 {
|
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) {
|
} catch (IllegalAccessException e) {
|
||||||
assert false;
|
assert false;
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
assert false;
|
assert false;
|
||||||
}
|
}
|
||||||
} else if (active) {
|
} else {
|
||||||
ProbeSkeleton p = probes.get(method);
|
triggerProbe(method, args);
|
||||||
if (p != null) {
|
|
||||||
// Skips argument check -- already done by javac
|
|
||||||
p.uncheckedTrigger(args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -252,4 +257,14 @@ public abstract class ProviderSkeleton implements InvocationHandler, Provider {
|
|||||||
}
|
}
|
||||||
return ret;
|
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
|
// directly. So this method should never get invoked. We also wire up the
|
||||||
// DTraceProbe.uncheckedTrigger() method to call the proxy method instead
|
// DTraceProbe.uncheckedTrigger() method to call the proxy method instead
|
||||||
// of doing the work itself.
|
// of doing the work itself.
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) {
|
protected void triggerProbe(Method method, Object[] args) {
|
||||||
if (method.getDeclaringClass() != providerType) {
|
assert false : "This method should have been overridden by the JVM";
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProviderName() {
|
public String getProviderName() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user