Apply patch for HARMONY-6436: [java6]implement javax.annotation package

git-svn-id: https://svn.apache.org/repos/asf/harmony/enhanced/classlib/branches/java6@907559 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/modules/annotation/src/main/java/javax/annotation/Generated.java b/modules/annotation/src/main/java/javax/annotation/Generated.java
new file mode 100644
index 0000000..7007fd1
--- /dev/null
+++ b/modules/annotation/src/main/java/javax/annotation/Generated.java
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 javax.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(value = RetentionPolicy.SOURCE)
+@Target(value = { ElementType.PACKAGE, ElementType.TYPE,
+        ElementType.ANNOTATION_TYPE, ElementType.METHOD,
+        ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE,
+        ElementType.PARAMETER })
+public @interface Generated {
+    String[] value();
+
+    String comments();
+
+    String date();
+}
diff --git a/modules/annotation/src/main/java/javax/annotation/PostConstruct.java b/modules/annotation/src/main/java/javax/annotation/PostConstruct.java
new file mode 100644
index 0000000..21a4e0b
--- /dev/null
+++ b/modules/annotation/src/main/java/javax/annotation/PostConstruct.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 javax.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = ElementType.METHOD)
+public @interface PostConstruct {
+
+}
diff --git a/modules/annotation/src/main/java/javax/annotation/PreDestroy.java b/modules/annotation/src/main/java/javax/annotation/PreDestroy.java
new file mode 100644
index 0000000..f9966d0
--- /dev/null
+++ b/modules/annotation/src/main/java/javax/annotation/PreDestroy.java
@@ -0,0 +1,30 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 javax.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = ElementType.METHOD)
+public @interface PreDestroy {
+}
diff --git a/modules/annotation/src/main/java/javax/annotation/Resource.java b/modules/annotation/src/main/java/javax/annotation/Resource.java
new file mode 100644
index 0000000..d0827bd
--- /dev/null
+++ b/modules/annotation/src/main/java/javax/annotation/Resource.java
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 javax.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
+@Retention(value = RetentionPolicy.RUNTIME)
+public @interface Resource {
+    public enum AuthenticationType {
+        CONTAINER, APPLICATION
+    }
+
+    AuthenticationType authenticationType() default javax.annotation.Resource.AuthenticationType.CONTAINER;
+
+    String description() default "";
+
+    String mappedName() default "";
+
+    String name() default "";
+
+    boolean shareable() default true;
+
+    Class type() default java.lang.Object.class;
+}
diff --git a/modules/annotation/src/main/java/javax/annotation/Resources.java b/modules/annotation/src/main/java/javax/annotation/Resources.java
new file mode 100644
index 0000000..decb186
--- /dev/null
+++ b/modules/annotation/src/main/java/javax/annotation/Resources.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 javax.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = ElementType.TYPE)
+public @interface Resources {
+    Resource[] value();
+}
diff --git a/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/GeneratedTest.java b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/GeneratedTest.java
new file mode 100644
index 0000000..50820fd
--- /dev/null
+++ b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/GeneratedTest.java
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.harmony.annotation.tests.javax.annotation;
+
+import javax.annotation.Generated;
+
+import junit.framework.TestCase;
+
+public class GeneratedTest extends TestCase {
+    public void testGenerated() throws SecurityException, NoSuchFieldException {
+        assertTrue(Generated.class.isAnnotation());
+    }
+}
diff --git a/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PostConstructTest.java b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PostConstructTest.java
new file mode 100644
index 0000000..518a061
--- /dev/null
+++ b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PostConstructTest.java
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.harmony.annotation.tests.javax.annotation;
+
+import javax.annotation.PostConstruct;
+
+import junit.framework.TestCase;
+
+public class PostConstructTest extends TestCase {
+    public void testPostConstruct() {
+        assertTrue(PostConstruct.class.isAnnotation());
+    }
+}
diff --git a/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
new file mode 100644
index 0000000..c3ece0e
--- /dev/null
+++ b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.harmony.annotation.tests.javax.annotation;
+
+import javax.annotation.PreDestroy;
+
+import junit.framework.TestCase;
+
+public class PreDestroyTest extends TestCase {
+    public void testPreDestroyTest() {
+        assertTrue(PreDestroy.class.isAnnotation());
+    }
+}
diff --git a/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourceTest.java b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourceTest.java
new file mode 100644
index 0000000..0fe4143
--- /dev/null
+++ b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourceTest.java
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.harmony.annotation.tests.javax.annotation;
+
+import javax.annotation.Resource;
+
+import junit.framework.TestCase;
+
+public class ResourceTest extends TestCase {
+    public void testResource() {
+        assertTrue(Resource.class.isAnnotation());
+    }
+}
diff --git a/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/Resource_AuthenticationTypeTest.java b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/Resource_AuthenticationTypeTest.java
new file mode 100644
index 0000000..2add1b7
--- /dev/null
+++ b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/Resource_AuthenticationTypeTest.java
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.harmony.annotation.tests.javax.annotation;
+
+import javax.annotation.Resource;
+
+import junit.framework.TestCase;
+
+public class Resource_AuthenticationTypeTest extends TestCase {
+    public void testValues() {
+        Resource.AuthenticationType[] types = Resource.AuthenticationType
+                .values();
+        assertEquals(2, types.length);
+        // the result array should be ordered
+        assertEquals(Resource.AuthenticationType.CONTAINER, types[0]);
+        assertEquals(Resource.AuthenticationType.APPLICATION, types[1]);
+    }
+
+    public void testValueOf() {
+        Resource.AuthenticationType type = Resource.AuthenticationType
+                .valueOf("CONTAINER");
+        assertEquals(Resource.AuthenticationType.CONTAINER, type);
+
+        type = Resource.AuthenticationType.valueOf("APPLICATION");
+        assertEquals(Resource.AuthenticationType.APPLICATION, type);
+
+        try {
+            type = Resource.AuthenticationType.valueOf(null);
+            fail("should throw NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
+
+        try {
+            type = Resource.AuthenticationType.valueOf("wrong name");
+            fail("should throw IAE");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+}
diff --git a/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
new file mode 100644
index 0000000..92dbd6f
--- /dev/null
+++ b/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.harmony.annotation.tests.javax.annotation;
+
+import javax.annotation.Resources;
+
+import junit.framework.TestCase;
+
+public class ResourcesTest extends TestCase {
+    public void testResources() {
+        assertTrue(Resources.class.isAnnotation());
+    }
+}