Bug 427274 - [compiler] Wrong error: Annotation type cannot be resolved to a type
Summary: [compiler] Wrong error: Annotation type cannot be resolved to a type
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-03 10:05 EST by Markus Keller CLA
Modified: 2023-11-07 01:05 EST (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 Markus Keller CLA 2014-02-03 10:05:09 EST
Compiler reports an invalid error "A cannot be resolved to a type" for "@A" in the example below. The "@Scope.A(Scope.CONST)" in front of the class declaration is necessary to reproduce the problem.


package jsr308.bug.scope;

import java.lang.annotation.*;

@Scope.A(Scope.CONST) // compiles if this line is commented out!
public class Scope {

    @Target(ElementType.TYPE_USE)
    @Retention(RetentionPolicy.RUNTIME)
    @interface A {
        int value() default -1;
    }
    
    private @A(CONST) A fA; // OK
    public static final @A int CONST = 1; // A cannot be resolved to a type
    
    public static void main(String[] args) throws Exception {
        Annotation[] annotations = Scope.class.getDeclaredField("CONST").getAnnotatedType().getAnnotations();
        System.out.println(java.util.Arrays.asList(annotations));
    }
}
Comment 1 Srikanth Sankaran CLA 2014-02-04 08:50:47 EST
This problem dates back to Helios, perhaps much earlier than too.
Comment 2 Srikanth Sankaran CLA 2014-09-01 03:59:54 EDT
I don't expect to get to this anytime soon.
Comment 3 Eclipse Genie CLA 2019-11-25 16:34:40 EST
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.
Comment 4 Stephan Herrmann CLA 2019-11-26 03:49:54 EST
Still relevant, but sounds more like an academic problem, unless we get reports about real-world occurrence.
Comment 5 Eclipse Genie CLA 2021-11-16 13:27:06 EST
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.
Comment 6 Eclipse Genie CLA 2023-11-07 01:05:24 EST
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.