changeset 6315:160cde99bb1a

8010209: Better provision of factories Reviewed-by: dcubed, ahgross
author jbachorik
date Wed, 27 Mar 2013 13:29:22 +0100
parents ffef9e05564e
children b1cf36f3435c
files src/share/classes/sun/tracing/ProviderSkeleton.java src/share/classes/sun/tracing/dtrace/DTraceProvider.java
diffstat 2 files changed, 25 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/tracing/ProviderSkeleton.java	Wed Mar 27 14:32:58 2013 +0400
+++ b/src/share/classes/sun/tracing/ProviderSkeleton.java	Wed Mar 27 13:29:22 2013 +0100
@@ -150,20 +150,25 @@
      * @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;
     }
@@ -248,4 +253,14 @@
         }
         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);
+            }
+        }
+    }
 }
--- a/src/share/classes/sun/tracing/dtrace/DTraceProvider.java	Wed Mar 27 14:32:58 2013 +0400
+++ b/src/share/classes/sun/tracing/dtrace/DTraceProvider.java	Wed Mar 27 13:29:22 2013 +0100
@@ -160,19 +160,8 @@
     // 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() {