Bug 362969 - JDT compiler does allow access to private members where javac doesn't
Summary: JDT compiler does allow access to private members where javac doesn't
Status: VERIFIED DUPLICATE of bug 334622
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-05 10:56 EDT by Sven Köhler CLA
Modified: 2011-12-06 00:57 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Köhler CLA 2011-11-05 10:56:05 EDT
Build Identifier: 

I reported a bug to Oracle, since I believed that the code should compile fine, and it did compile with JDT and javac up to JDK 1.6. But starting with JDK 1.7, javac disallows access to private members in certain situations.

Here's my original bug report:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7108257
Here Oracle claims that the error reported by javac 1.7 is indeed correct:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7022052

I don't understand the issue completely, but I have the feeling that JDT should be consistent with javac.

Reproducible: Always

Steps to Reproduce:
The reports in oracle database include source (class Foo and class JavaBug) which compile fine with JDT but not with javac 1.7.
Comment 1 Sven Köhler CLA 2011-11-06 11:52:34 EST
Note that javac 1.7 reports errors on both class Foo and Javabug (from the bug reports above) no matter whether the source level is 1.6 or 1.5 while at the same time, javac 1.6 and 1.5 report no errors. Not sure, what JDT's compiler should do.
Comment 2 Ayushman Jain CLA 2011-11-07 00:44:35 EST
This has already been fixed in 3.7. Please use a newer build.

*** This bug has been marked as a duplicate of bug 334622 ***
Comment 3 Ayushman Jain CLA 2011-11-07 01:06:29 EST
Sven, even with 3.7.1 this works as expected. Can you please re-check?

Note that the private members are not allowed to be accessed from *type parameters* only.
Comment 4 Sven Köhler CLA 2011-11-07 07:03:44 EST
You are right. The JDT compiler reports an error for the classes Foo and JavaBug, but only if the compiler compliance level is set to 1.7.

Is this the correct behaviour, concerning that javac 1.7 reports errors no matter whether source/target level are set to 1.5, 1.6, or 1.7?

IMHO, JDT should follow javac 1.7's behaviour, and always report the error.
Comment 5 Ayushman Jain CLA 2011-11-07 07:21:32 EST
(In reply to comment #4)
> You are right. The JDT compiler reports an error for the classes Foo and
> JavaBug, but only if the compiler compliance level is set to 1.7.
> 
> Is this the correct behaviour, concerning that javac 1.7 reports errors no
> matter whether source/target level are set to 1.5, 1.6, or 1.7?

JDT shows this behaviour as well. There are 2 settings in JDT:
1) Compliance: This is a special setting to ask the user which javac he wants JDT to mimic.
2) Source: This is similar to javac's source flag, and asks the user which java's language features he wants to use.

In this case, since ONLY javac7 gives an error, the compliance should be set to 1.7. You can then try changing source levels as you want, and JDT will always give an error. Ofcourse, if you change the compliance itself to 1.6, JDT will start to mimic javac6 and no longer give any error. HTH

*** This bug has been marked as a duplicate of bug 334622 ***
Comment 6 Jay Arthanareeswaran CLA 2011-12-06 00:57:48 EST
Verified for 3.8M4 with build I20111204-2000.