diff --git a/jdk/src/share/classes/sun/tracing/ProviderSkeleton.java b/jdk/src/share/classes/sun/tracing/ProviderSkeleton.java index ca5e58fbc6c..2a5bc360430 100644 --- a/jdk/src/share/classes/sun/tracing/ProviderSkeleton.java +++ b/jdk/src/share/classes/sun/tracing/ProviderSkeleton.java @@ -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); + } + } + } } diff --git a/jdk/src/share/classes/sun/tracing/dtrace/DTraceProvider.java b/jdk/src/share/classes/sun/tracing/dtrace/DTraceProvider.java index 4a9eb2888d6..fdc447dbd15 100644 --- a/jdk/src/share/classes/sun/tracing/dtrace/DTraceProvider.java +++ b/jdk/src/share/classes/sun/tracing/dtrace/DTraceProvider.java @@ -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() {