This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fwd: Resources in natively compiled executables


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Third time lucky...

Begin forwarded message:

From: Chris Burdess <dog@bluezoo.org>
Date: April 15, 2004 12:25:38 BST
To: Tom Tromey <tromey@redhat.com>
Cc: java@gcc.gnu.org
Subject: Re: Resources in natively compiled executables

Tom Tromey wrote:
Chris> All is well when building a jarfile. However, when our target is a
Chris> native executable, there is currently (AFAIK) no way for gcj to be
Chris> informed of these resources and package them into the executable in
Chris> such a way as to be accessible via the above methods.


Look at the `--resource' option.  This lets you compile in a file as a
resource.  It is available via the special `core:' URL handler;
`core:/' is put on the class path by default.  I think all the methods
you mention will work fine with core resources.

OK, thanks. I've had a look at this. FWIW the version of gcj is 3.5.0 20040310.


If I just compile my jar to native directly, i.e.:

# gcj -c -o activation.o activation.jar

this works normally. If instead I try:

# gcj -c --resource META-INF/mailcap.default --resource META-INF/mimetypes.default -o activation.o activation.jar

then it completes with no error but:

# nm activation.o
         U __gcj_personality_v0
00000000 t _GLOBAL__I_lib_activation.jar_00000000_7AF780A8_resource
00000000 r _Jr1
         U _Jv_RegisterResource

none of my code is in the binary. I don't know if this is a bug or a
feature?

In any case the gcj manpage says:

       file.jar
           An archive containing one or more ".class" files, all of
           which are compiled.  The archive may be compressed.  Files
           in an archive which donât end with .class are treated as
           resource files; they are copmiled into the resulting object
           file as core: URLs.

So the first method should have worked fine anyway?

The code I'm using is, for instance:

  Enumeration resources =
	ClassLoader.getSystemResources("META-INF/mailcap");
  while (resources.hasMoreElements())
  {
	URL url = (URL)resources.nextElement();
  }

or

getClass().getResourceAsStream("META-INF/javamail.default.providers");

Is the problem that I need to also try "core:/META-INF/mailcap", or
something like that? Why doesn't it support the normal usage if that's
the case?
--
Chris Burdess
- -- Chris Burdess
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)


iD8DBQFAfpVQ6dl1DEqHgrgRAtp6AKCgUm0wcD3LPKlK70ux5WkxlBfKLgCfaDz8
+4E1Tta9DL/go49UlN8UJ14=
=8LNO
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]