This is the mail archive of the java-prs@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]

libgcj/6576: java.util.ResourceBundle.getResource ignores locale



>Number:         6576
>Category:       libgcj
>Synopsis:       java.util.ResourceBundle.getResource ignores locale
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 06 04:26:04 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Bruno Haible
>Release:        3.1 20020423 (prerelease)
>Organization:
GNU hackers
>Environment:
System: Linux linuix 2.4.18-4GB #1 Wed Mar 27 13:57:05 UTC 2002 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --prefix=/packages/gnu-snapshot --enable-shared --enable-version-specific-runtime-libs --enable-nls
>Description:

The java.util.ResourceBundle.getBundle(String,Locale) function
appears to ignore the locale argument.

>How-To-Repeat:

$ export CLASSPATH=.
$ cat <<\EOF > prog_fr.java
/* Automatically generated by GNU msgfmt.  Do not modify!  */
public class prog_fr extends java.util.ResourceBundle {
  private static final java.util.Hashtable table;
  static {
    java.util.Hashtable t = new java.util.Hashtable();
    t.put("","Content-Type: text/plain; charset=UTF-8\nPlural-Forms: nplurals=2; plural=(n > 1);\n");
    t.put("'Your command, please?', asked the waiter.","\u00abVotre commande, s'il vous plait\u00bb, dit le gar\u00e7on.");
    t.put("a piece of cake",new java.lang.String[] { "un morceau de gateau", "{0,number} morceaux de gateau" });
    t.put("{0} is replaced by {1}.","{1} remplace {0}.");
    table = t;
  }
  public static final java.util.Hashtable plural;
  static {
    java.util.Hashtable p = new java.util.Hashtable();
    p.put("a piece of cake","{0,number} pieces of cake");
    plural = p;
  }
  public java.lang.Object lookup (java.lang.String msgid) {
    return table.get(msgid);
  }
  public java.lang.Object handleGetObject (java.lang.String msgid) throws java.util.MissingResourceException {
    java.lang.Object value = table.get(msgid);
    return (value instanceof java.lang.String[] ? ((java.lang.String[])value)[0] : value);
  }
  public java.util.Enumeration getKeys () {
    return table.keys();
  }
  public static long pluralEval (long n) {
    return ((n > 1) ? 1 : 0);
  }
  public java.util.ResourceBundle getParent () {
    return parent;
  }
}
EOF
$ gcj -C -O -d . prog_fr.java
$ cat <<\EOF > DumpResource.java
import java.lang.reflect.*;
import java.util.*;
import java.io.*;
public class DumpResource {
  public DumpResource (String resource_name, String locale_name) {
    // Split locale_name into language_country_variant.
    String language;
    String country;
    String variant;
    language = locale_name;
    {
      int i = language.indexOf('_');
      if (i >= 0) {
        country = language.substring(i+1);
        language = language.substring(0,i);
      } else
        country = "";
    }
    {
      int j = country.indexOf('_');
      if (j >= 0) {
        variant = country.substring(j+1);
        country = country.substring(0,j);
      } else
        variant = "";
    }
    Locale locale = new Locale(language,country,variant);
    // Get the resource.
    System.out.println("Calling getBundle("+resource_name+","+locale+").");
    ResourceBundle catalog = ResourceBundle.getBundle(resource_name,locale);
  }
  public static void main (String[] args) {
    new DumpResource(args[0], args.length > 1 ? args[1] : "");
    System.exit(0);
  }
}
EOF
$ gcj -C -O -d . DumpResource.java
$ gij DumpResource prog fr
Calling getBundle(prog,fr).
Exception in thread "main" java.util.MissingResourceException: Bundle prog not found
   at 0x4025bf70: java.lang.Throwable.Throwable(java.lang.String) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x4024aed6: java.lang.Exception.Exception(java.lang.String) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x4024fba6: java.lang.RuntimeException.RuntimeException(java.lang.String) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x402a0ea9: java.util.MissingResourceException.MissingResourceException(java.lang.String, java.lang.String, java.lang.String) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x402a4ec9: java.util.ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x402a495b: java.util.ResourceBundle.getBundle(java.lang.String, java.util.Locale) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x403d76e7: ffi_call_SYSV (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x403d7697: ffi_raw_call (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x4022e20b: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x403e2644: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodInvocation) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x4022c024: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x403d754c: ?? (??:0)
   at 0x403d76e7: ffi_call_SYSV (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x403d7697: ffi_raw_call (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x4022e20b: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x403e2644: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodInvocation) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x4022c024: _Jv_InBFD: Dwarf Error: Invalid or unhandled FORM value: 14.
BFD: Dwarf Error: Invalid or unhandled FORM value: 14.
BFD: Dwarf Error: Invalid or unhandled FORM value: 14.
BFD: Dwarf Error: Invalid or unhandled FORM value: 14.
terpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x403d754c: ?? (??:0)
   at 0x40232408: gnu.gcj.runtime.FirstThread.call_main() (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x402bab18: gnu.gcj.runtime.FirstThread.run() (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x4023dbcc: _Jv_ThreadRun(java.lang.Thread) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x4021a2c4: _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/packages/gnu-snapshot/lib/libgcj.so.3)
   at 0x08048a20: main (get_vector/../../../libjava/gij.cc:140)
   at 0x405de668: __libc_start_main (/lib/libc.so.6)
   at 0x08048781: _start (??:0)

When I look (using strace) what files gij is trying to open(),
I see that it searching for "./prog.properties" and "./prog.class"
but not for "./prog_fr.properties" and "./prog_fr.class". It should
search first for "./prog_fr.properties" and "./prog_fr.class" and
then only for "./prog.properties" and "./prog.class".

>Fix:

Fix the internal working of this function.
>Release-Note:
>Audit-Trail:
>Unformatted:


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