Bug 530366 - Mismatched source and class name leads to missing .class

Given classes MyClass1$InnerClass and MyClass2$InnerClass, renaming
MyClass2 to MyClass1 and back results in missing .class file for
MyClass1$InnerClass. The class file is restored on changes in
MyClass1.java or on a clean build.

This is the case, since AbstractImageBuilder.acceptResult doesn't
correctly detect that MyClass1$InnerClass already exists, upon renaming
MyClass2 to MyClass1. It searches for duplicates with type name
MyClass1$InnerClass, instead of MyClass1. Inner classes are not noted,
and so the search yields nothing. The inner class of the original
MyClass1 is then overwritten, and removed as a secondary type later on.

With this change, when compiling after the change,
ClassFile.enclosingClassFile is correctly set for the new inner class
MyClass1$InnerClass. This allows AbstractImageBuilder to detect that it
is a duplicate, and so avoids the issue.

Change-Id: I837df5c53ac42ba15a43c2eec634633c9bc9986f
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
3 files changed
tree: 5b5de7d79ae58fcd00f9abfae98e3401a0333ab5
  1. modules/
  2. org.eclipse.jdt.annotation/
  3. org.eclipse.jdt.annotation_v1/
  4. org.eclipse.jdt.apt.core/
  5. org.eclipse.jdt.apt.pluggable.core/
  6. org.eclipse.jdt.apt.pluggable.tests/
  7. org.eclipse.jdt.apt.tests/
  8. org.eclipse.jdt.apt.ui/
  9. org.eclipse.jdt.compiler.apt/
  10. org.eclipse.jdt.compiler.apt.tests/
  11. org.eclipse.jdt.compiler.tool/
  12. org.eclipse.jdt.compiler.tool.tests/
  13. org.eclipse.jdt.core/
  14. org.eclipse.jdt.core.internal.tools/
  15. org.eclipse.jdt.core.tests.builder/
  16. org.eclipse.jdt.core.tests.compiler/
  17. org.eclipse.jdt.core.tests.model/
  18. org.eclipse.jdt.core.tests.performance/
  19. tests-pom/
  20. .gitignore
  21. pom.xml
  22. README.md
README.md

JDT Core

This is the core part of Eclipse's Java development tools. It contains the non-UI support for compiling and working with Java code, including the following:

  • an incremental or batch Java compiler that can run standalone or as part of the Eclipse IDE
  • Java source and class file indexer and search infrastructure
  • a Java source code formatter
  • APIs for code assist, access to the AST and structured manipulation of Java source.

For more information, refer to the [JDT wiki page] 1 or the [JDT project overview page] 2.

License

Eclipse Public License (EPL) v1.0