Bug 244804 - [1.5][compiler] public method with varags and protected single-argument method behave differently from javac
Summary: [1.5][compiler] public method with varags and protected single-argument metho...
Status: VERIFIED NOT_ECLIPSE
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-21 07:59 EDT by Joachim Sauer CLA
Modified: 2008-09-16 05:38 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Sauer CLA 2008-08-21 07:59:30 EDT
Build ID: I20080617-2000

Steps To Reproduce:
1.Create a class Caller in package p1:

package p1;

import p2.Callee;

public class Caller {
	public void bar() {
		Callee.foo(new Object());
	}
}

2. Create a class Callee in package p2:

package p2;

public class Callee {
	public static void foo(final Object... varargs) {
	};

	protected static void foo(final Object singleArg) {
	};
}

3. compile using Eclipse (ecj): compilation succeeds without warnings or errors
4. compile using javac (tried with 1.6.0_06 and 1.6.0_10 rc1): the following error is reported:

p1/Caller.java:7: foo(java.lang.Object) has protected access in p2.Callee
		Callee.foo(new Object());
		      ^
1 error

More information:
I don't know which compile follows the spec correctly in this case, but there is a discrepancy that should be looked into.
Comment 1 Joachim Sauer CLA 2008-08-21 09:35:06 EDT
http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#316811
seems to suggest that the behavior of Eclipse is correct here, as the protected method should not be considered at all, since it's not even "potentially applicable", since it's not accessible.

I've filed a bug in the Sun bug parade as well and will update this bug, as soon as I hear back from Sun.

Side note: Java 5 produces exactly the same problem when compiling the example.
Comment 2 Joachim Sauer CLA 2008-09-09 10:06:55 EDT
I've got a reply from Sun saying that the behaviour is indeed a bug (or at least was accepted into their bug tracking system as a bug).

The bug _will be_ visible at
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6746184
(according to the mail it can take 1 or 2 days until it is visible).

This seems to indicate that the behaviour of ejc is in fact correct and this bug entry is invalid.
Comment 3 Kent Johnson CLA 2008-09-09 10:54:01 EDT
Thank you.

Closing as NOT_ECLIPSE
Comment 4 Jerome Lanneluc CLA 2008-09-16 05:38:27 EDT
Verified for 3.5M2