langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java
changeset 25848 3bc09f4676a9
parent 24895 dd091d389fbf
equal deleted inserted replaced
25847:90e43c49e318 25848:3bc09f4676a9
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    65         public static final TypePathEntry WILDCARD = new TypePathEntry(TypePathEntryKind.WILDCARD);
    65         public static final TypePathEntry WILDCARD = new TypePathEntry(TypePathEntryKind.WILDCARD);
    66 
    66 
    67         private TypePathEntry(TypePathEntryKind tag) {
    67         private TypePathEntry(TypePathEntryKind tag) {
    68             Assert.check(tag == TypePathEntryKind.ARRAY ||
    68             Assert.check(tag == TypePathEntryKind.ARRAY ||
    69                     tag == TypePathEntryKind.INNER_TYPE ||
    69                     tag == TypePathEntryKind.INNER_TYPE ||
    70                     tag == TypePathEntryKind.WILDCARD,
    70                     tag == TypePathEntryKind.WILDCARD);
    71                     "Invalid TypePathEntryKind: " + tag);
       
    72             this.tag = tag;
    71             this.tag = tag;
    73             this.arg = 0;
    72             this.arg = 0;
    74         }
    73         }
    75 
    74 
    76         public TypePathEntry(TypePathEntryKind tag, int arg) {
    75         public TypePathEntry(TypePathEntryKind tag, int arg) {
    77             Assert.check(tag == TypePathEntryKind.TYPE_ARGUMENT,
    76             Assert.check(tag == TypePathEntryKind.TYPE_ARGUMENT);
    78                     "Invalid TypePathEntryKind: " + tag);
       
    79             this.tag = tag;
    77             this.tag = tag;
    80             this.arg = arg;
    78             this.arg = arg;
    81         }
    79         }
    82 
    80 
    83         public static TypePathEntry fromBinary(int tag, int arg) {
    81         public static TypePathEntry fromBinary(int tag, int arg) {
    84             Assert.check(arg == 0 || tag == TypePathEntryKind.TYPE_ARGUMENT.tag,
    82             Assert.check(arg == 0 || tag == TypePathEntryKind.TYPE_ARGUMENT.tag);
    85                     "Invalid TypePathEntry tag/arg: " + tag + "/" + arg);
       
    86             switch (tag) {
    83             switch (tag) {
    87             case 0:
    84             case 0:
    88                 return ARRAY;
    85                 return ARRAY;
    89             case 1:
    86             case 1:
    90                 return INNER_TYPE;
    87                 return INNER_TYPE;
   349     public static List<TypePathEntry> getTypePathFromBinary(java.util.List<Integer> list) {
   346     public static List<TypePathEntry> getTypePathFromBinary(java.util.List<Integer> list) {
   350         ListBuffer<TypePathEntry> loc = new ListBuffer<>();
   347         ListBuffer<TypePathEntry> loc = new ListBuffer<>();
   351         Iterator<Integer> iter = list.iterator();
   348         Iterator<Integer> iter = list.iterator();
   352         while (iter.hasNext()) {
   349         while (iter.hasNext()) {
   353             Integer fst = iter.next();
   350             Integer fst = iter.next();
   354             Assert.check(iter.hasNext(), "Could not decode type path: " + list);
   351             Assert.check(iter.hasNext());
   355             Integer snd = iter.next();
   352             Integer snd = iter.next();
   356             loc = loc.append(TypePathEntry.fromBinary(fst, snd));
   353             loc = loc.append(TypePathEntry.fromBinary(fst, snd));
   357         }
   354         }
   358         return loc.toList();
   355         return loc.toList();
   359     }
   356     }