< prev index next >

src/java.base/share/classes/sun/reflect/annotation/TypeAnnotation.java

Print this page

        

*** 185,194 **** --- 185,216 ---- System.arraycopy(this.locations, 0, res, 0, depth); res[newDepth - 1] = new Location(tag, (short)(index & 0xFF)); 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<TypeAnnotation> l = new ArrayList<>(ta.length); for (TypeAnnotation t : ta) { if (isSameLocationInfo(t.getLocationInfo())) l.add(t);
< prev index next >