This is the mail archive of the
java-prs@gcc.gnu.org
mailing list for the Java project.
[Bug libgcj/27101] New: GCJ rejects valid code (for Sun's measure of "valid')
- From: "vnasardinov at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: java-prs at gcc dot gnu dot org
- Date: 10 Apr 2006 13:55:00 -0000
- Subject: [Bug libgcj/27101] New: GCJ rejects valid code (for Sun's measure of "valid')
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This is probably a duplicate of something that has been filed before,
but my cursory search failed to turn up any similar tickets.
GCJ rejects code that both Sun and Eclipse compilers accept.
Here's the test case:
| $ cat Reluctant.java
| public class Reluctant {
| private Reluctant internalInstance = new Reluctant();
|
| public Reluctant() throws Exception {
| throw new Exception("I'm not coming out");
| }
|
| public static void main(String[] args) {
| try {
| Reluctant b = new Reluctant();
| System.out.println("Surprise!");
| } catch (Exception ex) {
| System.out.println("I told you so");
| }
| }
| }
The test comes from
http://www.javapuzzlers.com/java-puzzlers.zip
Here's what I'm using
| $ gcj -v
| Using built-in specs.
| Reading specs from /usr/lib/gcc/x86_64-redhat-linux/4.1.0/libgcj.spec
| rename spec lib to liborig
| Target: x86_64-redhat-linux
| Configured with: ../configure --prefix=/usr --mandir=/usr/share/man \
| --infodir=/usr/share/info --enable-shared --enable-threads=posix \
| --enable-checking=release --with-system-zlib --enable-__cxa_atexit \
| --disable-libunwind-exceptions --enable-libgcj-multifile \
| --enable-languages=c,c++,objc,obj-c++,java,fortran,ada \
| --enable-java-awt=gtk --disable-dssi \
| --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre \
| --with-cpu=generic --host=x86_64-redhat-linux
|
| Thread model: posix
| gcc version 4.1.0 20060304 (Red Hat 4.1.0-3)
Here's the compilation error the above code triggers:
| $ gcj -C Reluctant.java
| Reluctant.java: In class 'Reluctant':
| Reluctant.java: In method 'finit$()':
| Reluctant.java:2: error: Exception $-1òøjava.lang.Exceptionòù can't be
thrown in initializer.
| private Reluctant internalInstance = new Reluctant();
| ^
| 1 error
Here's what the Eclipse compiler has to say:
| $ ecj -v
| Eclipse Java Compiler v_585_R31x, 3.1.2 release, Copyright IBM Corp 2000,
2006. All rights reserved.
| $ ecj Reluctant.java
| ----------
| 1. WARNING in Reluctant.java
| (at line 2)
| private Reluctant internalInstance = new Reluctant();
| ^^^^^^^^^^^^^^^^
| The field Reluctant.internalInstance is never read locally
| ----------
| ----------
| 2. WARNING in Reluctant.java
| (at line 10)
| Reluctant b = new Reluctant();
| ^
| The local variable b is never read
| ----------
| 2 problems (2 warnings)
No errors.
Same with Sun's javac:
| $ javac -version 2>&1 | head -n1
| javac 1.5.0_06
| $ javac -Xlint Reluctant.java
| $ echo $?
| 0
--
Summary: GCJ rejects valid code (for Sun's measure of "valid')
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgcj
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: vnasardinov at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27101