Re: How to find out if Remapper / ClassRemapper actually remapped anything?

"\"Alexander Kriegisch\"" (via asm Mailing List) <[email protected]> Sat, 22 May 2021 13:03:42 +0200 (CEST)
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
This is a multi-part message in MIME format...

------------=_1621681426-7718-6
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

That is basically what I ended up doing. The only disadvantage in my
specific situation was that there was only one remapper instance used
for multiple files. So I had to use a thread-local variable in order to
store a boolean state, because theoretically multiple threads could call
the same remapper concurrently. But other than that being somewhat ugly,
it works nicely. I wanted to avoid refactoring in such a way as to use
one remapper per file, so that is a decision the consequences of which I
have to live with, because I made the decision like that. That is not a
problem of ASM as such, of course.

Thanks for your advice. :-)

-- 
Alexander Kriegisch
https://scrum-master.de


ebruneton schrieb am 22.05.2021 16:51 (GMT +07:00):

> Hi,
> 
> Can't you use your own Remapper or SimplerRemapper subclass, to check 
> whether any call to its method return a remapped name?
> 
> Le 2021-05-20 05:41, "Alexander Kriegisch" a écrit :
>> Hello.
>> 
>> This might be a naive question, but is there a simple (or not so 
>> simple,
>> if necessary) way to find out if a ClassRemapper or Remapper actually
>> did remap anything?
>> 
>> Background: I am using Maven Shade Plugin, which in turn uses ASM in
>> order to implement relocating packages. For that purpose is provides a
>> 
>>>>> RelocatorRemapper extends Remapper
>> 
>> If a plugin configuration contains any relocation rules, Maven Shade
>> will either replace package names in Java source files or - if the
>> target file is a class file - pass the class through to Remapper in
>> order too do the magic. So far, so good, this works nicely.
>> 
>> Now here is my problem: In build verification steps I would like to
>> check which classes were actually remapped, at least for some expected
>> relocations. Negative tests would check thatt other classes remain
>> unchanged. But the latter does not work, because Shade passes through
>> all classes, which often changes them, because e.g. the constant pool
>> gets overwritten, even if no actual relocation took place because the
>> target class neither needs to be relocated itself nor 
>> imports/references
>> another relocated class. But still, the byte code looks different, i.e.
>> a simple checksum comparison between the class files before and after
>> the (basically and semantically no-op) relocation yields a difference.
>> 
>> My idea was to try and create a pull request for Maven Shade which
>> writes the original class into the resulting JAR file, if the relocator
>> (and hence the remapper) did not effectively change anything. Do you
>> have any suggestion how to do that?
>> 
>> Thanks in advance
>> 
>> --
>> You receive this message as a subscriber of the [email protected] mailing 
>> list.
>> To unsubscribe: mailto:[email protected]
>> For general help: mailto:[email protected]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
> 
> 
> -- 
> You receive this message as a subscriber of the [email protected] mailing list.
> To unsubscribe: mailto:[email protected]
> For general help: mailto:[email protected]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
> 

------------=_1621681426-7718-6
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

------------=_1621681426-7718-6--