Re: [Fwd: compiling errors with latest gcc 4.4 and AWT/Swing]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/4/14 David Michel <dmichel76@xxxxxxxxxxxxxx>:
> Hi All,
>
> I was recently trying to run a java project, developed for and run
> with Sun's java, with the gcc compiler instead. When I first installed
> the gcj available from the Ubuntu repository, I ran into compilation
> erros and then realised that the version shipped on the repos was
> relatively old  (4.2.4) so I decided to upgrade it to the latest one,
> hoping that these compilation issues will get resolved.
>
> With great help from this forum, I got the newest GCC running on my
> machine with the following commands:
>
> $ svn co http://gcc.gnu.org/svn/gcc/branches/gcc-4_4-branch/
> $ mkdir gcc-4_4-branch/obj-x86_64-unknown-linux-gnu
> $ cd gcc-4_4-branch/obj-x86_64-unknown-linux-gnu
> $ `pwd`/../configure --enable-languages=java
> --prefix=/local/gcc-4_4-branch/install --enable-java-home
> --enable-java-awt=gtk
> $ make && make install
> $ /local/gcc-4_4-branch/install/lib/jvm/bin/java -version java version
> "1.5.0" gij (GNU libgcj) version 4.4.0 20090330 (prerelease)
>
> Using Eclipse, I linked my project to the newly installed JRE
> (JRE home directory on '/local/gcc-4_4-branch/install/lib/jvm' ; JRE
> system libraries on
> '/local/gcc-4_4-branch/install/share/java/libgcj-4.4.0.jar' and the
> sourcefile on '~/gcc-4_4-branch/libjava/classpath' )
>
> When I try ro tun the project (from Eclipse), I ran into exactly the
> same compilation errors as encountered with the older gcc version:
>
> Exception in thread "main" java.lang.IllegalArgumentException
>  at javax.swing.ScrollPaneLayout.addLayoutComponent(ScrollPaneLayout.java:148)
>  at java.awt.Container.addImpl(Container.java:392)
>  at java.awt.Container.add(Container.java:230)
>  at nl.kbna.dioscuri.GUI.setScreen(GUI.java:512)
>  at nl.kbna.dioscuri.GUI.<init>(GUI.java:256)
>  at nl.kbna.dioscuri.GUI.<init>(GUI.java:295)
>  at nl.kbna.dioscuri.GUI.main(GUI.java:213)
>
> The problem seem to lie with AWT and Swing... and by digging deeper
> into the code I found that:
>
> In GUI.java the following call is made:
>       screenPane.add(screen);
> This works using Sun's Java, but causes a IllegalArgumentException in
> GCJ and the reason seems to be as follows:
>
> GCJ java.awt.Container class on line 276 contains code for the above call:
>       add(Component comp)
>       {
>               addImpl(comp, null, -1)
>       }
>
> The addImpl function calls, near the end (line 390):
>       layoutMgr.addLayoutComponent("", comp);
> because it was passed null constraints.
>
> The ScrollPaneLayout class implements the addLayoutComp (line 125):
>       addLayoutComponent(String key, Component component)
> but notice that the 'key' variable has been passed an empty String;
> this function now throws an IllegalArgumentException.
>
> .... As anyone had this sort of problem ? Any idea how to fix it ?
> Could it be a problem of mixing AWT and Swing together ?
>
> Regards
>
> David Michel
>
>

It's not necessary to mix the two to trigger this bug.  You merely
need to add a component to a component using the ScrollPaneLayout:

  public TestSwing()
  {
    setLayout(new ScrollPaneLayout());
    add(new JButton());
  }

This runs on IcedTea but fails on Classpath:

Exception in thread "main" java.lang.IllegalArgumentException
   at javax.swing.ScrollPaneLayout.addLayoutComponent(ScrollPaneLayout.java:148)
   at java.awt.Container.addImpl(Container.java:392)
   at java.awt.Container.add(Container.java:297)
   at javax.swing.JFrame.addImpl(JFrame.java:264)
   at java.awt.Container.add(Container.java:230)
   at TestSwing.<init>(TestSwing.java:12)
   at TestSwing.main(TestSwing.java:17)

The error is not in ScrollPaneLayout.  Changing the code to:

    ScrollPaneLayout l = new ScrollPaneLayout();
    l.addLayoutComponent("", new JButton());

correctly triggers an IllegalArgumentException on both IcedTea and Classpath:

$ cacao TestSwing
Exception in thread "main" java.lang.IllegalArgumentException
   at javax.swing.ScrollPaneLayout.addLayoutComponent(ScrollPaneLayout.java:148)
   at TestSwing.<init>(TestSwing.java:12)
   at TestSwing.main(TestSwing.java:19)

$ /usr/lib/icedtea6/bin/java TestSwing
Exception in thread "main" java.lang.IllegalArgumentException: invalid
layout key
	at javax.swing.ScrollPaneLayout.addLayoutComponent(ScrollPaneLayout.java:257)
	at TestSwing.<init>(TestSwing.java:12)
	at TestSwing.main(TestSwing.java:19)

Existing bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39553
-- 
Andrew :-)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net

PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint: F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8



[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux