Bug 327881

Summary: [compiler] Eclipse Compiler compiles code, but Sun's javac does not
Product: [Eclipse Project] JDT Reporter: Mihhail Verhovtsov <mihey77>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, pwebster
Version: 3.7   
Target Milestone: 3.7 M4   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Test case (Eclipse project and classes) none

Description Mihhail Verhovtsov CLA 2010-10-15 08:31:06 EDT
Build Identifier: 20100617-1415

Using Java 1.6.

Suppose class A implements interface SomeInterface:

A.java:

package org.example;
public class A implements SomeInterface {
   public String someMethod() { return "test someMethod"; }
}

SomeInterface.java:

package org.example;
public interface SomeInterface {
  public String someMethod();
}

Compile it with javac and make a jar of it:
javac org/example/A.java
jar -cf testjar.jar org/example/*.class

Now create a new Java project in Eclipse, create "lib" folder in it, copy testjar.jar into it. Go to Project options -> Java Build Path -> Libraries -> Add JARs and add testjar.jar.

Now we create the same interface in our project, but with more methods:

SomeInterface.java:

package org.example;
public interface SomeInterface {
   public String someMethod();
   public String someOtherMethod();
}

Now create empty class B, which extends A:

SomeInterface.java:

package org.example;
public class B extends A {
}

Eclipse compiles it without problems. Method someMethod() is usable. 

Sun's javac doesn't compile that code.

Reproducible: Always

Steps to Reproduce:
See above
Comment 1 Mihhail Verhovtsov CLA 2010-10-15 08:34:51 EDT
Created attachment 180950 [details]
Test case (Eclipse project and classes)

TestBug folder is Eclipse project.
The other folder I used to create the JAR file.
Comment 2 Olivier Thomann CLA 2010-10-15 10:30:11 EDT
This might be related to the fact that A comes as a binary type binding.
Comment 3 Srikanth Sankaran CLA 2011-01-10 05:05:48 EST
This is the same bug as the one reported in 
https://bugs.eclipse.org/bugs/show_bug.cgi?id=324945.

(In reply to comment #0)
[...]

> Eclipse compiles it without problems. Method someMethod() is usable. 
> 
> Sun's javac doesn't compile that code.

Yes, it does. For a proper comparison, you need to delete A.java
and A.class and ensure that A is presented to the compiler only
in the incarnation available in the jar file when it compiles B.

*** This bug has been marked as a duplicate of bug 324945 ***
Comment 4 Olivier Thomann CLA 2011-01-25 09:35:09 EST
Verified for 3.7M5 using I20110124-1800