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

Submitted by:  sasha <predator>
Submitted on:  Tue 16 Feb 2010 08:40:21 AM UTC  
 
Category: JavaSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Bruno Haible <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>
Project AdministratorIn charge of this item.
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>

 

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
  • -unavailable- added by haible (Posted a comment)
  • -unavailable- added by predator (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 27 Nov 2016 12:29:21 AM UTChaibleCategoryNone=>Java
    Wed 17 Feb 2010 11:49:12 PM UTChaibleStatusNone=>Fixed
      Assigned toNone=>haible
      Open/ClosedOpen=>Closed
    Tue 16 Feb 2010 11:21:38 AM UTCpredatorAttached File-=>Added write-java.c, #19717

    Back to the top


    Powered by Savane 3.1-cleanup1