Thanks for the feedback.

On 07/31/2013 04:32 PM, Jesse Glick wrote:
On Tue, Jul 30, 2013 at 7:38 PM, Kohsuke Kawaguchi
<[email protected]> wrote:
    @AdaptField
    protected volatile DescribableList<...> triggers = ...

    @AdaptField("DESCRIPTOR")
    @Restricted(NoExternalUse.class)
    public static DescriptorImpl _getDescriptor() {
       return ...;
    }

From an API design perspective this seems like an overly specific
(inflexible) annotation; there are a bunch of kinds of signature
change that people commonly want to make for which bytecode
transformation of clients would be necessary, and this annotation
seems to cover just two. (Changing field type, and replacing final
field access with a method call.)

Can we instead define a general annotation to be applied to any member
whose signature has changed (or which has a nested element whose
signature has changed or been removed), with a reference to a
transformation? This would let people write modules offering fixes for
other changes like renamed methods, etc.:

@Transformed(by=MethodRenamed.class, info="toURL")
public URL toUrl() {…}

I think this would be better served as a set of annotations with a common meta-annotation. I've modified the code accordingly and pushed the change.

Not letting the client code write their own transformers is actually a conscious choice. This is because ASM changes signatures with every class file revision.

If we want to add more transformation rules, let's add them to this library.


Here @Transformed would be the general marker which class loaders
could scan for (or which could even be indexed during compilation for
runtime efficiency); MethodRenamed would implement the specific
bytecode changes; and the option "toURL" (i.e. previous name) could be
passed to the transformer. Specifically:

@Retention(CLASS)
@interface Transformed {
   Class<? extends Transformer> by();
   String[] info() default {};
}

Maybe too much work to justify the effort, but thought I would put it out there.



--
Kohsuke Kawaguchi | CloudBees, Inc. | http://cloudbees.com/
Try Jenkins Enterprise, our professional version of Jenkins

--
You received this message because you are subscribed to the Google Groups "Jenkins 
Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to