Bug 52942 - [Compiler] Incremental Compiler generates error when accessing a protected attribute
Summary: [Compiler] Incremental Compiler generates error when accessing a protected at...
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-24 10:29 EST by Shane Holder CLA
Modified: 2004-04-08 04:50 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shane Holder CLA 2004-02-24 10:29:56 EST
I'm working on some code similar to below and I'm experiencing
differences between the Sun java compiler and the Eclipse incremental
compiler in how they see protected attributes of a class.

In Eclipse, I get the error "Type myPrivateClass.Goober is not
visible." on all accesses to x, y, and z.  But when I compile the code
using 1.4.2_01 of the Sun SDK I only receive 2 errors one on x and the
other on z.

-8< file: myPrivateClass.java ----------------------------
package myPackage;
public final class  myPrivateClass {
    
	private class Goober {
	    private int x;
	    protected int y;
	    public int z;
	}
	Goober goober = new Goober();
}

-8< file: myTestClass.java ------------------------------
package myPackage;
public class myTestClass {
	public void lmnop() {
		myPrivateClass x = new myPrivateClass();
		x.goober.x = 0; // private not accessable via javac
		x.goober.y = 1; // protected accessable via javac
		x.goober.z = 2; // public not accessable via javac
	}
}
-8< file: build.xml ------------------------------
<project name="stuff" default="default" basedir=".">
<property name="build.dest" value="./bin" />
<target name="default">
<mkdir dir="${build.dest}"/>
<javac 	   srcdir="."
           destdir="${build.dest}"
	   />
</target>
</project>
Comment 1 Philipe Mulet CLA 2004-03-08 18:40:24 EST
In 3 cases, we complain that the declaring class of the field (Goober) is not 
visible. Since it is accessed 3 times in the same way, I don't see the problem 
to have them all issue the same error.

I would say this is a bug in javac. The protected field shouldn't be more 
accessible than the public one. 
Comment 2 Shane Holder CLA 2004-03-08 18:45:40 EST
I agree with you, one should not be more visible than another.  The real 
problem is the difference in the compilers.  I once worked on a product where 
we had to be bug-for-bug compatible with another product.  The Eclipse 
compiler team just needs to decide what they want the experience of the end 
user to look like.  This issue might prevent me from deploying Eclipse as a 
development environment (which I really want to do).

Perhaps an option to the compiler that enables the "features" of the Sun 
compiler could be implemented?
Comment 3 Philipe Mulet CLA 2004-03-10 07:29:24 EST
We cannot and certainly do not want to be bug compatible with javac. 
Check out the bug database for javac and you'll get an idea of what I mean.

Why should we emulate Sun behavior ? You should argue with them they should fix 
this bug.
Comment 4 Philipe Mulet CLA 2004-04-08 04:50:04 EDT
Invalid