• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JavaModule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.bytebuddy.utility.JavaModule的典型用法代码示例。如果您正苦于以下问题:Java JavaModule类的具体用法?Java JavaModule怎么用?Java JavaModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JavaModule类属于net.bytebuddy.utility包,在下文中一共展示了JavaModule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: transform

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public DynamicType.Builder<?> transform(
        final DynamicType.Builder<?> builder,
        final TypeDescription typeDescription,
        final ClassLoader classLoader,
        final JavaModule module) {

    final AsmVisitorWrapper methodsVisitor =
            Advice.to(EnterAdvice.class, ExitAdviceMethods.class)
                    .on(ElementMatchers.isAnnotatedWith(CollectMetrics.class)
                            .and(ElementMatchers.isMethod()));

    final AsmVisitorWrapper constructorsVisitor =
            Advice.to(EnterAdvice.class, ExitAdviceConstructors.class)
                    .on(ElementMatchers.isAnnotatedWith(CollectMetrics.class)
                            .and(ElementMatchers.isConstructor()));

    return builder.visit(methodsVisitor).visit(constructorsVisitor);
}
 
开发者ID:ivanyu,项目名称:java-agents-demo,代码行数:20,代码来源:MetricsCollectionByteBuddyAgent.java


示例2: testIgnoredTypeMatcherOnlyAppliedOnceWithMultipleTransformations

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Test
public void testIgnoredTypeMatcherOnlyAppliedOnceWithMultipleTransformations() throws Exception {
    AgentBuilder.RawMatcher ignored = mock(AgentBuilder.RawMatcher.class);
    ClassFileTransformer classFileTransformer = new AgentBuilder.Default(byteBuddy)
            .with(initializationStrategy)
            .with(poolStrategy)
            .with(typeStrategy)
            .with(installationListener)
            .with(listener)
            .disableNativeMethodPrefix()
            .ignore(ignored)
            .type(typeMatcher).transform(transformer)
            .type(typeMatcher).transform(transformer)
            .installOn(instrumentation);
    assertThat(transform(classFileTransformer, JavaModule.ofType(REDEFINED), REDEFINED.getClassLoader(), REDEFINED.getName(), REDEFINED, REDEFINED.getProtectionDomain(), QUX), nullValue(byte[].class));
    verify(listener).onDiscovery(REDEFINED.getName(), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true);
    verify(listener).onIgnored(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true);
    verify(listener).onComplete(REDEFINED.getName(), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true);
    verifyNoMoreInteractions(listener);
    verify(ignored).matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), REDEFINED, REDEFINED.getProtectionDomain());
    verifyNoMoreInteractions(ignored);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:23,代码来源:AgentBuilderDefaultTest.java


示例3: doTransform

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
/**
 * Applies a transformation for a class that was captured by this {@link ClassFileTransformer}.
 *
 * @param module              The instrumented class's Java module in its wrapped form or {@code null} if the current VM does not support modules.
 * @param classLoader         The instrumented class's class loader.
 * @param typeName            The binary name of the instrumented class.
 * @param classBeingRedefined The loaded {@link Class} being redefined or {@code null} if no such class exists.
 * @param loaded              {@code true} if the instrumented type is loaded.
 * @param protectionDomain    The instrumented type's protection domain.
 * @param typePool            The type pool to use.
 * @param classFileLocator    The class file locator to use.
 * @return The transformed class file or an empty byte array if this transformer does not apply an instrumentation.
 */
