Summary: | [compiler] Illegal permission to invoke the constructor of a member class of an inaccessible type. | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Christian Zoller <eclipse> | ||||||||||
Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> | ||||||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||||||
Severity: | normal | ||||||||||||
Priority: | P3 | CC: | amj87.iitr, jarthana, Olivier_Thomann | ||||||||||
Version: | 3.6 | Flags: | jarthana:
review+
|
||||||||||
Target Milestone: | 3.7 M1 | ||||||||||||
Hardware: | PC | ||||||||||||
OS: | Linux | ||||||||||||
Whiteboard: | |||||||||||||
Attachments: |
|
Description
Christian Zoller
2010-06-17 12:26:47 EDT
Created attachment 172139 [details]
Example code
Potential 3.6.1 candidate depending on the risk of the fix. Comment on attachment 172139 [details] Example code > B.m().new M(); This line should produce a compiler error according to JLS § 6.6.1, but does nut. => http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.6.1 Created attachment 172209 [details]
example with obvious corrections
The same example code with two tiny obvious corrections:
- return type of m() must be A, not B
- added missing import in C
Interestingly, javac (1.6.0_18) gives a pretty strange error:
p1/C.java:6: package p0.A does not exist
B.m().new M();
^
1 error
I'm sure the JDT can do better :)
> The same example code with two tiny obvious corrections:
> - return type of m() must be A, not B
> - added missing import in C
Thank you. I was a bit in a hurry when I wrote that. Sorry.
Reproduced on HEAD. See that for method invocations and field references under similar conditions, we do issue the correct error. The problem seems to be specific to constructors. Also broken is: public class B { public static A m() { return new A(); } private static class A { public class M { public M() {} } } } class C { public static void main(String[] args) { B.m().new M(); // no error here } } Created attachment 172386 [details]
Patch under test
Created attachment 172392 [details]
Revised patch
Earlier patch had a problem, like this one better.
Patch looks good to me. Fixed an unneeded set of parenthesis pointed out by Jay and released patch in HEAD for 3.7 M1 Verified for 3.7M1 using build I20100802-1800. Note that the quick fix given here is "change visibility of m() to public", which is not correct. It should instead offer changing visibility of A to public. Raised bug 321582 for that. |