Issue547727

classification
Title: Class-path in jar manifest is ignored
Type: Severity: normal
Components: Core Versions: Jython 2.7, Jython 2.5
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: balldarrens, fwierzbicki, jeff.allen, zyasoft
Priority: low Keywords:

Created on 2002-04-23.19:24:05 by anonymous, last changed 2018-03-22.06:45:44 by jeff.allen.

Messages
msg648 (view) Author: Nobody/Anonymous (nobody) Date: 2002-04-23.19:24:05
Jython does not appear to support loading of jar files which are specified in the MANIFEST.MF file, 
via the Class-Path attribute.
msg649 (view) Author: Nobody/Anonymous (nobody) Date: 2004-01-23.20:55:11
Logged In: NO 

Here's a workaround.  Import JythonClassPathMagic before
accessing the
java code in the jar file manifest Class-Path.

Jeff Emanuel
jemanuel@lgc.com

JythonClassPathMagic.py:
import java,sys

# This adds the class path elements specified in jar file
manifests to
# the jython package manager so the java packages and
classes listed
# in the manifests can be imported in jython.

def handleJarClassPath(jcp,parent):
  for p in jcp.split():
    f = java.io.File(parent,p)
    if p[-1]=='/':
      sys.packageManager.addDirectory(f)
    else:
      sys.packageManager.addJar(f.canonicalPath,1)

classpath=java.lang.System.getProperty('java.class.path')
for element in
classpath.split(java.lang.System.getProperty('path.separator')):
  try:
    jar = java.util.jar.JarFile(element)
    if jar:
      if jar.manifest:
        jarAttrs = jar.manifest.mainAttributes
        jarClassPath =
jarAttrs[java.util.jar.Attributes.Name.CLASS_PATH]
        if jarClassPath:
          f=java.io.File(element)
          handleJarClassPath(jarClassPath,f.parentFile)

  except java.io.IOException:
    pass
msg4268 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-03-13.23:44:17
jythonc is no longer maintained.
msg4342 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-03-23.13:21:26
re-opening as Oti pointed out that this is also true for non-jythonc. 
I'm still leaving it as "low" though, since I don't know if this should
hold up 2.5.0
msg9718 (view) Author: Darren Ball (balldarrens) Date: 2015-03-27.19:10:36
Is there any active development on this?  It seems unusual that jython, loading a JVM would not recognize and entire jar, especially items in the manifest.  This basically leaves UberJar's unavailable for use with Jython?
msg9719 (view) Author: Jim Baker (zyasoft) Date: 2015-03-27.23:35:53
Darren, it would seem to me the workaround in msg649 would still be applicable. Re singlejar support, there's Clamp - https://github.com/jythontools/clamp
msg11840 (view) Author: Jeff Allen (jeff.allen) Date: 2018-03-22.06:45:44
Is this the same as #1778514?

Discussion there led me to the summary that there are work arounds, and we won't fix it because it is at odds with our package scanning. I could be wrong on both counts, however. And maybe our package scanning is not sufficient as it stands.
History
Date User Action Args
2018-03-22 06:45:44jeff.allensetnosy: + jeff.allen
messages: + msg11840
2015-03-27 23:35:53zyasoftsetnosy: + zyasoft
messages: + msg9719
2015-03-27 19:10:36balldarrenssetnosy: + balldarrens
messages: + msg9718
2013-02-26 21:40:52fwierzbickisetnosy: - nobody
versions: + Jython 2.5, Jython 2.7
2012-08-13 18:30:05fwierzbickisetcomponents: + Core, - Jythonc compiler
2012-08-13 18:29:28fwierzbickisetresolution: wont fix ->
2009-03-23 13:21:26fwierzbickisetstatus: closed -> open
messages: + msg4342
2009-03-13 23:44:17fwierzbickisetstatus: open -> closed
resolution: wont fix
messages: + msg4268
nosy: + fwierzbicki
2002-04-23 19:24:05anonymouscreate