[PATCH] Make java compiled resources public.

Marco Trudel marco@mtsystems.ch
Thu Dec 20 08:49:00 GMT 2007


David Daney wrote:
> This patch makes java compiled resources public symbols.  This is needed
> so that when statically linking to libgcj, the resource files in
> libgcj.a can be linked by passing -u to the linker.

Awesome! That was indeed a pain so far...
Can you give a concrete example how the linker line will look like? For 
instance, there was just recently someone on the users list running into 
an "java.util.MissingResourceException: Bundle 
gnu/java/util/regex/MessagesBundle not found".
How can that missing bundle be included into the compilation with your 
new solution?


thanks
Marco

> In 4.2 we could
> statically link java.util.Currency, but in 4.3 this class now depends on
> an compiled core:/ resource file.  Without this patch it is impossible
> (or at least very awkward) to force the resource file to be linked.
> 
> There are two changes:  The first is to generate a name for the resource
> that is a mangled version of the resource name.  Second, make the
> resource names public.  This allows us to force the resource to be
> linked by referring to the symbol from either the linker command line or
> some other object that is being linked.
> 
> The mangling is as follows:
> 
> The resource name is broken into path components by '/' characters. Each
> component then has an '_' prepended and all '.' -> "$_" and '$' ->
> "$$".  The length of each component is then prepended to this and all
> are concatenated together and preceeded by "_ZGr".  "Gr" being an unused
> special-name designator that could be thought of as representing
> GNU-resource.  For example:
> 
> "java/util/iso4217.properties" mangles as:
> "_ZGr5_java5_util20_iso4217$_properties"
> 
> These symbols seem to pass through the demangler unaffected (GNU nm
> 2.17.50.0.6-5.fc6 20061020 from FC6).
> 
> If the patch is accepted, I will follow up with a demangler patch that
> handles this new mangling.
> 
> Tested on x86_64-pc-linux-gnu with bootstrap and make check in libjava
> with no FAILures.
> 
> OK to commit?
> 
> 2007-12-20  David Daney  <ddaney@avtrex.com>
> 
>     * resource.c (Jr_count): Remove.
>     (compile_resource_data): Call java_mangle_resource_name to generate
>     decl name.  Make resource decl public.
>     * mangle.c (append_resource_name_hunk): New function.
>     (java_mangle_resource_name): Same.
>     * java-tree.h (java_mangle_resource_name): Declare new function.
> 
> 



More information about the Java-patches mailing list