# HG changeset patch # User Jaroslav Tulach # Date 1348908725 -7200 # Node ID 8a74b5d8d1d45dea954bec868fa601d4c0d87d78 # Parent e9062591e91de9a3fd5850de381e042be8514d17 Exceptions and annotations diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that an array has been accessed with an + * illegal index. The index is either negative or greater than or + * equal to the size of the array. + * + * @author unascribed + * @since JDK1.0 + */ +public +class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException { + private static final long serialVersionUID = -5116101128118950844L; + + /** + * Constructs an ArrayIndexOutOfBoundsException with no + * detail message. + */ + public ArrayIndexOutOfBoundsException() { + super(); + } + + /** + * Constructs a new ArrayIndexOutOfBoundsException + * class with an argument indicating the illegal index. + * + * @param index the illegal index. + */ + public ArrayIndexOutOfBoundsException(int index) { + super("Array index out of range: " + index); + } + + /** + * Constructs an ArrayIndexOutOfBoundsException class + * with the specified detail message. + * + * @param s the detail message. + */ + public ArrayIndexOutOfBoundsException(String s) { + super(s); + } +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/ClassNotFoundException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/ClassNotFoundException.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,125 @@ +/* + * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown when an application tries to load in a class through its + * string name using: + * + *

+ * but no definition for the class with the specified name could be found. + * + *

