[jboss-cvs] JBoss Profiler SVN: r469 - branches/JBossProfiler2/src/main/org/jboss/profiler/agent.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Aug 17 09:33:24 EDT 2008


Author: jesper.pedersen
Date: 2008-08-17 09:33:23 -0400 (Sun, 17 Aug 2008)
New Revision: 469

Modified:
   branches/JBossProfiler2/src/main/org/jboss/profiler/agent/JavassistTransformer.java
Log:
The visibility doesnt change over time over the instrumentation

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/JavassistTransformer.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/JavassistTransformer.java	2008-08-16 11:22:30 UTC (rev 468)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/JavassistTransformer.java	2008-08-17 13:33:23 UTC (rev 469)
@@ -57,18 +57,20 @@
     try {
       ClassPool pool = ClassPool.getDefault();
       bis = new ByteArrayInputStream(ob);
+
+      Visibility v = Agent.getVisibility(className);
       
       CtClass cc = pool.makeClass(bis);
       CtConstructor[] constructors =  cc.getDeclaredConstructors();
       for (int i = 0; i < constructors.length; i++) {
         CtConstructor constructor = constructors[i];
-        instrumentConstructor(constructor, className);
+        instrumentConstructor(constructor, className, v);
       }
 
       CtMethod[] methods =  cc.getDeclaredMethods();
       for (int i = 0; i < methods.length; i++) {
         CtMethod method = methods[i];
-        instrumentMethod(method, className);
+        instrumentMethod(method, className, v);
       }
 
       return cc.toBytecode();
@@ -92,27 +94,25 @@
    * Instrument constructor
    * @param constructor The constructor
    * @param className The class name
+   * @param v The visibility
    * @exception CannotCompileException If the constructor cant be modified
    */
-  private void instrumentConstructor(CtConstructor constructor, String className) throws CannotCompileException {
+  private void instrumentConstructor(CtConstructor constructor, String className, Visibility v) throws CannotCompileException {
     if (!constructor.isClassInitializer()) {
       boolean include = true;
       
       if (Modifier.isPrivate(constructor.getModifiers())) {
-        Visibility v = Agent.getVisibility(className);
         if (v == Visibility.PROTECTED ||
             v == Visibility.PACKAGE ||
             v == Visibility.PUBLIC) {
           include = false;
         }
       } else if (Modifier.isProtected(constructor.getModifiers())) {
-        Visibility v = Agent.getVisibility(className);
         if (v == Visibility.PACKAGE ||
             v == Visibility.PUBLIC) {
           include = false;
         }
       } else if (Modifier.isPackage(constructor.getModifiers())) {
-        Visibility v = Agent.getVisibility(className);
         if (v == Visibility.PUBLIC) {
           include = false;
         }
@@ -136,26 +136,24 @@
    * Instrument method
    * @param method The method
    * @param className The class name
+   * @param v The visibility
    * @exception CannotCompileException If the constructor cant be modified
    */
-  private void instrumentMethod(CtMethod method, String className) throws CannotCompileException {
+  private void instrumentMethod(CtMethod method, String className, Visibility v) throws CannotCompileException {
     boolean include = true;
       
     if (Modifier.isPrivate(method.getModifiers())) {
-      Visibility v = Agent.getVisibility(className);
       if (v == Visibility.PROTECTED ||
           v == Visibility.PACKAGE ||
           v == Visibility.PUBLIC) {
         include = false;
       }
     } else if (Modifier.isProtected(method.getModifiers())) {
-      Visibility v = Agent.getVisibility(className);
       if (v == Visibility.PACKAGE ||
           v == Visibility.PUBLIC) {
         include = false;
       }
     } else if (Modifier.isPackage(method.getModifiers())) {
-      Visibility v = Agent.getVisibility(className);
       if (v == Visibility.PUBLIC) {
         include = false;
       }




More information about the jboss-cvs-commits mailing list