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
Error when trying to modify the response of a method assigned to a public static final config variable #1605
Comments
What's your interceptor class, including annotations and imports? |
It is, but the static initializer will not be rerun on a retransformation. In this case, you would need to hook before the class is loaded for the first time. |
I agree Rafael, with AgentBuilder could I achieve it? |
You mean rerun the static initializer? That is not possible, unfortunately, the JVM does not support it. |
If I understood what you indicated... ("you would need to hook before the class is loaded for the first time.") |
@raphw |
You are doing it right, but there's nothing that can fix your problem if the initializer already ran. |
Thank you very much for the support! , I found everything about bytebuddy interesting. |
jdk corretto-17.0.7 , and bytebuddy version is 1.14.9
I get :
None of [public static java.lang.Object com.bcp.fraud.streams.Main$MyInterceptor.intercept(com.bcp.fraud.streams.Main$MyCallable,java.lang.Object[]) throws java.lang.Exception] allows for delegation from public static org.apache.kafka.common.config.ConfigDef io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig.baseSchemaRegistryConfigDef()
this is my code:
new AgentBuilder.Default()
.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
.with(AgentBuilder.TypeStrategy.Default.REDEFINE)
.with(new FlowListener())
.ignore(nameStartsWith("net.bytebuddy."))
.type(ElementMatchers.named("io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig"))
.transform((builder, typeDescription, classLoader, module, protectionDomain) -> {
//return builder;
return builder
.method(named("baseSchemaRegistryConfigDef"))
.intercept(MethodDelegation.to(MyInterceptor.class));
})
.installOn(inst);
What I want is to modify a routine of that method in Java, what should I use?
I use net.bytebuddy.agent.ByteBuddyAgent.install method to instrumentation at runtime.
The text was updated successfully, but these errors were encountered: