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

Confusing error message from javac when overriding a method from a raw supertype

XMLWordPrintable

    • b11
    • x86
    • linux

      When a class extends a raw superclass, and overrides a method from it, the compiler issues a confusing error message. Example:

      class A<T> {
          void foo(Clazz<?> clazz) { ... }
      }

      class B extends A /* raw A here */ {
          @Override
          void foo(Clazz<?> clazz) { ... }
      }

      The error message is:
      error: name clash: run(Class<?>) in A and run(Class<?>) in B have the same erasure, yet neither overrides the other

      What is happening is that when you extend a raw type, the method descriptors are erased; at least the message should say run(Class<?>) and run(Class) to make it clear that erasure is the problem.

            vromero Vicente Arturo Romero Zaldivar
            briangoetz Brian Goetz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: