all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chris Marusich <cmmarusich@gmail.com>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: guix-devel@gnu.org
Subject: Re: store reference detection (was Re: JARs and reference scanning)
Date: Thu, 11 May 2017 01:41:34 -0700	[thread overview]
Message-ID: <87inl7n5tt.fsf@gmail.com> (raw)
In-Reply-To: <87vapbkeua.fsf@elephly.net> (Ricardo Wurmus's message of "Mon, 08 May 2017 09:06:05 +0200")


[-- Attachment #1.1: Type: text/plain, Size: 3031 bytes --]

Hi Ricardo,

Ricardo Wurmus <rekado@elephly.net> writes:

> Chris Marusich <cmmarusich@gmail.com> writes:
>
>> There are probably many ways to accomplish that.  For example, in Java,
>> perhaps we could implement a custom classloader.  Or maybe we could
>> patch the built-in class loading mechanism [1].  Similarly, in Python
>> there are also ways to customize the import mechanism [2].  Perhaps Perl
>> also has a similar mechanism?
>
> Jar files can be told to import classes from another Jar by adding it to
> the “Class-Path” field of the Jar’s manifest.
>
> Here’s an example:
> https://docs.oracle.com/javase/tutorial/deployment/jar/downman.html

I didn't know this!  That's awesome; it might be just what we need.

> I don’t know if this mechanism permits the use of absolute paths, but
> it’s worth a try.  I should note that this doesn’t help with store
> reference detection, because the manifest will be part of the compressed
> Jar.  But if this works we could avoid propagation for Java packages.

Preliminary testing shows that this does in fact work.  See the attached
tarball; when you run "make" on its extracted contents, you can verify
for yourself that it works (don't forget to do 'guix -i icedtea:jdk'):

--8<---------------cut here---------------start------------->8---
[0] marusich@garuda:~
$ java -cp /tmp/embed-absolute-classpath-in-jar/Main.jar Main
Hello world!
[0] marusich@garuda:~
$ jar -tvf /tmp/embed-absolute-classpath-in-jar/Main.jar
     0 Thu May 11 01:35:26 PDT 2017 META-INF/
   131 Thu May 11 01:35:26 PDT 2017 META-INF/MANIFEST.MF
   309 Thu May 11 01:35:26 PDT 2017 Main.class
[0] marusich@garuda:~
$ jar -tvf /tmp/embed-absolute-classpath-in-jar/Greeter.jar
     0 Thu May 11 01:35:28 PDT 2017 META-INF/
    69 Thu May 11 01:35:28 PDT 2017 META-INF/MANIFEST.MF
   396 Thu May 11 01:35:26 PDT 2017 Greeter.class
[0] marusich@garuda:~
$ grep /tmp/embed-absolute-classpath-in-jar /tmp/embed-absolute-classpath-in-jar/*
Binary file /tmp/embed-absolute-classpath-in-jar/Main.jar matches
/tmp/embed-absolute-classpath-in-jar/Main.txt:Class-Path: /tmp/embed-absolute-classpath-in-jar/Greeter.jar
[0] marusich@garuda:~
$ strings /tmp/embed-absolute-classpath-in-jar/Main.jar | grep /tmp/embed-absolute-classpath-in-jar
Class-Path: /tmp/embed-absolute-classpath-in-jar/Greeter.jar
[0] marusich@garuda:~
$ 
--8<---------------cut here---------------end--------------->8---

Based on this test, it looks like we can embed absolute paths in
uncompressed JAR files.  This is great!  It means that if we can package
Java libraries in this way, we won't need to propagate inputs for Java
libraries (because Java will find the classes via the embedded
Class-Path values), and the usual reference scanning mechanism will just
work (because the JAR files are not compressed).

I don't know what limits there are on the number of entries one can put
into the Class-Path line, but hopefully that won't be an issue.

-- 
Chris

[-- Attachment #1.2: embed-absolute-classpath-in-jar.tar.xz --]
[-- Type: application/octet-stream, Size: 1228 bytes --]

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  parent reply	other threads:[~2017-05-11  8:41 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13 11:29 Need help from Java-developers Hartmut Goebel
2017-04-23  8:41 ` Chris Marusich
2017-04-23 22:57   ` Chris Marusich
2017-04-25 19:28     ` JARs and reference scanning (was: Need help from Java-developers) Hartmut Goebel
2017-04-26  5:34       ` JARs and reference scanning Chris Marusich
2017-04-26 11:53         ` store reference detection (was Re: JARs and reference scanning) Thomas Danckaert
2017-04-26 19:31           ` Maxim Cournoyer
2017-04-27 13:46           ` Ludovic Courtès
2017-04-27 14:14             ` store reference detection Thomas Danckaert
2017-04-27 17:46             ` store reference detection (was Re: JARs and reference scanning) Hartmut Goebel
2017-05-02 12:43               ` Ludovic Courtès
2017-05-07 12:48                 ` Hartmut Goebel
2017-05-07 20:23                   ` Chris Marusich
2017-05-08  7:06                     ` Ricardo Wurmus
2017-05-08 14:11                       ` Ludovic Courtès
2017-05-11  8:41                       ` Chris Marusich [this message]
2017-05-11 11:27                         ` Ricardo Wurmus
2017-05-12  6:54                           ` Chris Marusich
2017-05-12  8:21                             ` Ricardo Wurmus
2017-05-12  9:35                         ` Hartmut Goebel
2017-05-12 18:22                           ` Mark H Weaver
2017-05-12 20:05                             ` Hartmut Goebel
2017-05-12 21:24                               ` Mark H Weaver
2017-05-12  6:18                   ` Mark H Weaver
2017-05-12  8:19                     ` Chris Marusich
2017-05-12  9:46                       ` store reference detection Hartmut Goebel
2017-05-12 17:39                       ` store reference detection (was Re: JARs and reference scanning) Mark H Weaver
2017-05-12 18:27                         ` Leo Famulari
2017-05-12 19:54                         ` Hartmut Goebel
2017-05-12 21:51                           ` Mark H Weaver
2017-05-13  7:15                             ` Hartmut Goebel
2017-05-23  7:29                               ` Chris Marusich
2017-04-25  8:44   ` Need help from Java-developers Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87inl7n5tt.fsf@gmail.com \
    --to=cmmarusich@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=rekado@elephly.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.