--- old/src/java.base/share/classes/sun/reflect/annotation/TypeAnnotation.java 2015-10-24 09:55:17.000000000 +0200 +++ new/src/java.base/share/classes/sun/reflect/annotation/TypeAnnotation.java 2015-10-24 09:55:16.000000000 +0200 @@ -187,6 +187,28 @@ return new LocationInfo(newDepth, res); } + public LocationInfo popLocation(byte tag) { + if (locations[depth-1].tag != tag) + throw new IllegalStateException("Tags not matching"); + return popLocation(); + } + + public LocationInfo popLocation() { + int newDepth = this.depth - 1; + Location[] res = new Location[newDepth]; + System.arraycopy(this.locations, 0, res, 0, newDepth); + return new LocationInfo(newDepth, res); + } + + /** Pop a series of locations matching {@code tag}. Stop poping as soon as a non-matching tag is found. */ + public LocationInfo popAllLocations(byte tag) { + LocationInfo l = this; + while(l.depth > 0 && l.locations[l.depth - 1].tag == tag) { + l = l.popLocation(); + } + return l; + } + public TypeAnnotation[] filter(TypeAnnotation[] ta) { ArrayList l = new ArrayList<>(ta.length); for (TypeAnnotation t : ta) {