Bug 48401 - extra parantheses: javac, javadoc do not accept
Summary: extra parantheses: javac, javadoc do not accept
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1.1   Edit
Hardware: PC Windows 2000
: P3 minor (vote)
Target Milestone: 3.0 M6   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-10 05:16 EST by Wolfgang Frech CLA
Modified: 2003-12-10 05:25 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Frech CLA 2003-12-10 05:16:04 EST
According to the JDT compiler the following source code is correct:

public class Demo {
	Object ok = (Object) new Object();
	Object nok = ((Object)) new Object();
}

javac and javadoc both find the second cast expression in error.

Demo.java:3: ';' expected
        Object nok = ((Object)) new Object()
                                ^
1 error

Version of javac and javadoc
java version "1.4.2_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)

In my opinion both type casts may be correct, because extra parantheses can be
added to any expression, though I am not really sure.

I read JDT's compliance settings as: code that compiles in JDT compiles in a 1.4
(or 1.3) JDK.  This does not hold here.
It might be a defect of Sun's javac implementation, relative to the JLS.

The practical problem is not with the javac compatibility, because I use that
compiler rarely, but with javadoc, which is called by the JDT and which uses the
javac parser apparently.
Comment 1 Philipe Mulet CLA 2003-12-10 05:25:11 EST
This was an Eclipse compiler bug which got resolved in 3.0 stream.