apache / apache/maven-shade-plugin

[MSHADE-436] Skips relocation of dependencies if not referenced from class body.

Open
#458 0 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
188
Forks
103
Avg merge
16h 39m
Merged PRs (30d)
4

Description

**[Andres Luuk](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mysticel)** opened **[MSHADE-436](https://issues.apache.org/jira/browse/MSHADE-436?redirect=false)** and commented

So I have a class like this:

import static org.objectweb.asm.Opcodes.*;

public class CheckUtil {

  public static boolean isPrivate(int access) {
    return (access & ACC_PRIVATE) == ACC_PRIVATE;
  }
}

At compile time Opcodes is inlined. So nothing in the class should reference the class.

But If I look at the javap of CheckUtil.class I see the following:

Constant pool:
    #1 = Class              #2            // org/objectweb/asm/Opcodes
    #2 = Utf8               org/objectweb/asm/Opcodes

Nothing in the method body/later references Opcodes!

Now with shade plugin I want to relocation the package of Opcodes.

Whit shade 3.2.4 the reference was stripped and was not present in the shaded jar, but now with 3.3.0+ the original not-relocation Opcodes is still present in the constant pool of that class.

Maybe stripping the Opcodes was wrong, but in case you don't strip it, you should probably relocation it even it the class body does not reference the class if the class is in the relocation list.

We have a shade & relocation into proguard job, where proguard starts to complain that the input shaded jar to the original not-relocation Opcodes.

 

---

**Affects:** 3.3.0, 3.4.0, 3.4.1

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with the CheckUtil example using Maven Shade Plugin 3.3.0+ and inspect the shaded class with javap. Compare the relocation result with 3.2.4, focusing on the unused Opcodes constant-pool entry and the ProGuard warning. Done means the referenced class is handled consistently with the relocation list and the resulting shaded JAR no longer triggers the reported original-package complaint.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.