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");
...
}
|