Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6500912

Compiler fails to reject program involving method call on raw type (Constructor.getAnnotation)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      The compiler fails to reject this program:

      import java.lang.annotation.Annotation;
      import java.lang.reflect.Constructor;
      public class X {
        void bar(Constructor constructor, Class<Ann> ann) {
          constructor.getAnnotation(ann).message(); // Should fail
        }
      }
      @interface Ann {
        String message();
      }

      class Y {
        void bar(MyConstructor constructor, Class<Ann> ann) {
          constructor.getAnnotation(ann).message(); // Should fail
        }
      }

      interface Z {
        <T extends Annotation> T getAnnotation(Class<T> c);
      }
      class MyAccessibleObject implements Z {
        public <T extends Annotation> T getAnnotation(Class<T> c) { return null; }
      }
      class MyConstructor<V> extends MyAccessibleObject {
        public <T extends Annotation> T getAnnotation(Class<T> c) { return null; }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ahe Peter Ahe
                Reporter:
                ahe Peter Ahe
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: