Issue2806

classification
Title: Installer contains dependencies unshaded (Java 8)
Type: crash Severity: major
Components: Installer Versions: Jython 2.7
Milestone: Jython 2.7.2
process
Status: pending Resolution: fixed
Dependencies: Superseder:
Assigned To: jeff.allen Nosy List: jeff.allen
Priority: high Keywords:

Created on 2019-09-28.09:21:05 by jeff.allen, last changed 2019-10-05.08:17:52 by jeff.allen.

Messages
msg12662 (view) Author: Jeff Allen (jeff.allen) Date: 2019-09-28.09:21:05
When built with Java 8, although the developer build checks out ok, the installed version of Jython (in fact, the installation itself) fails with the message:

PS 272a-trial> java -jar kit\jython-installer.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/MapMaker
        at org.python.core.ThreadStateMapping.<clinit>(ThreadStateMapping.java:31)
        at org.python.core.Py.<clinit>(Py.java:1734)
        at org.python.core.PySystemState.<clinit>(PySystemState.java:72)
        at org.python.util.jython.main(jython.java:531)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.MapMaker
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 4 more

Investigation shows that the call is there are described:

PS jython-trunk> javap -c -cp dist/jython.jar org.python.core.ThreadStateMapping
...
 static {};
   Code:
      0: new           #40                 // class com/google/common/collect/MapMaker

The cause is in the jarjar task in our Ant build that is responsible for renaming dependencies we bundle in the JAR.

When the target JVM is 1.7, the all is well. (I'm still actually building with Oracle Java version 1.8.0_211, but jython.java.version = "1.7".)

PS jython-trunk> ant -D"jython.java.version=1.7" clean installer

(A clean is needed to force recompilation.) In this case, the same investigation shows the call has been renamed correctly:

PS 272a-trial> javap -c -cp inst/jython.jar org.python.core.ThreadStateMapping
...
  static {};
    Code:
       0: new           #179                // class org/python/google/common/collect/MapMaker

Actually, it is only necessary to build the jython.jar (jar-complete target) to see the effect in dist/jython.jar.

I wonder if this is simply a consequence of jarjar 1.4 using an old version of ASM. However, it is not completely obvious where to get the legitimate successor version of jarjar.

Maybe we compile with 8 for this release but target 7 in the generated code?
msg12674 (view) Author: Jeff Allen (jeff.allen) Date: 2019-10-02.21:18:15
The best successor I have found to jarjar 1.4 is from Pantsbuild (https://github.com/pantsbuild/jarjar). It uses ASM 7.0, although now as an external dependency, and it appears to do the trick.

Clearly no British people were involved in the naming of this project, or the team are extremely self-deprecating.
msg12676 (view) Author: Jeff Allen (jeff.allen) Date: 2019-10-05.08:17:52
I claim this is fixed at https://hg.python.org/jython/rev/1a493dfcd2f1
History
Date User Action Args
2019-10-05 08:17:52jeff.allensetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg12676
2019-10-02 21:18:15jeff.allensetassignee: jeff.allen
resolution: accepted
messages: + msg12674
2019-09-28 09:21:05jeff.allencreate