Mercurial > hg > openjdk > jdk8 > jdk
changeset 8755:44fa6bf42846
8027796: Refactor Core Reflection for Type Annotations
Reviewed-by: psandoz
author | jfranck |
---|---|
date | Thu, 07 Nov 2013 13:33:03 +0100 |
parents | 88d1ed05a246 |
children | fb7abd509bd2 |
files | src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java src/share/classes/sun/reflect/annotation/TypeAnnotation.java src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java |
diffstat | 3 files changed, 24 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java Thu Nov 07 10:22:11 2013 +0000 +++ b/src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java Thu Nov 07 13:33:03 2013 +0100 @@ -34,7 +34,7 @@ import static sun.reflect.annotation.TypeAnnotation.*; -public class AnnotatedTypeFactory { +public final class AnnotatedTypeFactory { /** * Create an AnnotatedType. * @@ -47,10 +47,10 @@ * corresponds to */ public static AnnotatedType buildAnnotatedType(Type type, - LocationInfo currentLoc, - TypeAnnotation[] actualTypeAnnos, - TypeAnnotation[] allOnSameTarget, - AnnotatedElement decl) { + LocationInfo currentLoc, + TypeAnnotation[] actualTypeAnnos, + TypeAnnotation[] allOnSameTarget, + AnnotatedElement decl) { if (type == null) { return EMPTY_ANNOTATED_TYPE; } @@ -156,40 +156,40 @@ } @Override - public Annotation[] getDeclaredAnnotations() { + public final Annotation[] getDeclaredAnnotations() { return annotations.values().toArray(new Annotation[0]); } @Override @SuppressWarnings("unchecked") - public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotation) { + public final <T extends Annotation> T getDeclaredAnnotation(Class<T> annotation) { return (T)annotations.get(annotation); } @Override - public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotation) { + public final <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotation) { return AnnotationSupport.getDirectlyAndIndirectlyPresent(annotations, annotation); } // AnnotatedType @Override - public Type getType() { + public final Type getType() { return type; } // Implementation details - LocationInfo getLocation() { + final LocationInfo getLocation() { return location; } - TypeAnnotation[] getTypeAnnotations() { + final TypeAnnotation[] getTypeAnnotations() { return allOnSameTargetTypeAnnotations; } - AnnotatedElement getDecl() { + final AnnotatedElement getDecl() { return decl; } } - private static class AnnotatedArrayTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedArrayType { + private static final class AnnotatedArrayTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedArrayType { AnnotatedArrayTypeImpl(Type type, LocationInfo location, TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations, AnnotatedElement decl) { @@ -215,7 +215,7 @@ } } - private static class AnnotatedTypeVariableImpl extends AnnotatedTypeBaseImpl implements AnnotatedTypeVariable { + private static final class AnnotatedTypeVariableImpl extends AnnotatedTypeBaseImpl implements AnnotatedTypeVariable { AnnotatedTypeVariableImpl(TypeVariable<?> type, LocationInfo location, TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations, AnnotatedElement decl) { @@ -232,7 +232,8 @@ } } - private static class AnnotatedParameterizedTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedParameterizedType { + private static final class AnnotatedParameterizedTypeImpl extends AnnotatedTypeBaseImpl + implements AnnotatedParameterizedType { AnnotatedParameterizedTypeImpl(ParameterizedType type, LocationInfo location, TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations, AnnotatedElement decl) { @@ -265,7 +266,7 @@ } } - private static class AnnotatedWildcardTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedWildcardType { + private static final class AnnotatedWildcardTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedWildcardType { private final boolean hasUpperBounds; AnnotatedWildcardTypeImpl(WildcardType type, LocationInfo location, TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations,
--- a/src/share/classes/sun/reflect/annotation/TypeAnnotation.java Thu Nov 07 10:22:11 2013 +0000 +++ b/src/share/classes/sun/reflect/annotation/TypeAnnotation.java Thu Nov 07 13:33:03 2013 +0100 @@ -40,7 +40,7 @@ * distinguish between '@A Inner.@B Outer' in for example nested types), * target info and the declaration the TypeAnnotaiton was parsed from. */ -public class TypeAnnotation { +public final class TypeAnnotation { private final TypeAnnotationTargetInfo targetInfo; private final LocationInfo loc; private final Annotation annotation; @@ -92,7 +92,8 @@ METHOD_FORMAL_PARAMETER, THROWS; } - public static class TypeAnnotationTargetInfo { + + public static final class TypeAnnotationTargetInfo { private final TypeAnnotationTarget target; private final int count; private final int secondaryIndex; @@ -131,7 +132,7 @@ } } - public static class LocationInfo { + public static final class LocationInfo { private final int depth; private final Location[] locations; @@ -204,7 +205,7 @@ return true; } - public static class Location { + public static final class Location { public final byte tag; public final byte index;
--- a/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java Thu Nov 07 10:22:11 2013 +0000 +++ b/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java Thu Nov 07 13:33:03 2013 +0100 @@ -43,7 +43,7 @@ * TypeAnnotationParser implements the logic needed to parse * TypeAnnotations from an array of bytes. */ -public class TypeAnnotationParser { +public final class TypeAnnotationParser { private static final TypeAnnotation[] EMPTY_TYPE_ANNOTATION_ARRAY = new TypeAnnotation[0]; /** @@ -237,7 +237,7 @@ return parseAnnotatedBounds(bounds, decl, typeVarIndex, LocationInfo.BASE_LOCATION); } //helper for above - static <D extends GenericDeclaration> AnnotatedType[] parseAnnotatedBounds(Type[] bounds, + private static <D extends GenericDeclaration> AnnotatedType[] parseAnnotatedBounds(Type[] bounds, D decl, int typeVarIndex, LocationInfo loc) {