public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: MessageBundle ???
@ 2011-04-01 14:22 dj_def
  2011-04-01 14:57 ` Andrew Haley
  0 siblings, 1 reply; 12+ messages in thread
From: dj_def @ 2011-04-01 14:22 UTC (permalink / raw)
  To: java

1)
There is this test that is working under gcc 4.3.0 compiled by me with
ecj1.exe created under ubuntu linux 11.04 (with i686-pc-mingw32-gcj
cross compiler).
This same test is not working with thisiscool gcc 4.3.0 (eclipse):
import java.util.*;
import java.util.regex.*;
public class Test {
  static public void  main (String[] argv) {
    String s = new String("hom hom");
    String t = new String("om");
    String u = s.replaceAll(t, "i Jack!");
    System.out.println(u);
  }
}------------->gives: java.lang.NumberFormatException: invalid character
at position 1 g$ò< ...


2)
This other test is not working with both the versions.

class Test {

   public static void main(String argv[]) {

       System.out.printf("%09.3f%n",3.1415926535);
   }
}

-------------> gives a: Exception in thread "main"
java.lang.NumberFormatException: invalid character at position 2 in 09


3)
This last test works with thisiscool gcc and not with the gcc I
compiled:

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class LastTest {
  public static void main(String args[]) {
    try {
      URL url = new URL("http://www.google.it");
      url.openConnection();
    }
    catch(Exception e) {
      System.out.println("exception");
    }
  }
}------------->the execution gives:
Exception in thread "main" java.lang.ExceptionInInitializerError
   at
java.lang.Class.initializeClass(/extra/src/gcc-4.3.0/libjava/java/lang/nat
Class.cc:792)
   at
java.util.Currency.getInstance(/extra/wgcc/sys-root/i686-pc-mingw32/libjav
a/java/util/Currency.java:290)
   at
java.text.DecimalFormatSymbols.<init>(/extra/wgcc/sys-root/i686-pc-mingw32
/libjava/java/text/DecimalFormatSymbols.java:161)
   at
java.text.DecimalFormat.<clinit>(/extra/wgcc/sys-root/i686-pc-mingw32/libj
ava/java/text/DecimalFormat.java:96)
   at
java.lang.Class.initializeClass(/extra/src/gcc-4.3.0/libjava/gcj/cni.h:99)

   at
gnu.java.net.protocol.http.HTTPDateFormat.<init>(/extra/wgcc/sys-root/i686
-pc-mingw32/libjava/gnu/java/net/protocol/http/HTTPDateFormat.java:75)
   at
gnu.java.net.protocol.http.Headers.<clinit>(/extra/wgcc/sys-root/i686-pc-m
ingw32/libjava/gnu/java/net/protocol/http/Headers.java:76)
   at
java.lang.Class.initializeClass(/extra/src/gcc-4.3.0/libjava/gcj/cni.h:99)

   at
gnu.java.net.protocol.http.HTTPURLConnection.<init>(/extra/wgcc/sys-root/i
686-pc-mingw32/libjava/gnu/java/net/protocol/http/HTTPURLConnection.java:101)
   at
gnu.java.net.protocol.http.Handler.openConnection(/extra/wgcc/sys-root/i68
6-pc-mingw32/libjava/gnu/java/net/protocol/http/Handler.java:69)
   at
java.net.URL.openConnection(/extra/wgcc/sys-root/i686-pc-mingw32/libjava/j
ava/net/URL.java:724)
   at Test.<init>(ccSsHWJM.jar:0)
Caused by: java.lang.NullPointerException
   at
java.io.InputStreamReader.read(/extra/wgcc/sys-root/i686-pc-mingw32/libjav
a/java/io/InputStreamReader.java:246)
   at
java.io.BufferedReader.fill(/extra/wgcc/sys-root/i686-pc-mingw32/libjava/j
ava/io/BufferedReader.java:374)
   at
java.io.BufferedReader.readLine(/extra/wgcc/sys-root/i686-pc-mingw32/libja
va/java/io/BufferedReader.java:476)
   at
java.util.Properties.load(/extra/wgcc/sys-root/i686-pc-mingw32/libjava/jav
a/util/Properties.java:201)
   at
java.util.Currency.<clinit>(/extra/wgcc/sys-root/i686-pc-mingw32/libjava/j
ava/util/Currency.java:136)
   at
java.lang.Class.initializeClass(/extra/src/gcc-4.3.0/libjava/gcj/cni.h:99)

   ...11 more


WTH!!! Is this an April's fish? :D
I would like to have working connections and working replaceAll at the
same time... is it possible? :)
Are we facing the same problem of previous mail or this is another
problem?
How could this be solved? Please save me! 


ps. I could get rid of the MessageBundle problem linking everytime a
libgcj.o created with gcj --resource
gnu/java/util/regex/MessagesBundle.properties C:\wgcc\share\java
\libgcj-4.3.0.jar and then compiling the application with: gcj
--main=MainName MainName.java libgcj.o -o Output.exe

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: MessageBundle ???
  2011-04-01 14:22 MessageBundle ??? dj_def
@ 2011-04-01 14:57 ` Andrew Haley
  2011-04-01 17:43   ` Andrew Haley
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Haley @ 2011-04-01 14:57 UTC (permalink / raw)
  To: java

On 04/01/2011 03:22 PM, dj_def@webmail.it wrote:
> 1)
> There is this test that is working under gcc 4.3.0 compiled by me with
> ecj1.exe created under ubuntu linux 11.04 (with i686-pc-mingw32-gcj
> cross compiler).
> This same test is not working with thisiscool gcc 4.3.0 (eclipse):
> import java.util.*;
> import java.util.regex.*;
> public class Test {
>   static public void  main (String[] argv) {
>     String s = new String("hom hom");
>     String t = new String("om");
>     String u = s.replaceAll(t, "i Jack!");
>     System.out.println(u);
>   }
> }

Sorry, I have no idea what this is.

------------->gives: java.lang.NumberFormatException: invalid character
> at position 1 g$ò< ...
> 
> 
> 2)
> This other test is not working with both the versions.
> 
> class Test {
> 
>    public static void main(String argv[]) {
> 
>        System.out.printf("%09.3f%n",3.1415926535);
>    }
> }
> 
> -------------> gives a: Exception in thread "main"
> java.lang.NumberFormatException: invalid character at position 2 in 09

That's just a bug: leading zeroes in format fields aren't being handled
correctly.  The "09" is being parsed as an octal number because it begins
with a zero.

> 3)
> This last test works with thisiscool gcc and not with the gcc I
> compiled:
> 
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.net.URLConnection;
> 
> public class LastTest {
>   public static void main(String args[]) {
>     try {
>       URL url = new URL("http://www.google.it");
>       url.openConnection();
>     }
>     catch(Exception e) {
>       System.out.println("exception");
>     }
>   }
> }

This will be another missing resource, I expect.

Here's the actual exception

>    at
> java.util.Currency.<clinit>(/extra/wgcc/sys-root/i686-pc-mingw32/libjava/j
> ava/util/Currency.java:136)
>    at
> java.lang.Class.initializeClass(/extra/src/gcc-4.3.0/libjava/gcj/cni.h:99)

Look at Currency.java:136

        properties.load(Currency.class.getResourceAsStream("iso4217.properties"));

So you need to link iso4217.properties.o

Andrew.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: MessageBundle ???
  2011-04-01 14:57 ` Andrew Haley
