shadow icon indicating copy to clipboard operation
shadow copied to clipboard

Modifying string constants as part of relocating packages

Open shalom938 opened this issue 8 years ago • 1 comments

Shadow Version

2.0.2

Gradle Version

4.3

In a java agent we are developing we are trying to relocate the aspectjrt and aspectjweaver packages but it looks impossible because aspectj weaver uses string constants to test if a class is an aspect. something like that: public final static UnresolvedType ASPECT_ANNOTATION = UnresolvedType.forSignature("Lorg/aspectj/lang/annotation/Aspect;"

I've tried various suggestions like exclusion of some packages but nothing worked. The aspectj project lead suggested that "It seems reasonably robust to modify Lorg/aspectj/lang prefixed strings to Lshadow/org/aspectj/lang"

My question is if that seems reasonable to implements something like that as part of shadow plugin? or what would be the correct way to hook into the plugin and implement that as a gradle task?

Thank you

shalom938 avatar Jan 04 '18 12:01 shalom938

Related to #232.

Goooler avatar Mar 03 '25 08:03 Goooler

You can declare a const and refer to it; the string const could be relocated.

private static final TYPE = "foo.Bar".

public static final UnresolvedType U_TYPE = UnresolvedType.forSignature("foo.Bar".replace(".", "/"));

Goooler avatar Aug 06 '25 10:08 Goooler