Fixed bug 384663 - Package Based Annotation Compilation Error in JDT
3.8/4.2 (works in 3.7.2) 

Change-Id: Iee1685b7897675e2a4cefba147bad99e71304611
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
index 875c58e..c5a75b4 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
@@ -11,6 +11,7 @@
  *								bug 295551 - Add option to automatically promote all warnings to error
  *								bug 185682 - Increment/decrement operators mark local variables as read
  *								bug 366003 - CCE in ASTNode.resolveAnnotations(ASTNode.java:639)
+ *								bug 384663 - Package Based Annotation Compilation Error in JDT 3.8/4.2 (works in 3.7.2) 
  *******************************************************************************/
 package org.eclipse.jdt.core.tests.compiler.regression;
 
@@ -47,7 +48,7 @@
 	// Static initializer to specify tests subset using TESTS_* static variables
 	// All specified tests which do not belong to the class are skipped...
 	static {
-//		TESTS_NAMES = new String[] { "testBug376429" };
+//		TESTS_NAMES = new String[] { "testBug384663" };
 //		TESTS_NUMBERS = new int[] { 297 };
 //		TESTS_RANGE = new int[] { 294, -1 };
 	}
@@ -10608,4 +10609,32 @@
 			expectedErrorString,
 			JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
 }
+// https://bugs.eclipse.org/384663
+// Package Based Annotation Compilation Error in JDT 3.8/4.2 (works in 3.7.2)
+public void testBug384663() {
+	String[] testFiles = {
+		"annotations/test/IExtendsInterface.java",
+		"package annotations.test;\n" +
+		"public interface IExtendsInterface extends Interface {}\n",
+
+		"annotations/test/Interface.java",
+		"package annotations.test;\n" +
+		"public interface Interface {}\n",
+
+		"annotations/test/package-info.java",
+		"@AnnotationDefinition(\"Test1\") \n" +
+		"package annotations.test;\n" +
+		"import annotations.AnnotationDefinition;",
+
+		"annotations/AnnotationDefinition.java",
+		"package annotations;\n" +
+		"import java.lang.annotation.*;\n" +
+		"@Retention(RetentionPolicy.RUNTIME)\n" +
+		"@Target(ElementType.PACKAGE)\n" +
+		"public @interface AnnotationDefinition {\n" +
+		"	String value();\n" + 
+		"}",
+	};
+	runConformTest(testFiles);
+}
 }
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index 901769c..a8fbc59 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -16,6 +16,7 @@
  *								bug 365662 - [compiler][null] warn on contradictory and redundant null annotations
  *								bug 365531 - [compiler][null] investigate alternative strategy for internally encoding nullness defaults
  *								bug 366063 - Compiler should not add synthetic @NonNull annotations
+ *								bug 384663 - Package Based Annotation Compilation Error in JDT 3.8/4.2 (works in 3.7.2)
  *******************************************************************************/
 package org.eclipse.jdt.internal.compiler.lookup;
 
@@ -1180,6 +1181,10 @@
 	if ((this.tagBits & TagBits.AreMethodsComplete) != 0)
 		return this.methods;
 
+	if (!areMethodsInitialized()) { // https://bugs.eclipse.org/384663
+		this.scope.buildMethods();
+	}
+
 	// lazily sort methods
 	if ((this.tagBits & TagBits.AreMethodsSorted) == 0) {
 		int length = this.methods.length;