Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge the AdviceTemplate in the Sermant framework and no longer set a unique Template for the Bootstrap class #1234

Closed
luanwenfei-venus opened this issue Jun 25, 2023 · 2 comments
Assignees
Labels
area/framework Issues or PRs releated to sermant core service kind/enhancement Issues or PRs releated to sermant enhancement
Milestone

Comments

@luanwenfei-venus
Copy link
Collaborator

luanwenfei-venus commented Jun 25, 2023

What would you like to be added?

Merge AdviceTemplate in the Sermant framework, merge AdviceConstTemplate, AdviceMemberTemplate, AdviceStaticTemplate and BootstrapConstTemplate, BootstrapMemberTemplate, BootstrapStaticTemplate

Why is this needed?

**For the ordinary class AdviceTemplate will be added to the bytecode file of the class during bytecode enhancement: **
"INTERCEPTOR_MAP$SERMANT", "EXT_STATIC_FIELDS$SERMANT", "EXT_MEMBER_FIELDS$SERMANT" static fields, this will affect:

  • Compatibility when Sermant and other agents are running at the same time, resulting in the bytecode not being able to RETRANSFORM

**For Bootstrap classes, BootstrapTemplate will be added to the class when bytecode is enhanced: **
static { ClassLoader.getSystemClassLoader().loadClass("net.bytebuddy.dynamic.Nexus").getMethod("initialize", Class.class, Integer.TYPE).invoke((Object)null, StringBuilder.class, -1854685050); }
The following static code block will have the following effects:

  • If the class itself does not have a static code block, bytecode enhancement has no effect and an exception will be thrown: "java.lang.UnsupportedOperationException: class redefinition failed: attempted to add a method" occurs when i transform a class which has been loaded.”
  • The enhancement can only be successful if the class itself has a static code block
    This static code block is added for the ByteBuddy framework. If you want to disable it, you need to enable "disableClassFormatChanges" of ByteBuddy.AgentBuilder, which will strictly comply with the limitations of the Instrumentation API. This will cause the AdviceTemplate for ordinary classes to be unusable and throw an exception.

AdviceTemplate for Bootstrap class will use reflection when using Interceptor, which will affect the performance of bytecode enhancement

@github-actions
Copy link

This issue seems to be Stale. We will close it in a few days.

@github-actions github-actions bot added the Stale label Jul 24, 2023
@github-actions
Copy link

We close this issue because it hasn't been updated in a while. Remove Stale label if you want to reopen it.

@luanwenfei-venus luanwenfei-venus added the kind/enhancement Issues or PRs releated to sermant enhancement label Sep 28, 2023
@kkf1 kkf1 changed the title 将Sermant框架中的AdviceTemplate进行合并,不再为Bootstrap类设置独特的Template Merge the AdviceTemplate in the Sermant framework and no longer set a unique Template for the Bootstrap class Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/framework Issues or PRs releated to sermant core service kind/enhancement Issues or PRs releated to sermant enhancement
Projects
None yet
Development

No branches or pull requests

2 participants