bugGNU gettext - Bugs: bug #28909, Gettext. Java compiler error when...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #28909: Gettext. Java compiler error when try generate java class from po files - code too large

Submitter:  sasha <predator>
Submitted:  Tue 16 Feb 2010 08:40:21 AM UTC
   
 
Category:  Java Severity:  3 - Normal
Item Group:  None Status:  Fix Released
Privacy:  Public Assigned to:  haible
Open/Closed:  Closed

Thu 18 Feb 2010 08:08:02 AM UTC, comment #2: 

Thank you so much!

p.s. My patch was just example for how it can be :)
p.p.s. I don't write on C for a long time If be honest if I don't use Eclipse for auto format I will never make this patch :)

sasha <predator>
Wed 17 Feb 2010 11:49:12 PM UTC, comment #1: 

Thanks for the report and patch. I could not use your patch
because it also reindented the entire file (no offense intended,
I understand that GNU coding style does not match everyone's
taste and habits).

I committed and tested this fix:
http://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=aa81fd4bdfefe778c39ecbc74a760c1cfe638d04

Bruno Haible <haible>
Group administrator
Tue 16 Feb 2010 08:40:21 AM UTC, original submission:  

I try run next command:
msgfmt --java2 -d mydir -r com.mycompany.Messages -l de my.po

And receive error from java compiler:

Messages_de.java:5: code too large
  static {
  ^
1 error
msgfmt: compilation of Java class failed, please try --verbose or set $JAVAC

I investigate and found that this is because java support not more than 64kb for method byte code.
msgfmt generate code like this

class MyClass {

private static final String[] data = new String[messageCount];

static {
       data[0] = "msg_1";
       ...
       data[messageCount-1] = "msg_messageCount";
}

...

}

As I understand problem with this large static block. It can be fix if msgfmt began generate something like

class MyClass {

private static final String[] data = new String[messageCount];

static {
       m_1()
       ...
       m_N()
}

private static m_1() {
       data[0] = "msg_1";
       ...
       data[someNumber-1] = "msg_someNumber";
}

...

private static m_N() {
       data[someNumber*(N-1)] = "msg_someNumber*(N-1)";
       ...
       data[someNumber*N - 1] = "msg_messageCount";
}

...

}

Maybe here some errors (don't want think :)

I found that code generated in write-java.c (here is for java 1.1.)

static void
write_java_code (FILE *stream, const char *class_name, message_list_ty *mlp,
         bool assume_java2) {

...

      /* Java 1.1.x uses a different hash function.  If compatibility with
this Java version is required, the hash table must be built at run time,
not at compile time.  */
      fprintf (stream, "  private static final java.util.Hashtable table;\n");
      fprintf (stream, "  static {\n");
      fprintf (stream, "    java.util.Hashtable t = new java.util.Hashtable();\n");
      for (j = 0; j < mlp->nitems; j++)
{
  fprintf (stream, "    t.put(");
  write_java_msgid (stream, mlp->item[j]);
  fprintf (stream, ",");
  write_java_msgstr (stream, mlp->item[j]);
  fprintf (stream, ");\n");
}
      fprintf (stream, "    table = t;\n");
      fprintf (stream, "  }\n");
...

}

sasha <predator>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #19717:  write-java.c added by predator (30KiB - application/octet-stream - This changes which I think should help but I even can't compile all this under windows!)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by predator (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-04 haible StatusFixed Fix Released
    2016-11-27 haible CategoryNone Java
    2010-02-17 haible StatusNone Fixed
        Assigned toNone haible
        Open/ClosedOpen Closed
    2010-02-16 predator Attached File- Added write-java.c, #19717

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code