JDK-8027189 : Incorrect type path for type annotations on wildcards
  • Type: Sub-task
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P2
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2013-10-23
  • Updated: 2013-10-25
  • Resolved: 2013-10-25
Description
The following program should emit a class file with a RuntimeVisibleTypeAnnotations attribute on TestWildcard.meth with a type path of [WILDCARD].  Instead, the type path is [TYPE_ARGUMENT(0)].

import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import static java.lang.annotation.ElementType.*;

class WithArgs<T> {}

public class TestWildcard {
  public void meth(WithArgs<@A @A @B @B ?> a) {}
}

@Retention(RUNTIME)
@Target({TYPE_USE,TYPE_PARAMETER})
@interface AC { A[] value(); }
@Retention(RUNTIME)
@Target({TYPE_USE,TYPE_PARAMETER})
@Repeatable(AC.class)
@interface A { }@Retention(RUNTIME)
@Target({TYPE_USE})
@interface BC { B[] value(); }
@Retention(RUNTIME)
@Target({TYPE_USE})
@Repeatable(BC.class)
@interface B { }

Comments
Closed in light of Werner's explanation.
25-10-2013

This error report is invalid. The type annotations in: WithArgs<@A @A @B @B ?> should only have [TYPE_ARGUMENT(0)] as generic location, as is correctly generated. The WILDCARD location is for type annotations in bounds of wildcards. That is, if you have: WithArgs<? extends @A @A @B @B Object> the generic location should be [TYPE_ARGUMENT(0), WILDCARD] Note that the TYPE_ARGUMENT(0) needs to be present in both cases.
24-10-2013