HoneyHyeok / jarjar

Automatically exported from code.google.com/p/jarjar
0 stars 0 forks source link

Method annotations are not transformed #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Jar that includes an annotation class and a class that declares the 
annotation on a method (probably doesn't work for other annotated objects 
either)
2. Transform the jar changing the package name from one thing to another
3. The declared annotation still uses the old package name

What is the expected output? What do you see instead?
If I have an annotation class defined as follows:
package org.blah.function;

@Target( { ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Function {
    public String description() default "";
    public String group() default "";
    public boolean visibleInUI() default true;
}

And a class that declares the annotation on a method as follows:
package org.blah.function;
public class SimpleTest{
    @Function(group="Content")
    public boolean beginswith(String s, String prefix) {
        return s.startsWith(prefix);
    }
}

Then run jarjar transforming org.blah to com.mycompany.

The class file for the @Function annotation now has a package of 
com.mycompany.function

The class file for SimpleTest also now has a package of 
com.mycompany.function.  However, the annotation on the method is still 
org.blah.function.Function.

What version of the product are you using? On what operating system?
jarjar-1.0rc8.jar
Windows XP

Please provide any additional information below.

Original issue reported on code.google.com by jaysp...@gmail.com on 22 Nov 2008 at 6:31

GoogleCodeExporter commented 8 years ago
Can confirm this is an open issue with class-level annotations also.

Original comment by phil.h.s...@gmail.com on 3 Dec 2008 at 11:09

GoogleCodeExporter commented 8 years ago
This currently prevents applications that use Guice from using jarjar on the 
application.  After jarjar'ing the application, Guice complains that they 
annotaions are missing.

Original comment by bsoutham on 30 Jan 2009 at 12:31

GoogleCodeExporter commented 8 years ago
Funny story, I was using guice too.

Original comment by phil.h.s...@gmail.com on 30 Jan 2009 at 5:15

GoogleCodeExporter commented 8 years ago
I'm trying to Jar Jar the google collections API, most famous for it's
incompatibilities over the years.  

And I am having the seeing the same issue with the 1.0 rc2 version.

Has anyone found a workaround?

Original comment by ksaranta...@gmail.com on 4 Aug 2009 at 11:05

GoogleCodeExporter commented 8 years ago
I hit the same problem, have done some investigation, and have an initial patch.

The issue seems to be in ASM, used by jarjar for the renaming of types.  It 
variously
doesn't attempt to rename annotation related types or calls what seems to be the
wrong method to do so (mapType calls that I think should be mapDesc).

I attach two patches - one for ASM that fixes the issue for me, and another for
jarjar with a test for annotation repackaging.  The test would probably now be 
better
rewritten as an ASM test.  I patched ASM from the 3.1 tag but it also applies 
cleanly
to trunk (not otherwise tested).

To test the patch you need to build and replace jarjar's 
lib/asm-commons-3.1.jar.

I guess the next step is to raise an ASM bug.  I'll leave that for the moment 
in case
someone here wants to pick that up.

Original comment by matt%hil...@gtempaccount.com on 15 Nov 2009 at 11:55

Attachments:

GoogleCodeExporter commented 8 years ago
I have submitted a bug for this to the asm issue tracker here -
http://forge.ow2.org/tracker/index.php?func=detail&aid=314481&group_id=23&atid=1
00023

Original comment by prashant...@gmail.com on 18 Nov 2009 at 7:00

GoogleCodeExporter commented 8 years ago
(m...@hillsdon.net) commentor 5 - could you post your updated fixed copy of the 
jarjarlinks jar here?

Original comment by prashant...@gmail.com on 18 Nov 2009 at 9:52

GoogleCodeExporter commented 8 years ago
Attached.  This is jarjar trunk r128 with asm-commons 3.1 with my patch.

I'm new to both jarjar and ASM so I'd advise waiting for some review before 
using it
for anything other than testing.

Original comment by matt%hil...@gtempaccount.com on 18 Nov 2009 at 10:40

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks a lot. It seems to work for me.

Original comment by prashant...@gmail.com on 19 Nov 2009 at 7:04

GoogleCodeExporter commented 8 years ago
Ok it seems asm framework has committed your patch.
http://forge.ow2.org/tracker/?func=detail&atid=100023&aid=314481&group_id=23

Original comment by prashant...@gmail.com on 22 Nov 2009 at 8:39

GoogleCodeExporter commented 8 years ago
For the record the patch was committed to asm trunk in r1412.

Original comment by matt%hil...@gtempaccount.com on 22 Nov 2009 at 10:09

GoogleCodeExporter commented 8 years ago
ASM 3.3 has now been released, which includes the fix from above.

Original comment by matt%hil...@gtempaccount.com on 30 May 2010 at 6:12

GoogleCodeExporter commented 8 years ago

Original comment by hayward.chan on 10 Feb 2011 at 12:28

GoogleCodeExporter commented 8 years ago
1.1 should fix this (by upgrading asm from 3.1 to 3.3.1).

Original comment by hayward.chan on 10 Feb 2011 at 12:49