As of release 1.4, this exception has been retrofitted to conform to + * the general purpose exception-chaining mechanism. The "optional exception + * that was raised while loading the class" that may be provided at + * construction time and accessed via the {@link #getException()} method is + * now known as the cause, and may be accessed via the {@link + * Throwable#getCause()} method, as well as the aforementioned "legacy method." + * + * @author unascribed + * @see java.lang.Class#forName(java.lang.String) + * @see java.lang.ClassLoader#findSystemClass(java.lang.String) + * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) + * @since JDK1.0 + */ +public class ClassNotFoundException extends ReflectiveOperationException { + /** + * use serialVersionUID from JDK 1.1.X for interoperability + */ + private static final long serialVersionUID = 9176873029745254542L; + + /** + * This field holds the exception ex if the + * ClassNotFoundException(String s, Throwable ex) constructor was + * used to instantiate the object + * @serial + * @since 1.2 + */ + private Throwable ex; + + /** + * Constructs a ClassNotFoundException with no detail message. + */ + public ClassNotFoundException() { + super((Throwable)null); // Disallow initCause + } + + /** + * Constructs a ClassNotFoundException with the + * specified detail message. + * + * @param s the detail message. + */ + public ClassNotFoundException(String s) { + super(s, null); // Disallow initCause + } + + /** + * Constructs a ClassNotFoundException with the + * specified detail message and optional exception that was + * raised while loading the class. + * + * @param s the detail message + * @param ex the exception that was raised while loading the class + * @since 1.2 + */ + public ClassNotFoundException(String s, Throwable ex) { + super(s, null); // Disallow initCause + this.ex = ex; + } + + /** + * Returns the exception that was raised if an error occurred while + * attempting to load the class. Otherwise, returns null. + * + *

This method predates the general-purpose exception chaining facility. + * The {@link Throwable#getCause()} method is now the preferred means of + * obtaining this information. + * + * @return the Exception that was raised while loading a class + * @since 1.2 + */ + public Throwable getException() { + return ex; + } + + /** + * Returns the cause of this exception (the exception that was raised + * if an error occurred while attempting to load the class; otherwise + * null). + * + * @return the cause of this exception. + * @since 1.4 + */ + public Throwable getCause() { + return ex; + } +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/IllegalStateException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/IllegalStateException.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Signals that a method has been invoked at an illegal or + * inappropriate time. In other words, the Java environment or + * Java application is not in an appropriate state for the requested + * operation. + * + * @author Jonni Kanerva + * @since JDK1.1 + */ +public +class IllegalStateException extends RuntimeException { + /** + * Constructs an IllegalStateException with no detail message. + * A detail message is a String that describes this particular exception. + */ + public IllegalStateException() { + super(); + } + + /** + * Constructs an IllegalStateException with the specified detail + * message. A detail message is a String that describes this particular + * exception. + * + * @param s the String that contains a detailed message + */ + public IllegalStateException(String s) { + super(s); + } + + /** + * Constructs a new exception with the specified detail message and + * cause. + * + *

Note that the detail message associated with cause is + * not automatically incorporated in this exception's detail + * message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link Throwable#getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link Throwable#getCause()} method). (A null value + * is permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public IllegalStateException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail + * message of (cause==null ? null : cause.toString()) (which + * typically contains the class and detail message of cause). + * This constructor is useful for exceptions that are little more than + * wrappers for other throwables (for example, {@link + * java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the + * {@link Throwable#getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public IllegalStateException(Throwable cause) { + super(cause); + } + + static final long serialVersionUID = -1848914673093119416L; +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/IndexOutOfBoundsException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/IndexOutOfBoundsException.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that an index of some sort (such as to an array, to a + * string, or to a vector) is out of range. + *

+ * Applications can subclass this class to indicate similar exceptions. + * + * @author Frank Yellin + * @since JDK1.0 + */ +public +class IndexOutOfBoundsException extends RuntimeException { + private static final long serialVersionUID = 234122996006267687L; + + /** + * Constructs an IndexOutOfBoundsException with no + * detail message. + */ + public IndexOutOfBoundsException() { + super(); + } + + /** + * Constructs an IndexOutOfBoundsException with the + * specified detail message. + * + * @param s the detail message. + */ + public IndexOutOfBoundsException(String s) { + super(s); + } +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/InstantiationException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/InstantiationException.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown when an application tries to create an instance of a class + * using the {@code newInstance} method in class + * {@code Class}, but the specified class object cannot be + * instantiated. The instantiation can fail for a variety of + * reasons including but not limited to: + * + *

+ * + * @author unascribed + * @see java.lang.Class#newInstance() + * @since JDK1.0 + */ +public +class InstantiationException extends ReflectiveOperationException { + private static final long serialVersionUID = -8441929162975509110L; + + /** + * Constructs an {@code InstantiationException} with no detail message. + */ + public InstantiationException() { + super(); + } + + /** + * Constructs an {@code InstantiationException} with the + * specified detail message. + * + * @param s the detail message. + */ + public InstantiationException(String s) { + super(s); + } +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/StringIndexOutOfBoundsException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/StringIndexOutOfBoundsException.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown by String methods to indicate that an index + * is either negative or greater than the size of the string. For + * some methods such as the charAt method, this exception also is + * thrown when the index is equal to the size of the string. + * + * @author unascribed + * @see java.lang.String#charAt(int) + * @since JDK1.0 + */ +public +class StringIndexOutOfBoundsException extends IndexOutOfBoundsException { + private static final long serialVersionUID = -6762910422159637258L; + + /** + * Constructs a StringIndexOutOfBoundsException with no + * detail message. + * + * @since JDK1.0. + */ + public StringIndexOutOfBoundsException() { + super(); + } + + /** + * Constructs a StringIndexOutOfBoundsException with + * the specified detail message. + * + * @param s the detail message. + */ + public StringIndexOutOfBoundsException(String s) { + super(s); + } + + /** + * Constructs a new StringIndexOutOfBoundsException + * class with an argument indicating the illegal index. + * + * @param index the illegal index. + */ + public StringIndexOutOfBoundsException(int index) { + super("String index out of range: " + index); + } +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/annotation/Annotation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/Annotation.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.annotation; + +/** + * The common interface extended by all annotation types. Note that an + * interface that manually extends this one does not define + * an annotation type. Also note that this interface does not itself + * define an annotation type. + * + * More information about annotation types can be found in section 9.6 of + * The Java™ Language Specification. + * + * @author Josh Bloch + * @since 1.5 + */ +public interface Annotation { + /** + * Returns true if the specified object represents an annotation + * that is logically equivalent to this one. In other words, + * returns true if the specified object is an instance of the same + * annotation type as this instance, all of whose members are equal + * to the corresponding member of this annotation, as defined below: + * + * + * @return true if the specified object represents an annotation + * that is logically equivalent to this one, otherwise false + */ + boolean equals(Object obj); + + /** + * Returns the hash code of this annotation, as defined below: + * + *

The hash code of an annotation is the sum of the hash codes + * of its members (including those with default values), as defined + * below: + * + * The hash code of an annotation member is (127 times the hash code + * of the member-name as computed by {@link String#hashCode()}) XOR + * the hash code of the member-value, as defined below: + * + *

The hash code of a member-value depends on its type: + *

+ * + * @return the hash code of this annotation + */ + int hashCode(); + + /** + * Returns a string representation of this annotation. The details + * of the representation are implementation-dependent, but the following + * may be regarded as typical: + *
+     *   @com.acme.util.Name(first=Alfred, middle=E., last=Neuman)
+     * 
+ * + * @return a string representation of this annotation + */ + String toString(); + + /** + * Returns the annotation type of this annotation. + */ + Class annotationType(); +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/annotation/Documented.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/Documented.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.annotation; + +/** + * Indicates that annotations with a type are to be documented by javadoc + * and similar tools by default. This type should be used to annotate the + * declarations of types whose annotations affect the use of annotated + * elements by their clients. If a type declaration is annotated with + * Documented, its annotations become part of the public API + * of the annotated elements. + * + * @author Joshua Bloch + * @since 1.5 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Documented { +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/annotation/NullPointerException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/NullPointerException.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown when an application attempts to use {@code null} in a + * case where an object is required. These include: + * + *

+ * Applications should throw instances of this class to indicate + * other illegal uses of the {@code null} object. + * + * {@code NullPointerException} objects may be constructed by the + * virtual machine as if {@linkplain Throwable#Throwable(String, + * Throwable, boolean, boolean) suppression were disabled and/or the + * stack trace was not writable}. + * + * @author unascribed + * @since JDK1.0 + */ +public +class NullPointerException extends RuntimeException { + private static final long serialVersionUID = 5162710183389028792L; + + /** + * Constructs a {@code NullPointerException} with no detail message. + */ + public NullPointerException() { + super(); + } + + /** + * Constructs a {@code NullPointerException} with the specified + * detail message. + * + * @param s the detail message. + */ + public NullPointerException(String s) { + super(s); + } +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/annotation/Retention.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/Retention.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.annotation; + +/** + * Indicates how long annotations with the annotated type are to + * be retained. If no Retention annotation is present on + * an annotation type declaration, the retention policy defaults to + * {@code RetentionPolicy.CLASS}. + * + *

A Retention meta-annotation has effect only if the + * meta-annotated type is used directly for annotation. It has no + * effect if the meta-annotated type is used as a member type in + * another annotation type. + * + * @author Joshua Bloch + * @since 1.5 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Retention { + RetentionPolicy value(); +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/annotation/RetentionPolicy.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/RetentionPolicy.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.annotation; + +/** + * Annotation retention policy. The constants of this enumerated type + * describe the various policies for retaining annotations. They are used + * in conjunction with the {@link Retention} meta-annotation type to specify + * how long annotations are to be retained. + * + * @author Joshua Bloch + * @since 1.5 + */ +public enum RetentionPolicy { + /** + * Annotations are to be discarded by the compiler. + */ + SOURCE, + + /** + * Annotations are to be recorded in the class file by the compiler + * but need not be retained by the VM at run time. This is the default + * behavior. + */ + CLASS, + + /** + * Annotations are to be recorded in the class file by the compiler and + * retained by the VM at run time, so they may be read reflectively. + * + * @see java.lang.reflect.AnnotatedElement + */ + RUNTIME +} diff -r e9062591e91d -r 8a74b5d8d1d4 emul/src/main/java/java/lang/annotation/UnsupportedOperationException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/UnsupportedOperationException.java Sat Sep 29 10:52:05 2012 +0200 @@ -0,0 +1,94 @@ +/* + * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that the requested operation is not supported.

+ * + * This class is a member of the + * + * Java Collections Framework. + * + * @author Josh Bloch + * @since 1.2 + */ +public class UnsupportedOperationException extends RuntimeException { + /** + * Constructs an UnsupportedOperationException with no detail message. + */ + public UnsupportedOperationException() { + } + + /** + * Constructs an UnsupportedOperationException with the specified + * detail message. + * + * @param message the detail message + */ + public UnsupportedOperationException(String message) { + super(message); + } + + /** + * Constructs a new exception with the specified detail message and + * cause. + * + *

Note that the detail message associated with cause is + * not automatically incorporated in this exception's detail + * message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link Throwable#getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link Throwable#getCause()} method). (A null value + * is permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public UnsupportedOperationException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail + * message of (cause==null ? null : cause.toString()) (which + * typically contains the class and detail message of cause). + * This constructor is useful for exceptions that are little more than + * wrappers for other throwables (for example, {@link + * java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the + * {@link Throwable#getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public UnsupportedOperationException(Throwable cause) { + super(cause); + } + + static final long serialVersionUID = -1242599979055084673L; +}