Class ExternalAnnotationDecorator
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator
- All Implemented Interfaces:
IBinaryType
,IDependent
,IGenericType
A decorator for
IBinaryType
that allows external annotations to be attached. This can be used to change the
result of enrichWithExternalAnnotationsFor(org.aspectj.org.eclipse.jdt.internal.compiler.env.ITypeAnnotationWalker, java.lang.Object, org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment)
or getExternalAnnotationStatus()
.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Auxiliary interface forgetAnnotationZipFile(String, ZipFileProducer)
. -
Field Summary
Fields inherited from interface org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType
NoField, NoInterface, NoMethod, NoNestedType
Fields inherited from interface org.aspectj.org.eclipse.jdt.internal.compiler.env.IDependent
JAR_FILE_ENTRY_SEPARATOR
-
Constructor Summary
ConstructorDescriptionExternalAnnotationDecorator(IBinaryType toDecorate, boolean isFromSource)
ExternalAnnotationDecorator(IBinaryType toDecorate, ExternalAnnotationProvider externalAnnotationProvider)
-
Method Summary
Modifier and TypeMethodDescriptionstatic IBinaryType
create(IBinaryType toDecorate, String basePath, String qualifiedBinaryTypeName, ZipFile zipFile)
Possibly wrap the provided binary type in a ClassWithExternalAnnotations to which a fresh provider for external annotations is associated.enrichWithExternalAnnotationsFor(ITypeAnnotationWalker walker, Object member, LookupEnvironment environment)
Answer a type annotation walker that takes into consideration also external annotations.static ExternalAnnotationProvider
externalAnnotationProvider(String basePath, String qualifiedBinaryTypeName, ZipFile zipFile)
Creates an external annotation provider for external annotations using the given basePath, which is either a directory holding .eea text files, or a zip file of entries of the same format.Answer the runtime visible and invisible annotations for this type or null if none.static ZipFile
getAnnotationZipFile(String basePath, ExternalAnnotationDecorator.ZipFileProducer producer)
Returns the zip file containing external annotations, if any.char[]
Answer the enclosing method (including method selector and method descriptor), or null if none.char[]
Answer the resolved name of the enclosing type in the class file format as specified in section 4.2 of the Java 2 VM spec or null if the receiver is a top level type.Answer whether a provider for external annotations is associated with this binary type.Answer the receiver's fields or null if the array is empty.char[]
Answer the file name which defines the type.char[]
Answer the receiver's ClassSignature, which describes the type parameters, super class, and super interfaces as specified in section "4.7.9.1 Signatures" of the Java SE 8 VM spec.char[][]
Answer the resolved names of the receiver's interfaces in the class file format as specified in section 4.2 of the Java 2 VM spec or null if the array is empty.Answer the receiver's nested types or null if the array is empty.Answer the receiver's methods or null if the array is empty.char[][][]
Answer the list of missing type names which were referenced from the problem classfile.int
Answer an int whose bits are set according the access constants defined by the VM spec.char[]
Answer the module to which this type belongs.char[]
getName()
Answer the resolved name of the type in the class file format as specified in section 4.2 of the Java 2 VM spec.Answer the receiver's record components or null if the array is empty.char[]
Answer the simple name of the type in the class file.char[]
Answer the resolved name of the receiver's superclass in the class file format as specified in section 4.2 of the Java 2 VM spec or null if it does not have one.long
Answer the tagbits set according to the bits for annotations.Answer the runtime visible and invisible type annotations for this type or null if none.boolean
Answer true if the receiver is an anonymous class.boolean
Answer whether the receiver contains the resolved binary form or the unresolved source form of the type.boolean
isLocal()
Answer true if the receiver is a local class.boolean
isMember()
Answer true if the receiver is a member class.boolean
isRecord()
Answer true if the receiver is a record.char[]
Answer the source file attribute, or null if none.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType
getPermittedSubtypeNames
-
Constructor Details
-
ExternalAnnotationDecorator
public ExternalAnnotationDecorator(IBinaryType toDecorate, ExternalAnnotationProvider externalAnnotationProvider) -
ExternalAnnotationDecorator
-
-
Method Details
-
getFileName
public char[] getFileName()Description copied from interface:IDependent
Answer the file name which defines the type. The path part (optional) must be separated from the actual file proper name by a separator suitable for the type (java.io.File.separator for example), e.g. "c:\\source\\com\\p\\X.java" or "/com/p/Y.java". The path to the zip or jar file (optional) must be separated from the actual path part by JAR_FILE_ENTRY_SEPARATOR, e.g. "c:\\lib\\some.jar|/com/p/X.class" or "/lib/some.zip|/com/q/Y.class". The proper file name includes the suffix extension (e.g. ".java") e.g. "c:/org/aspectj/org/eclipse/jdt/internal/compileri/env/IDependent.java" Return null if no file defines the type.- Specified by:
getFileName
in interfaceIDependent
-
isBinaryType
public boolean isBinaryType()Description copied from interface:IGenericType
Answer whether the receiver contains the resolved binary form or the unresolved source form of the type.- Specified by:
isBinaryType
in interfaceIGenericType
-
getAnnotations
Description copied from interface:IBinaryType
Answer the runtime visible and invisible annotations for this type or null if none.- Specified by:
getAnnotations
in interfaceIBinaryType
-
getTypeAnnotations
Description copied from interface:IBinaryType
Answer the runtime visible and invisible type annotations for this type or null if none.- Specified by:
getTypeAnnotations
in interfaceIBinaryType
-
getEnclosingMethod
public char[] getEnclosingMethod()Description copied from interface:IBinaryType
Answer the enclosing method (including method selector and method descriptor), or null if none. For example, "foo()Ljava/lang/Object;V"- Specified by:
getEnclosingMethod
in interfaceIBinaryType
-
getEnclosingTypeName
public char[] getEnclosingTypeName()Description copied from interface:IBinaryType
Answer the resolved name of the enclosing type in the class file format as specified in section 4.2 of the Java 2 VM spec or null if the receiver is a top level type. For example, java.lang.String is java/lang/String.- Specified by:
getEnclosingTypeName
in interfaceIBinaryType
-
getFields
Description copied from interface:IBinaryType
Answer the receiver's fields or null if the array is empty.- Specified by:
getFields
in interfaceIBinaryType
-
getRecordComponents
Description copied from interface:IBinaryType
Answer the receiver's record components or null if the array is empty.- Specified by:
getRecordComponents
in interfaceIBinaryType
-
getGenericSignature
public char[] getGenericSignature()Description copied from interface:IBinaryType
Answer the receiver's ClassSignature, which describes the type parameters, super class, and super interfaces as specified in section "4.7.9.1 Signatures" of the Java SE 8 VM spec. Returns null if none.- Specified by:
getGenericSignature
in interfaceIBinaryType
- Returns:
- the receiver's signature, null if none
-
getInterfaceNames
public char[][] getInterfaceNames()Description copied from interface:IBinaryType
Answer the resolved names of the receiver's interfaces in the class file format as specified in section 4.2 of the Java 2 VM spec or null if the array is empty. For example, java.lang.String is java/lang/String.- Specified by:
getInterfaceNames
in interfaceIBinaryType
-
getMemberTypes
Description copied from interface:IBinaryType
Answer the receiver's nested types or null if the array is empty. This nested type info is extracted from the inner class attributes. Ask the name environment to find a member type using its compound name.- Specified by:
getMemberTypes
in interfaceIBinaryType
-
getMethods
Description copied from interface:IBinaryType
Answer the receiver's methods or null if the array is empty.- Specified by:
getMethods
in interfaceIBinaryType
-
getMissingTypeNames
public char[][][] getMissingTypeNames()Description copied from interface:IBinaryType
Answer the list of missing type names which were referenced from the problem classfile. This list is encoded via an extra attribute.- Specified by:
getMissingTypeNames
in interfaceIBinaryType
-
getName
public char[] getName()Description copied from interface:IBinaryType
Answer the resolved name of the type in the class file format as specified in section 4.2 of the Java 2 VM spec. For example, java.lang.String is java/lang/String.- Specified by:
getName
in interfaceIBinaryType
-
getSourceName
public char[] getSourceName()Description copied from interface:IBinaryType
Answer the simple name of the type in the class file. For member A$B, will answer B. For anonymous will answer null.- Specified by:
getSourceName
in interfaceIBinaryType
-
getSuperclassName
public char[] getSuperclassName()Description copied from interface:IBinaryType
Answer the resolved name of the receiver's superclass in the class file format as specified in section 4.2 of the Java 2 VM spec or null if it does not have one. For example, java.lang.String is java/lang/String.- Specified by:
getSuperclassName
in interfaceIBinaryType
-
getTagBits
public long getTagBits()Description copied from interface:IBinaryType
Answer the tagbits set according to the bits for annotations.- Specified by:
getTagBits
in interfaceIBinaryType
-
isAnonymous
public boolean isAnonymous()Description copied from interface:IBinaryType
Answer true if the receiver is an anonymous class. false otherwise- Specified by:
isAnonymous
in interfaceIBinaryType
-
isLocal
public boolean isLocal()Description copied from interface:IBinaryType
Answer true if the receiver is a local class. false otherwise- Specified by:
isLocal
in interfaceIBinaryType
-
isRecord
public boolean isRecord()Description copied from interface:IBinaryType
Answer true if the receiver is a record. false otherwise- Specified by:
isRecord
in interfaceIBinaryType
-
isMember
public boolean isMember()Description copied from interface:IBinaryType
Answer true if the receiver is a member class. false otherwise- Specified by:
isMember
in interfaceIBinaryType
-
sourceFileName
public char[] sourceFileName()Description copied from interface:IBinaryType
Answer the source file attribute, or null if none. For example, "String.java"- Specified by:
sourceFileName
in interfaceIBinaryType
-
getModifiers
public int getModifiers()Description copied from interface:IGenericType
Answer an int whose bits are set according the access constants defined by the VM spec. NOTE 1: We have added AccDeprecated & AccSynthetic. NOTE 2: If the receiver represents a member type, the modifiers are extracted from its inner class attributes.- Specified by:
getModifiers
in interfaceIGenericType
-
getModule
public char[] getModule()Description copied from interface:IBinaryType
Answer the module to which this type belongs.null
if the type is associated to the unnamed module.- Specified by:
getModule
in interfaceIBinaryType
- Returns:
- the module name or
null
-
getAnnotationZipFile
public static ZipFile getAnnotationZipFile(String basePath, ExternalAnnotationDecorator.ZipFileProducer producer) throws IOExceptionReturns the zip file containing external annotations, if any. Returns null if there are no external annotations or if the basePath refers to a directory.- Parameters:
basePath
- resolved filesystem path of either directory or zip fileproducer
- an optional helper to produce the zipFile when needed.- Returns:
- the client provided zip file; or else a fresh new zip file, to let clients cache it, if desired; or null to signal that basePath is not a zip file, but a directory.
- Throws:
IOException
- any unexpected errors during file access. File not found while accessing an individual file if basePath is a directory is expected, and simply answered with null. If basePath is neither a directory nor a zip file, this is unexpected.
-
externalAnnotationProvider
public static ExternalAnnotationProvider externalAnnotationProvider(String basePath, String qualifiedBinaryTypeName, ZipFile zipFile) throws IOExceptionCreates an external annotation provider for external annotations using the given basePath, which is either a directory holding .eea text files, or a zip file of entries of the same format.- Parameters:
basePath
- resolved filesystem path of either directory or zip filequalifiedBinaryTypeName
- slash-separated type namezipFile
- an existing zip file for the same basePath, or null.- Returns:
- the annotation provider or null if there are no external annotations.
- Throws:
IOException
- any unexpected errors during file access. File not found while accessing an individual file if basePath is a directory is expected, and simply answered with null. If basePath is neither a directory nor a zip file, this is unexpected.
-
create
public static IBinaryType create(IBinaryType toDecorate, String basePath, String qualifiedBinaryTypeName, ZipFile zipFile) throws IOExceptionPossibly wrap the provided binary type in a ClassWithExternalAnnotations to which a fresh provider for external annotations is associated. This provider is constructed using the given basePath, which is either a directory holding .eea text files, or a zip file of entries of the same format. If no such provider could be constructed, then the original binary type is returned unchanged.- Parameters:
toDecorate
- the binary type to wrap, if neededbasePath
- resolved filesystem path of either directory or zip filequalifiedBinaryTypeName
- slash-separated type namezipFile
- an existing zip file for the same basePath, or null.- Returns:
- either a fresh ClassWithExternalAnnotations or the original binary type unchanged.
- Throws:
IOException
- any unexpected errors during file access. File not found while accessing an individual file if basePath is a directory is expected, and simply handled by not setting up an external annotation provider. If basePath is neither a directory nor a zip file, this is unexpected, resulting in an exception.
-
enrichWithExternalAnnotationsFor
public ITypeAnnotationWalker enrichWithExternalAnnotationsFor(ITypeAnnotationWalker walker, Object member, LookupEnvironment environment)Description copied from interface:IBinaryType
Answer a type annotation walker that takes into consideration also external annotations.- Specified by:
enrichWithExternalAnnotationsFor
in interfaceIBinaryType
- Parameters:
walker
- previous walker, may be empty, otherwise it will be returned unchangedmember
- if either a IBinaryField or a IBinaryMethod is provided, answer a walker specifically for that memberenvironment
- for use by the walker- Returns:
- either a matching walker with data from external annotations or the walker provided via argument 'walker'.
-
getExternalAnnotationStatus
Description copied from interface:IBinaryType
Answer whether a provider for external annotations is associated with this binary type.- Specified by:
getExternalAnnotationStatus
in interfaceIBinaryType
-