当前位置: 首页>>代码示例>>Java>>正文


Java TypeDescription类代码示例

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


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

示例1: transform

import net.bytebuddy.description.type.TypeDescription; //导入依赖的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: result

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
@Override
public final Result<StackManipulation> result() {
    final TypeDescription declaringType = field.getDeclaringType().asErasure();
    final TypeDescription fieldType = field.getType().asErasure();
    if(new NaturalJavaAtom().matches(fieldType)) {
        return new SmtInvokeMethod(
            new TypeDescription.ForLoadedType(Object.class),
            ElementMatchers.named("equals")
        );
    } else {
        return new SmtInvokeMethod(
            declaringType,
            new ConjunctionMatcher<>(
                ElementMatchers.isSynthetic(),
                ElementMatchers.named("atom$equal")
            )
        );
    }
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:20,代码来源:SmtCompareAtomFields.java

示例3: EnforcingAtomPlugin

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
public EnforcingAtomPlugin() {
    super(
        new BtApplyIfMatches(
            new ConjunctionMatcher<TypeDescription>(
                not(new AnnotatedNonAtom()),
                not(new AnnotatedAtom()),
                not(isInterface())
            ),
            new BtConditional(
                new ExplicitlyExtendingAnything(),
                new BtApplyAtomAliasPatch(),
                new BtApplyAtomPatch()
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:17,代码来源:EnforcingAtomPlugin.java

示例4: matches

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
@Override
public final boolean matches(TypeDescription target) {
    MethodList<MethodDescription.InDefinedShape> methodsToCheck = target.getDeclaredMethods()
            .filter(not(isConstructor()))
            .filter(isPublic())
            .filter(not(isStatic()))
            .filter(not(isBridge()))
            .filter(not(named("equals")))
            .filter(not(named("hashCode")))
            .filter(not(named("toString")));
    
    for(MethodDescription md : methodsToCheck) {
        if(!md.isFinal()) {
            return false;
        }
    }
    return true;
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:19,代码来源:AllMethodsAreFinal.java

示例5: check

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
@Override
public final void check() throws Exception {
    final TypeDescription typeDescription = new TypeDescription.ForLoadedType(clazz);
    final DynamicType.Builder<?> subclass = new ByteBuddy().redefine(clazz);
    final DynamicType.Unloaded<?> make = bt
            .transitionResult(subclass, typeDescription)
            .value()
            .get()
            .make();
    final Class<?> newClazz = make.load(new AnonymousClassLoader()).getLoaded();
    assertThat(
        List.of(newClazz.getDeclaredMethods()).map(Method::getName)
    ).containsOnlyElementsOf(
        methodNames
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:17,代码来源:AssertClassToHaveCertainMethodsAfterBuilderTransition.java

示例6: AssertValidatorSuccessTest

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
public AssertValidatorSuccessTest() {
    super(
        new TestCase(
            "passes when validator under test passes",
            new AssertAssertionPasses(
                new AssertValidatorSuccess(
                    new ValSuccess(),
                    new TypeDescription.ForLoadedType(Object.class)
                )
            )
        ),
        new TestCase(
            "fails when validator under test fails",
            new AssertAssertionFails(
                new AssertValidatorSuccess(
                    new ValFail(
                        "Just as planned"
                    ),
                    new TypeDescription.ForLoadedType(Object.class)
                )
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:25,代码来源:AssertValidatorSuccessTest.java

示例7: AssertValidatorFailureTest

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
public AssertValidatorFailureTest() {
    super(
        new TestCase(
            "passes when validator fails",
            new AssertAssertionPasses(
                new AssertValidatorFailure(
                    new ValFail("Just as planned"),
                    new TypeDescription.ForLoadedType(Object.class),
                    "Just as planned"
                )
            )
        ),
        new TestCase(
            "fails when validator passes",
            new AssertAssertionFails(
                new AssertValidatorFailure(
                    new ValSuccess(),
                    new TypeDescription.ForLoadedType(Object.class),
                    "Expected failure"
                )
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:25,代码来源:AssertValidatorFailureTest.java

示例8: SmtBoxTest

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
public SmtBoxTest() {
    super(
        new TestCase(
            "attempt to box non-primitive must fail",
            new AssertResultIsErroneous(
                new SmtBox(
                    new TypeDescription.ForLoadedType(Object.class)
                ),
                "Attempt to box non-primitive type java.lang.Object"
            )
        ),
        new TestCase(
            "can box integer primitive", 
            new AssertTokenToRepresentExpectedStackManipulation(
                new SmtBox(
                    new TypeDescription.ForLoadedType(int.class)
                ),
                () -> MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(INT_VALUEOF))
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:23,代码来源:SmtBoxTest.java

示例9: ExtendingTest

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
public ExtendingTest() {
    super(
        new TestCase(
            "matches types inherited from atom", 
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(
                    Bar.class
                ), 
                new Extending(
                    ElementMatchers.anyOf(Foo.class)
                )
            )
        ),
        new TestCase(
            "mismatch atoms",
            new AssertThatTypeDoesNotMatch(
                new TypeDescription.ForLoadedType(
                    Foo.class
                ), 
                new Extending(
                    ElementMatchers.anyOf(Foo.class)
                )
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:27,代码来源:ExtendingTest.java

示例10: IsNotAbstractTest

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
public IsNotAbstractTest() {
    super(
        new TestCase(
            "match non-abstract classes",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Foo.class),
                new IsNotAbstract()
            )
        ),
        new TestCase(
            "mismatch abstract classes",
            new AssertThatTypeDoesNotMatch(
                new TypeDescription.ForLoadedType(Bar.class),
                new IsNotAbstract()
            )
        ),
        new TestCase(
            "match enumeration types",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Faz.class),
                new IsNotAbstract()
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:26,代码来源:IsNotAbstractTest.java

示例11: NoMethodsTest

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
public NoMethodsTest() {
    super(
        new TestCase(
            "match type with no methods",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Foo.class),
                new NoMethods()
            )
        ),
        new TestCase(
            "mismatch type with at least one method",
            new AssertThatTypeDoesNotMatch(
                new TypeDescription.ForLoadedType(Bar.class),
                new NoMethods()
            )
        ),
        new TestCase(
            "match type ignoring methods declared in base class",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Barr.class),
                new NoMethods()
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:26,代码来源:NoMethodsTest.java

示例12: NoFieldsTest

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
public NoFieldsTest() {
    super(
        new TestCase(
            "match type with no fields",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Foo.class),
                new NoFields()
            )
        ),
        new TestCase(
            "mismatch type with at least one field",
            new AssertThatTypeDoesNotMatch(
                new TypeDescription.ForLoadedType(Bar.class),
                new NoFields()
            )
        ),
        new TestCase(
            "match type ignoring fields from the base class",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Barr.class),
                new NoFields()
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:26,代码来源:NoFieldsTest.java

示例13: createMatcher

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
private static ElementMatcher.Junction<TypeDescription> createMatcher() {
  // This matcher matches implementations of Executor, but excludes CurrentContextExecutor and
  // FixedContextExecutor from io.grpc.Context, which already propagate the context.
  // TODO(stschmidt): As the executor implementation itself (e.g. ThreadPoolExecutor) is
  // instrumented by the agent for automatic context propagation, CurrentContextExecutor could be
  // turned into a no-op to avoid another unneeded context propagation. Likewise, when using
  // FixedContextExecutor, the automatic context propagation added by the agent is unneeded.
  return isSubTypeOf(Executor.class)
      .and(not(isAbstract()))
      .and(
          not(
              nameStartsWith("io.grpc.Context$")
                  .and(
                      nameEndsWith("CurrentContextExecutor")
                          .or(nameEndsWith("FixedContextExecutor")))));
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:17,代码来源:ExecutorInstrumentation.java

示例14: UserCodeMethodInvocation

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
UserCodeMethodInvocation(
    @Nullable Integer returnVarIndex,
    MethodDescription targetMethod,
    MethodDescription instrumentedMethod) {
  this.returnVarIndex = returnVarIndex;
  this.targetMethod = targetMethod;
  this.instrumentedMethod = instrumentedMethod;
  this.returnType = targetMethod.getReturnType().asErasure();

  boolean targetMethodReturnsVoid = TypeDescription.VOID.equals(returnType);
  checkArgument(
      (returnVarIndex == null) == targetMethodReturnsVoid,
      "returnVarIndex should be defined if and only if the target method has a return value");

  try {
    createUserCodeException =
        new MethodDescription.ForLoadedMethod(
            UserCodeException.class.getDeclaredMethod("wrap", Throwable.class));
  } catch (NoSuchMethodException | SecurityException e) {
    throw new RuntimeException("Unable to find UserCodeException.wrap", e);
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:23,代码来源:ByteBuddyDoFnInvokerFactory.java

示例15: getAnnotations

import net.bytebuddy.description.type.TypeDescription; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public static Annotation[] getAnnotations(Collection<AnnotationDescription> annotations)
{
    Collection<Annotation> col = new ArrayList<>(annotations.size());
    for (AnnotationDescription annotation : annotations)
    {
        TypeDescription annotationType = annotation.getAnnotationType();
        try
        {
            Class<?> forName = Class.forName(annotationType.getActualName());
            if (! forName.isAnnotation())
            {
                continue;
            }
            col.add(annotation.prepare((Class) forName).load());
        }
        catch (ClassNotFoundException ignored)
        {
        }
    }
    return col.toArray(new Annotation[col.size()]);
}
 
开发者ID:Diorite,项目名称:Diorite,代码行数:23,代码来源:AsmUtils.java


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