private byte[] doTransform(JavaModule module,
                           ClassLoader classLoader,
                           String typeName,
                           Class<?> classBeingRedefined,
                           boolean loaded,
                           ProtectionDomain protectionDomain,
                           TypePool typePool,
                           ClassFileLocator classFileLocator) {
    return resolve(module, classLoader, typeName, classBeingRedefined, loaded, protectionDomain, typePool).apply(initializationStrategy,
            classFileLocator,
            typeStrategy,
            byteBuddy,
            nativeMethodStrategy,
            bootstrapInjectionStrategy,
            accessControlContext,
            listener);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:31,代码来源:AgentBuilder.java


示例4: onTransformation

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public void onTransformation(
    TypeDescription typeDescription,
    ClassLoader classLoader,
    JavaModule module,
    boolean loaded,
    DynamicType dynamicType) {
  logger.log(Level.FINE, "{0}", typeDescription);
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:10,代码来源:AgentBuilderListener.java


示例5: onError

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public void onError(
    String typeName,
    ClassLoader classLoader,
    JavaModule module,
    boolean loaded,
    Throwable throwable) {
  logger.log(Level.WARNING, "Failed to handle " + typeName, throwable);
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:10,代码来源:AgentBuilderListener.java


示例6: transform

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public DynamicType.Builder<?> transform(
    DynamicType.Builder<?> builder,
    TypeDescription typeDescription,
    ClassLoader classLoader,
    JavaModule module) {
  return builder.visit(Advice.to(GetContent.class).on(named("getContent")));
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:9,代码来源:UrlInstrumentation.java


示例7: transform

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public DynamicType.Builder<?> transform(
    DynamicType.Builder<?> builder,
    TypeDescription typeDescription,
    ClassLoader classLoader,
    JavaModule module) {
  return builder
      .visit(Advice.to(Start.class).on(named("start")))
      .visit(Advice.to(Run.class).on(named("run")));
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:11,代码来源:ThreadInstrumentation.java


示例8: transform

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public DynamicType.Builder<?> transform(
    DynamicType.Builder<?> builder,
    TypeDescription typeDescription,
    ClassLoader classLoader,
    JavaModule module) {
  return builder.visit(Advice.to(Execute.class).on(named("execute")));
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:9,代码来源:ExecutorInstrumentation.java


示例9: onDiscovery

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onDiscovery(
    final String typeName,
    final ClassLoader classLoader,
    final JavaModule module,
    final boolean loaded)
{
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:8,代码来源:EventLogAgent.java


示例10: onTransformation

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onTransformation(
    final TypeDescription typeDescription,
    final ClassLoader classLoader,
    final JavaModule module,
    final boolean loaded,
    final DynamicType dynamicType)
{
    System.out.println("TRANSFORM " + typeDescription.getName());
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:10,代码来源:EventLogAgent.java


示例11: onIgnored

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onIgnored(
    final TypeDescription typeDescription,
    final ClassLoader classLoader,
    final JavaModule module,
    final boolean loaded)
{
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:8,代码来源:EventLogAgent.java


示例12: onError

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onError(
    final String typeName,
    final ClassLoader classLoader,
    final JavaModule module,
    final boolean loaded,
    final Throwable throwable)
{
    System.out.println("ERROR " + typeName);
    throwable.printStackTrace(System.out);
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:11,代码来源:EventLogAgent.java


示例13: onComplete

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onComplete(
    final String typeName,
    final ClassLoader classLoader,
    final JavaModule module,
    final boolean loaded)
{
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:8,代码来源:EventLogAgent.java


示例14: onTransformation

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onTransformation(
    final TypeDescription typeDescription,
    final ClassLoader classLoader,
    final JavaModule module,
    final boolean loaded,
    final DynamicType dynamicType)
{
}
 
开发者ID:real-logic,项目名称:agrona,代码行数:9,代码来源:BufferAlignmentAgent.java


示例15: testRetransformationConsiderationException

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Test
public void testRetransformationConsiderationException() throws Exception {
    RuntimeException exception = new RuntimeException();
    when(instrumentation.isRetransformClassesSupported()).thenReturn(true);
    when(instrumentation.getAllLoadedClasses()).thenReturn(new Class<?>[]{REDEFINED});
    when(instrumentation.isModifiableClass(REDEFINED)).thenReturn(true);
    when(typeMatcher.matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), REDEFINED, REDEFINED.getProtectionDomain()))
            .thenThrow(exception);
    ResettableClassFileTransformer classFileTransformer = new AgentBuilder.Default(byteBuddy)
            .with(initializationStrategy)
            .with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
            .with(poolStrategy)
            .with(typeStrategy)
            .with(installationListener)
            .with(listener)
            .disableNativeMethodPrefix()
            .ignore(none())
            .type(typeMatcher).transform(transformer)
            .installOn(instrumentation);
    verify(instrumentation).addTransformer(classFileTransformer, true);
    verify(listener).onError(REDEFINED.getName(), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true, exception);
    verify(listener).onComplete(REDEFINED.getName(), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true);
    verifyNoMoreInteractions(listener);
    verify(installationListener).onBeforeInstall(instrumentation, classFileTransformer);
    verify(installationListener).onInstall(instrumentation, classFileTransformer);
    verifyNoMoreInteractions(installationListener);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:28,代码来源:AgentBuilderDefaultTest.java


示例16: testSuccessfulWithRedefinitionMatchedFallback

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Test
public void testSuccessfulWithRedefinitionMatchedFallback() throws Exception {
    when(typeMatcher.matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), REDEFINED, REDEFINED.getProtectionDomain()))
            .thenThrow(new RuntimeException());
    when(typeMatcher.matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), null, REDEFINED.getProtectionDomain()))
            .thenReturn(true);
    when(resolution.resolve()).thenReturn(new TypeDescription.ForLoadedType(REDEFINED));
    when(instrumentation.isModifiableClass(REDEFINED)).thenReturn(true);
    when(instrumentation.isRedefineClassesSupported()).thenReturn(true);
    ResettableClassFileTransformer classFileTransformer = new AgentBuilder.Default(byteBuddy)
            .with(initializationStrategy)
            .with(AgentBuilder.RedefinitionStrategy.REDEFINITION)
            .with(poolStrategy)
            .with(typeStrategy)
            .with(installationListener)
            .with(AgentBuilder.FallbackStrategy.Simple.ENABLED)
            .with(listener)
            .disableNativeMethodPrefix()
            .ignore(none())
            .type(typeMatcher).transform(transformer)
            .installOn(instrumentation);
    verifyZeroInteractions(listener);
    verify(instrumentation).addTransformer(classFileTransformer, false);
    verify(instrumentation).getAllLoadedClasses();
    verify(instrumentation).isModifiableClass(REDEFINED);
    verify(instrumentation).redefineClasses(any(ClassDefinition.class));
    verify(instrumentation).isRedefineClassesSupported();
    verifyNoMoreInteractions(instrumentation);
    verify(typeMatcher).matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), REDEFINED, REDEFINED.getProtectionDomain());
    verify(typeMatcher).matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), null, REDEFINED.getProtectionDomain());
    verifyNoMoreInteractions(typeMatcher);
    verifyZeroInteractions(initializationStrategy);
    verify(installationListener).onBeforeInstall(instrumentation, classFileTransformer);
    verify(installationListener).onInstall(instrumentation, classFileTransformer);
    verifyNoMoreInteractions(installationListener);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:37,代码来源:AgentBuilderDefaultTest.java


示例17: matches

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public boolean matches(TypeDescription typeDescription,
                       ClassLoader classLoader,
                       JavaModule module,
                       Class<?> classBeingRedefined,
                       ProtectionDomain protectionDomain) {
    return classBeingRedefined == null == unloaded;
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:9,代码来源:AgentBuilder.java


示例18: testSuccessfulWithRedefinitionMatchedFallbackAndReset

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Test
public void testSuccessfulWithRedefinitionMatchedFallbackAndReset() throws Exception {
    when(typeMatcher.matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), REDEFINED, REDEFINED.getProtectionDomain()))
            .thenThrow(new RuntimeException());
    when(typeMatcher.matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), null, REDEFINED.getProtectionDomain()))
            .thenReturn(true);
    when(resolution.resolve()).thenReturn(new TypeDescription.ForLoadedType(REDEFINED));
    when(instrumentation.isModifiableClass(REDEFINED)).thenReturn(true);
    when(instrumentation.isRedefineClassesSupported()).thenReturn(true);
    ResettableClassFileTransformer classFileTransformer = new AgentBuilder.Default(byteBuddy)
            .with(initializationStrategy)
            .with(AgentBuilder.RedefinitionStrategy.REDEFINITION)
            .with(poolStrategy)
            .with(typeStrategy)
            .with(installationListener)
            .with(AgentBuilder.FallbackStrategy.Simple.ENABLED)
            .with(listener)
            .disableNativeMethodPrefix()
            .ignore(none())
            .type(typeMatcher).transform(transformer)
            .installOn(instrumentation);
    when(instrumentation.removeTransformer(classFileTransformer)).thenReturn(true);
    assertThat(classFileTransformer.reset(instrumentation, AgentBuilder.RedefinitionStrategy.REDEFINITION), is(true));
    verifyZeroInteractions(listener);
    verify(instrumentation).addTransformer(classFileTransformer, false);
    verify(instrumentation).removeTransformer(classFileTransformer);
    verify(instrumentation, times(2)).getAllLoadedClasses();
    verify(instrumentation, times(2)).isModifiableClass(REDEFINED);
    verify(instrumentation, times(2)).redefineClasses(any(ClassDefinition.class));
    verify(instrumentation, times(2)).isRedefineClassesSupported();
    verifyNoMoreInteractions(instrumentation);
    verify(typeMatcher, times(2)).matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), REDEFINED, REDEFINED.getProtectionDomain());
    verify(typeMatcher, times(2)).matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), null, REDEFINED.getProtectionDomain());
    verifyNoMoreInteractions(typeMatcher);
    verify(installationListener).onBeforeInstall(instrumentation, classFileTransformer);
    verify(installationListener).onInstall(instrumentation, classFileTransformer);
    verify(installationListener).onReset(instrumentation, classFileTransformer);
    verifyNoMoreInteractions(installationListener);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:40,代码来源:AgentBuilderDefaultTest.java


示例19: transform

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder,
                                        TypeDescription typeDescription,
                                        ClassLoader classLoader,
                                        JavaModule module) {
    return builder.constructor(ElementMatchers.any()).intercept(SuperMethodCall.INSTANCE);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:8,代码来源:AgentBuilderDefaultApplicationTest.java


示例20: testResolvableMatches

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Test
public void testResolvableMatches() throws Exception {
    assertThat(AgentBuilder.RawMatcher.ForResolvableTypes.INSTANCE.matches(new TypeDescription.ForLoadedType(Foo.class),
            Foo.class.getClassLoader(),
            JavaModule.ofType(Foo.class),
            Foo.class,
            Foo.class.getProtectionDomain()), is(true));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:9,代码来源:RawMatcherForResolvableTypesTest.java



注:本文中的net.bytebuddy.utility.JavaModule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Password类代码示例发布时间:2022-05-22
下一篇:
Java DCEndElement类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap