diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/AndroidManifest.xml b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/AndroidManifest.xml
index d69a63ba519b3..6bd47c2ca3e04 100644
--- a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/AndroidManifest.xml
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/AndroidManifest.xml
@@ -7,6 +7,7 @@
value();
+
+}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/AnnotationWithEnum.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/AnnotationWithEnum.java
new file mode 100644
index 0000000000000..15855d5f2f0b9
--- /dev/null
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/AnnotationWithEnum.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.multidexlegacytestapp;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AnnotationWithEnum {
+
+ ReferencedByAnnotation value();
+
+}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/AnnotationWithEnum2.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/AnnotationWithEnum2.java
new file mode 100644
index 0000000000000..ce37b185b8f60
--- /dev/null
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/AnnotationWithEnum2.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.multidexlegacytestapp;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AnnotationWithEnum2 {
+
+ ReferencedByAnnotationWithOtherReferences value();
+
+}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/InterfaceWithEnum.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/InterfaceWithEnum.java
new file mode 100644
index 0000000000000..085c0a3dfda63
--- /dev/null
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/InterfaceWithEnum.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.multidexlegacytestapp;
+
+public interface InterfaceWithEnum {
+
+ ReferencedByInterface getEnum();
+
+}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/MainActivity.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/MainActivity.java
index 3228825d99a46..5bc03f11a76d6 100644
--- a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/MainActivity.java
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/MainActivity.java
@@ -17,7 +17,6 @@ package com.android.multidexlegacytestapp;
import android.app.Activity;
import android.os.Bundle;
-import android.support.multidex.MultiDex;
import android.util.Log;
import android.widget.TextView;
@@ -36,9 +35,6 @@ public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
- Log.i(TAG, "onCreate");
- MultiDex.install(getApplicationContext());
- Log.i(TAG, "Multi dex installation done.");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int value = getValue();
@@ -94,4 +90,8 @@ public class MainActivity extends Activity {
return value;
}
+ public int getAnnotation2Value() {
+ return ((AnnotationWithEnum2) TestApplication.annotation2).value().get();
+ }
+
}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByAnnotation.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByAnnotation.java
new file mode 100644
index 0000000000000..0aa6995cc3b9c
--- /dev/null
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByAnnotation.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.multidexlegacytestapp;
+
+public enum ReferencedByAnnotation {
+
+ A,
+ B;
+
+}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByAnnotationWithOtherReferences.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByAnnotationWithOtherReferences.java
new file mode 100644
index 0000000000000..8cc0d9d02932b
--- /dev/null
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByAnnotationWithOtherReferences.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.multidexlegacytestapp;
+
+public enum ReferencedByAnnotationWithOtherReferences {
+
+ A {
+ private ReferencedByEnum a = new ReferencedByEnum();
+ @Override
+ public int get() {
+ return a.hashCode();
+ }
+ },
+ B {
+ private ReferencedByEnum b = new ReferencedByEnum();
+ @Override
+ public int get() {
+ return b.hashCode();
+ }
+ };
+
+
+ public abstract int get();
+}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByClassInAnnotation.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByClassInAnnotation.java
new file mode 100644
index 0000000000000..06aa560f68019
--- /dev/null
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByClassInAnnotation.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.multidexlegacytestapp;
+
+public enum ReferencedByClassInAnnotation {
+
+ A {
+ private ReferencedByEnum a = new ReferencedByEnum();
+ @Override
+ public int get() {
+ return a.hashCode();
+ }
+ },
+ B {
+ private ReferencedByEnum b = new ReferencedByEnum();
+ @Override
+ public int get() {
+ return b.hashCode();
+ }
+ };
+
+
+ public abstract int get();
+}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByEnum.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByEnum.java
new file mode 100644
index 0000000000000..1ceb3d3b45e56
--- /dev/null
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByEnum.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.multidexlegacytestapp;
+
+public class ReferencedByEnum {
+
+}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByInterface.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByInterface.java
new file mode 100644
index 0000000000000..17f1449e5b695
--- /dev/null
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/ReferencedByInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.multidexlegacytestapp;
+
+public enum ReferencedByInterface {
+
+ A,
+ B;
+
+}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/Test.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/Test.java
index 59cac07aea709..bbdd3e5c5ccce 100644
--- a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/Test.java
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/Test.java
@@ -17,6 +17,11 @@ package com.android.multidexlegacytestapp;
import android.test.ActivityInstrumentationTestCase2;
+/**
+ * Run the tests with: adb shell am instrument -w
+ com.android.multidexlegacytestapp/android.test.InstrumentationTestRunner
+
+ */
public class Test extends ActivityInstrumentationTestCase2 {
public Test() {
super(MainActivity.class);
@@ -25,4 +30,23 @@ public class Test extends ActivityInstrumentationTestCase2 {
public void testAllClassesAvailable() {
assertEquals(3366, getActivity().getValue());
}
+
+ public void testAnnotation() {
+ assertEquals(ReferencedByAnnotation.B,
+ ((AnnotationWithEnum) TestApplication.annotation).value());
+ assertEquals(ReferencedByAnnotation.B,
+ ((AnnotationWithEnum) TestApplication.getAnnotationWithEnum()).value());
+ // Just to verify that it doesn't crash
+ getActivity().getAnnotation2Value();
+
+ assertEquals(ReferencedByClassInAnnotation.class,
+ ((AnnotationWithClass) TestApplication.annotation3).value());
+ // Just to verify that it doesn't crash
+ ReferencedByClassInAnnotation.A.get();
+ }
+
+ public void testInterface() {
+ assertEquals(InterfaceWithEnum.class,
+ TestApplication.interfaceClass);
+ }
}
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/TestApplication.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/TestApplication.java
new file mode 100644
index 0000000000000..c52ad292b6de4
--- /dev/null
+++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/src/com/android/multidexlegacytestapp/TestApplication.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.multidexlegacytestapp;
+
+import android.support.multidex.MultiDexApplication;
+
+import java.lang.annotation.Annotation;
+
+@AnnotationWithEnum(ReferencedByAnnotation.B)
+public class TestApplication extends MultiDexApplication {
+
+ public static Annotation annotation = getAnnotationWithEnum();
+ public static Annotation annotation2 = getSoleAnnotation(Annotated.class);
+ public static Annotation annotation3 = getSoleAnnotation(Annotated2.class);
+ public static Class> interfaceClass = InterfaceWithEnum.class;
+
+ public static Annotation getAnnotationWithEnum() {
+ return getSoleAnnotation(TestApplication.class);
+ }
+
+ public static Annotation getSoleAnnotation(Class> annotated) {
+ Annotation[] annot = annotated.getAnnotations();
+ if (annot.length == 1) {
+ return annot[0];
+ }
+
+ throw new AssertionError();
+ }
+
+}