Skip to content

Eclipse compiler re-orders properties when defined in multiple interfaces. #372

@JakeWharton

Description

@JakeWharton

Given the following source inside Eclipse:

interface Thing {
  String one();
  String two();
  boolean three();
  long four();
}
interface Other {
  String two();
  long four();
}
@com.google.auto.value.AutoValue
abstract class Impl implements Thing, Other {
}

with auto-value-1.3.jar added to the compilation and processor classpath, Eclipse generates .apt_generated/AutoValue_Impl.java which looks like this (abridged):

 final class AutoValue_Impl extends Impl {

  private final String one;
  private final boolean three;
  private final String two;
  private final long four;

  AutoValue_Impl(
      String one,
      boolean three,
      String two,
      long four) {

As you can see the order from the first interface is retained except for properties that were also defined in the second interface which were hoisted to the end of the list.

This reflects Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=500570 which was identified using Android's Jack compiler (built on ecj) http://b.android.com/219927. Oracle's JDK and OpenJDK javac do not exhibit this behavior and instead supply the annotation processor with the four properties in the order of the first interface only.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions