Community
Participate
Working Groups
Description: public class test { public static void main (String args[]) { Object foo = null; String bar = ((String)) foo; } } The cast with double parens produces an "Invalid cast type expression" message in Eclipse 3.0 M8. No error is reported in 2.1.1. I realize that this is easy to fix, but I have just imported a ton of code that has double parens around its casts for some reason. Although the extra parens don't help anything, I don't think that they are illegal.
You could at least try to compile it using javac. javac 1.3.1 reports: Test.java:4: ';' expected String bar = ((String)) foo; ^ Test.java:4: cannot resolve symbol symbol : variable String location: class Test String bar = ((String)) foo; ^ 2 errors Jikes 1.18 reports: Found 1 semantic error compiling "C:/tests_sources/Test.java": 4. String bar = ((String)) foo; ^------^ *** Semantic Error: Expression found where a type is expected. javac 1.4.2 reports: Test.java:4: ';' expected String bar = ((String)) foo; ^ 1 error I think this was a bug in 2.1.1 that has been fixed. I will check 2.1.3.
This is still a problem against 2.1.3. In 3.0 the problem is fixed. It looks like another case of bug 38124.
You're right, I should have run it through javac. I've just never seen extra parenthesis cause a problem. I did try to find an existing bug first, but bug 38124 doesn't have the word parens or parenthesis anywhere, so it didn't turn up in my search. Thanks for the clarification. I guess the status of this bug should be INVALID then.
Closing