apache / apache/maven-shade-plugin
[MSHADE-288] Class Signature involving inner classes is not processed correctly
- Dominant language
- Java
- Stars
- 188
- Forks
- 103
- Avg merge
- 16h 39m
- Merged PRs (30d)
- 4
Description
**[Søren Gjesse](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=sgjesse)** opened **[MSHADE-288](https://issues.apache.org/jira/browse/MSHADE-288?redirect=false)** and commented
The project https://github.com/square/haha re-package Guava and Trove as part of building. However this cause invalid class signatures to be generated. One example is the Guava class
com.google.common.collect.AbstractMultimap$EntrySet
The original class file have this class signature:
Lcom/google/common/collect/AbstractMultimap.Entries;Ljava/util/Set;>;
and the class re-packaging from com.google.common to com.squareup.haha.guava has this class signature:
Lcom/squareup/haha/guava/collect/AbstractMultimap.com/squareup/haha/guava/collect/AbstractMultimap$Entries;Ljava/util/Set;>;
which is not valid according to the specification
[https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.4](https://www.google.com/url?q=https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html%23jvms-4.3.4&sa=D&usg=AFQjCNEwyHbP2chG0jcbdAljds6pjTh4gw)
The .Entries part should not be changed to .com/squareup/haha/guava/collect/AbstractMultimap$Entries, but stay .Entries.
After building https://github.com/square/haha
$ git clone git@github.com:square/haha.git
$ git submodule sync
$ git submodule update --init --recursive
$ mvn clean install
There are quite a few of these class signatures in the jar:
$ find extracted_jar -type f | xargs javap -c -s -l -v | grep Signature | grep ".**//.**\.com.*"
Signature: #42 // Lcom/squareup/haha/guava/collect/AbstractMultimap.com/squareup/haha/guava/collect/AbstractMultimap$Entries;Ljava/util/Set;>;
Signature: #45 // (TK;Ljava/util/SortedSet;Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedCollection;)V
Signature: #57 // Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedCollection;Ljava/util/SortedSet;
Signature: #42 // Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedCollection;Ljava/util/Set;
Signature: #86 // (TK;Ljava/util/List;Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedCollection;)V
Signature: #97 // Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedCollection;Ljava/util/List;
Signature: #70 // Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedCollection.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedCollection$WrappedIterator;Ljava/util/ListIterator;
Signature: #102 // Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedCollection;
Signature: #93 // (TK;Ljava/util/Collection;Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedCollection;)V
Signature: #52 // Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$KeySet;Ljava/util/SortedSet;
Signature: #54 // Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$AsMap;Ljava/util/SortedMap;>;
Signature: #9 // (TK;Ljava/util/List;Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedCollection;)V
Signature: #18 // Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$WrappedList;Ljava/util/RandomAccess;
Signature: #25 // Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$Itr;>;
Signature: #19 // Lcom/squareup/haha/guava/collect/AbstractMapBasedMultimap.com/squareup/haha/guava/collect/AbstractMapBasedMultimap$Itr;
Signature: #47 // Lcom/squareup/haha/trove/THashMap.com/squareup/haha/trove/THashMap$MapBackedView;>;
Signature: #40 // Lcom/squareup/haha/trove/THashMap.com/squareup/haha/trove/THashMap$MapBackedView;
Signature: #30 // Lcom/squareup/haha/trove/THashMap.com/squareup/haha/trove/THashMap$MapBackedView;
This is based on the findings in https://issuetracker.google.com/80029761.
---
**Affects:** 2.4.3, 3.1.1
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue by building square/haha with Maven, then inspect the generated class Signature attributes with javap as shown in the report. Trace the Maven Shade Plugin's class-signature rewriting entry point; done means inner-class suffixes such as .Entries remain unchanged while enclosing class packages are relocated and the resulting signatures are valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100