Bug 95106 - [1.5][compiler] Unexpected compiler error: type must implement inherited abstract method
Summary: [1.5][compiler] Unexpected compiler error: type must implement inherited abst...
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-13 07:10 EDT by Frederic Fusier CLA
Modified: 2005-05-31 15:08 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2005-05-13 07:10:34 EDT
Using 3.1 M7 candidate: build I20050513-0010.

I've 2 projects in my workspace:
org.eclipse.jdt.core: HEAD or v_557 does not matter
org.eclipse.jdt.apt.core: APT branch, version v_548_APT_20050512

After having built all my workspace, I got following unexpected compiler error:
"The type PackageDeclarationImplNoBinding must implement the inherited abstract
method Declaration.getAnnotation(Class<A>)"

I've launched 3.1 M6 on this workspace and rebuild all and got no error...
Comment 1 Frederic Fusier CLA 2005-05-13 07:11:34 EDT
Kent, talking with philippe, it seems to comes from MethodVerifier...

I tried to reproduce this problem with a simple test case but without any success:
Test.java:
  package jdt.core;
  import java.lang.annotation.Annotation;
  import sun.mirror.PackageDeclaration;
  public class Test implements PackageDeclaration {
	public <A extends Object & Annotation> A getAnnotation(Class<A> arg0) {
		return null;
	}
  }
Declaration.java:
  package sun.mirror;
  import java.lang.annotation.Annotation;
  public interface Declaration {
	public <A extends Object & Annotation> A getAnnotation(Class<A> arg0);
  }
PackageDeclaration.java
  package sun.mirror;
  public interface PackageDeclaration extends Declaration {}

...compiles with no error both with 3.1 M6 and 3.1 M7...
Comment 2 Kent Johnson CLA 2005-05-25 13:25:46 EDT
What does this mean?

org.eclipse.jdt.apt.core: APT branch, version v_548_APT_20050512

I can only see 2 versions of org.eclipse.jdt.apt.core 0421 & 0414
Comment 3 Frederic Fusier CLA 2005-05-26 04:56:21 EDT
My fault, I mixed projects...
You should read:
org.eclipse.jdt.apt.core: HEAD
org.eclipse.jdt.core: APT branch, version v_548_APT_20050512

However, org.eclipse.jdt.apt.core HEAD has been changed since 05/12 and this
error has now disappeared...

So, to reproduce, you need to have in your workspace:
org.eclipse.jdt.apt.core: Date 2005/05/12 (time does not matter)
org.eclipse.jdt.core: APT branch, version v_548_APT_20050512

Sorry for the confusion
Comment 4 Kent Johnson CLA 2005-05-31 15:08:16 EDT
Reproduced with the following test case (must add tools.jar to classpath):

import java.lang.annotation.Annotation;
import java.util.*;
import com.sun.mirror.declaration.*;
import com.sun.mirror.util.*;
class X implements PackageDeclaration {
 public <A extends Object & Annotation> A getAnnotation(Class<A> arg0) {
  return null;
 }
 public String getQualifiedName() {return null;}
 public Collection<ClassDeclaration> getClasses() {return null;}
 public Collection<EnumDeclaration> getEnums() {return null;}
 public Collection<InterfaceDeclaration> getInterfaces() {return null;}
 public Collection<AnnotationTypeDeclaration> getAnnotationTypes() {
  return null;
 }
 public String getDocComment() {return null;}
 public Collection<AnnotationMirror> getAnnotationMirrors() {return null;}
 public Collection<Modifier> getModifiers() {return null;}
 public String getSimpleName() {return null;}
 public SourcePosition getPosition() {return null;}
 public void accept(final DeclarationVisitor visitor) {}
}

javac detects the same error as we do:

javac -classpath tools.jar X.java
X.java:7: X is not abstract and does not override abstract method 
<A>getAnnotation(java.lang.Class<A>) in com.sun.mirror.declaration.Declaration
class X implements PackageDeclaration {
^
1 error

You cannot override an inherited method while adding additional bounds even if 
its Object.