feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
71
jdkSrc/jdk8/javax/annotation/Generated.java
Normal file
71
jdkSrc/jdk8/javax/annotation/Generated.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, 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 javax.annotation;
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* The Generated annotation is used to mark source code that has been generated.
|
||||
* It can also be used to differentiate user written code from generated code
|
||||
* in a single file. When used, the value element must have the name of the
|
||||
* code generator. The recommended convention is to use the fully qualified
|
||||
* name of the code generator in the value field .
|
||||
* <p>For example: com.company.package.classname.
|
||||
* The date element is used to indicate the date the source was generated.
|
||||
* The date element must follow the ISO 8601 standard. For example the date
|
||||
* element would have the following value 2001-07-04T12:08:56.235-0700
|
||||
* which represents 2001-07-04 12:08:56 local time in the U.S. Pacific
|
||||
* Time time zone.</p>
|
||||
* <p>The comment element is a place holder for any comments that the code
|
||||
* generator may want to include in the generated code.</p>
|
||||
*
|
||||
* @since Common Annotations 1.0
|
||||
*/
|
||||
|
||||
@Documented
|
||||
@Retention(SOURCE)
|
||||
@Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD,
|
||||
LOCAL_VARIABLE, PARAMETER})
|
||||
public @interface Generated {
|
||||
/**
|
||||
* The value element MUST have the name of the code generator.
|
||||
* The recommended convention is to use the fully qualified name of the
|
||||
* code generator. For example: com.acme.generator.CodeGen.
|
||||
*/
|
||||
String[] value();
|
||||
|
||||
/**
|
||||
* Date when the source was generated.
|
||||
*/
|
||||
String date() default "";
|
||||
|
||||
/**
|
||||
* A place holder for any comments that the code generator may want to
|
||||
* include in the generated code.
|
||||
*/
|
||||
String comments() default "";
|
||||
}
|
||||
81
jdkSrc/jdk8/javax/annotation/PostConstruct.java
Normal file
81
jdkSrc/jdk8/javax/annotation/PostConstruct.java
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, 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 javax.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* The PostConstruct annotation is used on a method that needs to be executed
|
||||
* after dependency injection is done to perform any initialization. This
|
||||
* method MUST be invoked before the class is put into service. This
|
||||
* annotation MUST be supported on all classes that support dependency
|
||||
* injection. The method annotated with PostConstruct MUST be invoked even
|
||||
* if the class does not request any resources to be injected. Only one
|
||||
* method can be annotated with this annotation. The method on which the
|
||||
* PostConstruct annotation is applied MUST fulfill all of the following
|
||||
* criteria:
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>The method MUST NOT have any parameters except in the case of
|
||||
* interceptors in which case it takes an InvocationContext object as
|
||||
* defined by the Interceptors specification.</li>
|
||||
* <li>The method defined on an interceptor class MUST HAVE one of the
|
||||
* following signatures:
|
||||
* <p>
|
||||
* void <METHOD>(InvocationContext)
|
||||
* <p>
|
||||
* Object <METHOD>(InvocationContext) throws Exception
|
||||
* <p>
|
||||
* <i>Note: A PostConstruct interceptor method must not throw application
|
||||
* exceptions, but it may be declared to throw checked exceptions including
|
||||
* the java.lang.Exception if the same interceptor method interposes on
|
||||
* business or timeout methods in addition to lifecycle events. If a
|
||||
* PostConstruct interceptor method returns a value, it is ignored by
|
||||
* the container.</i>
|
||||
* </li>
|
||||
* <li>The method defined on a non-interceptor class MUST HAVE the
|
||||
* following signature:
|
||||
* <p>
|
||||
* void <METHOD>()
|
||||
* </li>
|
||||
* <li>The method on which PostConstruct is applied MAY be public, protected,
|
||||
* package private or private.</li>
|
||||
* <li>The method MUST NOT be static except for the application client.</li>
|
||||
* <li>The method MAY be final.</li>
|
||||
* <li>If the method throws an unchecked exception the class MUST NOT be put into
|
||||
* service except in the case of EJBs where the EJB can handle exceptions and
|
||||
* even recover from them.</li></ul>
|
||||
* @since Common Annotations 1.0
|
||||
* @see javax.annotation.PreDestroy
|
||||
* @see javax.annotation.Resource
|
||||
*/
|
||||
@Documented
|
||||
@Retention (RUNTIME)
|
||||
@Target(METHOD)
|
||||
public @interface PostConstruct {
|
||||
}
|
||||
82
jdkSrc/jdk8/javax/annotation/PreDestroy.java
Normal file
82
jdkSrc/jdk8/javax/annotation/PreDestroy.java
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, 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 javax.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* The PreDestroy annotation is used on methods as a callback notification to
|
||||
* signal that the instance is in the process of being removed by the
|
||||
* container. The method annotated with PreDestroy is typically used to
|
||||
* release resources that it has been holding. This annotation MUST be
|
||||
* supported by all container managed objects that support PostConstruct
|
||||
* except the application client container in Java EE 5. The method on which
|
||||
* the PreDestroy annotation is applied MUST fulfill all of the following
|
||||
* criteria:
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>The method MUST NOT have any parameters except in the case of
|
||||
* interceptors in which case it takes an InvocationContext object as
|
||||
* defined by the Interceptors specification.</li>
|
||||
* <li>The method defined on an interceptor class MUST HAVE one of the
|
||||
* following signatures:
|
||||
* <p>
|
||||
* void <METHOD>(InvocationContext)
|
||||
* <p>
|
||||
* Object <METHOD>(InvocationContext) throws Exception
|
||||
* <p>
|
||||
* <i>Note: A PreDestroy interceptor method must not throw application
|
||||
* exceptions, but it may be declared to throw checked exceptions including
|
||||
* the java.lang.Exception if the same interceptor method interposes on
|
||||
* business or timeout methods in addition to lifecycle events. If a
|
||||
* PreDestroy interceptor method returns a value, it is ignored by
|
||||
* the container.</i>
|
||||
* </li>
|
||||
* <li>The method defined on a non-interceptor class MUST HAVE the
|
||||
* following signature:
|
||||
* <p>
|
||||
* void <METHOD>()
|
||||
* </li>
|
||||
* <li>The method on which PreDestroy is applied MAY be public, protected,
|
||||
* package private or private.</li>
|
||||
* <li>The method MUST NOT be static.</li>
|
||||
* <li>The method MAY be final.</li>
|
||||
* <li>If the method throws an unchecked exception it is ignored except in the
|
||||
* case of EJBs where the EJB can handle exceptions.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see javax.annotation.PostConstruct
|
||||
* @see javax.annotation.Resource
|
||||
* @since Common Annotations 1.0
|
||||
*/
|
||||
|
||||
@Documented
|
||||
@Retention (RUNTIME)
|
||||
@Target(METHOD)
|
||||
public @interface PreDestroy {
|
||||
}
|
||||
132
jdkSrc/jdk8/javax/annotation/Resource.java
Normal file
132
jdkSrc/jdk8/javax/annotation/Resource.java
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 javax.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* The Resource annotation marks a resource that is needed
|
||||
* by the application. This annotation may be applied to an
|
||||
* application component class, or to fields or methods of the
|
||||
* component class. When the annotation is applied to a
|
||||
* field or method, the container will inject an instance
|
||||
* of the requested resource into the application component
|
||||
* when the component is initialized. If the annotation is
|
||||
* applied to the component class, the annotation declares a
|
||||
* resource that the application will look up at runtime. <p>
|
||||
*
|
||||
* Even though this annotation is not marked Inherited, deployment
|
||||
* tools are required to examine all superclasses of any component
|
||||
* class to discover all uses of this annotation in all superclasses.
|
||||
* All such annotation instances specify resources that are needed
|
||||
* by the application component. Note that this annotation may
|
||||
* appear on private fields and methods of superclasses; the container
|
||||
* is required to perform injection in these cases as well.
|
||||
*
|
||||
* @since Common Annotations 1.0
|
||||
*/
|
||||
@Target({TYPE, FIELD, METHOD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Resource {
|
||||
/**
|
||||
* The JNDI name of the resource. For field annotations,
|
||||
* the default is the field name. For method annotations,
|
||||
* the default is the JavaBeans property name corresponding
|
||||
* to the method. For class annotations, there is no default
|
||||
* and this must be specified.
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* The name of the resource that the reference points to. It can
|
||||
* link to any compatible resource using the global JNDI names.
|
||||
*
|
||||
* @since Common Annotations 1.1
|
||||
*/
|
||||
|
||||
String lookup() default "";
|
||||
|
||||
/**
|
||||
* The Java type of the resource. For field annotations,
|
||||
* the default is the type of the field. For method annotations,
|
||||
* the default is the type of the JavaBeans property.
|
||||
* For class annotations, there is no default and this must be
|
||||
* specified.
|
||||
*/
|
||||
Class<?> type() default java.lang.Object.class;
|
||||
|
||||
/**
|
||||
* The two possible authentication types for a resource.
|
||||
*/
|
||||
enum AuthenticationType {
|
||||
CONTAINER,
|
||||
APPLICATION
|
||||
}
|
||||
|
||||
/**
|
||||
* The authentication type to use for this resource.
|
||||
* This may be specified for resources representing a
|
||||
* connection factory of any supported type, and must
|
||||
* not be specified for resources of other types.
|
||||
*/
|
||||
AuthenticationType authenticationType() default AuthenticationType.CONTAINER;
|
||||
|
||||
/**
|
||||
* Indicates whether this resource can be shared between
|
||||
* this component and other components.
|
||||
* This may be specified for resources representing a
|
||||
* connection factory of any supported type, and must
|
||||
* not be specified for resources of other types.
|
||||
*/
|
||||
boolean shareable() default true;
|
||||
|
||||
/**
|
||||
* A product specific name that this resource should be mapped to.
|
||||
* The name of this resource, as defined by the <code>name</code>
|
||||
* element or defaulted, is a name that is local to the application
|
||||
* component using the resource. (It's a name in the JNDI
|
||||
* <code>java:comp/env</code> namespace.) Many application servers
|
||||
* provide a way to map these local names to names of resources
|
||||
* known to the application server. This mapped name is often a
|
||||
* <i>global</i> JNDI name, but may be a name of any form. <p>
|
||||
*
|
||||
* Application servers are not required to support any particular
|
||||
* form or type of mapped name, nor the ability to use mapped names.
|
||||
* The mapped name is product-dependent and often installation-dependent.
|
||||
* No use of a mapped name is portable.
|
||||
*/
|
||||
String mappedName() default "";
|
||||
|
||||
/**
|
||||
* Description of this resource. The description is expected
|
||||
* to be in the default language of the system on which the
|
||||
* application is deployed. The description can be presented
|
||||
* to the Deployer to help in choosing the correct resource.
|
||||
*/
|
||||
String description() default "";
|
||||
}
|
||||
46
jdkSrc/jdk8/javax/annotation/Resources.java
Normal file
46
jdkSrc/jdk8/javax/annotation/Resources.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 javax.annotation;
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* This class is used to allow multiple resources declarations.
|
||||
*
|
||||
* @see javax.annotation.Resource
|
||||
* @since Common Annotations 1.0
|
||||
*/
|
||||
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Target(TYPE)
|
||||
public @interface Resources {
|
||||
/**
|
||||
* Array used for multiple resource declarations.
|
||||
*/
|
||||
Resource[] value();
|
||||
}
|
||||
195
jdkSrc/jdk8/javax/annotation/processing/AbstractProcessor.java
Normal file
195
jdkSrc/jdk8/javax/annotation/processing/AbstractProcessor.java
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, 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 javax.annotation.processing;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
/**
|
||||
* An abstract annotation processor designed to be a convenient
|
||||
* superclass for most concrete annotation processors. This class
|
||||
* examines annotation values to compute the {@linkplain
|
||||
* #getSupportedOptions options}, {@linkplain
|
||||
* #getSupportedAnnotationTypes annotation types}, and {@linkplain
|
||||
* #getSupportedSourceVersion source version} supported by its
|
||||
* subtypes.
|
||||
*
|
||||
* <p>The getter methods may {@linkplain Messager#printMessage issue
|
||||
* warnings} about noteworthy conditions using the facilities available
|
||||
* after the processor has been {@linkplain #isInitialized
|
||||
* initialized}.
|
||||
*
|
||||
* <p>Subclasses are free to override the implementation and
|
||||
* specification of any of the methods in this class as long as the
|
||||
* general {@link javax.annotation.processing.Processor Processor}
|
||||
* contract for that method is obeyed.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class AbstractProcessor implements Processor {
|
||||
/**
|
||||
* Processing environment providing by the tool framework.
|
||||
*/
|
||||
protected ProcessingEnvironment processingEnv;
|
||||
private boolean initialized = false;
|
||||
|
||||
/**
|
||||
* Constructor for subclasses to call.
|
||||
*/
|
||||
protected AbstractProcessor() {}
|
||||
|
||||
/**
|
||||
* If the processor class is annotated with {@link
|
||||
* SupportedOptions}, return an unmodifiable set with the same set
|
||||
* of strings as the annotation. If the class is not so
|
||||
* annotated, an empty set is returned.
|
||||
*
|
||||
* @return the options recognized by this processor, or an empty
|
||||
* set if none
|
||||
*/
|
||||
public Set<String> getSupportedOptions() {
|
||||
SupportedOptions so = this.getClass().getAnnotation(SupportedOptions.class);
|
||||
if (so == null)
|
||||
return Collections.emptySet();
|
||||
else
|
||||
return arrayToSet(so.value());
|
||||
}
|
||||
|
||||
/**
|
||||
* If the processor class is annotated with {@link
|
||||
* SupportedAnnotationTypes}, return an unmodifiable set with the
|
||||
* same set of strings as the annotation. If the class is not so
|
||||
* annotated, an empty set is returned.
|
||||
*
|
||||
* @return the names of the annotation types supported by this
|
||||
* processor, or an empty set if none
|
||||
*/
|
||||
public Set<String> getSupportedAnnotationTypes() {
|
||||
SupportedAnnotationTypes sat = this.getClass().getAnnotation(SupportedAnnotationTypes.class);
|
||||
if (sat == null) {
|
||||
if (isInitialized())
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING,
|
||||
"No SupportedAnnotationTypes annotation " +
|
||||
"found on " + this.getClass().getName() +
|
||||
", returning an empty set.");
|
||||
return Collections.emptySet();
|
||||
}
|
||||
else
|
||||
return arrayToSet(sat.value());
|
||||
}
|
||||
|
||||
/**
|
||||
* If the processor class is annotated with {@link
|
||||
* SupportedSourceVersion}, return the source version in the
|
||||
* annotation. If the class is not so annotated, {@link
|
||||
* SourceVersion#RELEASE_6} is returned.
|
||||
*
|
||||
* @return the latest source version supported by this processor
|
||||
*/
|
||||
public SourceVersion getSupportedSourceVersion() {
|
||||
SupportedSourceVersion ssv = this.getClass().getAnnotation(SupportedSourceVersion.class);
|
||||
SourceVersion sv = null;
|
||||
if (ssv == null) {
|
||||
sv = SourceVersion.RELEASE_6;
|
||||
if (isInitialized())
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING,
|
||||
"No SupportedSourceVersion annotation " +
|
||||
"found on " + this.getClass().getName() +
|
||||
", returning " + sv + ".");
|
||||
} else
|
||||
sv = ssv.value();
|
||||
return sv;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the processor with the processing environment by
|
||||
* setting the {@code processingEnv} field to the value of the
|
||||
* {@code processingEnv} argument. An {@code
|
||||
* IllegalStateException} will be thrown if this method is called
|
||||
* more than once on the same object.
|
||||
*
|
||||
* @param processingEnv environment to access facilities the tool framework
|
||||
* provides to the processor
|
||||
* @throws IllegalStateException if this method is called more than once.
|
||||
*/
|
||||
public synchronized void init(ProcessingEnvironment processingEnv) {
|
||||
if (initialized)
|
||||
throw new IllegalStateException("Cannot call init more than once.");
|
||||
Objects.requireNonNull(processingEnv, "Tool provided null ProcessingEnvironment");
|
||||
|
||||
this.processingEnv = processingEnv;
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public abstract boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnv);
|
||||
|
||||
/**
|
||||
* Returns an empty iterable of completions.
|
||||
*
|
||||
* @param element {@inheritDoc}
|
||||
* @param annotation {@inheritDoc}
|
||||
* @param member {@inheritDoc}
|
||||
* @param userText {@inheritDoc}
|
||||
*/
|
||||
public Iterable<? extends Completion> getCompletions(Element element,
|
||||
AnnotationMirror annotation,
|
||||
ExecutableElement member,
|
||||
String userText) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this object has been {@linkplain #init
|
||||
* initialized}, {@code false} otherwise.
|
||||
*
|
||||
* @return {@code true} if this object has been initialized,
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
protected synchronized boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
private static Set<String> arrayToSet(String[] array) {
|
||||
assert array != null;
|
||||
Set<String> set = new HashSet<String>(array.length);
|
||||
for (String s : array)
|
||||
set.add(s);
|
||||
return Collections.unmodifiableSet(set);
|
||||
}
|
||||
}
|
||||
51
jdkSrc/jdk8/javax/annotation/processing/Completion.java
Normal file
51
jdkSrc/jdk8/javax/annotation/processing/Completion.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 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 javax.annotation.processing;
|
||||
|
||||
/**
|
||||
* A suggested {@linkplain Processor#getCompletions <em>completion</em>} for an
|
||||
* annotation. A completion is text meant to be inserted into a
|
||||
* program as part of an annotation.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface Completion {
|
||||
|
||||
/**
|
||||
* Returns the text of the suggested completion.
|
||||
* @return the text of the suggested completion.
|
||||
*/
|
||||
String getValue();
|
||||
|
||||
/**
|
||||
* Returns an informative message about the completion.
|
||||
* @return an informative message about the completion.
|
||||
*/
|
||||
String getMessage();
|
||||
}
|
||||
87
jdkSrc/jdk8/javax/annotation/processing/Completions.java
Normal file
87
jdkSrc/jdk8/javax/annotation/processing/Completions.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2012, 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 javax.annotation.processing;
|
||||
|
||||
/**
|
||||
* Utility class for assembling {@link Completion} objects.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public class Completions {
|
||||
// No instances for you.
|
||||
private Completions() {}
|
||||
|
||||
private static class SimpleCompletion implements Completion {
|
||||
private String value;
|
||||
private String message;
|
||||
|
||||
SimpleCompletion(String value, String message) {
|
||||
if (value == null || message == null)
|
||||
throw new NullPointerException("Null completion strings not accepted.");
|
||||
this.value = value;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[\"" + value + "\", \"" + message + "\"]";
|
||||
}
|
||||
// Default equals and hashCode are fine.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a completion of the value and message.
|
||||
*
|
||||
* @param value the text of the completion
|
||||
* @param message a message about the completion
|
||||
* @return a completion of the provided value and message
|
||||
*/
|
||||
public static Completion of(String value, String message) {
|
||||
return new SimpleCompletion(value, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a completion of the value and an empty message
|
||||
*
|
||||
* @param value the text of the completion
|
||||
* @return a completion of the value and an empty message
|
||||
*/
|
||||
public static Completion of(String value) {
|
||||
return new SimpleCompletion(value, "");
|
||||
}
|
||||
}
|
||||
263
jdkSrc/jdk8/javax/annotation/processing/Filer.java
Normal file
263
jdkSrc/jdk8/javax/annotation/processing/Filer.java
Normal file
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 javax.annotation.processing;
|
||||
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.*;
|
||||
import javax.lang.model.element.Element;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This interface supports the creation of new files by an annotation
|
||||
* processor. Files created in this way will be known to the
|
||||
* annotation processing tool implementing this interface, better
|
||||
* enabling the tool to manage them. Source and class files so
|
||||
* created will be {@linkplain RoundEnvironment#getRootElements
|
||||
* considered for processing} by the tool in a subsequent {@linkplain
|
||||
* RoundEnvironment round of processing} after the {@code close}
|
||||
* method has been called on the {@code Writer} or {@code
|
||||
* OutputStream} used to write the contents of the file.
|
||||
*
|
||||
* Three kinds of files are distinguished: source files, class files,
|
||||
* and auxiliary resource files.
|
||||
*
|
||||
* <p> There are two distinguished supported locations (subtrees
|
||||
* within the logical file system) where newly created files are
|
||||
* placed: one for {@linkplain
|
||||
* javax.tools.StandardLocation#SOURCE_OUTPUT new source files}, and
|
||||
* one for {@linkplain javax.tools.StandardLocation#CLASS_OUTPUT new
|
||||
* class files}. (These might be specified on a tool's command line,
|
||||
* for example, using flags such as {@code -s} and {@code -d}.) The
|
||||
* actual locations for new source files and new class files may or
|
||||
* may not be distinct on a particular run of the tool. Resource
|
||||
* files may be created in either location. The methods for reading
|
||||
* and writing resources take a relative name argument. A relative
|
||||
* name is a non-null, non-empty sequence of path segments separated
|
||||
* by {@code '/'}; {@code '.'} and {@code '..'} are invalid path
|
||||
* segments. A valid relative name must match the
|
||||
* "path-rootless" rule of <a
|
||||
* href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>, section
|
||||
* 3.3.
|
||||
*
|
||||
* <p>The file creation methods take a variable number of arguments to
|
||||
* allow the <em>originating elements</em> to be provided as hints to
|
||||
* the tool infrastructure to better manage dependencies. The
|
||||
* originating elements are the types or packages (representing {@code
|
||||
* package-info} files) which caused an annotation processor to
|
||||
* attempt to create a new file. For example, if an annotation
|
||||
* processor tries to create a source file, {@code
|
||||
* GeneratedFromUserSource}, in response to processing
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* @Generate
|
||||
* public class UserSource {}
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* the type element for {@code UserSource} should be passed as part of
|
||||
* the creation method call as in:
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* filer.createSourceFile("GeneratedFromUserSource",
|
||||
* eltUtils.getTypeElement("UserSource"));
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* If there are no originating elements, none need to be passed. This
|
||||
* information may be used in an incremental environment to determine
|
||||
* the need to rerun processors or remove generated files.
|
||||
* Non-incremental environments may ignore the originating element
|
||||
* information.
|
||||
*
|
||||
* <p> During each run of an annotation processing tool, a file with a
|
||||
* given pathname may be created only once. If that file already
|
||||
* exists before the first attempt to create it, the old contents will
|
||||
* be deleted. Any subsequent attempt to create the same file during
|
||||
* a run will throw a {@link FilerException}, as will attempting to
|
||||
* create both a class file and source file for the same type name or
|
||||
* same package name. The {@linkplain Processor initial inputs} to
|
||||
* the tool are considered to be created by the zeroth round;
|
||||
* therefore, attempting to create a source or class file
|
||||
* corresponding to one of those inputs will result in a {@link
|
||||
* FilerException}.
|
||||
*
|
||||
* <p> In general, processors must not knowingly attempt to overwrite
|
||||
* existing files that were not generated by some processor. A {@code
|
||||
* Filer} may reject attempts to open a file corresponding to an
|
||||
* existing type, like {@code java.lang.Object}. Likewise, the
|
||||
* invoker of the annotation processing tool must not knowingly
|
||||
* configure the tool such that the discovered processors will attempt
|
||||
* to overwrite existing files that were not generated.
|
||||
*
|
||||
* <p> Processors can indicate a source or class file is generated by
|
||||
* including an {@link javax.annotation.Generated @Generated}
|
||||
* annotation.
|
||||
*
|
||||
* <p> Note that some of the effect of overwriting a file can be
|
||||
* achieved by using a <i>decorator</i>-style pattern. Instead of
|
||||
* modifying a class directly, the class is designed so that either
|
||||
* its superclass is generated by annotation processing or subclasses
|
||||
* of the class are generated by annotation processing. If the
|
||||
* subclasses are generated, the parent class may be designed to use
|
||||
* factories instead of public constructors so that only subclass
|
||||
* instances would be presented to clients of the parent class.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface Filer {
|
||||
/**
|
||||
* Creates a new source file and returns an object to allow
|
||||
* writing to it. The file's name and path (relative to the
|
||||
* {@linkplain StandardLocation#SOURCE_OUTPUT root output location
|
||||
* for source files}) are based on the type to be declared in that
|
||||
* file. If more than one type is being declared, the name of the
|
||||
* principal top-level type (the public one, for example) should
|
||||
* be used. A source file can also be created to hold information
|
||||
* about a package, including package annotations. To create a
|
||||
* source file for a named package, have {@code name} be the
|
||||
* package's name followed by {@code ".package-info"}; to create a
|
||||
* source file for an unnamed package, use {@code "package-info"}.
|
||||
*
|
||||
* <p> Note that to use a particular {@linkplain
|
||||
* java.nio.charset.Charset charset} to encode the contents of the
|
||||
* file, an {@code OutputStreamWriter} with the chosen charset can
|
||||
* be created from the {@code OutputStream} from the returned
|
||||
* object. If the {@code Writer} from the returned object is
|
||||
* directly used for writing, its charset is determined by the
|
||||
* implementation. An annotation processing tool may have an
|
||||
* {@code -encoding} flag or analogous option for specifying this;
|
||||
* otherwise, it will typically be the platform's default
|
||||
* encoding.
|
||||
*
|
||||
* <p>To avoid subsequent errors, the contents of the source file
|
||||
* should be compatible with the {@linkplain
|
||||
* ProcessingEnvironment#getSourceVersion source version} being used
|
||||
* for this run.
|
||||
*
|
||||
* @param name canonical (fully qualified) name of the principal type
|
||||
* being declared in this file or a package name followed by
|
||||
* {@code ".package-info"} for a package information file
|
||||
* @param originatingElements type or package elements causally
|
||||
* associated with the creation of this file, may be elided or
|
||||
* {@code null}
|
||||
* @return a {@code JavaFileObject} to write the new source file
|
||||
* @throws FilerException if the same pathname has already been
|
||||
* created, the same type has already been created, or the name is
|
||||
* not valid for a type
|
||||
* @throws IOException if the file cannot be created
|
||||
*/
|
||||
JavaFileObject createSourceFile(CharSequence name,
|
||||
Element... originatingElements) throws IOException;
|
||||
|
||||
/**
|
||||
* Creates a new class file, and returns an object to allow
|
||||
* writing to it. The file's name and path (relative to the
|
||||
* {@linkplain StandardLocation#CLASS_OUTPUT root output location
|
||||
* for class files}) are based on the name of the type being
|
||||
* written. A class file can also be created to hold information
|
||||
* about a package, including package annotations. To create a
|
||||
* class file for a named package, have {@code name} be the
|
||||
* package's name followed by {@code ".package-info"}; creating a
|
||||
* class file for an unnamed package is not supported.
|
||||
*
|
||||
* <p>To avoid subsequent errors, the contents of the class file
|
||||
* should be compatible with the {@linkplain
|
||||
* ProcessingEnvironment#getSourceVersion source version} being used
|
||||
* for this run.
|
||||
*
|
||||
* @param name binary name of the type being written or a package name followed by
|
||||
* {@code ".package-info"} for a package information file
|
||||
* @param originatingElements type or package elements causally
|
||||
* associated with the creation of this file, may be elided or
|
||||
* {@code null}
|
||||
* @return a {@code JavaFileObject} to write the new class file
|
||||
* @throws FilerException if the same pathname has already been
|
||||
* created, the same type has already been created, or the name is
|
||||
* not valid for a type
|
||||
* @throws IOException if the file cannot be created
|
||||
*/
|
||||
JavaFileObject createClassFile(CharSequence name,
|
||||
Element... originatingElements) throws IOException;
|
||||
|
||||
/**
|
||||
* Creates a new auxiliary resource file for writing and returns a
|
||||
* file object for it. The file may be located along with the
|
||||
* newly created source files, newly created binary files, or
|
||||
* other supported location. The locations {@link
|
||||
* StandardLocation#CLASS_OUTPUT CLASS_OUTPUT} and {@link
|
||||
* StandardLocation#SOURCE_OUTPUT SOURCE_OUTPUT} must be
|
||||
* supported. The resource may be named relative to some package
|
||||
* (as are source and class files), and from there by a relative
|
||||
* pathname. In a loose sense, the full pathname of the new file
|
||||
* will be the concatenation of {@code location}, {@code pkg}, and
|
||||
* {@code relativeName}.
|
||||
*
|
||||
* <p>Files created via this method are not registered for
|
||||
* annotation processing, even if the full pathname of the file
|
||||
* would correspond to the full pathname of a new source file
|
||||
* or new class file.
|
||||
*
|
||||
* @param location location of the new file
|
||||
* @param pkg package relative to which the file should be named,
|
||||
* or the empty string if none
|
||||
* @param relativeName final pathname components of the file
|
||||
* @param originatingElements type or package elements causally
|
||||
* associated with the creation of this file, may be elided or
|
||||
* {@code null}
|
||||
* @return a {@code FileObject} to write the new resource
|
||||
* @throws IOException if the file cannot be created
|
||||
* @throws FilerException if the same pathname has already been
|
||||
* created
|
||||
* @throws IllegalArgumentException for an unsupported location
|
||||
* @throws IllegalArgumentException if {@code relativeName} is not relative
|
||||
*/
|
||||
FileObject createResource(JavaFileManager.Location location,
|
||||
CharSequence pkg,
|
||||
CharSequence relativeName,
|
||||
Element... originatingElements) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns an object for reading an existing resource. The
|
||||
* locations {@link StandardLocation#CLASS_OUTPUT CLASS_OUTPUT}
|
||||
* and {@link StandardLocation#SOURCE_OUTPUT SOURCE_OUTPUT} must
|
||||
* be supported.
|
||||
*
|
||||
* @param location location of the file
|
||||
* @param pkg package relative to which the file should be searched,
|
||||
* or the empty string if none
|
||||
* @param relativeName final pathname components of the file
|
||||
* @return an object to read the file
|
||||
* @throws FilerException if the same pathname has already been
|
||||
* opened for writing
|
||||
* @throws IOException if the file cannot be opened
|
||||
* @throws IllegalArgumentException for an unsupported location
|
||||
* @throws IllegalArgumentException if {@code relativeName} is not relative
|
||||
*/
|
||||
FileObject getResource(JavaFileManager.Location location,
|
||||
CharSequence pkg,
|
||||
CharSequence relativeName) throws IOException;
|
||||
}
|
||||
52
jdkSrc/jdk8/javax/annotation/processing/FilerException.java
Normal file
52
jdkSrc/jdk8/javax/annotation/processing/FilerException.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, 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 javax.annotation.processing;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Indicates a {@link Filer} detected an attempt to open a file that
|
||||
* would violate the guarantees provided by the {@code Filer}. Those
|
||||
* guarantees include not creating the same file more than once, not
|
||||
* creating multiple files corresponding to the same type, and not
|
||||
* creating files for types with invalid names.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public class FilerException extends IOException {
|
||||
static final long serialVersionUID = 8426423106453163293L;
|
||||
/**
|
||||
* Constructs an exception with the specified detail message.
|
||||
* @param s the detail message, which should include the name of
|
||||
* the file attempting to be opened; may be {@code null}
|
||||
*/
|
||||
public FilerException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
101
jdkSrc/jdk8/javax/annotation/processing/Messager.java
Normal file
101
jdkSrc/jdk8/javax/annotation/processing/Messager.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 javax.annotation.processing;
|
||||
|
||||
import javax.annotation.*;
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.lang.model.element.*;
|
||||
|
||||
/**
|
||||
* A {@code Messager} provides the way for an annotation processor to
|
||||
* report error messages, warnings, and other notices. Elements,
|
||||
* annotations, and annotation values can be passed to provide a
|
||||
* location hint for the message. However, such location hints may be
|
||||
* unavailable or only approximate.
|
||||
*
|
||||
* <p>Printing a message with an {@linkplain
|
||||
* javax.tools.Diagnostic.Kind#ERROR error kind} will {@linkplain
|
||||
* RoundEnvironment#errorRaised raise an error}.
|
||||
*
|
||||
* <p>Note that the messages "printed" by methods in this
|
||||
* interface may or may not appear as textual output to a location
|
||||
* like {@link System#out} or {@link System#err}. Implementations may
|
||||
* choose to present this information in a different fashion, such as
|
||||
* messages in a window.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see ProcessingEnvironment#getLocale
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface Messager {
|
||||
/**
|
||||
* Prints a message of the specified kind.
|
||||
*
|
||||
* @param kind the kind of message
|
||||
* @param msg the message, or an empty string if none
|
||||
*/
|
||||
void printMessage(Diagnostic.Kind kind, CharSequence msg);
|
||||
|
||||
/**
|
||||
* Prints a message of the specified kind at the location of the
|
||||
* element.
|
||||
*
|
||||
* @param kind the kind of message
|
||||
* @param msg the message, or an empty string if none
|
||||
* @param e the element to use as a position hint
|
||||
*/
|
||||
void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e);
|
||||
|
||||
/**
|
||||
* Prints a message of the specified kind at the location of the
|
||||
* annotation mirror of the annotated element.
|
||||
*
|
||||
* @param kind the kind of message
|
||||
* @param msg the message, or an empty string if none
|
||||
* @param e the annotated element
|
||||
* @param a the annotation to use as a position hint
|
||||
*/
|
||||
void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a);
|
||||
|
||||
/**
|
||||
* Prints a message of the specified kind at the location of the
|
||||
* annotation value inside the annotation mirror of the annotated
|
||||
* element.
|
||||
*
|
||||
* @param kind the kind of message
|
||||
* @param msg the message, or an empty string if none
|
||||
* @param e the annotated element
|
||||
* @param a the annotation containing the annotation value
|
||||
* @param v the annotation value to use as a position hint
|
||||
*/
|
||||
void printMessage(Diagnostic.Kind kind,
|
||||
CharSequence msg,
|
||||
Element e,
|
||||
AnnotationMirror a,
|
||||
AnnotationValue v);
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, 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 javax.annotation.processing;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Locale;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.util.Elements;
|
||||
import javax.lang.model.util.Types;
|
||||
|
||||
/**
|
||||
* An annotation processing tool framework will {@linkplain
|
||||
* Processor#init provide an annotation processor with an object
|
||||
* implementing this interface} so the processor can use facilities
|
||||
* provided by the framework to write new files, report error
|
||||
* messages, and find other utilities.
|
||||
*
|
||||
* <p>Third parties may wish to provide value-add wrappers around the
|
||||
* facility objects from this interface, for example a {@code Filer}
|
||||
* extension that allows multiple processors to coordinate writing out
|
||||
* a single source file. To enable this, for processors running in a
|
||||
* context where their side effects via the API could be visible to
|
||||
* each other, the tool infrastructure must provide corresponding
|
||||
* facility objects that are {@code .equals}, {@code Filer}s that are
|
||||
* {@code .equals}, and so on. In addition, the tool invocation must
|
||||
* be able to be configured such that from the perspective of the
|
||||
* running annotation processors, at least the chosen subset of helper
|
||||
* classes are viewed as being loaded by the same class loader.
|
||||
* (Since the facility objects manage shared state, the implementation
|
||||
* of a wrapper class must know whether or not the same base facility
|
||||
* object has been wrapped before.)
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface ProcessingEnvironment {
|
||||
/**
|
||||
* Returns the processor-specific options passed to the annotation
|
||||
* processing tool. Options are returned in the form of a map from
|
||||
* option name to option value. For an option with no value, the
|
||||
* corresponding value in the map is {@code null}.
|
||||
*
|
||||
* <p>See documentation of the particular tool infrastructure
|
||||
* being used for details on how to pass in processor-specific
|
||||
* options. For example, a command-line implementation may
|
||||
* distinguish processor-specific options by prefixing them with a
|
||||
* known string like {@code "-A"}; other tool implementations may
|
||||
* follow different conventions or provide alternative mechanisms.
|
||||
* A given implementation may also provide implementation-specific
|
||||
* ways of finding options passed to the tool in addition to the
|
||||
* processor-specific options.
|
||||
*
|
||||
* @return the processor-specific options passed to the tool
|
||||
*/
|
||||
Map<String,String> getOptions();
|
||||
|
||||
/**
|
||||
* Returns the messager used to report errors, warnings, and other
|
||||
* notices.
|
||||
*
|
||||
* @return the messager
|
||||
*/
|
||||
Messager getMessager();
|
||||
|
||||
/**
|
||||
* Returns the filer used to create new source, class, or auxiliary
|
||||
* files.
|
||||
*
|
||||
* @return the filer
|
||||
*/
|
||||
Filer getFiler();
|
||||
|
||||
/**
|
||||
* Returns an implementation of some utility methods for
|
||||
* operating on elements
|
||||
*
|
||||
* @return element utilities
|
||||
*/
|
||||
Elements getElementUtils();
|
||||
|
||||
/**
|
||||
* Returns an implementation of some utility methods for
|
||||
* operating on types.
|
||||
*
|
||||
* @return type utilities
|
||||
*/
|
||||
Types getTypeUtils();
|
||||
|
||||
/**
|
||||
* Returns the source version that any generated {@linkplain
|
||||
* Filer#createSourceFile source} and {@linkplain
|
||||
* Filer#createClassFile class} files should conform to.
|
||||
*
|
||||
* @return the source version to which generated source and class
|
||||
* files should conform to
|
||||
* @see Processor#getSupportedSourceVersion
|
||||
*/
|
||||
SourceVersion getSourceVersion();
|
||||
|
||||
/**
|
||||
* Returns the current locale or {@code null} if no locale is in
|
||||
* effect. The locale can be be used to provide localized
|
||||
* {@linkplain Messager messages}.
|
||||
*
|
||||
* @return the current locale or {@code null} if no locale is in
|
||||
* effect
|
||||
*/
|
||||
Locale getLocale();
|
||||
}
|
||||
441
jdkSrc/jdk8/javax/annotation/processing/Processor.java
Normal file
441
jdkSrc/jdk8/javax/annotation/processing/Processor.java
Normal file
@@ -0,0 +1,441 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, 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 javax.annotation.processing;
|
||||
|
||||
import java.util.Set;
|
||||
import javax.lang.model.util.Elements;
|
||||
import javax.lang.model.AnnotatedConstruct;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
/**
|
||||
* The interface for an annotation processor.
|
||||
*
|
||||
* <p>Annotation processing happens in a sequence of {@linkplain
|
||||
* javax.annotation.processing.RoundEnvironment rounds}. On each
|
||||
* round, a processor may be asked to {@linkplain #process process} a
|
||||
* subset of the annotations found on the source and class files
|
||||
* produced by a prior round. The inputs to the first round of
|
||||
* processing are the initial inputs to a run of the tool; these
|
||||
* initial inputs can be regarded as the output of a virtual zeroth
|
||||
* round of processing. If a processor was asked to process on a
|
||||
* given round, it will be asked to process on subsequent rounds,
|
||||
* including the last round, even if there are no annotations for it
|
||||
* to process. The tool infrastructure may also ask a processor to
|
||||
* process files generated implicitly by the tool's operation.
|
||||
*
|
||||
* <p> Each implementation of a {@code Processor} must provide a
|
||||
* public no-argument constructor to be used by tools to instantiate
|
||||
* the processor. The tool infrastructure will interact with classes
|
||||
* implementing this interface as follows:
|
||||
*
|
||||
* <ol>
|
||||
*
|
||||
* <li>If an existing {@code Processor} object is not being used, to
|
||||
* create an instance of a processor the tool calls the no-arg
|
||||
* constructor of the processor class.
|
||||
*
|
||||
* <li>Next, the tool calls the {@link #init init} method with
|
||||
* an appropriate {@code ProcessingEnvironment}.
|
||||
*
|
||||
* <li>Afterwards, the tool calls {@link #getSupportedAnnotationTypes
|
||||
* getSupportedAnnotationTypes}, {@link #getSupportedOptions
|
||||
* getSupportedOptions}, and {@link #getSupportedSourceVersion
|
||||
* getSupportedSourceVersion}. These methods are only called once per
|
||||
* run, not on each round.
|
||||
*
|
||||
* <li>As appropriate, the tool calls the {@link #process process}
|
||||
* method on the {@code Processor} object; a new {@code Processor}
|
||||
* object is <em>not</em> created for each round.
|
||||
*
|
||||
* </ol>
|
||||
*
|
||||
* If a processor object is created and used without the above
|
||||
* protocol being followed, then the processor's behavior is not
|
||||
* defined by this interface specification.
|
||||
*
|
||||
* <p> The tool uses a <i>discovery process</i> to find annotation
|
||||
* processors and decide whether or not they should be run. By
|
||||
* configuring the tool, the set of potential processors can be
|
||||
* controlled. For example, for a {@link javax.tools.JavaCompiler
|
||||
* JavaCompiler} the list of candidate processors to run can be
|
||||
* {@linkplain javax.tools.JavaCompiler.CompilationTask#setProcessors
|
||||
* set directly} or controlled by a {@linkplain
|
||||
* javax.tools.StandardLocation#ANNOTATION_PROCESSOR_PATH search path}
|
||||
* used for a {@linkplain java.util.ServiceLoader service-style}
|
||||
* lookup. Other tool implementations may have different
|
||||
* configuration mechanisms, such as command line options; for
|
||||
* details, refer to the particular tool's documentation. Which
|
||||
* processors the tool asks to {@linkplain #process run} is a function
|
||||
* of the types of the annotations <em>{@linkplain AnnotatedConstruct present}</em>
|
||||
* on the {@linkplain
|
||||
* RoundEnvironment#getRootElements root elements}, what {@linkplain
|
||||
* #getSupportedAnnotationTypes annotation types a processor
|
||||
* supports}, and whether or not a processor {@linkplain #process
|
||||
* claims the annotation types it processes}. A processor will be asked to
|
||||
* process a subset of the annotation types it supports, possibly an
|
||||
* empty set.
|
||||
*
|
||||
* For a given round, the tool computes the set of annotation types
|
||||
* that are present on the elements enclosed within the root elements.
|
||||
* If there is at least one annotation type present, then as
|
||||
* processors claim annotation types, they are removed from the set of
|
||||
* unmatched annotation types. When the set is empty or no more
|
||||
* processors are available, the round has run to completion. If
|
||||
* there are no annotation types present, annotation processing still
|
||||
* occurs but only <i>universal processors</i> which support
|
||||
* processing all annotation types, {@code "*"}, can claim the (empty)
|
||||
* set of annotation types.
|
||||
*
|
||||
* <p>An annotation type is considered present if there is at least
|
||||
* one annotation of that type present on an element enclosed within
|
||||
* the root elements of a round. For this purpose, a type parameter is
|
||||
* considered to be enclosed by its {@linkplain
|
||||
* TypeParameterElement#getGenericElement generic
|
||||
* element}. Annotations on {@linkplain
|
||||
* java.lang.annotation.ElementType#TYPE_USE type uses}, as opposed to
|
||||
* annotations on elements, are ignored when computing whether or not
|
||||
* an annotation type is present.
|
||||
*
|
||||
* <p>An annotation is present if it meets the definition of being
|
||||
* present given in {@link AnnotatedConstruct}. In brief, an
|
||||
* annotation is considered present for the purposes of discovery if
|
||||
* it is directly present or present via inheritance. An annotation is
|
||||
* <em>not</em> considered present by virtue of being wrapped by a
|
||||
* container annotation. Operationally, this is equivalent to an
|
||||
* annotation being present on an element if and only if it would be
|
||||
* included in the results of {@link
|
||||
* Elements#getAllAnnotationMirrors(Element)} called on that element. Since
|
||||
* annotations inside container annotations are not considered
|
||||
* present, to properly process {@linkplain
|
||||
* java.lang.annotation.Repeatable repeatable annotation types},
|
||||
* processors are advised to include both the repeatable annotation
|
||||
* type and its containing annotation type in the set of {@linkplain
|
||||
* #getSupportedAnnotationTypes() supported annotation types} of a
|
||||
* processor.
|
||||
*
|
||||
* <p>Note that if a processor supports {@code "*"} and returns {@code
|
||||
* true}, all annotations are claimed. Therefore, a universal
|
||||
* processor being used to, for example, implement additional validity
|
||||
* checks should return {@code false} so as to not prevent other such
|
||||
* checkers from being able to run.
|
||||
*
|
||||
* <p>If a processor throws an uncaught exception, the tool may cease
|
||||
* other active annotation processors. If a processor raises an
|
||||
* error, the current round will run to completion and the subsequent
|
||||
* round will indicate an {@linkplain RoundEnvironment#errorRaised
|
||||
* error was raised}. Since annotation processors are run in a
|
||||
* cooperative environment, a processor should throw an uncaught
|
||||
* exception only in situations where no error recovery or reporting
|
||||
* is feasible.
|
||||
*
|
||||
* <p>The tool environment is not required to support annotation
|
||||
* processors that access environmental resources, either {@linkplain
|
||||
* RoundEnvironment per round} or {@linkplain ProcessingEnvironment
|
||||
* cross-round}, in a multi-threaded fashion.
|
||||
*
|
||||
* <p>If the methods that return configuration information about the
|
||||
* annotation processor return {@code null}, return other invalid
|
||||
* input, or throw an exception, the tool infrastructure must treat
|
||||
* this as an error condition.
|
||||
*
|
||||
* <p>To be robust when running in different tool implementations, an
|
||||
* annotation processor should have the following properties:
|
||||
*
|
||||
* <ol>
|
||||
*
|
||||
* <li>The result of processing a given input is not a function of the presence or absence
|
||||
* of other inputs (orthogonality).
|
||||
*
|
||||
* <li>Processing the same input produces the same output (consistency).
|
||||
*
|
||||
* <li>Processing input <i>A</i> followed by processing input <i>B</i>
|
||||
* is equivalent to processing <i>B</i> then <i>A</i>
|
||||
* (commutativity)
|
||||
*
|
||||
* <li>Processing an input does not rely on the presence of the output
|
||||
* of other annotation processors (independence)
|
||||
*
|
||||
* </ol>
|
||||
*
|
||||
* <p>The {@link Filer} interface discusses restrictions on how
|
||||
* processors can operate on files.
|
||||
*
|
||||
* <p>Note that implementors of this interface may find it convenient
|
||||
* to extend {@link AbstractProcessor} rather than implementing this
|
||||
* interface directly.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface Processor {
|
||||
/**
|
||||
* Returns the options recognized by this processor. An
|
||||
* implementation of the processing tool must provide a way to
|
||||
* pass processor-specific options distinctly from options passed
|
||||
* to the tool itself, see {@link ProcessingEnvironment#getOptions
|
||||
* getOptions}.
|
||||
*
|
||||
* <p>Each string returned in the set must be a period separated
|
||||
* sequence of {@linkplain
|
||||
* javax.lang.model.SourceVersion#isIdentifier identifiers}:
|
||||
*
|
||||
* <blockquote>
|
||||
* <dl>
|
||||
* <dt><i>SupportedOptionString:</i>
|
||||
* <dd><i>Identifiers</i>
|
||||
*
|
||||
* <dt><i>Identifiers:</i>
|
||||
* <dd> <i>Identifier</i>
|
||||
* <dd> <i>Identifier</i> {@code .} <i>Identifiers</i>
|
||||
*
|
||||
* <dt><i>Identifier:</i>
|
||||
* <dd>Syntactic identifier, including keywords and literals
|
||||
* </dl>
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> A tool might use this information to determine if any
|
||||
* options provided by a user are unrecognized by any processor,
|
||||
* in which case it may wish to report a warning.
|
||||
*
|
||||
* @return the options recognized by this processor or an
|
||||
* empty collection if none
|
||||
* @see javax.annotation.processing.SupportedOptions
|
||||
*/
|
||||
Set<String> getSupportedOptions();
|
||||
|
||||
/**
|
||||
* Returns the names of the annotation types supported by this
|
||||
* processor. An element of the result may be the canonical
|
||||
* (fully qualified) name of a supported annotation type.
|
||||
* Alternately it may be of the form "<tt><i>name</i>.*</tt>"
|
||||
* representing the set of all annotation types with canonical
|
||||
* names beginning with "<tt><i>name.</i></tt>". Finally, {@code
|
||||
* "*"} by itself represents the set of all annotation types,
|
||||
* including the empty set. Note that a processor should not
|
||||
* claim {@code "*"} unless it is actually processing all files;
|
||||
* claiming unnecessary annotations may cause a performance
|
||||
* slowdown in some environments.
|
||||
*
|
||||
* <p>Each string returned in the set must be accepted by the
|
||||
* following grammar:
|
||||
*
|
||||
* <blockquote>
|
||||
* <dl>
|
||||
* <dt><i>SupportedAnnotationTypeString:</i>
|
||||
* <dd><i>TypeName</i> <i>DotStar</i><sub><i>opt</i></sub>
|
||||
* <dd><tt>*</tt>
|
||||
*
|
||||
* <dt><i>DotStar:</i>
|
||||
* <dd><tt>.</tt> <tt>*</tt>
|
||||
* </dl>
|
||||
* </blockquote>
|
||||
*
|
||||
* where <i>TypeName</i> is as defined in
|
||||
* <cite>The Java™ Language Specification</cite>.
|
||||
*
|
||||
* @return the names of the annotation types supported by this processor
|
||||
* @see javax.annotation.processing.SupportedAnnotationTypes
|
||||
* @jls 3.8 Identifiers
|
||||
* @jls 6.5.5 Meaning of Type Names
|
||||
*/
|
||||
Set<String> getSupportedAnnotationTypes();
|
||||
|
||||
/**
|
||||
* Returns the latest source version supported by this annotation
|
||||
* processor.
|
||||
*
|
||||
* @return the latest source version supported by this annotation
|
||||
* processor.
|
||||
* @see javax.annotation.processing.SupportedSourceVersion
|
||||
* @see ProcessingEnvironment#getSourceVersion
|
||||
*/
|
||||
SourceVersion getSupportedSourceVersion();
|
||||
|
||||
/**
|
||||
* Initializes the processor with the processing environment.
|
||||
*
|
||||
* @param processingEnv environment for facilities the tool framework
|
||||
* provides to the processor
|
||||
*/
|
||||
void init(ProcessingEnvironment processingEnv);
|
||||
|
||||
/**
|
||||
* Processes a set of annotation types on type elements
|
||||
* originating from the prior round and returns whether or not
|
||||
* these annotation types are claimed by this processor. If {@code
|
||||
* true} is returned, the annotation types are claimed and subsequent
|
||||
* processors will not be asked to process them; if {@code false}
|
||||
* is returned, the annotation types are unclaimed and subsequent
|
||||
* processors may be asked to process them. A processor may
|
||||
* always return the same boolean value or may vary the result
|
||||
* based on chosen criteria.
|
||||
*
|
||||
* <p>The input set will be empty if the processor supports {@code
|
||||
* "*"} and the root elements have no annotations. A {@code
|
||||
* Processor} must gracefully handle an empty set of annotations.
|
||||
*
|
||||
* @param annotations the annotation types requested to be processed
|
||||
* @param roundEnv environment for information about the current and prior round
|
||||
* @return whether or not the set of annotation types are claimed by this processor
|
||||
*/
|
||||
boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnv);
|
||||
|
||||
/**
|
||||
* Returns to the tool infrastructure an iterable of suggested
|
||||
* completions to an annotation. Since completions are being asked
|
||||
* for, the information provided about the annotation may be
|
||||
* incomplete, as if for a source code fragment. A processor may
|
||||
* return an empty iterable. Annotation processors should focus
|
||||
* their efforts on providing completions for annotation members
|
||||
* with additional validity constraints known to the processor, for
|
||||
* example an {@code int} member whose value should lie between 1
|
||||
* and 10 or a string member that should be recognized by a known
|
||||
* grammar, such as a regular expression or a URL.
|
||||
*
|
||||
* <p>Since incomplete programs are being modeled, some of the
|
||||
* parameters may only have partial information or may be {@code
|
||||
* null}. At least one of {@code element} and {@code userText}
|
||||
* must be non-{@code null}. If {@code element} is non-{@code
|
||||
* null}, {@code annotation} and {@code member} may be {@code
|
||||
* null}. Processors may not throw a {@code NullPointerException}
|
||||
* if some parameters are {@code null}; if a processor has no
|
||||
* completions to offer based on the provided information, an
|
||||
* empty iterable can be returned. The processor may also return
|
||||
* a single completion with an empty value string and a message
|
||||
* describing why there are no completions.
|
||||
*
|
||||
* <p>Completions are informative and may reflect additional
|
||||
* validity checks performed by annotation processors. For
|
||||
* example, consider the simple annotation:
|
||||
*
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* @MersennePrime {
|
||||
* int value();
|
||||
* }
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* (A Mersenne prime is prime number of the form
|
||||
* 2<sup><i>n</i></sup> - 1.) Given an {@code AnnotationMirror}
|
||||
* for this annotation type, a list of all such primes in the
|
||||
* {@code int} range could be returned without examining any other
|
||||
* arguments to {@code getCompletions}:
|
||||
*
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* import static javax.annotation.processing.Completions.*;
|
||||
* ...
|
||||
* return Arrays.asList({@link Completions#of(String) of}("3"),
|
||||
* of("7"),
|
||||
* of("31"),
|
||||
* of("127"),
|
||||
* of("8191"),
|
||||
* of("131071"),
|
||||
* of("524287"),
|
||||
* of("2147483647"));
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* A more informative set of completions would include the number
|
||||
* of each prime:
|
||||
*
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* return Arrays.asList({@link Completions#of(String, String) of}("3", "M2"),
|
||||
* of("7", "M3"),
|
||||
* of("31", "M5"),
|
||||
* of("127", "M7"),
|
||||
* of("8191", "M13"),
|
||||
* of("131071", "M17"),
|
||||
* of("524287", "M19"),
|
||||
* of("2147483647", "M31"));
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* However, if the {@code userText} is available, it can be checked
|
||||
* to see if only a subset of the Mersenne primes are valid. For
|
||||
* example, if the user has typed
|
||||
*
|
||||
* <blockquote>
|
||||
* <code>
|
||||
* @MersennePrime(1
|
||||
* </code>
|
||||
* </blockquote>
|
||||
*
|
||||
* the value of {@code userText} will be {@code "1"}; and only
|
||||
* two of the primes are possible completions:
|
||||
*
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* return Arrays.asList(of("127", "M7"),
|
||||
* of("131071", "M17"));
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* Sometimes no valid completion is possible. For example, there
|
||||
* is no in-range Mersenne prime starting with 9:
|
||||
*
|
||||
* <blockquote>
|
||||
* <code>
|
||||
* @MersennePrime(9
|
||||
* </code>
|
||||
* </blockquote>
|
||||
*
|
||||
* An appropriate response in this case is to either return an
|
||||
* empty list of completions,
|
||||
*
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* return Collections.emptyList();
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* or a single empty completion with a helpful message
|
||||
*
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* return Arrays.asList(of("", "No in-range Mersenne primes start with 9"));
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* @param element the element being annotated
|
||||
* @param annotation the (perhaps partial) annotation being
|
||||
* applied to the element
|
||||
* @param member the annotation member to return possible completions for
|
||||
* @param userText source code text to be completed
|
||||
*
|
||||
* @return suggested completions to the annotation
|
||||
*/
|
||||
Iterable<? extends Completion> getCompletions(Element element,
|
||||
AnnotationMirror annotation,
|
||||
ExecutableElement member,
|
||||
String userText);
|
||||
}
|
||||
113
jdkSrc/jdk8/javax/annotation/processing/RoundEnvironment.java
Normal file
113
jdkSrc/jdk8/javax/annotation/processing/RoundEnvironment.java
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2007, 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 javax.annotation.processing;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import java.util.Set;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
/**
|
||||
* An annotation processing tool framework will {@linkplain
|
||||
* Processor#process provide an annotation processor with an object
|
||||
* implementing this interface} so that the processor can query for
|
||||
* information about a round of annotation processing.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface RoundEnvironment {
|
||||
/**
|
||||
* Returns {@code true} if types generated by this round will not
|
||||
* be subject to a subsequent round of annotation processing;
|
||||
* returns {@code false} otherwise.
|
||||
*
|
||||
* @return {@code true} if types generated by this round will not
|
||||
* be subject to a subsequent round of annotation processing;
|
||||
* returns {@code false} otherwise
|
||||
*/
|
||||
boolean processingOver();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if an error was raised in the prior round
|
||||
* of processing; returns {@code false} otherwise.
|
||||
*
|
||||
* @return {@code true} if an error was raised in the prior round
|
||||
* of processing; returns {@code false} otherwise
|
||||
*/
|
||||
boolean errorRaised();
|
||||
|
||||
/**
|
||||
* Returns the root elements for annotation processing generated
|
||||
* by the prior round.
|
||||
*
|
||||
* @return the root elements for annotation processing generated
|
||||
* by the prior round, or an empty set if there were none
|
||||
*/
|
||||
Set<? extends Element> getRootElements();
|
||||
|
||||
/**
|
||||
* Returns the elements annotated with the given annotation type.
|
||||
* The annotation may appear directly or be inherited. Only
|
||||
* package elements and type elements <i>included</i> in this
|
||||
* round of annotation processing, or declarations of members,
|
||||
* constructors, parameters, or type parameters declared within
|
||||
* those, are returned. Included type elements are {@linkplain
|
||||
* #getRootElements root types} and any member types nested within
|
||||
* them. Elements in a package are not considered included simply
|
||||
* because a {@code package-info} file for that package was
|
||||
* created.
|
||||
*
|
||||
* @param a annotation type being requested
|
||||
* @return the elements annotated with the given annotation type,
|
||||
* or an empty set if there are none
|
||||
* @throws IllegalArgumentException if the argument does not
|
||||
* represent an annotation type
|
||||
*/
|
||||
Set<? extends Element> getElementsAnnotatedWith(TypeElement a);
|
||||
|
||||
/**
|
||||
* Returns the elements annotated with the given annotation type.
|
||||
* The annotation may appear directly or be inherited. Only
|
||||
* package elements and type elements <i>included</i> in this
|
||||
* round of annotation processing, or declarations of members,
|
||||
* constructors, parameters, or type parameters declared within
|
||||
* those, are returned. Included type elements are {@linkplain
|
||||
* #getRootElements root types} and any member types nested within
|
||||
* them. Elements in a package are not considered included simply
|
||||
* because a {@code package-info} file for that package was
|
||||
* created.
|
||||
*
|
||||
* @param a annotation type being requested
|
||||
* @return the elements annotated with the given annotation type,
|
||||
* or an empty set if there are none
|
||||
* @throws IllegalArgumentException if the argument does not
|
||||
* represent an annotation type
|
||||
*/
|
||||
Set<? extends Element> getElementsAnnotatedWith(Class<? extends Annotation> a);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, 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 javax.annotation.processing;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
/**
|
||||
* An annotation used to indicate what annotation types an annotation
|
||||
* processor supports. The {@link
|
||||
* Processor#getSupportedAnnotationTypes} method can construct its
|
||||
* result from the value of this annotation, as done by {@link
|
||||
* AbstractProcessor#getSupportedAnnotationTypes}. Only {@linkplain
|
||||
* Processor#getSupportedAnnotationTypes strings conforming to the
|
||||
* grammar} should be used as values.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface SupportedAnnotationTypes {
|
||||
/**
|
||||
* Returns the names of the supported annotation types.
|
||||
* @return the names of the supported annotation types
|
||||
*/
|
||||
String [] value();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, 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 javax.annotation.processing;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
/**
|
||||
* An annotation used to indicate what options an annotation processor
|
||||
* supports. The {@link Processor#getSupportedOptions} method can
|
||||
* construct its result from the value of this annotation, as done by
|
||||
* {@link AbstractProcessor#getSupportedOptions}. Only {@linkplain
|
||||
* Processor#getSupportedOptions strings conforming to the
|
||||
* grammar} should be used as values.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface SupportedOptions {
|
||||
/**
|
||||
* Returns the supported options.
|
||||
* @return the supported options
|
||||
*/
|
||||
String [] value();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, 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 javax.annotation.processing;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
|
||||
/**
|
||||
* An annotation used to indicate the latest source version an
|
||||
* annotation processor supports. The {@link
|
||||
* Processor#getSupportedSourceVersion} method can construct its
|
||||
* result from the value of this annotation, as done by {@link
|
||||
* AbstractProcessor#getSupportedSourceVersion}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface SupportedSourceVersion {
|
||||
/**
|
||||
* Returns the latest supported source version.
|
||||
* @return the latest supported source version
|
||||
*/
|
||||
SourceVersion value();
|
||||
}
|
||||
43
jdkSrc/jdk8/javax/annotation/processing/package-info.java
Normal file
43
jdkSrc/jdk8/javax/annotation/processing/package-info.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Facilities for declaring annotation processors and for
|
||||
* allowing annotation processors to communicate with an annotation processing
|
||||
* tool environment.
|
||||
*
|
||||
* <p> Unless otherwise specified in a particular implementation, the
|
||||
* collections returned by methods in this package should be expected
|
||||
* to be unmodifiable by the caller and unsafe for concurrent access.
|
||||
*
|
||||
* <p> Unless otherwise specified, methods in this package will throw
|
||||
* a {@code NullPointerException} if given a {@code null} argument.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
package javax.annotation.processing;
|
||||
Reference in New Issue
Block a user