Created
October 5, 2019 19:46
-
-
Save olegchir/7dcd7c079e610d2e0d06e3b4a273a743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class<?> dynamicType = new ByteBuddy() | |
.subclass(Object.class) | |
.method(ElementMatchers.named("toString")) | |
.intercept(FixedValue.value("Hello World!")) | |
.make() | |
.load(getClass().getClassLoader()) | |
.getLoaded(); | |
assertThat(dynamicType.newInstance().toString(), is("Hello World!")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment