wu-sheng commented on a change in pull request #3176: Remove javassist from 
agent dependency
URL: https://github.com/apache/skywalking/pull/3176#discussion_r308005636
 
 

 ##########
 File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/bootstrap/BootstrapInstrumentBoost.java
 ##########
 @@ -160,29 +173,49 @@ private static boolean 
prepareJREInstrumentation(PluginFinder pluginFinder,
      * One key step to avoid class confliction between AppClassLoader and 
BootstrapClassLoader
      *
      * @param classesTypeMap hosts injected binary of generated class
-     * @param classPool to generate new class
+     * @param typePool to generate new class
      * @param templateClassName represents the class as template in this 
generation process. The templates are
      * pre-defined in SkyWalking agent core.
      * @param methodsInterceptor
      */
-    private static void generateDelegator(Map<String, byte[]> classesTypeMap, 
ClassPool classPool,
+    private static void generateDelegator(Map<String, byte[]> classesTypeMap, 
TypePool typePool,
         String templateClassName, String methodsInterceptor) {
         String internalInterceptorName = internalDelegate(methodsInterceptor);
         try {
-            CtClass interClass = classPool.get(templateClassName);
-            interClass.setName(internalInterceptorName);
-
-            CtField interceptorDefine = 
interClass.getField("TARGET_INTERCEPTOR");
-            interClass.removeField(interceptorDefine);
-
-            interceptorDefine = CtField.make("private static String 
TARGET_INTERCEPTOR = \"" + methodsInterceptor + "\";", interClass);
-            interClass.addField(interceptorDefine);
+            TypeDescription templateTypeDescription = 
typePool.describe(templateClassName)
+                .resolve();
+
+            DynamicType.Unloaded interceptorType = new ByteBuddy()
+                .redefine(templateTypeDescription, 
ClassFileLocator.ForClassLoader.of(BootstrapInstrumentBoost.class.getClassLoader()))
+                .name(internalInterceptorName)
+                .field(named("TARGET_INTERCEPTOR")).value(methodsInterceptor)
+                .make();
+
+            classesTypeMap.put(internalInterceptorName, 
interceptorType.getBytes());
+
+            try {
+                File debuggingClassesRootPath = null;
 
 Review comment:
   I removed the duplicated file write and map#put. Please recheck, if it is OK 
now, please approve again.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to