/**
  * Return exceptions this method or constructor throws.
  *
  * @return an array of ClassDoc[] representing the exceptions thrown by this method.
  */
 public ClassDoc[] thrownExceptions() {
   ListBuffer<ClassDocImpl> l = new ListBuffer<ClassDocImpl>();
   for (Type ex : sym.type.getThrownTypes()) {
     ex = env.types.erasure(ex);
     // ### Will these casts succeed in the face of static semantic
     // ### errors in the documented code?
     ClassDocImpl cdi = env.getClassDoc((ClassSymbol) ex.tsym);
     if (cdi != null) l.append(cdi);
   }
   return l.toArray(new ClassDocImpl[l.length()]);
 }
Exemple #2
0
 /**
  * Process Win32-style command files for the specified command line arguments and return the
  * resulting arguments. A command file argument is of the form '@file' where 'file' is the name of
  * the file whose contents are to be parsed for additional arguments. The contents of the command
  * file are parsed using StreamTokenizer and the original '@file' argument replaced with the
  * resulting tokens. Recursive command files are not supported. The '@' character itself can be
  * quoted with the sequence '@@'.
  */
 public static String[] parse(String[] args) throws IOException {
   ListBuffer<String> newArgs = new ListBuffer<String>();
   for (int i = 0; i < args.length; i++) {
     String arg = args[i];
     if (arg.length() > 1 && arg.charAt(0) == '@') {
       arg = arg.substring(1);
       if (arg.charAt(0) == '@') {
         newArgs.append(arg);
       } else {
         loadCmdFile(arg, newArgs);
       }
     } else {
       newArgs.append(arg);
     }
   }
   return newArgs.toList().toArray(new String[newArgs.length()]);
 }
 static Option[] getOptions(OptionHelper helper, Set<OptionName> desired) {
   ListBuffer<Option> options = new ListBuffer<Option>();
   for (Option option : getAll(helper))
     if (desired.contains(option.getName())) options.append(option);
   return options.toArray(new Option[options.length()]);
 }
 Attribute enterAttributeValue(Type expected, JCExpression tree, Env<AttrContext> env) {
   // first, try completing the attribution value sym - if a completion
   // error is thrown, we should recover gracefully, and display an
   // ordinary resolution diagnostic.
   try {
     expected.tsym.complete();
   } catch (CompletionFailure e) {
     log.error(tree.pos(), "cant.resolve", Kinds.kindName(e.sym), e.sym);
     return new Attribute.Error(expected);
   }
   if (expected.isPrimitive() || types.isSameType(expected, syms.stringType)) {
     Type result = attr.attribExpr(tree, env, expected);
     if (result.isErroneous()) return new Attribute.Error(expected);
     if (result.constValue() == null) {
       log.error(tree.pos(), "attribute.value.must.be.constant");
       return new Attribute.Error(expected);
     }
     result = cfolder.coerce(result, expected);
     return new Attribute.Constant(expected, result.constValue());
   }
   if (expected.tsym == syms.classType.tsym) {
     Type result = attr.attribExpr(tree, env, expected);
     if (result.isErroneous()) return new Attribute.Error(expected);
     if (TreeInfo.name(tree) != names._class) {
       log.error(tree.pos(), "annotation.value.must.be.class.literal");
       return new Attribute.Error(expected);
     }
     return new Attribute.Class(types, (((JCFieldAccess) tree).selected).type);
   }
   if ((expected.tsym.flags() & Flags.ANNOTATION) != 0
       || types.isSameType(expected, syms.annotationType)) {
     if (tree.getTag() != JCTree.ANNOTATION) {
       log.error(tree.pos(), "annotation.value.must.be.annotation");
       expected = syms.errorType;
     }
     return enterAnnotation((JCAnnotation) tree, expected, env);
   }
   if (expected.tag == TypeTags.ARRAY) { // should really be isArray()
     if (tree.getTag() != JCTree.NEWARRAY) {
       tree = make.at(tree.pos).NewArray(null, List.<JCExpression>nil(), List.of(tree));
     }
     JCNewArray na = (JCNewArray) tree;
     if (na.elemtype != null) {
       log.error(na.elemtype.pos(), "new.not.allowed.in.annotation");
       return new Attribute.Error(expected);
     }
     ListBuffer<Attribute> buf = new ListBuffer<Attribute>();
     for (List<JCExpression> l = na.elems; l.nonEmpty(); l = l.tail) {
       buf.append(enterAttributeValue(types.elemtype(expected), l.head, env));
     }
     na.type = expected;
     return new Attribute.Array(expected, buf.toArray(new Attribute[buf.length()]));
   }
   if (expected.tag == TypeTags.CLASS && (expected.tsym.flags() & Flags.ENUM) != 0) {
     attr.attribExpr(tree, env, expected);
     Symbol sym = TreeInfo.symbol(tree);
     if (sym == null
         || TreeInfo.nonstaticSelect(tree)
         || sym.kind != Kinds.VAR
         || (sym.flags() & Flags.ENUM) == 0) {
       log.error(tree.pos(), "enum.annotation.must.be.enum.constant");
       return new Attribute.Error(expected);
     }
     VarSymbol enumerator = (VarSymbol) sym;
     return new Attribute.Enum(expected, enumerator);
   }
   if (!expected.isErroneous()) log.error(tree.pos(), "annotation.value.not.allowable.type");
   return new Attribute.Error(attr.attribExpr(tree, env, expected));
 }