diff --git a/jdk/src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java b/jdk/src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java index 926d6d0fc12..ae32624c071 100644 --- a/jdk/src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java +++ b/jdk/src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java @@ -34,7 +34,7 @@ import java.util.Map; import static sun.reflect.annotation.TypeAnnotation.*; -public class AnnotatedTypeFactory { +public final class AnnotatedTypeFactory { /** * Create an AnnotatedType. * @@ -47,10 +47,10 @@ public class AnnotatedTypeFactory { * 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 @@ public class AnnotatedTypeFactory { } @Override - public Annotation[] getDeclaredAnnotations() { + public final Annotation[] getDeclaredAnnotations() { return annotations.values().toArray(new Annotation[0]); } @Override @SuppressWarnings("unchecked") - public T getDeclaredAnnotation(Class annotation) { + public final T getDeclaredAnnotation(Class annotation) { return (T)annotations.get(annotation); } @Override - public T[] getDeclaredAnnotationsByType(Class annotation) { + public final T[] getDeclaredAnnotationsByType(Class 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 @@ public class AnnotatedTypeFactory { } } - 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 @@ public class AnnotatedTypeFactory { } } - 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 @@ public class AnnotatedTypeFactory { } } - 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, diff --git a/jdk/src/share/classes/sun/reflect/annotation/TypeAnnotation.java b/jdk/src/share/classes/sun/reflect/annotation/TypeAnnotation.java index 1f4b9e71f5e..5c94db4d6d5 100644 --- a/jdk/src/share/classes/sun/reflect/annotation/TypeAnnotation.java +++ b/jdk/src/share/classes/sun/reflect/annotation/TypeAnnotation.java @@ -40,7 +40,7 @@ import java.util.List; * 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 @@ public class TypeAnnotation { 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 class TypeAnnotation { } } - public static class LocationInfo { + public static final class LocationInfo { private final int depth; private final Location[] locations; @@ -204,7 +205,7 @@ public class TypeAnnotation { return true; } - public static class Location { + public static final class Location { public final byte tag; public final byte index; diff --git a/jdk/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java b/jdk/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java index d716a4734c3..abd28cfafd0 100644 --- a/jdk/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java +++ b/jdk/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java @@ -43,7 +43,7 @@ import static sun.reflect.annotation.TypeAnnotation.*; * 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 @@ public class TypeAnnotationParser { return parseAnnotatedBounds(bounds, decl, typeVarIndex, LocationInfo.BASE_LOCATION); } //helper for above - static AnnotatedType[] parseAnnotatedBounds(Type[] bounds, + private static AnnotatedType[] parseAnnotatedBounds(Type[] bounds, D decl, int typeVarIndex, LocationInfo loc) {