Java Code Examples for net.bytebuddy.description.type.TypeDescription#getName()

The following examples show how to use net.bytebuddy.description.type.TypeDescription#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformerInvokerGenerator.java    From Diorite with MIT License 6 votes vote down vote up
@Override
        public ClassVisitor wrap(TypeDescription typeDescription, ClassVisitor cv, Context context, TypePool typePool,
                                 FieldList<FieldDescription.InDefinedShape> fieldList, MethodList<?> methodList, int i, int i1)
        {
//            public void visit(int version, int modifiers, String name, String signature, String superName, String[] interfaces) {
            cv.visit(ClassFileVersion.JAVA_V9.getMinorMajorVersion(), typeDescription.getModifiers(), typeDescription.getInternalName(), null,
                     typeDescription.getSuperClass().asErasure().getInternalName(), typeDescription.getInterfaces().asErasures().toInternalNames());
            TypeDescription clazz = this.clazz;
            String internalName = clazz.getInternalName();
            String descriptor = clazz.getDescriptor();
            MethodList<InDefinedShape> declaredMethods = clazz.getDeclaredMethods();
            int methodsSize = declaredMethods.size();
            String implName = GENERATED_PREFIX + "." + clazz.getName();
            String internalImplName = GENERATED_PREFIX.replace('.', '/') + "/" + internalName;
            String descriptorImplName = "L" + GENERATED_PREFIX.replace('.', '/') + "/" + internalName + ";";

            FieldVisitor fv;
            MethodVisitor mv;
            AnnotationVisitor av0;

            cv.visitEnd();
            return cv;
        }
 
Example 2
Source File: ByteBuddyManager.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
@Override
public void onTransformation(final TypeDescription typeDescription, final ClassLoader classLoader, final JavaModule module, final boolean loaded, final DynamicType dynamicType) {
  if (events[Event.TRANSFORMATION.ordinal()] != null)
    log(Level.SEVERE, "Event::onTransformation(" + typeDescription.getName() + ", " + AssembleUtil.getNameId(classLoader) + ", " + module + ", " + loaded + ", " + dynamicType + ")");

  // FIXME: Should remove the `pluginManifest != null` condition, because a pluginManifest here should be required!
  // FIXME: How to communicate an error here? Cause ByteBuddy swallows all exceptions in this context.
  final PluginManifest pluginManifest = this.pluginManifest != null ? this.pluginManifest : AgentRule.getPluginManifest(typeDescription);
  if (pluginManifest != null && !SpecialAgent.linkRule(pluginManifest, classLoader))
    throw new IncompatiblePluginException(typeDescription.getName());

  if (classLoader != null) {
    try {
      final JavaModule unnamedModule = JavaModule.of(ClassLoader.class.getMethod("getUnnamedModule").invoke(classLoader));
      if (!module.canRead(unnamedModule)) {
        module.modify(inst, Collections.singleton(unnamedModule), Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_SET, Collections.EMPTY_MAP);
        if (logger.isLoggable(Level.FINEST))
          logger.finest("Added module reads: " + module + " -> " + unnamedModule);
      }
    }
    catch (final NoSuchMethodException e) {
    }
    catch (final Throwable t) {
      logger.log(Level.SEVERE, t.getMessage(), t);
    }
  }
}
 
Example 3
Source File: NamingStrategy.java    From byte-buddy with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public String redefine(TypeDescription typeDescription) {
    return typeDescription.getName();
}
 
Example 4
Source File: NamingStrategy.java    From byte-buddy with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public String rebase(TypeDescription typeDescription) {
    return typeDescription.getName();
}
 
Example 5
Source File: NamingStrategy.java    From byte-buddy with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public String resolve(TypeDescription typeDescription) {
    return typeDescription.getName();
}
 
Example 6
Source File: NamingStrategy.java    From byte-buddy with Apache License 2.0 4 votes vote down vote up
@Override
protected String name(TypeDescription superClass) {
    return prefix + "." + superClass.getName() + "$" + randomString.nextString();
}
 
Example 7
Source File: ToStringMethod.java    From byte-buddy with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
public String resolve(TypeDescription instrumentedType) {
    return instrumentedType.getName();
}
 
Example 8
Source File: AuxiliaryType.java    From byte-buddy with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public String name(TypeDescription instrumentedType) {
    return instrumentedType.getName() + "$" + suffix + "$" + randomString.nextString();
}