Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 370814

Summary: [compiler] annotation fields can reference private static inner classes, inconsistent to oracle javac
Product: [Eclipse Project] JDT Reporter: Jakob Magiera <jam>
Component: CoreAssignee: Manoj N Palat <manoj.palat>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, srikanth_sankaran
Version: 3.8   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug
Attachments:
Description Flags
proposed fix v1.0 + regression tests
none
proposed fix v1.0 + regression tests updated none

Description Jakob Magiera CLA 2012-02-07 07:28:02 EST
Build Identifier: 20110916-0149

@interface A{
    String name();
}

@A(name=CompilerTest.Q.X)
public class CompilerTest {
    private static class Q {
        static final String X = "y"; //$NON-NLS-1$
    }
}

Reproducible: Always

Steps to Reproduce:
The class and annotation outlined in the details compile with compliance level 1.6 in the eclipse IDE, but not with the oracle jdk compiler.

Output of oracle jdk compiler:

[ERROR] CompilerTest.java:[7,20] CompilerTest.Q has private access in CompilerTest
Comment 1 Ayushman Jain CLA 2012-02-07 09:07:40 EST
This is a problem in org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.canBeSeenBy(ReferenceBinding, ReferenceBinding) , where we think that the receiver type and the invocation type are both same i.e. CompilerTest. The invocation type in this case should be the enclosing type of ComplierTest which is null in this case, IMHO
Comment 2 Ayushman Jain CLA 2012-02-07 09:15:13 EST
The fix for bug 316456 seems incomplete. Extending that should fix the problem.
Comment 3 Ayushman Jain CLA 2012-02-07 09:25:53 EST
Created attachment 210643 [details]
proposed fix v1.0 + regression tests

Srikanth, can you take a quick look? Thanks!
Comment 4 Ayushman Jain CLA 2012-02-08 01:33:00 EST
Created attachment 210709 [details]
proposed fix v1.0 + regression tests updated

A full run of the test suite showed one test that needed remastering. Updated the patch.
Ofcourse, comment 1 can be ignored.
Comment 5 Srikanth Sankaran CLA 2012-10-16 04:11:33 EDT
Manoj, Please review Ayush's fix and help take it forward. If patch needs
to be synched up with latest, do so and repost a fresh patch.
Comment 6 Eclipse Genie CLA 2019-07-28 13:46:03 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.