jdk/src/share/classes/sun/tracing/ProviderSkeleton.java
changeset 18208 5c6150ffbc80
parent 16923 50bfa0defec2
child 19813 4aa8cfd46576
equal deleted inserted replaced
18207:64dcc0ad2298 18208:5c6150ffbc80
   152      * @param method the method that was called
   152      * @param method the method that was called
   153      * @param args the arguments passed in the call.
   153      * @param args the arguments passed in the call.
   154      * @return always null, if the method is a user-defined probe
   154      * @return always null, if the method is a user-defined probe
   155      */
   155      */
   156     public Object invoke(Object proxy, Method method, Object[] args) {
   156     public Object invoke(Object proxy, Method method, Object[] args) {
   157         if (method.getDeclaringClass() != providerType) {
   157         Class declaringClass = method.getDeclaringClass();
       
   158         // not a provider subtype's own method
       
   159         if (declaringClass != providerType) {
   158             try {
   160             try {
   159                 return method.invoke(this, args);
   161                 // delegate only to methods declared by
       
   162                 // com.sun.tracing.Provider or java.lang.Object
       
   163                 if (declaringClass == Provider.class ||
       
   164                     declaringClass == Object.class) {
       
   165                     return method.invoke(this, args);
       
   166                 } else {
       
   167                     assert false;
       
   168                 }
   160             } catch (IllegalAccessException e) {
   169             } catch (IllegalAccessException e) {
   161                 assert false;
   170                 assert false;
   162             } catch (InvocationTargetException e) {
   171             } catch (InvocationTargetException e) {
   163                 assert false;
   172                 assert false;
   164             }
   173             }
   165         } else if (active) {
   174         } else {
   166             ProbeSkeleton p = probes.get(method);
   175             triggerProbe(method, args);
   167             if (p != null) {
       
   168                 // Skips argument check -- already done by javac
       
   169                 p.uncheckedTrigger(args);
       
   170             }
       
   171         }
   176         }
   172         return null;
   177         return null;
   173     }
   178     }
   174 
   179 
   175     /**
   180     /**
   250         } catch (NullPointerException e) {
   255         } catch (NullPointerException e) {
   251             assert false;
   256             assert false;
   252         }
   257         }
   253         return ret;
   258         return ret;
   254     }
   259     }
       
   260 
       
   261     protected void triggerProbe(Method method, Object[] args) {
       
   262         if (active) {
       
   263             ProbeSkeleton p = probes.get(method);
       
   264             if (p != null) {
       
   265                 // Skips argument check -- already done by javac
       
   266                 p.uncheckedTrigger(args);
       
   267             }
       
   268         }
       
   269     }
   255 }
   270 }