Skip to content

Commit

Permalink
Removed ModifierTransformer and added MethodTransformer that allows f…
Browse files Browse the repository at this point in the history
…or more generic transformation.
  • Loading branch information
Rafael Winterhalter committed Aug 4, 2015
1 parent b53de98 commit 76ff47b
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 574 deletions.
33 changes: 22 additions & 11 deletions byte-buddy-dep/src/main/java/net/bytebuddy/ByteBuddy.java
Expand Up @@ -12,7 +12,7 @@
import net.bytebuddy.description.type.generic.GenericTypeList; import net.bytebuddy.description.type.generic.GenericTypeList;
import net.bytebuddy.dynamic.ClassFileLocator; import net.bytebuddy.dynamic.ClassFileLocator;
import net.bytebuddy.dynamic.DynamicType; import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.dynamic.ModifierResolver; import net.bytebuddy.dynamic.MethodTransformer;
import net.bytebuddy.dynamic.TargetType; import net.bytebuddy.dynamic.TargetType;
import net.bytebuddy.dynamic.scaffold.FieldRegistry; import net.bytebuddy.dynamic.scaffold.FieldRegistry;
import net.bytebuddy.dynamic.scaffold.InstrumentedType; import net.bytebuddy.dynamic.scaffold.InstrumentedType;
Expand Down Expand Up @@ -1420,6 +1420,8 @@ public static class MethodAnnotationTarget extends Proxy {
*/ */
protected final MethodAttributeAppender.Factory attributeAppenderFactory; protected final MethodAttributeAppender.Factory attributeAppenderFactory;


protected final MethodTransformer methodTransformer;

/** /**
* Creates a new method annotation target. * Creates a new method annotation target.
* *
Expand Down Expand Up @@ -1458,7 +1460,8 @@ protected MethodAnnotationTarget(ClassFileVersion classFileVersion,
MethodAttributeAppender.Factory defaultMethodAttributeAppenderFactory, MethodAttributeAppender.Factory defaultMethodAttributeAppenderFactory,
LatentMethodMatcher methodMatcher, LatentMethodMatcher methodMatcher,
MethodRegistry.Handler handler, MethodRegistry.Handler handler,
MethodAttributeAppender.Factory attributeAppenderFactory) { MethodAttributeAppender.Factory attributeAppenderFactory,
MethodTransformer methodTransformer) {
super(classFileVersion, super(classFileVersion,
namingStrategy, namingStrategy,
auxiliaryTypeNamingStrategy, auxiliaryTypeNamingStrategy,
Expand All @@ -1474,6 +1477,7 @@ protected MethodAnnotationTarget(ClassFileVersion classFileVersion,
this.methodMatcher = methodMatcher; this.methodMatcher = methodMatcher;
this.handler = handler; this.handler = handler;
this.attributeAppenderFactory = attributeAppenderFactory; this.attributeAppenderFactory = attributeAppenderFactory;
this.methodTransformer = methodTransformer;
} }


/** /**
Expand All @@ -1499,7 +1503,8 @@ public MethodAnnotationTarget attribute(MethodAttributeAppender.Factory attribut
defaultMethodAttributeAppenderFactory, defaultMethodAttributeAppenderFactory,
methodMatcher, methodMatcher,
handler, handler,
new MethodAttributeAppender.Factory.Compound(this.attributeAppenderFactory, nonNull(attributeAppenderFactory))); new MethodAttributeAppender.Factory.Compound(this.attributeAppenderFactory, nonNull(attributeAppenderFactory)),
methodTransformer);
} }


/** /**
Expand Down Expand Up @@ -1587,7 +1592,7 @@ protected ByteBuddy materialize() {
interfaceTypes, interfaceTypes,
ignoredMethods, ignoredMethods,
classVisitorWrapperChain, classVisitorWrapperChain,
methodRegistry.prepend(methodMatcher, handler, attributeAppenderFactory), methodRegistry.prepend(methodMatcher, handler, attributeAppenderFactory, methodTransformer),
modifiers, modifiers,
typeAttributeAppender, typeAttributeAppender,
methodGraphCompiler, methodGraphCompiler,
Expand All @@ -1607,7 +1612,8 @@ public boolean equals(Object other) {
MethodAnnotationTarget that = (MethodAnnotationTarget) other; MethodAnnotationTarget that = (MethodAnnotationTarget) other;
return attributeAppenderFactory.equals(that.attributeAppenderFactory) return attributeAppenderFactory.equals(that.attributeAppenderFactory)
&& handler.equals(that.handler) && handler.equals(that.handler)
&& methodMatcher.equals(that.methodMatcher); && methodMatcher.equals(that.methodMatcher)
&& methodTransformer.equals(that.methodTransformer);
} }


@Override @Override
Expand All @@ -1616,6 +1622,7 @@ public int hashCode() {
result = 31 * result + methodMatcher.hashCode(); result = 31 * result + methodMatcher.hashCode();
result = 31 * result + handler.hashCode(); result = 31 * result + handler.hashCode();
result = 31 * result + attributeAppenderFactory.hashCode(); result = 31 * result + attributeAppenderFactory.hashCode();
result = 31 * result + methodTransformer.hashCode();
return result; return result;
} }


Expand All @@ -1637,6 +1644,7 @@ public String toString() {
", methodMatcher=" + methodMatcher + ", methodMatcher=" + methodMatcher +
", handler=" + handler + ", handler=" + handler +
", attributeAppenderFactory=" + attributeAppenderFactory + ", attributeAppenderFactory=" + attributeAppenderFactory +
", methodTransformer=" + methodTransformer +
'}'; '}';
} }
} }
Expand Down Expand Up @@ -2354,8 +2362,9 @@ public MethodAnnotationTarget intercept(Implementation implementation) {
defaultFieldAttributeAppenderFactory, defaultFieldAttributeAppenderFactory,
defaultMethodAttributeAppenderFactory, defaultMethodAttributeAppenderFactory,
methodMatcher, methodMatcher,
new MethodRegistry.Handler.ForImplementation(nonNull(implementation), ModifierResolver.Retaining.INSTANCE), new MethodRegistry.Handler.ForImplementation(nonNull(implementation)),
MethodAttributeAppender.NoOp.INSTANCE); MethodAttributeAppender.NoOp.INSTANCE,
MethodTransformer.Retaining.INSTANCE);
} }


@Override @Override
Expand All @@ -2373,8 +2382,9 @@ public MethodAnnotationTarget withoutCode() {
defaultFieldAttributeAppenderFactory, defaultFieldAttributeAppenderFactory,
defaultMethodAttributeAppenderFactory, defaultMethodAttributeAppenderFactory,
methodMatcher, methodMatcher,
new MethodRegistry.Handler.ForAbstractMethod(ModifierResolver.Retaining.INSTANCE), MethodRegistry.Handler.ForAbstractMethod.INSTANCE,
MethodAttributeAppender.NoOp.INSTANCE); MethodAttributeAppender.NoOp.INSTANCE,
MethodTransformer.Retaining.INSTANCE);
} }


@Override @Override
Expand All @@ -2397,8 +2407,9 @@ public MethodAnnotationTarget withDefaultValue(Object value) {
defaultFieldAttributeAppenderFactory, defaultFieldAttributeAppenderFactory,
defaultMethodAttributeAppenderFactory, defaultMethodAttributeAppenderFactory,
methodMatcher, methodMatcher,
MethodRegistry.Handler.ForAnnotationValue.of(value, ModifierResolver.Retaining.INSTANCE), MethodRegistry.Handler.ForAnnotationValue.of(value),
MethodAttributeAppender.NoOp.INSTANCE); MethodAttributeAppender.NoOp.INSTANCE,
MethodTransformer.Retaining.INSTANCE);
} }


/** /**
Expand Down

0 comments on commit 76ff47b

Please sign in to comment.