@ 2011-04-01 17:43   ` Andrew Haley
  2011-04-01 19:32     ` Mark Wielaard
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Haley @ 2011-04-01 17:43 UTC (permalink / raw)
  To: java


>> at position 1 g$ò< ...
>>
>>
>> 2)
>> This other test is not working with both the versions.
>>
>> class Test {
>>
>>    public static void main(String argv[]) {
>>
>>        System.out.printf("%09.3f%n",3.1415926535);
>>    }
>> }
>>
>> -------------> gives a: Exception in thread "main"
>> java.lang.NumberFormatException: invalid character at position 2 in 09
> 
> That's just a bug: leading zeroes in format fields aren't being handled
> correctly.  The "09" is being parsed as an octal number because it begins
> with a zero.

The fix for the exception is

Index: Formatter.java
===================================================================
--- Formatter.java	(revision 171834)
+++ Formatter.java	(working copy)
@@ -1188,7 +1188,7 @@
       advance();
     if (start == index)
       return -1;
-    return Integer.decode(format.substring(start, index));
+    return Integer.parseInt(format.substring(start, index));
   }

   /**

BUT:

I just had a look, and as far as I can tell floating-point formatted
conversion has never been implemented in gcj.  Sorry.

Andrew.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: MessageBundle ???
  2011-04-01 17:43   ` Andrew Haley
@ 2011-04-01 19:32     ` Mark Wielaard
  2011-04-04  9:38       ` Andrew Haley
  0 siblings, 1 reply; 12+ messages in thread
From: Mark Wielaard @ 2011-04-01 19:32 UTC (permalink / raw)
  To: Andrew Haley; +Cc: java

On Fri, 2011-04-01 at 18:43 +0100, Andrew Haley wrote:
> >> java.lang.NumberFormatException: invalid character at position 2 in 09
> > 
> > That's just a bug: leading zeroes in format fields aren't being handled
> > correctly.  The "09" is being parsed as an octal number because it begins
> > with a zero.
> 
> The fix for the exception is
> 
> Index: Formatter.java
> ===================================================================
> --- Formatter.java	(revision 171834)
> +++ Formatter.java	(working copy)
> @@ -1188,7 +1188,7 @@
>        advance();
>      if (start == index)
>        return -1;
> -    return Integer.decode(format.substring(start, index));
> +    return Integer.parseInt(format.substring(start, index));
>    }
> 

Coincidentally the exact same problem and fix were discovered by Pekka
and went into GNU Classpath recently.

2010-02-16  Pekka Enberg  <penberg@kernel.org>

        * java/util/Formatter.java:
        (parseInt): Use Integer.parseInt() insted of Integer.decode()
        because the latter doesn't work with leading zeros which are
        used in String.format() formatting, for example.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: MessageBundle ???
  2011-04-01 19:32     ` Mark Wielaard
@ 2011-04-04  9:38       ` Andrew Haley
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Haley @ 2011-04-04  9:38 UTC (permalink / raw)
  To: java; +Cc: classpath

On 04/01/2011 08:32 PM, Mark Wielaard wrote:
> On Fri, 2011-04-01 at 18:43 +0100, Andrew Haley wrote:
>>>> java.lang.NumberFormatException: invalid character at position 2 in 09
>>>
>>> That's just a bug: leading zeroes in format fields aren't being handled
>>> correctly.  The "09" is being parsed as an octal number because it begins
>>> with a zero.
>>
>> The fix for the exception is
>>
> Coincidentally the exact same problem and fix were discovered by Pekka
> and went into GNU Classpath recently.

gcc is in Stage 1, so we could just bulk-import Classpath.

What do you think?

Andrew.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: MessageBundle ???
  2011-04-04 13:04 dj_def
@ 2011-04-04 13:09 ` Andrew Haley
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Haley @ 2011-04-04 13:09 UTC (permalink / raw)
  To: java

On 04/04/2011 02:04 PM, dj_def wrote:
>> It should just detect /usr/bin/gcj .  What is i686-pc-linux-gnu-gcj doing 
>> is
>> /usr/bin anyway?
> 
> Yes, in ubuntu /usr/bin/i686-linux-gnu-gcj points to /usr/bin/gcj-x.x where 
> x-x is the version. Even /usr/bin/gcj points to /usr/bin/gcj-x.x (so the 
> debian update-alternatives script can make you choose among versions simply 
> modifying the /usr/bin/gcj link).
> The link I made (i686-pc-linux-gnu-gcj) points to 
> /usr/bin/i686-linux-gnu-gcj that points to /usr/bin/gcj-x.x .
> 
> A question: especially for prerequisites and dependancies, are there 
> specific instructions when cross-compiling for windows? Should I consider 
> http://kegel.com/crosstool/ as the main reference?

I can guess, but I don't really know.  Windows, thank heaven, is something
I haven't had to touch for a long time.

Andrew.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: MessageBundle ???
@ 2011-04-04 13:04 dj_def
  2011-04-04 13:09 ` Andrew Haley
  0 siblings, 1 reply; 12+ messages in thread
From: dj_def @ 2011-04-04 13:04 UTC (permalink / raw)
  To: java

> It should just detect /usr/bin/gcj .  What is i686-pc-linux-gnu-gcj doing 
> is
> /usr/bin anyway?

Yes, in ubuntu /usr/bin/i686-linux-gnu-gcj points to /usr/bin/gcj-x.x where 
x-x is the version. Even /usr/bin/gcj points to /usr/bin/gcj-x.x (so the 
debian update-alternatives script can make you choose among versions simply 
modifying the /usr/bin/gcj link).
The link I made (i686-pc-linux-gnu-gcj) points to 
/usr/bin/i686-linux-gnu-gcj that points to /usr/bin/gcj-x.x .

A question: especially for prerequisites and dependancies, are there 
specific instructions when cross-compiling for windows? Should I consider 
http://kegel.com/crosstool/ as the main reference?
Thanks!

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: MessageBundle ???
  2011-04-04 12:00 dj_def
@ 2011-04-04 12:13 ` Andrew Haley
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Haley @ 2011-04-04 12:13 UTC (permalink / raw)
  To: java

On 04/04/2011 01:00 PM, dj_def wrote:
> I did other tests: I compiled gcc-4.3.0 (with 4.6 and 4.7 I was unable to 
> compile because of libltdl errors and missing jvm.exe) correcting 
> Formatter.java and with --enable-maintainer-mode.
> To make it succesfully I had to
> 
> 1) sudo ln -sf /usr/bin/i686-linux-gnu-gcj /usr/bin/i686-pc-linux-gnu-gcj
> (I did this because during some gcc configuration process, it detects 
> /usr/bin/i686-pc-linux-gnu-gcj instead of /usr/bin/i686-linux-gnu-gcj...
> it could be some ubuntu packaging issue as before compiling I installed the 
> whole gcc ubuntu package...)

It should just detect /usr/bin/gcj .  What is i686-pc-linux-gnu-gcj doing is
/usr/bin anyway?

> 2) gcj 
> /pathToSrcDir/gcc-4.3.0/ecj.jar -findirect-dispatch --main=org.eclipse.jdt.internal.compiler.batch.GCCMain 
>  -o ~/moveinecj1
>    sudo mv ~/moveinecj1 /usr/bin/ecj1
>    sudo chmod +x /usr/bin/ecj1
> (this should be a known issue when cross-compiling)

I don't quite see what the problem is here.  Yes, you have to have ecj1
to build with --enable-java-maintainer-mode.

> Well... with this version there is not any "MessagesBundle.properties 
> missing resource problem" but the previous problem is not completely solved:
> 
> class Test {
>   public static void main(String argv[]) {
>     System.out.printf("%09.3f%n",3.1415926535);
>   }
> }

> this time the program does not crash but also does not print anything (it 
> could be normal as now it uses parseInt).

I already said, I think.  Formatted floating-point output has not been written.

Andrew.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* MessageBundle ???
@ 2011-04-04 12:00 dj_def
  2011-04-04 12:13 ` Andrew Haley
  0 siblings, 1 reply; 12+ messages in thread
From: dj_def @ 2011-04-04 12:00 UTC (permalink / raw)
  To: java

I did other tests: I compiled gcc-4.3.0 (with 4.6 and 4.7 I was unable to 
compile because of libltdl errors and missing jvm.exe) correcting 
Formatter.java and with --enable-maintainer-mode.
To make it succesfully I had to

1) sudo ln -sf /usr/bin/i686-linux-gnu-gcj /usr/bin/i686-pc-linux-gnu-gcj
(I did this because during some gcc configuration process, it detects 
/usr/bin/i686-pc-linux-gnu-gcj instead of /usr/bin/i686-linux-gnu-gcj...
it could be some ubuntu packaging issue as before compiling I installed the 
whole gcc ubuntu package...)


2) gcj 
/pathToSrcDir/gcc-4.3.0/ecj.jar -findirect-dispatch --main=org.eclipse.jdt.internal.compiler.batch.GCCMain 
 -o ~/moveinecj1
   sudo mv ~/moveinecj1 /usr/bin/ecj1
   sudo chmod +x /usr/bin/ecj1
(this should be a known issue when cross-compiling)

Well... with this version there is not any "MessagesBundle.properties 
missing resource problem" but the previous problem is not completely solved:

class Test {
  public static void main(String argv[]) {
    System.out.printf("%09.3f%n",3.1415926535);
  }
}

this time the program does not crash but also does not print anything (it 
could be normal as now it uses parseInt).

The other test with the openConnection() function now succeeds :)
I did as you told me:
gcj --resource java/util/iso4217.properties -c 
pathTo\libjava\classpath\resource\java\util\iso4217.properties -o 
iso4217.properties.o

Thank you for all! 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: MessageBundle ???
  2011-04-01  9:57 ` Andrew Haley
@ 2011-04-01 10:09   ` Andrew Haley
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Haley @ 2011-04-01 10:09 UTC (permalink / raw)
  To: java

On 04/01/2011 10:57 AM, Andrew Haley wrote:
> 
> The problem here is that the linker doesn't know that a MessagesBundle
> is required.  The core cause of all this is that dynamic linking still
> doesn't work for gcj on Linux.

Aieeeeeee!  Dynamic linking still doesn't work for gcj on *Windows*.
April 1 is really getting to me...

Andrew.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: MessageBundle ???
  2011-04-01  8:51 dj_def
@ 2011-04-01  9:57 ` Andrew Haley
  2011-04-01 10:09   ` Andrew Haley
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Haley @ 2011-04-01  9:57 UTC (permalink / raw)
  To: java

On 04/01/2011 09:51 AM, dj_def@webmail.it wrote:
> I have problems with all java programs containing regex and string
> functions like split() or replace()/replaceAll().
> This programs will compile and run correctly on linux but will compile
> and crash on windows; the output says something about a missing resource
> (MessageBundle). I tried many things to get around of this but I did not
> find any solution.
> I would like to better understand why this happens but the most
> important thing would be to find a solution.
> I use this class as an example:
> 
> import java.util.regex.Pattern;
> class FFooClass {
>   public static void main(String args[]) {
>     Pattern p = Pattern.compile("bye");
>     System.out.println("bye");
>   }
> }
> 
> I do:
> gcj --main FFoo.java -o FFoo
> on linux and it works!
> I do:
> gcj --main FFoo.java -o FFoo.exe
> on windows (or even with a cross compiler for linux) and the app
> FFoo.exe doesn't work!
> Starting from this class, what are the steps to get a working exe?

The problem here is that the linker doesn't know that a MessagesBundle
is required.  The core cause of all this is that dynamic linking still
doesn't work for gcj on Linux.

You need to link explicitly on the command line with the MessagesBundle
files.  Look for something like

   gnu/java/util/regex/MessagesBundle.properties.o

in the libcgj build dir.

Andrew.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* MessageBundle ???
@ 2011-04-01  8:51 dj_def
  2011-04-01  9:57 ` Andrew Haley
  0 siblings, 1 reply; 12+ messages in thread
From: dj_def @ 2011-04-01  8:51 UTC (permalink / raw)
  To: java

I have problems with all java programs containing regex and string
functions like split() or replace()/replaceAll().
This programs will compile and run correctly on linux but will compile
and crash on windows; the output says something about a missing resource
(MessageBundle). I tried many things to get around of this but I did not
find any solution.
I would like to better understand why this happens but the most
important thing would be to find a solution.
I use this class as an example:

import java.util.regex.Pattern;
class FFooClass {
  public static void main(String args[]) {
    Pattern p = Pattern.compile("bye");
    System.out.println("bye");
  }
}

I do:
gcj --main FFoo.java -o FFoo
on linux and it works!
I do:
gcj --main FFoo.java -o FFoo.exe
on windows (or even with a cross compiler for linux) and the app
FFoo.exe doesn't work!
Starting from this class, what are the steps to get a working exe?

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-04-04 13:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-01 14:22 MessageBundle ??? dj_def
2011-04-01 14:57 ` Andrew Haley
2011-04-01 17:43   ` Andrew Haley
2011-04-01 19:32     ` Mark Wielaard
2011-04-04  9:38       ` Andrew Haley
  -- strict thread matches above, loose matches on Subject: below --
2011-04-04 13:04 dj_def
2011-04-04 13:09 ` Andrew Haley
2011-04-04 12:00 dj_def
2011-04-04 12:13 ` Andrew Haley
2011-04-01  8:51 dj_def
2011-04-01  9:57 ` Andrew Haley
2011-04-01 10:09   ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).