Description of problem: gcj refuses a syntax accepted by javac. Factory.java: In class `spec.jbb.infra.Factory.Factory': Factory.java: In method `spec.jbb.infra.Factory.Factory.tempArray Near(int,int)': Factory.java:300: error: Unreachable statement. case T_CHAR: The following syntax is refused by gcj: switch (type) { case T_BOOLEAN: { result = new boolean[entries]; break; }; case T_CHAR: { result = new char[entries]; break; }; etc. Removing the {} inside the case code fixes the problem. Version-Release number of selected component (if applicable): # cat /etc/redhat-release Red Hat Linux release 9 (Shrike) 2.4.20-8smp # gcj --version gcj (GCC) 3.3.1 How reproducible: Easy. Steps to Reproduce: Welcome.java : public class Welcome { static final int T_BOOLEAN = 4; static final int T_CHAR = 5; public static void main(String[] args) { System.out.println("You're welcome!"); System.out.println(); } private static Object pb (int type) { Object result = null; switch (type) { case T_BOOLEAN: { result = new boolean[1]; break; }; case T_CHAR: { result = new char[2]; break; }; } return result; } } Actual results: Compiler error message. Expected results: No compiler error message. Additional info:
This isn't a bug. Change both instances of "};" to "}" in the switch statement and this code will compile -- those semicolons are invalid. FWIW both jikes and Sun JDK 1.4.2 also reject this code. Thanks for a very easy-to-reproduce bug report. This is the kind I like.
This code compiled perfectly well with IBM javac 1.1.8 and IBM javac 1.3.1. I've tried now to compile it with IBM java 1.4.1 : yes that fails ! So it seems to be some uncompatibility between Java 1.4 and previous versions. Thanks for help.
Yeah, just FYI, older versions of javac tended to be more lenient with regard to extraneous semicolons. At one point we added code to gcj to let it do this too, but I think we only added cases where we had access to code causing problems for us. In any case, it is a deprecated feature of the compiler (both standard and gcj) -- best to fix the code.