Class DeclarationAnnotationHelper.DeclarationAnnotationsInfo
- java.lang.Object
-
- org.benf.cfr.reader.bytecode.analysis.types.DeclarationAnnotationHelper.DeclarationAnnotationsInfo
-
- Enclosing class:
- DeclarationAnnotationHelper
public static class DeclarationAnnotationHelper.DeclarationAnnotationsInfo extends java.lang.Object
Represents information about where to place declaration andElementType.TYPE_USE
annotations for a place where both can occur.This information differentiates between admissible and non-admissible types. What this means is defined in JLS 9.7.4. Depending on whether a type is admissible or not annotation placement has to be adjusted.
Examples for annotation
@DeclTypeUse
with targetTYPE_USE
andFIELD
:// Applies both to declaration and type; placement in front of type is admissible @TypeUse public String f; // Would consider the annotation repeated @TypeUse public @TypeUse String f; // Applies only to type public java.lang.@TypeUse String f; // Applies both to declaration and type // Probably javac bug (JDK-8223936) and should only apply to declaration @TypeUse public java.lang.String f;
So depending on how the type is written by the decompiler (maybe the qualified name is used to resolve type collisions) the annotations have to be placed differently. Additionally the annotations present in the class files can require creating a non-admissible type, e.g. because the annotation is only present on the type, but not on the declaration, or because it was different values or appears in a different order.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<AnnotationTableEntry>
declAnnotationsAdmissible
private java.util.List<AnnotationTableEntry>
declAnnotationsNonAdmissible
private boolean
requiresNonAdmissibleType
private java.util.List<AnnotationTableTypeEntry>
typeAnnotationsAdmissible
private java.util.List<AnnotationTableTypeEntry>
typeAnnotationsNonAdmissible
-
Constructor Summary
Constructors Modifier Constructor Description private
DeclarationAnnotationsInfo(java.util.List<AnnotationTableEntry> declAnnotationsAdmissible, java.util.List<AnnotationTableEntry> declAnnotationsNonAdmissible, java.util.List<AnnotationTableTypeEntry> typeAnnotationsAdmissible, java.util.List<AnnotationTableTypeEntry> typeAnnotationsNonAdmissible, boolean requiresNonAdmissibleType)
-
Method Summary
-
-
-
Field Detail
-
declAnnotationsAdmissible
private final java.util.List<AnnotationTableEntry> declAnnotationsAdmissible
-
declAnnotationsNonAdmissible
private final java.util.List<AnnotationTableEntry> declAnnotationsNonAdmissible
-
typeAnnotationsAdmissible
private final java.util.List<AnnotationTableTypeEntry> typeAnnotationsAdmissible
-
typeAnnotationsNonAdmissible
private final java.util.List<AnnotationTableTypeEntry> typeAnnotationsNonAdmissible
-
requiresNonAdmissibleType
private final boolean requiresNonAdmissibleType
-
-
Constructor Detail
-
DeclarationAnnotationsInfo
private DeclarationAnnotationsInfo(java.util.List<AnnotationTableEntry> declAnnotationsAdmissible, java.util.List<AnnotationTableEntry> declAnnotationsNonAdmissible, java.util.List<AnnotationTableTypeEntry> typeAnnotationsAdmissible, java.util.List<AnnotationTableTypeEntry> typeAnnotationsNonAdmissible, boolean requiresNonAdmissibleType)
-
-
Method Detail
-
possibleAdmissible
private static DeclarationAnnotationHelper.DeclarationAnnotationsInfo possibleAdmissible(java.util.List<AnnotationTableEntry> declAnnotations, java.util.List<AnnotationTableTypeEntry> typeAnnotations)
-
possibleAdmissible
private static DeclarationAnnotationHelper.DeclarationAnnotationsInfo possibleAdmissible(java.util.List<AnnotationTableEntry> declAnnotationsAdmissible, java.util.List<AnnotationTableEntry> declAnnotationsNonAdmissible, java.util.List<AnnotationTableTypeEntry> typeAnnotationsAdmissible, java.util.List<AnnotationTableTypeEntry> typeAnnotationsNonAdmissible)
-
requiringNonAdmissible
private static DeclarationAnnotationHelper.DeclarationAnnotationsInfo requiringNonAdmissible(java.util.List<AnnotationTableEntry> declAnnotations, java.util.List<AnnotationTableTypeEntry> typeAnnotations)
-
requiresNonAdmissibleType
public boolean requiresNonAdmissibleType()
- Returns:
- Whether the type has to be written in a way that makes placing
TYPE_USE
annotations in front of it non-admissible, e.g. using the qualified name or qualifying it using a non-admissible outer class (StaticOuter.StaticInner f;
)
-
checkCanProvideAnnotations
private void checkCanProvideAnnotations(boolean usesAdmissibleType)
-
getDeclarationAnnotations
public java.util.List<AnnotationTableEntry> getDeclarationAnnotations(boolean usesAdmissibleType)
- Parameters:
usesAdmissibleType
- Whether the caller writes the type in a way that makes placingTYPE_USE
annotations in front of it admissible- Returns:
- Annotations to place on the declaration
- Throws:
java.lang.IllegalArgumentException
- If annotations for an admissible type are requested, but this placement information does not support it
-
getTypeAnnotations
public java.util.List<AnnotationTableTypeEntry> getTypeAnnotations(boolean usesAdmissibleType)
- Parameters:
usesAdmissibleType
- Whether the caller writes the type in a way that makes placingTYPE_USE
annotations in front of it admissible- Returns:
- Annotations to place on the type
- Throws:
java.lang.IllegalArgumentException
- If annotations for an admissible type are requested, but this placement information does not support it
-
-