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

Use getInternalName() instead of getName() #78

Merged
merged 1 commit into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public DynamicType.Builder<?> transform(
.withCustomMapping()
.bind(new AllowedArgument.Factory(methods))
.to(AllowAdvice.class)
.on(method -> methods.containsKey(method.getName()));
.on(method -> methods.containsKey(method.getInternalName()));

return builder.visit(advice);
}
Expand Down Expand Up @@ -94,7 +94,7 @@ public Advice.OffsetMapping make(
AdviceType adviceType
) {
return (instrumentedType, instrumentedMethod, assigner, argumentHandler, sort) -> {
boolean allowed = methods.get(instrumentedMethod.getName());
boolean allowed = methods.get(instrumentedMethod.getInternalName());
return Advice.OffsetMapping.Target.ForStackManipulation.of(allowed);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public DynamicType.Builder<?> transform(
.bind(ModifiersArgument.Factory.INSTANCE)
.to(BlockingCallAdvice.class)
.on(method -> {
Set<String> descriptors = methods.get(method.getName());
Set<String> descriptors = methods.get(method.getInternalName());
return descriptors != null && descriptors.contains(method.getDescriptor());
});

Expand Down
46 changes: 46 additions & 0 deletions example/src/test/java/com/example/StaticInitTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2020-Present Pivotal Software Inc, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example;

import org.junit.Test;
import reactor.blockhound.BlockHound;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

public class StaticInitTest {

static {
BlockHound.install(b -> {
b.allowBlockingCallsInside(ClassWithStaticInit.class.getName(), "<clinit>");
});
}

@Test
public void shouldInstrumentStaticInitializers() {
Mono.fromCallable(ClassWithStaticInit::new).subscribeOn(Schedulers.parallel()).block();
}

static class ClassWithStaticInit {
static {
try {
Thread.sleep(0);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
}