提交 b33830e6 编写于 作者: L lana

Merge

/* /*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -76,7 +76,7 @@ public interface Doc extends Comparable<Object> { ...@@ -76,7 +76,7 @@ public interface Doc extends Comparable<Object> {
/** /**
* Return comment as an array of tags. Includes inline tags * Return comment as an array of tags. Includes inline tags
* (i.e. {&#64link <i>reference</i>} tags) but not * (i.e. {&#64;link <i>reference</i>} tags) but not
* block tags. * block tags.
* Each section of plain text is represented as a {@link Tag} * Each section of plain text is represented as a {@link Tag}
* of {@linkplain Tag#kind() kind} "Text". * of {@linkplain Tag#kind() kind} "Text".
...@@ -90,7 +90,7 @@ public interface Doc extends Comparable<Object> { ...@@ -90,7 +90,7 @@ public interface Doc extends Comparable<Object> {
/** /**
* Return the first sentence of the comment as an array of tags. * Return the first sentence of the comment as an array of tags.
* Includes inline tags * Includes inline tags
* (i.e. {&#64link <i>reference</i>} tags) but not * (i.e. {&#64;link <i>reference</i>} tags) but not
* block tags. * block tags.
* Each section of plain text is represented as a {@link Tag} * Each section of plain text is represented as a {@link Tag}
* of {@linkplain Tag#kind() kind} "Text". * of {@linkplain Tag#kind() kind} "Text".
......
/* /*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -90,8 +90,8 @@ public interface ExecutableMemberDoc extends MemberDoc { ...@@ -90,8 +90,8 @@ public interface ExecutableMemberDoc extends MemberDoc {
/** /**
* Return the throws tags in this method. * Return the throws tags in this method.
* *
* @return an array of ThrowTag containing all <code>&#64exception</code> * @return an array of ThrowTag containing all <code>&#64;exception</code>
* and <code>&#64throws</code> tags. * and <code>&#64;throws</code> tags.
*/ */
ThrowsTag[] throwsTags(); ThrowsTag[] throwsTags();
...@@ -99,7 +99,7 @@ public interface ExecutableMemberDoc extends MemberDoc { ...@@ -99,7 +99,7 @@ public interface ExecutableMemberDoc extends MemberDoc {
* Return the param tags in this method, excluding the type * Return the param tags in this method, excluding the type
* parameter tags. * parameter tags.
* *
* @return an array of ParamTag containing all <code>&#64param</code> tags * @return an array of ParamTag containing all <code>&#64;param</code> tags
* corresponding to the parameters of this method. * corresponding to the parameters of this method.
*/ */
ParamTag[] paramTags(); ParamTag[] paramTags();
...@@ -107,7 +107,7 @@ public interface ExecutableMemberDoc extends MemberDoc { ...@@ -107,7 +107,7 @@ public interface ExecutableMemberDoc extends MemberDoc {
/** /**
* Return the type parameter tags in this method. * Return the type parameter tags in this method.
* *
* @return an array of ParamTag containing all <code>&#64param</code> tags * @return an array of ParamTag containing all <code>&#64;param</code> tags
* corresponding to the type parameters of this method. * corresponding to the type parameters of this method.
* @since 1.5 * @since 1.5
*/ */
......
/* /*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -127,7 +127,7 @@ public interface Tag { ...@@ -127,7 +127,7 @@ public interface Tag {
/** /**
* Return the first sentence of the comment as an array of tags. * Return the first sentence of the comment as an array of tags.
* Includes inline tags * Includes inline tags
* (i.e. {&#64link <i>reference</i>} tags) but not * (i.e. {&#64;link <i>reference</i>} tags) but not
* block tags. * block tags.
* Each section of plain text is represented as a {@link Tag} * Each section of plain text is represented as a {@link Tag}
* of kind "Text". * of kind "Text".
......
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,11 +31,11 @@ import java.util.List; ...@@ -31,11 +31,11 @@ import java.util.List;
* A tree node for a lambda expression. * A tree node for a lambda expression.
* *
* For example: * For example:
* <pre> * <pre>{@code
* ()->{} * ()->{}
* (List<String> ls)->ls.size() * (List<String> ls)->ls.size()
* (x,y)-> { return x + y; } * (x,y)-> { return x + y; }
* </pre> * }</pre>
*/ */
public interface LambdaExpressionTree extends ExpressionTree { public interface LambdaExpressionTree extends ExpressionTree {
......
/* /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -38,8 +38,8 @@ public interface LineMap { ...@@ -38,8 +38,8 @@ public interface LineMap {
* @param line line number (beginning at 1) * @param line line number (beginning at 1)
* @return position of first character in line * @return position of first character in line
* @throws IndexOutOfBoundsException * @throws IndexOutOfBoundsException
* if <tt>lineNumber < 1</tt> * if {@code lineNumber < 1}
* if <tt>lineNumber > no. of lines</tt> * if {@code lineNumber > no. of lines}
*/ */
long getStartPosition(long line); long getStartPosition(long line);
......
/* /*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -52,7 +52,7 @@ import com.sun.source.tree.*; ...@@ -52,7 +52,7 @@ import com.sun.source.tree.*;
* *
* <p>Here is an example to count the number of identifier nodes in a tree: * <p>Here is an example to count the number of identifier nodes in a tree:
* <pre> * <pre>
* class CountIdentifiers extends TreeScanner<Integer,Void> { * class CountIdentifiers extends TreeScanner&lt;Integer,Void&gt; {
* {@literal @}Override * {@literal @}Override
* public Integer visitIdentifier(IdentifierTree node, Void p) { * public Integer visitIdentifier(IdentifierTree node, Void p) {
* return 1; * return 1;
......
/* /*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -227,46 +227,44 @@ public class ConfigurationImpl extends Configuration { ...@@ -227,46 +227,44 @@ public class ConfigurationImpl extends Configuration {
String[] os = options[oi]; String[] os = options[oi];
String opt = os[0].toLowerCase(); String opt = os[0].toLowerCase();
if (opt.equals("-footer")) { if (opt.equals("-footer")) {
footer = os[1]; footer = os[1];
} else if (opt.equals("-header")) { } else if (opt.equals("-header")) {
header = os[1]; header = os[1];
} else if (opt.equals("-packagesheader")) { } else if (opt.equals("-packagesheader")) {
packagesheader = os[1]; packagesheader = os[1];
} else if (opt.equals("-doctitle")) { } else if (opt.equals("-doctitle")) {
doctitle = os[1]; doctitle = os[1];
} else if (opt.equals("-windowtitle")) { } else if (opt.equals("-windowtitle")) {
windowtitle = os[1]; windowtitle = os[1];
} else if (opt.equals("-top")) { } else if (opt.equals("-top")) {
top = os[1]; top = os[1];
} else if (opt.equals("-bottom")) { } else if (opt.equals("-bottom")) {
bottom = os[1]; bottom = os[1];
} else if (opt.equals("-helpfile")) { } else if (opt.equals("-helpfile")) {
helpfile = os[1]; helpfile = os[1];
} else if (opt.equals("-stylesheetfile")) { } else if (opt.equals("-stylesheetfile")) {
stylesheetfile = os[1]; stylesheetfile = os[1];
} else if (opt.equals("-charset")) { } else if (opt.equals("-charset")) {
charset = os[1]; charset = os[1];
} else if (opt.equals("-xdocrootparent")) { } else if (opt.equals("-xdocrootparent")) {
docrootparent = os[1]; docrootparent = os[1];
} else if (opt.equals("-nohelp")) { } else if (opt.equals("-nohelp")) {
nohelp = true; nohelp = true;
} else if (opt.equals("-splitindex")) { } else if (opt.equals("-splitindex")) {
splitindex = true; splitindex = true;
} else if (opt.equals("-noindex")) { } else if (opt.equals("-noindex")) {
createindex = false; createindex = false;
} else if (opt.equals("-use")) { } else if (opt.equals("-use")) {
classuse = true; classuse = true;
} else if (opt.equals("-notree")) { } else if (opt.equals("-notree")) {
createtree = false; createtree = false;
} else if (opt.equals("-nodeprecatedlist")) { } else if (opt.equals("-nodeprecatedlist")) {
nodeprecatedlist = true; nodeprecatedlist = true;
} else if (opt.equals("-nosince")) { } else if (opt.equals("-nonavbar")) {
nosince = true;
} else if (opt.equals("-nonavbar")) {
nonavbar = true; nonavbar = true;
} else if (opt.equals("-nooverview")) { } else if (opt.equals("-nooverview")) {
nooverview = true; nooverview = true;
} else if (opt.equals("-overview")) { } else if (opt.equals("-overview")) {
overview = true; overview = true;
} }
} }
......
/* /*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1260,7 +1260,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { ...@@ -1260,7 +1260,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
/** /**
* Print the Html table tag for the index summary tables. The table tag * Print the Html table tag for the index summary tables. The table tag
* printed is * printed is
* &lt;TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> * {@code <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> }
*/ */
public void tableIndexSummary() { public void tableIndexSummary() {
table(1, "100%", 3, 0); table(1, "100%", 3, 0);
...@@ -1548,7 +1548,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { ...@@ -1548,7 +1548,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
} }
/** /**
* Print the heading in Html &lt;H2> format. * Print the heading in Html {@literal <H2>} format.
* *
* @param str The Header string. * @param str The Header string.
*/ */
...@@ -2416,15 +2416,15 @@ public class HtmlDocletWriter extends HtmlDocWriter { ...@@ -2416,15 +2416,15 @@ public class HtmlDocletWriter extends HtmlDocWriter {
* <p> * <p>
* Here is the algorithm used to fix the link: * Here is the algorithm used to fix the link:
* <p> * <p>
* &lt;relative link&gt; => docRoot + &lt;relative path to file&gt; + &lt;relative link&gt; * {@literal <relative link> => docRoot + <relative path to file> + <relative link> }
* <p> * <p>
* For example, suppose com.sun.javadoc.RootDoc has this link: * For example, suppose com.sun.javadoc.RootDoc has this link:
* &lt;a href="package-summary.html"&gt;The package Page&lt;/a&gt; * {@literal <a href="package-summary.html">The package Page</a> }
* <p> * <p>
* If this link appeared in the index, we would redirect * If this link appeared in the index, we would redirect
* the link like this: * the link like this:
* *
* &lt;a href="./com/sun/javadoc/package-summary.html"&gt;The package Page&lt;/a&gt; * {@literal <a href="./com/sun/javadoc/package-summary.html">The package Page</a>}
* *
* @param doc the Doc object whose documentation is being written. * @param doc the Doc object whose documentation is being written.
* @param text the text being written. * @param text the text being written.
......
/* /*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -352,19 +352,21 @@ public abstract class Configuration { ...@@ -352,19 +352,21 @@ public abstract class Configuration {
if (opt.equals("-d")) { if (opt.equals("-d")) {
destDirName = addTrailingFileSep(os[1]); destDirName = addTrailingFileSep(os[1]);
docFileDestDirName = destDirName; docFileDestDirName = destDirName;
} else if (opt.equals("-docfilessubdirs")) { } else if (opt.equals("-docfilessubdirs")) {
copydocfilesubdirs = true; copydocfilesubdirs = true;
} else if (opt.equals("-docencoding")) { } else if (opt.equals("-docencoding")) {
docencoding = os[1]; docencoding = os[1];
} else if (opt.equals("-encoding")) { } else if (opt.equals("-encoding")) {
encoding = os[1]; encoding = os[1];
} else if (opt.equals("-author")) { } else if (opt.equals("-author")) {
showauthor = true; showauthor = true;
} else if (opt.equals("-version")) { } else if (opt.equals("-nosince")) {
nosince = true;
} else if (opt.equals("-version")) {
showversion = true; showversion = true;
} else if (opt.equals("-nodeprecated")) { } else if (opt.equals("-nodeprecated")) {
nodeprecated = true; nodeprecated = true;
} else if (opt.equals("-sourcepath")) { } else if (opt.equals("-sourcepath")) {
sourcepath = os[1]; sourcepath = os[1];
} else if (opt.equals("-classpath") && } else if (opt.equals("-classpath") &&
sourcepath.length() == 0) { sourcepath.length() == 0) {
...@@ -388,17 +390,17 @@ public abstract class Configuration { ...@@ -388,17 +390,17 @@ public abstract class Configuration {
message.warning("doclet.sourcetab_warning"); message.warning("doclet.sourcetab_warning");
sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH; sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
} }
} else if (opt.equals("-notimestamp")) { } else if (opt.equals("-notimestamp")) {
notimestamp = true; notimestamp = true;
} else if (opt.equals("-nocomment")) { } else if (opt.equals("-nocomment")) {
nocomment = true; nocomment = true;
} else if (opt.equals("-tag") || opt.equals("-taglet")) { } else if (opt.equals("-tag") || opt.equals("-taglet")) {
customTagStrs.add(os); customTagStrs.add(os);
} else if (opt.equals("-tagletpath")) { } else if (opt.equals("-tagletpath")) {
tagletpath = os[1]; tagletpath = os[1];
} else if (opt.equals("-keywords")) { } else if (opt.equals("-keywords")) {
keywords = true; keywords = true;
} else if (opt.equals("-serialwarn")) { } else if (opt.equals("-serialwarn")) {
serialwarn = true; serialwarn = true;
} else if (opt.equals("-group")) { } else if (opt.equals("-group")) {
group.checkPackageGroups(os[1], os[2]); group.checkPackageGroups(os[1], os[2]);
......
/* /*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -125,7 +125,7 @@ public class ClassBuilder extends AbstractBuilder { ...@@ -125,7 +125,7 @@ public class ClassBuilder extends AbstractBuilder {
} }
/** /**
* Handles the &lt;ClassDoc> tag. * Handles the {@literal <ClassDoc>} tag.
* *
* @param node the XML element that specifies which components to document * @param node the XML element that specifies which components to document
* @param contentTree the content tree to which the documentation will be added * @param contentTree the content tree to which the documentation will be added
......
/* /*
* Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -600,6 +600,7 @@ public class TagletManager { ...@@ -600,6 +600,7 @@ public class TagletManager {
ArrayList<Taglet> mTags = new ArrayList<Taglet>(customTags.size()); ArrayList<Taglet> mTags = new ArrayList<Taglet>(customTags.size());
ArrayList<Taglet> iTags = new ArrayList<Taglet>(customTags.size()); ArrayList<Taglet> iTags = new ArrayList<Taglet>(customTags.size());
ArrayList<Taglet> oTags = new ArrayList<Taglet>(customTags.size()); ArrayList<Taglet> oTags = new ArrayList<Taglet>(customTags.size());
ArrayList<Taglet> sTags = new ArrayList<Taglet>();
Taglet current; Taglet current;
while (it.hasNext()) { while (it.hasNext()) {
current = it.next(); current = it.next();
...@@ -634,11 +635,12 @@ public class TagletManager { ...@@ -634,11 +635,12 @@ public class TagletManager {
inlineTags = iTags.toArray(new Taglet[] {}); inlineTags = iTags.toArray(new Taglet[] {});
//Init the serialized form tags //Init the serialized form tags
serializedFormTags = new Taglet[4]; sTags.add(customTags.get("serialData"));
serializedFormTags[0] = customTags.get("serialData"); sTags.add(customTags.get("throws"));
serializedFormTags[1] = customTags.get("throws"); if (!nosince)
serializedFormTags[2] = customTags.get("since"); sTags.add(customTags.get("since"));
serializedFormTags[3] = customTags.get("see"); sTags.add(customTags.get("see"));
serializedFormTags = sTags.toArray(new Taglet[] {});
} }
/** /**
......
...@@ -117,7 +117,7 @@ public class JavacTrees extends Trees { ...@@ -117,7 +117,7 @@ public class JavacTrees extends Trees {
return instance; return instance;
} }
private JavacTrees(Context context) { protected JavacTrees(Context context) {
context.put(JavacTrees.class, this); context.put(JavacTrees.class, this);
init(context); init(context);
} }
...@@ -286,7 +286,7 @@ public class JavacTrees extends Trees { ...@@ -286,7 +286,7 @@ public class JavacTrees extends Trees {
JCCompilationUnit unit = (JCCompilationUnit) path.getCompilationUnit(); JCCompilationUnit unit = (JCCompilationUnit) path.getCompilationUnit();
Copier copier = new Copier(treeMaker.forToplevel(unit)); Copier copier = createCopier(treeMaker.forToplevel(unit));
Env<AttrContext> env = null; Env<AttrContext> env = null;
JCMethodDecl method = null; JCMethodDecl method = null;
...@@ -372,10 +372,10 @@ public class JavacTrees extends Trees { ...@@ -372,10 +372,10 @@ public class JavacTrees extends Trees {
/** /**
* Makes a copy of a tree, noting the value resulting from copying a particular leaf. * Makes a copy of a tree, noting the value resulting from copying a particular leaf.
**/ **/
static class Copier extends TreeCopier<JCTree> { protected static class Copier extends TreeCopier<JCTree> {
JCTree leafCopy = null; JCTree leafCopy = null;
Copier(TreeMaker M) { protected Copier(TreeMaker M) {
super(M); super(M);
} }
...@@ -388,6 +388,10 @@ public class JavacTrees extends Trees { ...@@ -388,6 +388,10 @@ public class JavacTrees extends Trees {
} }
} }
protected Copier createCopier(TreeMaker maker) {
return new Copier(maker);
}
/** /**
* Gets the original type from the ErrorType object. * Gets the original type from the ErrorType object.
* @param errorType The errorType for which we want to get the original type. * @param errorType The errorType for which we want to get the original type.
......
...@@ -251,7 +251,8 @@ public class Symtab { ...@@ -251,7 +251,8 @@ public class Symtab {
} }
/** Enter a binary operation, as above but with two opcodes, /** Enter a binary operation, as above but with two opcodes,
* which get encoded as (opcode1 << ByteCodeTags.preShift) + opcode2. * which get encoded as
* {@code (opcode1 << ByteCodeTags.preShift) + opcode2 }.
* @param opcode1 First opcode. * @param opcode1 First opcode.
* @param opcode2 Second opcode. * @param opcode2 Second opcode.
*/ */
......
...@@ -692,7 +692,7 @@ public class Type implements PrimitiveType { ...@@ -692,7 +692,7 @@ public class Type implements PrimitiveType {
/** A class type is raw if it misses some /** A class type is raw if it misses some
* of its type parameter sections. * of its type parameter sections.
* After validation, this is equivalent to: * After validation, this is equivalent to:
* allparams.isEmpty() && tsym.type.allparams.nonEmpty(); * {@code allparams.isEmpty() && tsym.type.allparams.nonEmpty(); }
*/ */
public boolean isRaw() { public boolean isRaw() {
return return
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
package com.sun.tools.javac.comp; package com.sun.tools.javac.comp;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
...@@ -151,10 +150,10 @@ public class Annotate { ...@@ -151,10 +150,10 @@ public class Annotate {
Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated, Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated,
Map<Attribute.Compound, JCDiagnostic.DiagnosticPosition> pos, Map<Attribute.Compound, JCDiagnostic.DiagnosticPosition> pos,
Log log) { Log log) {
Objects.requireNonNull(env); Assert.checkNonNull(env);
Objects.requireNonNull(annotated); Assert.checkNonNull(annotated);
Objects.requireNonNull(pos); Assert.checkNonNull(pos);
Objects.requireNonNull(log); Assert.checkNonNull(log);
this.env = env; this.env = env;
this.annotated = annotated; this.annotated = annotated;
......
...@@ -2373,9 +2373,12 @@ public class Check { ...@@ -2373,9 +2373,12 @@ public class Check {
tree.accept(new AnnotationValidator()); tree.accept(new AnnotationValidator());
} }
/** Annotation types are restricted to primitives, String, an /**
* {@literal
* Annotation types are restricted to primitives, String, an
* enum, an annotation, Class, Class<?>, Class<? extends * enum, an annotation, Class, Class<?>, Class<? extends
* Anything>, arrays of the preceding. * Anything>, arrays of the preceding.
* }
*/ */
void validateAnnotationType(JCTree restype) { void validateAnnotationType(JCTree restype) {
// restype may be null if an error occurred, so don't bother validating it // restype may be null if an error occurred, so don't bother validating it
......
...@@ -77,12 +77,12 @@ import static com.sun.tools.javac.code.Kinds.*; ...@@ -77,12 +77,12 @@ import static com.sun.tools.javac.code.Kinds.*;
* *
* <p>Classes migrate from one phase to the next via queues: * <p>Classes migrate from one phase to the next via queues:
* *
* <pre> * <pre>{@literal
* class enter -> (Enter.uncompleted) --> member enter (1) * class enter -> (Enter.uncompleted) --> member enter (1)
* -> (MemberEnter.halfcompleted) --> member enter (2) * -> (MemberEnter.halfcompleted) --> member enter (2)
* -> (Todo) --> attribute * -> (Todo) --> attribute
* (only for toplevel classes) * (only for toplevel classes)
* </pre> * }</pre>
* *
* <p><b>This is NOT part of any supported API. * <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk. * If you write code that depends on this, you do so at your own risk.
......
...@@ -1449,7 +1449,7 @@ public class Lower extends TreeTranslator { ...@@ -1449,7 +1449,7 @@ public class Lower extends TreeTranslator {
return access(v, make.at(pos).Ident(v), null, false); return access(v, make.at(pos).Ident(v), null, false);
} }
/** Construct a tree simulating the expression <C.this>. /** Construct a tree simulating the expression {@code C.this}.
* @param pos The source code position to be used for the tree. * @param pos The source code position to be used for the tree.
* @param c The qualifier class. * @param c The qualifier class.
*/ */
...@@ -1623,7 +1623,7 @@ public class Lower extends TreeTranslator { ...@@ -1623,7 +1623,7 @@ public class Lower extends TreeTranslator {
} }
/** Construct a tree that represents the outer instance /** Construct a tree that represents the outer instance
* <C.this>. Never pick the current `this'. * {@code C.this}. Never pick the current `this'.
* @param pos The source code position to be used for the tree. * @param pos The source code position to be used for the tree.
* @param c The qualifier class. * @param c The qualifier class.
*/ */
...@@ -1661,7 +1661,7 @@ public class Lower extends TreeTranslator { ...@@ -1661,7 +1661,7 @@ public class Lower extends TreeTranslator {
} }
/** Construct a tree that represents the closest outer instance /** Construct a tree that represents the closest outer instance
* <C.this> such that the given symbol is a member of C. * {@code C.this} such that the given symbol is a member of C.
* @param pos The source code position to be used for the tree. * @param pos The source code position to be used for the tree.
* @param sym The accessed symbol. * @param sym The accessed symbol.
* @param preciseMatch should we accept a type that is a subtype of * @param preciseMatch should we accept a type that is a subtype of
...@@ -1713,7 +1713,7 @@ public class Lower extends TreeTranslator { ...@@ -1713,7 +1713,7 @@ public class Lower extends TreeTranslator {
return tree; return tree;
} }
/** Return tree simulating the assignment <this.name = name>, where /** Return tree simulating the assignment {@code this.name = name}, where
* name is the name of a free variable. * name is the name of a free variable.
*/ */
JCStatement initField(int pos, Name name) { JCStatement initField(int pos, Name name) {
...@@ -1730,7 +1730,7 @@ public class Lower extends TreeTranslator { ...@@ -1730,7 +1730,7 @@ public class Lower extends TreeTranslator {
make.Ident(rhs)).setType(lhs.erasure(types))); make.Ident(rhs)).setType(lhs.erasure(types)));
} }
/** Return tree simulating the assignment <this.this$n = this$n>. /** Return tree simulating the assignment {@code this.this$n = this$n}.
*/ */
JCStatement initOuterThis(int pos) { JCStatement initOuterThis(int pos) {
VarSymbol rhs = outerThisStack.head; VarSymbol rhs = outerThisStack.head;
...@@ -3194,7 +3194,7 @@ public class Lower extends TreeTranslator { ...@@ -3194,7 +3194,7 @@ public class Lower extends TreeTranslator {
* *
* (where arrayexpr is of an array type) gets translated to * (where arrayexpr is of an array type) gets translated to
* *
* <pre> * <pre>{@code
* for ( { arraytype #arr = arrayexpr; * for ( { arraytype #arr = arrayexpr;
* int #len = array.length; * int #len = array.length;
* int #i = 0; }; * int #i = 0; };
...@@ -3202,7 +3202,7 @@ public class Lower extends TreeTranslator { ...@@ -3202,7 +3202,7 @@ public class Lower extends TreeTranslator {
* T v = arr$[#i]; * T v = arr$[#i];
* stmt; * stmt;
* } * }
* </pre> * }</pre>
* *
* where #arr, #len, and #i are freshly named synthetic local variables. * where #arr, #len, and #i are freshly named synthetic local variables.
*/ */
...@@ -3272,14 +3272,14 @@ public class Lower extends TreeTranslator { ...@@ -3272,14 +3272,14 @@ public class Lower extends TreeTranslator {
* for ( T v : coll ) stmt ; * for ( T v : coll ) stmt ;
* </pre> * </pre>
* *
* (where coll implements Iterable<? extends T>) gets translated to * (where coll implements {@code Iterable<? extends T>}) gets translated to
* *
* <pre> * <pre>{@code
* for ( Iterator<? extends T> #i = coll.iterator(); #i.hasNext(); ) { * for ( Iterator<? extends T> #i = coll.iterator(); #i.hasNext(); ) {
* T v = (T) #i.next(); * T v = (T) #i.next();
* stmt; * stmt;
* } * }
* </pre> * }</pre>
* *
* where #i is a freshly named synthetic local variable. * where #i is a freshly named synthetic local variable.
*/ */
......
...@@ -1516,7 +1516,7 @@ public class Resolve { ...@@ -1516,7 +1516,7 @@ public class Resolve {
/** If `sym' is a bad symbol: report error and return errSymbol /** If `sym' is a bad symbol: report error and return errSymbol
* else pass through unchanged, * else pass through unchanged,
* additional arguments duplicate what has been used in trying to find the * additional arguments duplicate what has been used in trying to find the
* symbol (--> flyweight pattern). This improves performance since we * symbol {@literal (--> flyweight pattern)}. This improves performance since we
* expect misses to happen frequently. * expect misses to happen frequently.
* *
* @param sym The symbol that was found, or a ResolveError. * @param sym The symbol that was found, or a ResolveError.
...@@ -1903,9 +1903,9 @@ public class Resolve { ...@@ -1903,9 +1903,9 @@ public class Resolve {
/** This method scans all the constructor symbol in a given class scope - /** This method scans all the constructor symbol in a given class scope -
* assuming that the original scope contains a constructor of the kind: * assuming that the original scope contains a constructor of the kind:
* Foo(X x, Y y), where X,Y are class type-variables declared in Foo, * {@code Foo(X x, Y y)}, where X,Y are class type-variables declared in Foo,
* a method check is executed against the modified constructor type: * a method check is executed against the modified constructor type:
* <X,Y>Foo<X,Y>(X x, Y y). This is crucial in order to enable diamond * {@code <X,Y>Foo<X,Y>(X x, Y y)}. This is crucial in order to enable diamond
* inference. The inferred return type of the synthetic constructor IS * inference. The inferred return type of the synthetic constructor IS
* the inferred type for the diamond operator. * the inferred type for the diamond operator.
*/ */
...@@ -2223,7 +2223,7 @@ public class Resolve { ...@@ -2223,7 +2223,7 @@ public class Resolve {
/** /**
* A name designates an operator if it consists * A name designates an operator if it consists
* of a non-empty sequence of operator symbols +-~!/*%&|^<>= * of a non-empty sequence of operator symbols {@literal +-~!/*%&|^<>= }
*/ */
boolean isOperator(Name name) { boolean isOperator(Name name) {
int i = 0; int i = 0;
......
/* /*
* Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -277,7 +277,7 @@ public interface ByteCodes { ...@@ -277,7 +277,7 @@ public interface ByteCodes {
/** Shift and mask constants for shifting prefix instructions. /** Shift and mask constants for shifting prefix instructions.
* a pair of instruction codes such as LCMP ; IFEQ is encoded * a pair of instruction codes such as LCMP ; IFEQ is encoded
* in Symtab as (LCMP << preShift) + IFEQ. * in Symtab as {@literal (LCMP << preShift) + IFEQ }.
*/ */
int preShift = 9; int preShift = 9;
int preMask = (1 << preShift) - 1; int preMask = (1 << preShift) - 1;
......
...@@ -162,7 +162,7 @@ implements CRTFlags { ...@@ -162,7 +162,7 @@ implements CRTFlags {
} }
/** Source file positions in CRT are integers in the format: /** Source file positions in CRT are integers in the format:
* line-number << LINESHIFT + column-number * {@literal line-number << LINESHIFT + column-number }
*/ */
private int encodePosition(int pos, Position.LineMap lineMap, Log log) { private int encodePosition(int pos, Position.LineMap lineMap, Log log) {
int line = lineMap.getLineNumber(pos); int line = lineMap.getLineNumber(pos);
......
/* /*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -45,7 +45,7 @@ import com.sun.tools.javac.util.Name; ...@@ -45,7 +45,7 @@ import com.sun.tools.javac.util.Name;
* classSignature ::= [ typeparams ] supertype { interfacetype } * classSignature ::= [ typeparams ] supertype { interfacetype }
* </pre> * </pre>
* <p>The type syntax in signatures is extended as follows: * <p>The type syntax in signatures is extended as follows:
* <pre> * <pre>{@literal
* type ::= ... | classtype | methodtype | typevar * type ::= ... | classtype | methodtype | typevar
* classtype ::= classsig { '.' classsig } * classtype ::= classsig { '.' classsig }
* classig ::= 'L' name [typeargs] ';' * classig ::= 'L' name [typeargs] ';'
...@@ -54,7 +54,7 @@ import com.sun.tools.javac.util.Name; ...@@ -54,7 +54,7 @@ import com.sun.tools.javac.util.Name;
* typeargs ::= '<' type { type } '>' * typeargs ::= '<' type { type } '>'
* typeparams ::= '<' typeparam { typeparam } '>' * typeparams ::= '<' typeparam { typeparam } '>'
* typeparam ::= name ':' type * typeparam ::= name ':' type
* </pre> * }</pre>
* <p>This class defines constants used in class files as well * <p>This class defines constants used in class files as well
* as routines to convert between internal ``.'' and external ``/'' * as routines to convert between internal ``.'' and external ``/''
* separators in class names. * separators in class names.
......
/* /*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -122,7 +122,7 @@ public class Code { ...@@ -122,7 +122,7 @@ public class Code {
/*---------- internal fields: --------------- */ /*---------- internal fields: --------------- */
/** Are we generating code with jumps >= 32K? /** Are we generating code with jumps &ge; 32K?
*/ */
public boolean fatcode; public boolean fatcode;
...@@ -1077,13 +1077,15 @@ public class Code { ...@@ -1077,13 +1077,15 @@ public class Code {
while (cp % incr != 0) emitop0(nop); while (cp % incr != 0) emitop0(nop);
} }
/** Place a byte into code at address pc. Pre: pc + 1 <= cp. /** Place a byte into code at address pc.
* Pre: {@literal pc + 1 <= cp }.
*/ */
private void put1(int pc, int op) { private void put1(int pc, int op) {
code[pc] = (byte)op; code[pc] = (byte)op;
} }
/** Place two bytes into code at address pc. Pre: pc + 2 <= cp. /** Place two bytes into code at address pc.
* Pre: {@literal pc + 2 <= cp }.
*/ */
private void put2(int pc, int od) { private void put2(int pc, int od) {
// pre: pc + 2 <= cp // pre: pc + 2 <= cp
...@@ -1091,7 +1093,8 @@ public class Code { ...@@ -1091,7 +1093,8 @@ public class Code {
put1(pc+1, od); put1(pc+1, od);
} }
/** Place four bytes into code at address pc. Pre: pc + 4 <= cp. /** Place four bytes into code at address pc.
* Pre: {@literal pc + 4 <= cp }.
*/ */
public void put4(int pc, int od) { public void put4(int pc, int od) {
// pre: pc + 4 <= cp // pre: pc + 4 <= cp
...@@ -1990,7 +1993,7 @@ public class Code { ...@@ -1990,7 +1993,7 @@ public class Code {
nextreg = max_locals; nextreg = max_locals;
} }
/** End scopes of all variables with registers >= first. /** End scopes of all variables with registers &ge; first.
*/ */
public void endScopes(int first) { public void endScopes(int first) {
int prevNextReg = nextreg; int prevNextReg = nextreg;
......
...@@ -247,10 +247,10 @@ public class Gen extends JCTree.Visitor { ...@@ -247,10 +247,10 @@ public class Gen extends JCTree.Visitor {
/** Construct a symbol to reflect the qualifying type that should /** Construct a symbol to reflect the qualifying type that should
* appear in the byte code as per JLS 13.1. * appear in the byte code as per JLS 13.1.
* *
* For target >= 1.2: Clone a method with the qualifier as owner (except * For {@literal target >= 1.2}: Clone a method with the qualifier as owner (except
* for those cases where we need to work around VM bugs). * for those cases where we need to work around VM bugs).
* *
* For target <= 1.1: If qualified variable or method is defined in a * For {@literal target <= 1.1}: If qualified variable or method is defined in a
* non-accessible class, clone it with the qualifier class as owner. * non-accessible class, clone it with the qualifier class as owner.
* *
* @param sym The accessed symbol * @param sym The accessed symbol
......
...@@ -670,6 +670,7 @@ public class JavacParser implements Parser { ...@@ -670,6 +670,7 @@ public class JavacParser implements Parser {
} }
/** /**
* {@literal
* Expression = Expression1 [ExpressionRest] * Expression = Expression1 [ExpressionRest]
* ExpressionRest = [AssignmentOperator Expression1] * ExpressionRest = [AssignmentOperator Expression1]
* AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | * AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" |
...@@ -679,6 +680,7 @@ public class JavacParser implements Parser { ...@@ -679,6 +680,7 @@ public class JavacParser implements Parser {
* TypeNoParams = TypeNoParams1 * TypeNoParams = TypeNoParams1
* StatementExpression = Expression * StatementExpression = Expression
* ConstantExpression = Expression * ConstantExpression = Expression
* }
*/ */
JCExpression term() { JCExpression term() {
JCExpression t = term1(); JCExpression t = term1();
...@@ -884,9 +886,12 @@ public class JavacParser implements Parser { ...@@ -884,9 +886,12 @@ public class JavacParser implements Parser {
return opStack; return opStack;
} }
/** Expression3 = PrefixOp Expression3 /**
* Expression3 = PrefixOp Expression3
* | "(" Expr | TypeNoParams ")" Expression3 * | "(" Expr | TypeNoParams ")" Expression3
* | Primary {Selector} {PostfixOp} * | Primary {Selector} {PostfixOp}
*
* {@literal
* Primary = "(" Expression ")" * Primary = "(" Expression ")"
* | Literal * | Literal
* | [TypeArguments] THIS [Arguments] * | [TypeArguments] THIS [Arguments]
...@@ -901,6 +906,8 @@ public class JavacParser implements Parser { ...@@ -901,6 +906,8 @@ public class JavacParser implements Parser {
* | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator ) * | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator )
* ] * ]
* | BasicType BracketsOpt "." CLASS * | BasicType BracketsOpt "." CLASS
* }
*
* PrefixOp = "++" | "--" | "!" | "~" | "+" | "-" * PrefixOp = "++" | "--" | "!" | "~" | "+" | "-"
* PostfixOp = "++" | "--" * PostfixOp = "++" | "--"
* Type3 = Ident { "." Ident } [TypeArguments] {TypeSelector} BracketsOpt * Type3 = Ident { "." Ident } [TypeArguments] {TypeSelector} BracketsOpt
...@@ -1453,7 +1460,10 @@ public class JavacParser implements Parser { ...@@ -1453,7 +1460,10 @@ public class JavacParser implements Parser {
return null; return null;
} }
/** TypeArguments = "<" TypeArgument {"," TypeArgument} ">" /**
* {@literal
* TypeArguments = "<" TypeArgument {"," TypeArgument} ">"
* }
*/ */
List<JCExpression> typeArguments(boolean diamondAllowed) { List<JCExpression> typeArguments(boolean diamondAllowed) {
if (token.kind == LT) { if (token.kind == LT) {
...@@ -1490,10 +1500,13 @@ public class JavacParser implements Parser { ...@@ -1490,10 +1500,13 @@ public class JavacParser implements Parser {
} }
} }
/** TypeArgument = Type /**
* {@literal
* TypeArgument = Type
* | "?" * | "?"
* | "?" EXTENDS Type {"&" Type} * | "?" EXTENDS Type {"&" Type}
* | "?" SUPER Type * | "?" SUPER Type
* }
*/ */
JCExpression typeArgument() { JCExpression typeArgument() {
if (token.kind != QUES) return parseType(); if (token.kind != QUES) return parseType();
...@@ -2991,7 +3004,10 @@ public class JavacParser implements Parser { ...@@ -2991,7 +3004,10 @@ public class JavacParser implements Parser {
return ts.toList(); return ts.toList();
} }
/** TypeParametersOpt = ["<" TypeParameter {"," TypeParameter} ">"] /**
* {@literal
* TypeParametersOpt = ["<" TypeParameter {"," TypeParameter} ">"]
* }
*/ */
List<JCTypeParameter> typeParametersOpt() { List<JCTypeParameter> typeParametersOpt() {
if (token.kind == LT) { if (token.kind == LT) {
...@@ -3010,9 +3026,12 @@ public class JavacParser implements Parser { ...@@ -3010,9 +3026,12 @@ public class JavacParser implements Parser {
} }
} }
/** TypeParameter = TypeVariable [TypeParameterBound] /**
* {@literal
* TypeParameter = TypeVariable [TypeParameterBound]
* TypeParameterBound = EXTENDS Type {"&" Type} * TypeParameterBound = EXTENDS Type {"&" Type}
* TypeVariable = Ident * TypeVariable = Ident
* }
*/ */
JCTypeParameter typeParameter() { JCTypeParameter typeParameter() {
int pos = token.pos; int pos = token.pos;
......
/* /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -61,7 +61,8 @@ public interface Lexer { ...@@ -61,7 +61,8 @@ public interface Lexer {
/** /**
* Splits the current token in two and return the first (splitted) token. * Splits the current token in two and return the first (splitted) token.
* For instance '<<<' is splitted into two tokens '<' and '<<' respectively, * For instance {@literal '<<<'} is split into two tokens
* {@literal '<'} and {@literal '<<'} respectively,
* and the latter is returned. * and the latter is returned.
*/ */
Token split(); Token split();
......
...@@ -1072,8 +1072,10 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea ...@@ -1072,8 +1072,10 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
Assert.checkNonNull(tokens); Assert.checkNonNull(tokens);
next.put(Tokens.tokensKey, tokens); next.put(Tokens.tokensKey, tokens);
Log nextLog = Log.instance(next);
// propogate the log's writers directly, instead of going through context // propogate the log's writers directly, instead of going through context
Log.instance(next).setWriters(log); nextLog.setWriters(log);
nextLog.setSourceMap(log);
JavaCompiler oldCompiler = JavaCompiler.instance(context); JavaCompiler oldCompiler = JavaCompiler.instance(context);
JavaCompiler nextCompiler = JavaCompiler.instance(next); JavaCompiler nextCompiler = JavaCompiler.instance(next);
...@@ -1362,7 +1364,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea ...@@ -1362,7 +1364,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
* {@inheritdoc} * {@inheritdoc}
* *
* Command line options suitable for presenting to annotation * Command line options suitable for presenting to annotation
* processors. "-Afoo=bar" should be "-Afoo" => "bar". * processors.
* {@literal "-Afoo=bar"} should be {@literal "-Afoo" => "bar"}.
*/ */
public Map<String,String> getOptions() { public Map<String,String> getOptions() {
return processorOptions; return processorOptions;
......
...@@ -2010,7 +2010,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { ...@@ -2010,7 +2010,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
} }
/** /**
* A parameterized type, T<...> * A parameterized type, {@literal T<...>}
*/ */
public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree { public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree {
public JCExpression clazz; public JCExpression clazz;
......
...@@ -256,7 +256,8 @@ public class Pretty extends JCTree.Visitor { ...@@ -256,7 +256,8 @@ public class Pretty extends JCTree.Visitor {
return pos; return pos;
} }
/** If type parameter list is non-empty, print it enclosed in "<...>" brackets. /** If type parameter list is non-empty, print it enclosed in
* {@literal "<...>"} brackets.
*/ */
public void printTypeParameters(List<JCTypeParameter> trees) throws IOException { public void printTypeParameters(List<JCTypeParameter> trees) throws IOException {
if (trees.nonEmpty()) { if (trees.nonEmpty()) {
......
...@@ -87,7 +87,7 @@ public class TreeMaker implements JCTree.Factory { ...@@ -87,7 +87,7 @@ public class TreeMaker implements JCTree.Factory {
/** Create a tree maker with a given toplevel and FIRSTPOS as initial position. /** Create a tree maker with a given toplevel and FIRSTPOS as initial position.
*/ */
TreeMaker(JCCompilationUnit toplevel, Names names, Types types, Symtab syms) { protected TreeMaker(JCCompilationUnit toplevel, Names names, Types types, Symtab syms) {
this.pos = Position.FIRSTPOS; this.pos = Position.FIRSTPOS;
this.toplevel = toplevel; this.toplevel = toplevel;
this.names = names; this.names = names;
......
/* /*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -127,7 +127,7 @@ public class Bits { ...@@ -127,7 +127,7 @@ public class Bits {
(bits[x >>> wordshift] & (1 << (x & wordmask))) != 0; (bits[x >>> wordshift] & (1 << (x & wordmask))) != 0;
} }
/** this set = this set & xs. /** {@literal this set = this set & xs}.
*/ */
public Bits andSet(Bits xs) { public Bits andSet(Bits xs) {
sizeTo(xs.bits.length); sizeTo(xs.bits.length);
...@@ -179,12 +179,12 @@ public class Bits { ...@@ -179,12 +179,12 @@ public class Bits {
return n - (x&1); return n - (x&1);
} }
/** Return the index of the least bit position >= x that is set. /** Return the index of the least bit position &ge; x that is set.
* If none are set, returns -1. This provides a nice way to iterate * If none are set, returns -1. This provides a nice way to iterate
* over the members of a bit set: * over the members of a bit set:
* <pre> * <pre>{@code
* for (int i = bits.nextBit(0); i>=0; i = bits.nextBit(i+1)) ... * for (int i = bits.nextBit(0); i>=0; i = bits.nextBit(i+1)) ...
* </pre> * }</pre>
*/ */
public int nextBit(int x) { public int nextBit(int x) {
int windex = x >>> wordshift; int windex = x >>> wordshift;
......
/* /*
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -115,7 +115,10 @@ public class Context { ...@@ -115,7 +115,10 @@ public class Context {
* The underlying map storing the data. * The underlying map storing the data.
* We maintain the invariant that this table contains only * We maintain the invariant that this table contains only
* mappings of the form * mappings of the form
* Key<T> -> T or Key<T> -> Factory<T> */ * {@literal Key<T> -> T }
* or
* {@literal Key<T> -> Factory<T> }
*/
private Map<Key<?>,Object> ht = new HashMap<Key<?>,Object>(); private Map<Key<?>,Object> ht = new HashMap<Key<?>,Object>();
/** Set the factory for the key in this context. */ /** Set the factory for the key in this context. */
......
...@@ -301,6 +301,10 @@ public class Log extends AbstractLog { ...@@ -301,6 +301,10 @@ public class Log extends AbstractLog {
this.errWriter = other.errWriter; this.errWriter = other.errWriter;
} }
public void setSourceMap(Log other) {
this.sourceMap = other.sourceMap;
}
/** Flush the logs /** Flush the logs
*/ */
public void flush() { public void flush() {
......
/* /*
* Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -43,28 +43,28 @@ public abstract class Name implements javax.lang.model.element.Name { ...@@ -43,28 +43,28 @@ public abstract class Name implements javax.lang.model.element.Name {
} }
/** /**
* @inheritDoc * {@inheritDoc}
*/ */
public boolean contentEquals(CharSequence cs) { public boolean contentEquals(CharSequence cs) {
return toString().equals(cs.toString()); return toString().equals(cs.toString());
} }
/** /**
* @inheritDoc * {@inheritDoc}
*/ */
public int length() { public int length() {
return toString().length(); return toString().length();
} }
/** /**
* @inheritDoc * {@inheritDoc}
*/ */
public char charAt(int index) { public char charAt(int index) {
return toString().charAt(index); return toString().charAt(index);
} }
/** /**
* @inheritDoc * {@inheritDoc}
*/ */
public CharSequence subSequence(int start, int end) { public CharSequence subSequence(int start, int end) {
return toString().subSequence(start, end); return toString().subSequence(start, end);
...@@ -142,6 +142,7 @@ public abstract class Name implements javax.lang.model.element.Name { ...@@ -142,6 +142,7 @@ public abstract class Name implements javax.lang.model.element.Name {
/** Return the string representation of this name. /** Return the string representation of this name.
*/ */
@Override
public String toString() { public String toString() {
return Convert.utf2string(getByteArray(), getByteOffset(), getByteLength()); return Convert.utf2string(getByteArray(), getByteOffset(), getByteLength());
} }
......
/* /*
* Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -79,12 +79,12 @@ public class Position { ...@@ -79,12 +79,12 @@ public class Position {
} }
/** Encode line and column numbers in an integer as: /** Encode line and column numbers in an integer as:
* line-number << LINESHIFT + column-number * {@code line-number << LINESHIFT + column-number }.
* {@link Position.NOPOS represents an undefined position. * {@link Position.NOPOS} represents an undefined position.
* *
* @param line number of line (first is 1) * @param line number of line (first is 1)
* @param col number of character on line (first is 1) * @param col number of character on line (first is 1)
* @return an encoded position or {@link Position.NOPOS * @return an encoded position or {@link Position.NOPOS}
* if the line or column number is too big to * if the line or column number is too big to
* represent in the encoded format * represent in the encoded format
* @throws IllegalArgumentException if line or col is less than 1 * @throws IllegalArgumentException if line or col is less than 1
...@@ -107,8 +107,8 @@ public class Position { ...@@ -107,8 +107,8 @@ public class Position {
* @param line number of line (first is 1) * @param line number of line (first is 1)
* @return position of first character in line * @return position of first character in line
* @throws ArrayIndexOutOfBoundsException * @throws ArrayIndexOutOfBoundsException
* if <tt>lineNumber < 1</tt> * if {@code lineNumber < 1}
* if <tt>lineNumber > no. of lines</tt> * if {@code lineNumber > no. of lines}
*/ */
int getStartPosition(int line); int getStartPosition(int line);
...@@ -119,8 +119,8 @@ public class Position { ...@@ -119,8 +119,8 @@ public class Position {
* *
* @return position of character * @return position of character
* @throws ArrayIndexOutOfBoundsException * @throws ArrayIndexOutOfBoundsException
* if <tt>line < 1</tt> * if {@code line < 1}
* if <tt>line > no. of lines</tt> * if {@code line > no. of lines}
*/ */
int getPosition(int line, int column); int getPosition(int line, int column);
......
/* /*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -386,7 +386,7 @@ class Comment { ...@@ -386,7 +386,7 @@ class Comment {
} }
/** /**
* Recursively search for the string "{@" followed by * Recursively search for the characters '{', '@', followed by
* name of inline tag and white space, * name of inline tag and white space,
* if found * if found
* return the index of the text following the white space. * return the index of the text following the white space.
......
/* /*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -138,7 +138,7 @@ public abstract class DocImpl implements Doc, Comparable<Object> { ...@@ -138,7 +138,7 @@ public abstract class DocImpl implements Doc, Comparable<Object> {
/** /**
* Return the see also tags in this Doc item. * Return the see also tags in this Doc item.
* *
* @return an array of SeeTag containing all &#64see tags. * @return an array of SeeTag containing all &#64;see tags.
*/ */
public SeeTag[] seeTags() { public SeeTag[] seeTags() {
return comment().seeTags(); return comment().seeTags();
......
/* /*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -241,7 +241,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc { ...@@ -241,7 +241,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
* Return the serialField tags in this FieldDocImpl item. * Return the serialField tags in this FieldDocImpl item.
* *
* @return an array of <tt>SerialFieldTagImpl</tt> containing all * @return an array of <tt>SerialFieldTagImpl</tt> containing all
* <code>&#64serialField</code> tags. * <code>&#64;serialField</code> tags.
*/ */
public SerialFieldTag[] serialFieldTags() { public SerialFieldTag[] serialFieldTags() {
return comment().serialFieldTags(); return comment().serialFieldTags();
......
...@@ -79,7 +79,7 @@ import com.sun.tools.javac.main.CommandLine; ...@@ -79,7 +79,7 @@ import com.sun.tools.javac.main.CommandLine;
/** /**
* Javah generates support files for native methods. * Javah generates support files for native methods.
* Parse commandline options & Invokes javadoc to execute those commands. * Parse commandline options and invokes javadoc to execute those commands.
* *
* <p><b>This is NOT part of any supported API. * <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own * If you write code that depends on this, you do so at your own
......
/* /*
* Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -374,8 +374,8 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { ...@@ -374,8 +374,8 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
task_locale = locale; task_locale = locale;
} }
public void setLog(PrintWriter log) { public void setLog(Writer log) {
this.log = log; this.log = getPrintWriterForWriter(log);
} }
public void setLog(OutputStream s) { public void setLog(OutputStream s) {
...@@ -383,7 +383,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { ...@@ -383,7 +383,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
} }
private static PrintWriter getPrintWriterForStream(OutputStream s) { private static PrintWriter getPrintWriterForStream(OutputStream s) {
return new PrintWriter(s, true); return new PrintWriter(s == null ? System.err : s, true);
} }
private static PrintWriter getPrintWriterForWriter(Writer w) { private static PrintWriter getPrintWriterForWriter(Writer w) {
......
/* /*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -79,12 +79,12 @@ public interface Elements { ...@@ -79,12 +79,12 @@ public interface Elements {
* *
* <p> A documentation comment of an element is a comment that * <p> A documentation comment of an element is a comment that
* begins with "{@code /**}" , ends with a separate * begins with "{@code /**}" , ends with a separate
* "<code>*&#47</code>", and immediately precedes the element, * "<code>*&#47;</code>", and immediately precedes the element,
* ignoring white space. Therefore, a documentation comment * ignoring white space. Therefore, a documentation comment
* contains at least three"{@code *}" characters. The text * contains at least three"{@code *}" characters. The text
* returned for the documentation comment is a processed form of * returned for the documentation comment is a processed form of
* the comment as it appears in source code. The leading "{@code * the comment as it appears in source code. The leading "{@code
* /**}" and trailing "<code>*&#47</code>" are removed. For lines * /**}" and trailing "<code>*&#47;</code>" are removed. For lines
* of the comment starting after the initial "{@code /**}", * of the comment starting after the initial "{@code /**}",
* leading white space characters are discarded as are any * leading white space characters are discarded as are any
* consecutive "{@code *}" characters appearing after the white * consecutive "{@code *}" characters appearing after the white
......
/* /*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -137,7 +137,7 @@ import javax.annotation.processing.Processor; ...@@ -137,7 +137,7 @@ import javax.annotation.processing.Processor;
* StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null); * StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
* compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits).call(); * compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits).call();
* *
* for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics()) * for ({@code Diagnostic<? extends JavaFileObject>} diagnostic : diagnostics.getDiagnostics())
* System.out.format("Error on line %d in %s%n", * System.out.format("Error on line %d in %s%n",
* diagnostic.getLineNumber(), * diagnostic.getLineNumber(),
* diagnostic.getSource().toUri()); * diagnostic.getSource().toUri());
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7180906
* @summary Test to make sure that the since tag works correctly
* @author Bhavesh Patel
* @library ../lib/
* @build JavadocTester TestSinceTag
* @run main TestSinceTag
*/
public class TestSinceTag extends JavadocTester {
//Test information.
private static final String BUG_ID = "7180906";
//Javadoc arguments.
private static final String[] ARGS1 = new String[] {
"-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"
};
private static final String[] ARGS2 = new String[] {
"-d", BUG_ID, "-sourcepath", SRC_DIR, "-nosince", "pkg1"
};
//Input for string search tests.
private static final String[][] TEST = {
{BUG_ID + FS + "pkg1" + FS + "C1.html",
"<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
" <dd>JDK1.0</dd>"
},
{BUG_ID + FS + "serialized-form.html",
"<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
" <dd>1.4</dd>"
}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestSinceTag tester = new TestSinceTag();
run(tester, ARGS1, TEST, NO_TEST);
run(tester, ARGS2, NO_TEST, TEST);
tester.printSummary();
}
/**
* {@inheritDoc}
*/
public String getBugId() {
return BUG_ID;
}
/**
* {@inheritDoc}
*/
public String getBugName() {
return getClass().getName();
}
}
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
import java.io.IOException;
import java.io.Serializable;
/**
* A class comment for testing.
*
* @author Bhavesh Patel
* @since JDK1.0
*/
public class C1 implements Serializable {
/**
* This field indicates whether the C1 is undecorated.
*
* @see #setUndecorated(boolean)
* @since 1.4
* @serial
* @deprecated As of JDK version 1.5, replaced by
* {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
*/
@Deprecated
public boolean undecorated = false;
/**
* This enum specifies the possible modal exclusion types.
*
* @since 1.6
*/
public static enum ModalExclusionType {
/**
* No modal exclusion.
*/
NO_EXCLUDE,
/**
* <code>APPLICATION_EXCLUDE</code> indicates that a top-level window
* won't be blocked by any application-modal dialogs. Also, it isn't
* blocked by document-modal dialogs from outside of its child hierarchy.
*/
APPLICATION_EXCLUDE
};
/**
* Constructor.
*
* @param title the title
* @param test boolean value
* @exception IllegalArgumentException if the <code>owner</code>'s
* <code>GraphicsConfiguration</code> is not from a screen device
* @exception HeadlessException
*/
public C1(String title, boolean test) {
}
public C1(String title) {
}
/**
* Method comments.
* @param undecorated <code>true</code> if no decorations are
* to be enabled;
* <code>false</code> if decorations are to be enabled.
* @see #readObject()
* @since 1.4
*/
public void setUndecorated(boolean undecorated) {
/* Make sure we don't run in the middle of peer creation.*/
}
/**
* @see #setUndecorated(boolean)
*/
public void readObject() throws IOException {
}
}
/*
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7196760
* @summary javac doesn't report Diagnostic end positions properly when
* an annotation processor is present
*/
import com.sun.source.tree.ClassTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.Tree;
import com.sun.source.util.JavacTask;
import com.sun.source.util.Trees;
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.*;
import javax.lang.model.element.*;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
import static javax.tools.JavaFileObject.Kind.SOURCE;
import javax.tools.ToolProvider;
@SupportedAnnotationTypes("*")
public class EndPositions extends AbstractProcessor {
public static void main(String... args) throws IOException {
class MyFileObject extends SimpleJavaFileObject {
MyFileObject() {
super(URI.create("myfo:///Test.java"), SOURCE);
}
@Override
public String getCharContent(boolean ignoreEncodingErrors) {
// 0 1 2 3
// 012345678901234567890123456789012345
return "class Test { String s = 1234; }";
}
}
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
List<JavaFileObject> compilationUnits =
Collections.<JavaFileObject>singletonList(new MyFileObject());
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
List<String> options = Arrays.asList("-processor", EndPositions.class.getCanonicalName());
JavacTask task = (JavacTask)javac.getTask(null, null, diagnostics, options, null, compilationUnits);
boolean valid = task.call();
if (valid)
throw new AssertionError("Compilation succeeded unexpectedly");
List<Diagnostic<? extends JavaFileObject>> errors = diagnostics.getDiagnostics();
if (errors.size() != 1)
throw new AssertionError("Expected one error only, but found " + errors.size() + " errors");
Diagnostic<?> error = errors.get(0);
if (error.getStartPosition() >= error.getEndPosition())
throw new AssertionError("Expected start to be less than end position: start [" +
error.getStartPosition() + "], end [" + error.getEndPosition() +"]");
System.out.println("All is good!");
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
return true;
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7186925
* @summary JavapTask passes null to java.io.Writer
*/
import java.io.*;
import java.util.*;
import javax.tools.*;
import com.sun.tools.javap.*;
public class T7186925
{
public static void main(String... args) {
new T7186925().run();
}
void run() {
verify("java.lang.Object");
if (errors > 0)
throw new Error(errors + " found.");
}
void verify(String className) {
try {
JavaFileManager fileManager = JavapFileManager.create(null, null);
JavaFileObject fo = fileManager.getJavaFileForInput(StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS);
if (fo == null) {
error("Can't find " + className);
} else {
JavapTask t = new JavapTask(null, fileManager, null);
t.handleOptions(new String[] { "-sysinfo", className });
JavapTask.ClassFileInfo cfInfo = t.read(fo);
expectEqual(cfInfo.cf.byteLength(), cfInfo.size);
}
} catch (NullPointerException ee) {
ee.printStackTrace();
error("Exception: " + ee);
} catch (Exception ee) {
System.err.println("Caught exception: " + ee);
}
}
void expectEqual(int found, int expected) {
if (found != expected)
error("bad value found: " + found + " expected: " + expected);
}
void error(String msg) {
System.err.println(msg);
errors++;
}
int errors;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册