-
Notifications
You must be signed in to change notification settings - Fork 412
The plugin changes constants with values similar to package names #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah, the relocation code is ported from Maven Shade which exhibits this same problem: I'll have to think about how best to tackle this. Those tickets have been open for 3 years and they haven't come up with a better solution. So, this might take a while for me to get something I'm happy with. |
I see. |
Are there updates on this issue? Is there any workaround for it? |
I'm having a similar issue, but it's worse because the strings in question are very clearly NOT package names - they just happen to start with something that could be a package name. The package is "redis" (the root package of the Jedis client - it's nonstandard, but unfortunately that's what they chose) and the string is a Redis URL string, "redis://localhost:6379". When I shade the Jedis dependency using a prefix of "xxx.shaded", my string becomes "xxx/shaded/redis://localhost:6379". Surely it ought to be possible to know that that wasn't a class/package path, given the double slash. |
I see two ways of addressing this that I would be happy to accept PRs for.
|
I think 2 sounds good— someone's inevitably going to have some strings in their code that will look like valid class names but aren't (the original reporter of this issue had some). |
That would be super helpful. We're doing a Gradle plugin that generates code so it contains a lot of Ultimately, something like GraalVM native image reflection support would be nice albeit considerably more work |
I am facing a similar problem: relocate 'io.netty','thirdparty.io.netty' I found string literals affected by this shading which caused some runtime errors with the netty dependency. The following string literal is defined in the original dependency: In the shaded jar, this string literal is changed to: Is there any way I can prevent this behavior of changing the string literals? |
Based on previous responses, it sounds like a workaround won't be implemented until someone contributes a PR. |
|
I am still experiencing this bug with my project, which uses Gradle 7.5.1 and Shadow 7.1.2. |
We now understand the root problem thanks to DennisTsar's investigation. The shadow plugin was by chance affecting a private variable deep inside the coroutine library (named completedExpandBuffersAndPauseFlag) which matched "com", even though we only expected relocations to work on packages. As a result, we add the "com" relocation back in, plus trailing "." suffixes to prevent accidental matching. See also: GradleUp/shadow#232 And also: https://issues.apache.org/jira/browse/MSHADE-156
Hi folks, Joining the party late :) I'm having a similar/same issue trying to relocate
With this I ended up having strings like I believe this is the exact same problem (maybe more like this), so just adding more info for future reference. |
Having a similar issue here
is interpreted as
I am curious though when is this going to be triggered; I tried excluding the package containing this static field but it did not work
|
I am also having this issue |
No update so far? This issue was opened in 2016. |
I would assume the transition to gradleup probably didn't help visibility to the devs. I'm hoping for a solution, but the solution I've received from peers is just to use something other than shadow. Would be glad to return once this gets fixed |
for anyone who is struggling, I managed to disable the remapping of the one constant causing me trouble by creating a custom relocator and returning the original value only for that constant. |
Shadow Version 1.2.3
Gradle Version 2.14
Expected Behavior: There will be an option to control this behavior, preferably using filters
Actual Behavior: All constants are changed
For example
Before Shadow:
public static final String AttributePrefix = "org.mypackage";
After Shadow
public static final String AttributePrefix = "shadow.mypackage";
The text was updated successfully, but these errors were encountered: