提交 b4994199 编写于 作者: C chegar

Merge

<html>
<head>
<TITLE>Doclet API Package</TITLE>
<!--
Copyright (c) 1998, 2003, 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.
-->
</head>
<body bgcolor="white">
/*
* Copyright (c) 1998, 2013, 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.
*/
/**
The Doclet API (also called the Javadoc API) provides a mechanism
for clients to inspect the source-level structure of programs and
for clients to inspect the source-level structure of programs and
libraries, including javadoc comments embedded in the source.
This is useful for documentation, program checking, automatic
code generation and many other tools.
<p>
Doclets are invoked by javadoc and use this API to write out
Doclets are invoked by javadoc and use this API to write out
program information to files. For example, the standard doclet is called
by default and writes out documentation to HTML files.
<p>
The invocation is defined by the abstract {@link com.sun.javadoc.Doclet} class
The invocation is defined by the abstract {@link com.sun.javadoc.Doclet} class
-- the entry point is the {@link com.sun.javadoc.Doclet#start(RootDoc) start} method:
<pre>
public static boolean <b>start</b>(RootDoc root)
</pre>
The {@link com.sun.javadoc.RootDoc} instance holds the root of the program structure
information. From this root all other program structure
information can be extracted.
information. From this root all other program structure
information can be extracted.
<p>
<a name="terminology"></a>
......@@ -56,28 +51,28 @@ information can be extracted.
<a name="included"></a>
When calling javadoc, you pass in package names and source file names --
these are called the <em>specified</em> packages and classes.
You also pass in Javadoc options; the <em>access control</em> Javadoc options
(<code>-public</code>, <code>-protected</code>, <code>-package</code>,
and <code>-private</code>) filter program elements, producing a
these are called the <em>specified</em> packages and classes.
You also pass in Javadoc options; the <em>access control</em> Javadoc options
(<code>-public</code>, <code>-protected</code>, <code>-package</code>,
and <code>-private</code>) filter program elements, producing a
result set, called the <em>included</em> set, or "documented" set.
(The unfiltered set is also available through
(The unfiltered set is also available through
{@link com.sun.javadoc.PackageDoc#allClasses(boolean) allClasses(false)}.)
<p>
<a name="class"></a>
Throughout this API, the term <em>class</em> is normally a
shorthand for "class or interface", as in: {@link com.sun.javadoc.ClassDoc},
shorthand for "class or interface", as in: {@link com.sun.javadoc.ClassDoc},
{@link com.sun.javadoc.PackageDoc#allClasses() allClasses()}, and
{@link com.sun.javadoc.PackageDoc#findClass(String) findClass(String)}.
In only a couple of other places, it means "class, as opposed to interface",
In only a couple of other places, it means "class, as opposed to interface",
as in: {@link com.sun.javadoc.Doc#isClass()}.
In the second sense, this API calls out four kinds of classes:
{@linkplain com.sun.javadoc.Doc#isOrdinaryClass() ordinary classes},
{@linkplain com.sun.javadoc.Doc#isOrdinaryClass() ordinary classes},
{@linkplain com.sun.javadoc.Doc#isEnum() enums},
{@linkplain com.sun.javadoc.Doc#isError() errors} and
{@linkplain com.sun.javadoc.Doc#isError() errors} and
{@linkplain com.sun.javadoc.Doc#isException() exceptions}.
Throughout the API, the detailed description of each program element
Throughout the API, the detailed description of each program element
describes explicitly which meaning is being used.
<p>
......@@ -89,8 +84,8 @@ name has no package name, such as <code>String</code>.
<a name="example"></a>
<h3>Example</h3>
The following is an example doclet that
The following is an example doclet that
displays information in the <code>@param</code> tags of the processed
classes:
<pre>
......@@ -117,17 +112,17 @@ public class ListParams extends <font color=red title="Doclet API">Doclet</font>
+ " - " + params[j].<font color=red title="Doclet API">parameterComment</font>());
}
}
}
}
}
</pre>
Interfaces and methods from the Javadoc API are marked in
<font color=red title="Doclet API">red</font>.
{@link com.sun.javadoc.Doclet Doclet} is an abstract class that specifies
the invocation interface for doclets,
{@link com.sun.javadoc.Doclet Doclet} holds class or interface information,
Interfaces and methods from the Javadoc API are marked in
<font color=red title="Doclet API">red</font>.
{@link com.sun.javadoc.Doclet Doclet} is an abstract class that specifies
the invocation interface for doclets,
{@link com.sun.javadoc.Doclet Doclet} holds class or interface information,
{@link com.sun.javadoc.ExecutableMemberDoc} is a
superinterface of {@link com.sun.javadoc.MethodDoc} and
{@link com.sun.javadoc.ConstructorDoc},
superinterface of {@link com.sun.javadoc.MethodDoc} and
{@link com.sun.javadoc.ConstructorDoc},
and {@link com.sun.javadoc.ParamTag} holds information
from "<code>@param</code>" tags.
<p>
......@@ -148,5 +143,6 @@ producing output like:
</pre>
@see com.sun.javadoc.Doclet
@see com.sun.javadoc.RootDoc
</BODY>
</HTML>
*/
@jdk.Exported
package com.sun.javadoc;
/*
* Copyright (c) 2007, 2013, 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.
*/
/**
A minimalist library to read and write class files into objects closely
based on the corresponding definitions in
<cite>The Java&trade; Virtual Machine Specification</cite> (JVMS).
<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.
This code and its internal interfaces are subject to change or
deletion without notice.</b>
*/
@jdk.Exported(false)
package com.sun.tools.classfile;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
A minimalist library to read and write class files into objects closely
based on the corresponding definitions in
<cite>The Java&trade; Virtual Machine Specification</cite> (JVMS).
</body>
</html>
/*
* Copyright (c) 2007, 2013, 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.
*/
/**
This package contains classes that write HTML markup tags.
<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.
This code and its internal interfaces are subject to change or
deletion without notice.</b>
*/
@jdk.Exported(false)
package com.sun.tools.doclets.formats.html.markup;
<!--
Copyright (c) 2003, 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.
-->
<html>
<head>
<title>com.sun.tools.doclets.formats.html.markup package</title>
<body bgcolor="white">
This package contains classes that write HTML markup tags.
</body>
</html>
/*
* Copyright (c) 2003, 2013, 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.
*/
/**
This is the default doclet provided with JDK that produces Javadoc's
default HTML-formatted API output. For more documentation
on this doclet, please refer to the link below.
@see <a href="http://www.java.sun.com/javadoc/standard-doclet.html">
http://www.java.sun.com/javadoc/standard-doclet.html </a>
<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.
This code and its internal interfaces are subject to change or
deletion without notice.</b>
*/
@jdk.Exported(false)
package com.sun.tools.doclets.formats.html;
<!--
Copyright (c) 2003, 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.
-->
<html>
<head>
<title>com.sun.tools.doclets.formats.html package</title>
</head>
<body bgcolor="white">
This is the default doclet provided with JDK that produces Javadoc's
default HTML-formatted API output. For more documentation
on this doclet, please refer to the link below.
@see <a href="http://www.java.sun.com/javadoc/standard-doclet.html">
http://www.java.sun.com/javadoc/standard-doclet.html </a>
</body>
</html>
/*
* Copyright (c) 2003, 2013, 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.
*/
/**
This doclet-independent package has a set of classes and
interfaces that are the building blocks for doclets. They
define the basic structure of doclets and make doclet
writing much easier because they provide the content generation
code to be shared among different doclets. Builders only provide
the structure and content of API documentation.
They will not provide any style markup.
<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.
This code and its internal interfaces are subject to change or
deletion without notice.</b>
*/
@jdk.Exported(false)
package com.sun.tools.doclets.internal.toolkit.builders;
<!--
Copyright (c) 2003, 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.
-->
<html>
<head>
<title>com.sun.tools.doclets.internal.toolkit.builders package</title>
</head>
<body bgcolor="white">
This doclet-independent package has a set of classes and
interfaces that are the building blocks for doclets. They
define the basic structure of doclets and make doclet
writing much easier because they provide the content generation
code to be shared among different doclets. Builders only provide
the structure and content of API documentation.
They will not provide any style markup.
<p>
This code is not part of an API.
It is implementation that is subject to change.
Do not use it as an API.
</body>
</html>
/*
* Copyright (c) 2003, 2013, 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.
*/
/**
Contains the base classes that make up a doclet. Doclets that reuse
the functionality provided by the toolkit should have the following
characteristics:
<ul>
<li>
The main driver class should extend
{@link com.sun.tools.doclets.internal.toolkit.AbstractDoclet}.
</li>
<li>
The doclet configuration class should extend
{@link com.sun.tools.doclets.internal.toolkit.Configuration}.
</li>
<li>
The doclet should have a writer factory that implements
{@link com.sun.tools.doclets.internal.toolkit.WriterFactory}.
This class constructs writers that write doclet specific output.
</li>
<li>
The doclet should have a taglet writer that extends
{@link com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter}.
This writer determines how to output each given tag.
</li>
</ul>
<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.
This code and its internal interfaces are subject to change or
deletion without notice.</b>
*/
@jdk.Exported(false)
package com.sun.tools.doclets.internal.toolkit;
<!--
Copyright (c) 2003, 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.
-->
<html>
<head>
<title>com.sun.tools.doclets.internal.toolkit package</title>
</head>
<body bgcolor="white">
Contains the base classes that make up a doclet. Doclets that reuse
the functionality provided by the toolkit should have the following
characteristics:
<ul>
<li>
The main driver class should extend
{@link com.sun.tools.doclets.internal.toolkit.AbstractDoclet}.
</li>
<li>
The doclet configuration class should extend
{@link com.sun.tools.doclets.internal.toolkit.Configuration}.
</li>
<li>
The doclet should have a writer factory that implements
{@link com.sun.tools.doclets.internal.toolkit.WriterFactory}.
This class constructs writers that write doclet specific output.
</li>
<li>
The doclet should have a taglet writer that extends
{@link com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter}.
This writer determines how to output each given tag.
</li>
</body>
</html>
/*
* Copyright (c) 2003, 2013, 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.
*/
/**
This package has classes used to generate Javadoc tag documentation.
Doclets no longer have to implement its own version of standard tags
such as &#64;param and &#64;throws. This is the single, doclet
implementation of each standard tag that is shared by all
doclets. Each doclet must have a taglet writer that takes a taglet
as input and writes doclet-dependent output. The taglet itself will
do the tag processing. For example, suppose we are outputing
&#64;throws tags. The taglet would:
<ul>
<li> Retrieve the list of throws tags to be documented.
<li> Replace {&#64;inheritDoc} with the appropriate documentation.
<li> Add throws documentation for exceptions that are declared in
the signature of the method but
not documented with the throws tags.
</ul>
After doing the steps above, the taglet would pass the information to
the taglet writer for writing. The taglets are essentially builders for
tags.
<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.
This code and its internal interfaces are subject to change or
deletion without notice.</b>
*/
@jdk.Exported(false)
package com.sun.tools.doclets.internal.toolkit.taglets;
<!--
Copyright (c) 2003, 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.
-->
<html>
<head>
<title>com.sun.tools.doclets.internal.toolkit.taglets package</title>
</head>
<body bgcolor="white">
This package has classes used to generate Javadoc tag documentation.
Doclets no longer have to implement its own version of standard tags
such as &#64;param and &#64;throws. This is the single, doclet
implementation of each standard tag that is shared by all
doclets. Each doclet must have a taglet writer that takes a taglet
as input and writes doclet-dependent output. The taglet itself will
do the tag processing. For example, suppose we are outputing
&#64;throws tags. The taglet would:
<ul>
<li> Retrieve the list of throws tags to be documented.
<li> Replace {&#64;inheritDoc} with the appropriate documentation.
<li> Add throws documentation for exceptions that are declared in
the signature of the method but
not documented with the throws tags.
</ul>
After doing the steps above, the taglet would pass the information to
the taglet writer for writing. The taglets are essentially builders for
tags.
<p>
This code is not part of an API.
It is implementation that is subject to change.
Do not use it as an API.
</body>
</html>
/*
* Copyright (c) 2003, 2013, 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.
*/
/**
Provides a factory for constructing links.
<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.
This code and its internal interfaces are subject to change or
deletion without notice.</b>
*/
@jdk.Exported(false)
package com.sun.tools.doclets.internal.toolkit.util.links;
<!--
Copyright (c) 2003, 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.
-->
<html>
<head>
<title>com.sun.tools.doclets.interal.toolkit.util.links package</title>
</head>
<body bgcolor="white">
Provides a factory for constructing links.
</body>
</html>
/*
* Copyright (c) 2003, 2013, 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.
*/
/**
This package has utility classes that perform common services required
for API documentation generation.
<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.
This code and its internal interfaces are subject to change or
deletion without notice.</b>
*/
@jdk.Exported(false)
package com.sun.tools.doclets.internal.toolkit.util;
<!--
Copyright (c) 2003, 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.
-->
<html>
<head>
<title>com.sun.tools.doclets.internal.toolkit.util package</title>
</head>
<body bgcolor="white">
This package has utility classes that perform common services required
for API documentation generation.
<p>
This code is not part of an API.
It is implementation that is subject to change.
Do not use it as an API.
</body>
</html>
/*
* Copyright (c) 2003, 2013, 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.
*/
/**
As of JDK version 1.5, replaced by
{@code com.sun.tools.doclets.internal.toolkit.util}.
<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.
This code and its internal interfaces are subject to change or
deletion without notice.</b>
*/
@jdk.Exported(false)
package com.sun.tools.doclets;
<!--
Copyright (c) 2003, 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.
-->
<html>
<head>
<title>com.sun.tools/doclets package</title>
</head>
<body bgcolor="white">
As of JDK version 1.5, replaced by
{@code com.sun.tools.doclets.internal.toolkit.util}.
</body>
</html>
......@@ -213,6 +213,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
public Void visitDocComment(DocCommentTree tree, Void ignore) {
super.visitDocComment(tree, ignore);
for (TagStackItem tsi: tagStack) {
warnIfEmpty(tsi, null);
if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
&& tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
StartElementTree t = (StartElementTree) tsi.tree;
......@@ -270,7 +271,6 @@ public class Checker extends DocTreePathScanner<Void, Void> {
@Override
public Void visitStartElement(StartElementTree tree, Void ignore) {
markEnclosingTag(Flag.HAS_ELEMENT);
final Name treeName = tree.getName();
final HtmlTag t = HtmlTag.get(treeName);
if (t == null) {
......@@ -279,7 +279,10 @@ public class Checker extends DocTreePathScanner<Void, Void> {
boolean done = false;
for (TagStackItem tsi: tagStack) {
if (tsi.tag.accepts(t)) {
while (tagStack.peek() != tsi) tagStack.pop();
while (tagStack.peek() != tsi) {
warnIfEmpty(tagStack.peek(), null);
tagStack.pop();
}
done = true;
break;
} else if (tsi.tag.endKind != HtmlTag.EndKind.OPTIONAL) {
......@@ -288,9 +291,13 @@ public class Checker extends DocTreePathScanner<Void, Void> {
}
}
if (!done && HtmlTag.BODY.accepts(t)) {
tagStack.clear();
while (!tagStack.isEmpty()) {
warnIfEmpty(tagStack.peek(), null);
tagStack.pop();
}
}
markEnclosingTag(Flag.HAS_ELEMENT);
checkStructure(tree, t);
// tag specific checks
......@@ -447,12 +454,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
"dc.no.summary.or.caption.for.table");
}
}
if (t.flags.contains(HtmlTag.Flag.EXPECT_CONTENT)
&& !top.flags.contains(Flag.HAS_TEXT)
&& !top.flags.contains(Flag.HAS_ELEMENT)
&& !top.flags.contains(Flag.HAS_INLINE_TAG)) {
env.messages.warning(HTML, tree, "dc.tag.empty", treeName);
}
warnIfEmpty(top, tree);
tagStack.pop();
done = true;
break;
......@@ -485,6 +487,20 @@ public class Checker extends DocTreePathScanner<Void, Void> {
return super.visitEndElement(tree, ignore);
}
void warnIfEmpty(TagStackItem tsi, DocTree endTree) {
if (tsi.tag != null && tsi.tree instanceof StartElementTree) {
if (tsi.tag.flags.contains(HtmlTag.Flag.EXPECT_CONTENT)
&& !tsi.flags.contains(Flag.HAS_TEXT)
&& !tsi.flags.contains(Flag.HAS_ELEMENT)
&& !tsi.flags.contains(Flag.HAS_INLINE_TAG)) {
DocTree tree = (endTree != null) ? endTree : tsi.tree;
Name treeName = ((StartElementTree) tsi.tree).getName();
env.messages.warning(HTML, tree, "dc.tag.empty", treeName);
}
}
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="HTML attributes">
......
......@@ -270,6 +270,11 @@ public class Flags {
*/
public static final long POTENTIALLY_AMBIGUOUS = 1L<<48;
/**
* Flag that marks a synthetic method body for a lambda expression
*/
public static final long LAMBDA_METHOD = 1L<<49;
/** Modifier masks.
*/
public static final int
......@@ -378,7 +383,8 @@ public class Flags {
NOT_IN_PROFILE(Flags.NOT_IN_PROFILE),
BAD_OVERRIDE(Flags.BAD_OVERRIDE),
SIGNATURE_POLYMORPHIC(Flags.SIGNATURE_POLYMORPHIC),
THROWS(Flags.THROWS);
THROWS(Flags.THROWS),
LAMBDA_METHOD(Flags.LAMBDA_METHOD);
Flag(long flag) {
this.value = flag;
......
......@@ -50,6 +50,7 @@ import com.sun.tools.javac.code.Symbol.VarSymbol;
import com.sun.tools.javac.code.Symbol.MethodSymbol;
import com.sun.tools.javac.comp.Annotate;
import com.sun.tools.javac.comp.Annotate.Annotator;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Env;
import com.sun.tools.javac.tree.JCTree;
......@@ -95,6 +96,7 @@ public class TypeAnnotations {
final Names names;
final Symtab syms;
final Annotate annotate;
final Attr attr;
private final boolean typeAnnoAsserts;
protected TypeAnnotations(Context context) {
......@@ -103,6 +105,7 @@ public class TypeAnnotations {
log = Log.instance(context);
syms = Symtab.instance(context);
annotate = Annotate.instance(context);
attr = Attr.instance(context);
Options options = Options.instance(context);
typeAnnoAsserts = options.isSet("TypeAnnotationAsserts");
}
......@@ -131,6 +134,21 @@ public class TypeAnnotations {
} );
}
public void validateTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
annotate.validate(new Annotator() { //validate annotations
@Override
public void enterAnnotation() {
JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
try {
attr.validateTypeAnnotations(tree, true);
} finally {
log.useSource(oldSource);
}
}
} );
}
/**
* This version only visits types in bodies, that is, field initializers,
* top-level blocks, and method bodies, and should be called from Attr.
......
......@@ -92,6 +92,7 @@ public class Annotate {
ListBuffer<Annotator> typesQ = new ListBuffer<Annotator>();
ListBuffer<Annotator> repeatedQ = new ListBuffer<Annotator>();
ListBuffer<Annotator> afterRepeatedQ = new ListBuffer<Annotator>();
ListBuffer<Annotator> validateQ = new ListBuffer<Annotator>();
public void earlier(Annotator a) {
q.prepend(a);
......@@ -113,6 +114,10 @@ public class Annotate {
afterRepeatedQ.append(a);
}
public void validate(Annotator a) {
validateQ.append(a);
}
/** Called when the Enter phase starts. */
public void enterStart() {
enterCount++;
......@@ -140,6 +145,9 @@ public class Annotate {
while (afterRepeatedQ.nonEmpty()) {
afterRepeatedQ.next().enterAnnotation();
}
while (validateQ.nonEmpty()) {
validateQ.next().enterAnnotation();
}
} finally {
enterCount--;
}
......
......@@ -965,12 +965,6 @@ public class Attr extends JCTree.Visitor {
chk.validateAnnotationType(tree.restype);
// ensure that annotation method does not clash with members of Object/Annotation
chk.validateAnnotationMethod(tree.pos(), m);
if (tree.defaultValue != null) {
// if default value is an annotation, check it is a well-formed
// annotation value (e.g. no duplicate values, no missing values, etc.)
chk.validateAnnotationTree(tree.defaultValue);
}
}
for (List<JCExpression> l = tree.thrown; l.nonEmpty(); l = l.tail)
......@@ -1032,7 +1026,6 @@ public class Attr extends JCTree.Visitor {
localEnv.info.scope.leave();
result = tree.type = m.type;
chk.validateAnnotations(tree.mods.annotations, m);
}
finally {
chk.setLint(prevLint);
......@@ -1090,7 +1083,6 @@ public class Attr extends JCTree.Visitor {
}
}
result = tree.type = v.type;
chk.validateAnnotations(tree.mods.annotations, v);
}
finally {
chk.setLint(prevLint);
......@@ -4155,7 +4147,6 @@ public class Attr extends JCTree.Visitor {
JCCompilationUnit toplevel = env.toplevel;
try {
annotate.flush();
chk.validateAnnotations(toplevel.packageAnnotations, toplevel.packge);
} catch (CompletionFailure ex) {
chk.completionError(toplevel.pos(), ex);
}
......@@ -4240,6 +4231,7 @@ public class Attr extends JCTree.Visitor {
chk.checkDeprecatedAnnotation(env.tree.pos(), c);
chk.checkClassOverrideEqualsAndHashIfNeeded(env.tree.pos(), c);
chk.checkFunctionalInterface((JCClassDecl) env.tree, c);
} finally {
env.info.returnResult = prevReturnRes;
log.useSource(prev);
......@@ -4258,9 +4250,6 @@ public class Attr extends JCTree.Visitor {
JCClassDecl tree = (JCClassDecl)env.tree;
Assert.check(c == tree.sym);
// Validate annotations
chk.validateAnnotations(tree.mods.annotations, c);
// Validate type parameters, supertype and interfaces.
attribStats(tree.typarams, env);
if (!c.isAnonymous()) {
......@@ -4361,7 +4350,7 @@ public class Attr extends JCTree.Visitor {
typeAnnotations.organizeTypeAnnotationsBodies(tree);
// Check type annotations applicability rules
validateTypeAnnotations(tree);
validateTypeAnnotations(tree, false);
}
}
// where
......@@ -4436,14 +4425,19 @@ public class Attr extends JCTree.Visitor {
return types.capture(type);
}
private void validateTypeAnnotations(JCTree tree) {
tree.accept(typeAnnotationsValidator);
public void validateTypeAnnotations(JCTree tree, boolean sigOnly) {
tree.accept(new TypeAnnotationsValidator(sigOnly));
}
//where
private final JCTree.Visitor typeAnnotationsValidator = new TreeScanner() {
private final class TypeAnnotationsValidator extends TreeScanner {
private final boolean sigOnly;
private boolean checkAllAnnotations = false;
public TypeAnnotationsValidator(boolean sigOnly) {
this.sigOnly = sigOnly;
}
public void visitAnnotation(JCAnnotation tree) {
if (tree.hasTag(TYPE_ANNOTATION) || checkAllAnnotations) {
chk.validateTypeAnnotation(tree, false);
......@@ -4467,12 +4461,26 @@ public class Attr extends JCTree.Visitor {
if (tree.restype != null && tree.restype.type != null) {
validateAnnotatedType(tree.restype, tree.restype.type);
}
super.visitMethodDef(tree);
if (sigOnly) {
scan(tree.mods);
scan(tree.restype);
scan(tree.typarams);
scan(tree.recvparam);
scan(tree.params);
scan(tree.thrown);
} else {
scan(tree.defaultValue);
scan(tree.body);
}
}
public void visitVarDef(final JCVariableDecl tree) {
if (tree.sym != null && tree.sym.type != null)
validateAnnotatedType(tree, tree.sym.type);
super.visitVarDef(tree);
scan(tree.mods);
scan(tree.vartype);
if (!sigOnly) {
scan(tree.init);
}
}
public void visitTypeCast(JCTypeCast tree) {
if (tree.clazz != null && tree.clazz.type != null)
......@@ -4509,6 +4517,29 @@ public class Attr extends JCTree.Visitor {
super.visitNewArray(tree);
}
@Override
public void visitClassDef(JCClassDecl tree) {
if (sigOnly) {
scan(tree.mods);
scan(tree.typarams);
scan(tree.extending);
scan(tree.implementing);
}
for (JCTree member : tree.defs) {
if (member.hasTag(Tag.CLASSDEF)) {
continue;
}
scan(member);
}
}
@Override
public void visitBlock(JCBlock tree) {
if (!sigOnly) {
scan(tree.stats);
}
}
/* I would want to model this after
* com.sun.tools.javac.comp.Check.Validator.visitSelectInternal(JCFieldAccess)
* and override visitSelect and visitTypeApply.
......
......@@ -30,6 +30,7 @@ import java.util.*;
import javax.tools.JavaFileManager;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Attribute.Compound;
import com.sun.tools.javac.jvm.*;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.util.*;
......@@ -1951,7 +1952,7 @@ public class Check {
* for errors.
* @param m The overriding method.
*/
void checkOverride(JCTree tree, MethodSymbol m) {
void checkOverride(JCMethodDecl tree, MethodSymbol m) {
ClassSymbol origin = (ClassSymbol)m.owner;
if ((origin.flags() & ENUM) != 0 && names.finalize.equals(m.name))
if (m.overrides(syms.enumFinalFinalize, origin, types, false)) {
......@@ -1967,6 +1968,17 @@ public class Check {
checkOverride(tree, t2, origin, m);
}
}
if (m.attribute(syms.overrideType.tsym) != null && !isOverrider(m)) {
DiagnosticPosition pos = tree.pos();
for (JCAnnotation a : tree.getModifiers().annotations) {
if (a.annotationType.type.tsym == syms.overrideType.tsym) {
pos = a.pos();
break;
}
}
log.error(pos, "method.does.not.override.superclass");
}
}
void checkOverride(JCTree tree, Type site, ClassSymbol origin, MethodSymbol m) {
......@@ -2725,20 +2737,11 @@ public class Check {
if (!annotationApplicable(a, s))
log.error(a.pos(), "annotation.type.not.applicable");
if (a.annotationType.type.tsym == syms.overrideType.tsym) {
if (!isOverrider(s))
log.error(a.pos(), "method.does.not.override.superclass");
}
if (a.annotationType.type.tsym == syms.functionalInterfaceType.tsym) {
if (s.kind != TYP) {
log.error(a.pos(), "bad.functional.intf.anno");
} else {
try {
types.findDescriptorSymbol((TypeSymbol)s);
} catch (Types.FunctionDescriptorLookupError ex) {
log.error(a.pos(), "bad.functional.intf.anno.1", ex.getDiagnostic());
}
} else if (!s.isInterface() || (s.flags() & ANNOTATION) != 0) {
log.error(a.pos(), "bad.functional.intf.anno.1", diags.fragment("not.a.functional.intf", s));
}
}
}
......@@ -2953,7 +2956,7 @@ public class Check {
return false;
}
/** Is the annotation applicable to type annotations? */
/** Is the annotation applicable to types? */
protected boolean isTypeAnnotation(JCAnnotation a, boolean isTypeParameter) {
Attribute.Compound atTarget =
a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym);
......@@ -3507,4 +3510,23 @@ public class Check {
public Warner convertWarner(DiagnosticPosition pos, Type found, Type expected) {
return new ConversionWarner(pos, "unchecked.assign", found, expected);
}
public void checkFunctionalInterface(JCClassDecl tree, ClassSymbol cs) {
Compound functionalType = cs.attribute(syms.functionalInterfaceType.tsym);
if (functionalType != null) {
try {
types.findDescriptorSymbol((TypeSymbol)cs);
} catch (Types.FunctionDescriptorLookupError ex) {
DiagnosticPosition pos = tree.pos();
for (JCAnnotation a : tree.getModifiers().annotations) {
if (a.annotationType.type.tsym == syms.functionalInterfaceType.tsym) {
pos = a.pos();
break;
}
}
log.error(pos, "bad.functional.intf.anno.1", ex.getDiagnostic());
}
}
}
}
......@@ -1718,9 +1718,9 @@ public class Flow {
if (tree.body == null) {
return;
}
/* MemberEnter can generate synthetic methods, ignore them
/* Ignore synthetic methods, except for translated lambda methods.
*/
if ((tree.sym.flags() & SYNTHETIC) != 0) {
if ((tree.sym.flags() & (SYNTHETIC | LAMBDA_METHOD)) == SYNTHETIC) {
return;
}
......
......@@ -30,6 +30,7 @@ import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.TreeTranslator;
import com.sun.tools.javac.code.Attribute;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Kinds;
import com.sun.tools.javac.code.Scope;
import com.sun.tools.javac.code.Symbol;
......@@ -1755,7 +1756,7 @@ public class LambdaToMethod extends TreeTranslator {
((VarSymbol)ret).pos = ((VarSymbol)sym).pos;
break;
case CAPTURED_VAR:
ret = new VarSymbol(SYNTHETIC | FINAL, name, types.erasure(sym.type), translatedSym) {
ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) {
@Override
public Symbol baseSymbol() {
//keep mapping with original captured symbol
......@@ -1763,6 +1764,13 @@ public class LambdaToMethod extends TreeTranslator {
}
};
break;
case LOCAL_VAR:
ret = new VarSymbol(FINAL, name, types.erasure(sym.type), translatedSym);
break;
case PARAM:
ret = new VarSymbol(FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym);
((VarSymbol) ret).adr = ((VarSymbol) sym).adr;
break;
default:
ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym);
}
......@@ -1845,7 +1853,7 @@ public class LambdaToMethod extends TreeTranslator {
// If instance access isn't needed, make it static.
// Interface instance methods must be default methods.
// Lambda methods are private synthetic.
translatedSym.flags_field = SYNTHETIC |
translatedSym.flags_field = SYNTHETIC | LAMBDA_METHOD |
PRIVATE |
(thisReferenced? (inInterface? DEFAULT : 0) : STATIC);
......
......@@ -871,6 +871,18 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
}
}
});
annotate.validate(new Annotate.Annotator() { //validate annotations
@Override
public void enterAnnotation() {
JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
try {
chk.validateAnnotations(annotations, s);
} finally {
log.useSource(prev);
}
}
});
}
/**
......@@ -951,6 +963,19 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
}
}
});
annotate.validate(new Annotate.Annotator() { //validate annotations
@Override
public void enterAnnotation() {
JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
try {
// if default value is an annotation, check it is a well-formed
// annotation value (e.g. no duplicate values, no missing values, etc.)
chk.validateAnnotationTree(defaultValue);
} finally {
log.useSource(prev);
}
}
});
}
/** Enter a default value for an attribute method. */
......@@ -1157,15 +1182,17 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
if (wasFirst) {
try {
while (halfcompleted.nonEmpty()) {
finish(halfcompleted.next());
Env<AttrContext> toFinish = halfcompleted.next();
finish(toFinish);
if (allowTypeAnnos) {
typeAnnotations.organizeTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree);
typeAnnotations.validateTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree);
}
}
} finally {
isFirst = true;
}
}
if (allowTypeAnnos) {
typeAnnotations.organizeTypeAnnotationsSignatures(env, tree);
}
}
/*
......
......@@ -2892,7 +2892,8 @@ public class Gen extends JCTree.Visitor {
@Override
public void visitMethodDef(JCMethodDecl tree) {
if ((tree.sym.flags() & (SYNTHETIC | GENERATEDCONSTR)) != 0) {
if ((tree.sym.flags() & (SYNTHETIC | GENERATEDCONSTR)) != 0
&& (tree.sym.flags() & LAMBDA_METHOD) == 0) {
return;
}
if (tree.name.equals(names.clinit)) {
......@@ -2906,6 +2907,7 @@ public class Gen extends JCTree.Visitor {
return;
}
currentMethod = tree.sym;
super.visitMethodDef(tree);
}
......
......@@ -619,8 +619,10 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
Names names = tsym.name.table.names;
List<MethodDocImpl> methods = List.nil();
for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
if (e.sym != null &&
e.sym.kind == Kinds.MTH && e.sym.name != names.init) {
if (e.sym != null
&& e.sym.kind == Kinds.MTH
&& e.sym.name != names.init
&& e.sym.name != names.clinit) {
MethodSymbol s = (MethodSymbol)e.sym;
if (!filter || env.shouldDocument(s)) {
methods = methods.prepend(env.getMethodDoc(s));
......
/*
* Copyright (c) 2007, 2013, 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.
*/
/**
Classes to dump class files in text format.
<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.
This code and its internal interfaces are subject to change or
deletion without notice.</b>
*/
@jdk.Exported(false)
package com.sun.tools.javap;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
Classes to dump class files in text format.
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2005, 2013, 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
......@@ -25,7 +23,9 @@ 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.
-->
<html>
<head>
<title>javax.lang.model</title>
</head>
<body bgcolor="white">
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--
Copyright (c) 2005, 2013, 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.
-->
<html>
<head>
<title>javax.tools</title>
</head>
<body>
<p>
......@@ -21,3 +51,4 @@ abstraction.</li>
</ul>
</body>
</html>
......@@ -10,7 +10,7 @@
/** */
public class HtmlAttrsTest {
/**
* <p xyz>
* <p xyz> text </p>
*/
public void unknown() { }
......
HtmlAttrsTest.java:13: error: unknown attribute: xyz
* <p xyz>
* <p xyz> text </p>
^
HtmlAttrsTest.java:18: warning: attribute obsolete: name
* <img name="x" alt="alt">
......
BadEnd.java:14: warning: nested tag not allowed: <code>
* <code> text <code>
^
BadEnd.java:14: warning: empty <code> tag
* <code> text <code>
^
BadEnd.java:14: error: element not closed: code
* <code> text <code>
^
......@@ -14,4 +17,4 @@ BadEnd.java:13: error: element not closed: a
* <a name="here"> text <a>
^
4 errors
1 warning
2 warnings
/*
* @test /nodynamiccopyright/
* @bug 8004832
* @bug 8004832 8026368
* @summary Add new doclint package
* @library ..
* @build DocLintTester
......@@ -26,4 +26,9 @@
* <ul></ul>
* <ul><li></li></ul>
*/
public class TrimmingEmptyTag { }
public class TrimmingEmptyTag {
/** <p> */
public void implicitParaEnd_endOfComment() { }
/** <p> <ul><li>text</ul> */
public void implicitParaEnd_nextBlockTag() { }
}
......@@ -43,4 +43,10 @@ TrimmingEmptyTag.java:25: warning: empty <tt> tag
TrimmingEmptyTag.java:26: warning: empty <ul> tag
* <ul></ul>
^
15 warnings
TrimmingEmptyTag.java:30: warning: empty <p> tag
/** <p> */
^
TrimmingEmptyTag.java:32: warning: empty <p> tag
/** <p> <ul><li>text</ul> */
^
17 warnings
CantAnnotateStaticClass.java:22:20: compiler.err.cant.annotate.static.class
CantAnnotateStaticClass.java:23:13: compiler.err.cant.annotate.static.class
CantAnnotateStaticClass.java:24:29: compiler.err.cant.annotate.static.class
CantAnnotateStaticClass.java:26:29: compiler.err.cant.annotate.static.class
CantAnnotateStaticClass.java:29:26: compiler.err.cant.annotate.static.class
CantAnnotateStaticClass.java:30:9: compiler.err.cant.annotate.static.class
CantAnnotateStaticClass.java:31:35: compiler.err.cant.annotate.static.class
CantAnnotateStaticClass.java:26:29: compiler.err.cant.annotate.static.class
- compiler.note.unchecked.filename: CantAnnotateStaticClass.java
- compiler.note.unchecked.recompile
7 errors
7 errors
\ No newline at end of file
/*
* Copyright (c) 2013, 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 8025998
* @summary Missing LV table in lambda bodies
* @compile -g LocalVariableTable.java
* @run main LocalVariableTable
*/
import java.lang.annotation.*;
import java.util.*;
import com.sun.tools.classfile.*;
/*
* The test checks that a LocalVariableTable attribute is generated for the
* method bodies representing lambda expressions, and checks that the expected
* set of entries is found in the attribute.
*
* Since the bug was about missing entries in the LVT, not malformed entries,
* the test is not intended to be a detailed test of the contents of each
* LocalVariableTable entry: it is assumed that if a entry is present, it
* will have the correct contents.
*
* The test looks for test cases represented by nested classes whose
* name begins with "Lambda". Each such class contains a lambda expression
* that will mapped into a lambda method, and because the test is compiled
* with -g, these methods should have a LocalVariableTable. The set of
* expected names in the LVT is provided in an annotation on the class for
* the test case.
*/
public class LocalVariableTable {
public static void main(String... args) throws Exception {
new LocalVariableTable().run();
}
void run() throws Exception {
// the declared classes are returned in an unspecified order,
// so for neatness, sort them by name before processing them
Class<?>[] classes = getClass().getDeclaredClasses();
Arrays.sort(classes, (c1, c2) -> c1.getName().compareTo(c2.getName()));
for (Class<?> c : classes) {
if (c.getSimpleName().startsWith("Lambda"))
check(c);
}
if (errors > 0)
throw new Exception(errors + " errors found");
}
/** Check an individual test case. */
void check(Class<?> c) throws Exception {
System.err.println("Checking " + c.getSimpleName());
Expect expect = c.getAnnotation(Expect.class);
if (expect == null) {
error("@Expect not found for class " + c.getSimpleName());
return;
}
ClassFile cf = ClassFile.read(getClass().getResource(c.getName() + ".class").openStream());
Method m = getLambdaMethod(cf);
if (m == null) {
error("lambda method not found");
return;
}
Code_attribute code = (Code_attribute) m.attributes.get(Attribute.Code);
if (code == null) {
error("Code attribute not found");
return;
}
LocalVariableTable_attribute lvt =
(LocalVariableTable_attribute) code.attributes.get(Attribute.LocalVariableTable);
if (lvt == null) {
error("LocalVariableTable attribute not found");
return;
}
Set<String> foundNames = new LinkedHashSet<>();
for (LocalVariableTable_attribute.Entry e: lvt.local_variable_table) {
foundNames.add(cf.constant_pool.getUTF8Value(e.name_index));
}
Set<String> expectNames = new LinkedHashSet<>(Arrays.asList(expect.value()));
if (!foundNames.equals(expectNames)) {
Set<String> foundOnly = new LinkedHashSet<>(foundNames);
foundOnly.removeAll(expectNames);
for (String s: foundOnly)
error("Unexpected name found: " + s);
Set<String> expectOnly = new LinkedHashSet<>(expectNames);
expectOnly.removeAll(foundNames);
for (String s: expectOnly)
error("Expected name not found: " + s);
}
}
/** Get a method whose name begins "lambda$...". */
Method getLambdaMethod(ClassFile cf) throws ConstantPoolException {
for (Method m: cf.methods) {
if (m.getName(cf.constant_pool).startsWith("lambda$"))
return m;
}
return null;
}
/** Report an error. */
void error(String msg) {
System.err.println("Error: " + msg);
errors++;
}
int errors;
/**
* Annotation used to provide the set of names expected in the LVT attribute.
*/
@Retention(RetentionPolicy.RUNTIME)
@interface Expect {
String[] value();
}
/** Functional interface with nullary method. */
interface Run0 {
public void run();
}
/** Functional interface with 1-ary method. */
interface Run1 {
public void run(int a0);
}
/** Functional interface with 2-ary method. */
interface Run2 {
public void run(int a0, int a1);
}
/*
* ---------- Test cases ---------------------------------------------------
*/
@Expect({ "x" })
static class Lambda_Args0_Local1 {
Run0 r = () -> { int x = 0; };
}
@Expect({ "x", "this" })
static class Lambda_Args0_Local1_this {
int v;
Run0 r = () -> { int x = v; };
}
@Expect({ "a" })
static class Lambda_Args1_Local0 {
Run1 r = (a) -> { };
}
@Expect({ "a", "x" })
static class Lambda_Args1_Local1 {
Run1 r = (a) -> { int x = a; };
}
@Expect({ "a", "x" })
static class Lambda_Args1_Local1_Captured1 {
void m() {
int v = 0;
Run1 r = (a) -> { int x = a + v; };
}
}
@Expect({ "a1", "a2", "x1", "x2", "this" })
static class Lambda_Args2_Local2_Captured2_this {
int v;
void m() {
int v1 = 0;
int v2 = 0;
Run2 r = (a1, a2) -> {
int x1 = a1 + v1 + v;
int x2 = a2 + v2 + v;
};
}
}
}
/*
* Copyright (c) 2013, 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 8014016
* @summary Ensure that an annotation processor can generate a super-interface
* which will make the current interface functional
* @build GenerateSuperInterfaceProcessor
* @compile -processor GenerateSuperInterfaceProcessor GenerateFunctionalInterface.java
*/
import java.lang.FunctionalInterface;
@FunctionalInterface
@Generate(fileName="SuperInterface.java", content="interface SuperInterface { public void run(); }")
interface GenerateFunctionalInterface extends SuperInterface {
}
/*
* Copyright (c) 2013, 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.
*/
import com.sun.tools.javac.util.Assert;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
@SupportedAnnotationTypes("*")
public class GenerateSuperInterfaceProcessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (Element el : roundEnv.getElementsAnnotatedWith(Generate.class)) {
Generate g = el.getAnnotation(Generate.class);
Assert.checkNonNull(g);
try (OutputStream out =
processingEnv.getFiler().createSourceFile(g.fileName()).openOutputStream()) {
out.write(g.content().getBytes());
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
return false;
}
}
@interface Generate {
String fileName();
String content();
}
\ No newline at end of file
/*
* Copyright (c) 2013, 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.
*/
import com.sun.source.tree.AnnotationTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.util.JavacTask;
import com.sun.source.util.TreeScanner;
import com.sun.source.util.Trees;
import com.sun.tools.javac.api.JavacTool;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.util.Assert;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
@SupportedAnnotationTypes("*")
public class Processor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
throw new IllegalStateException("Should not be invoked.");
}
public static void main(String... args) throws IOException, URISyntaxException {
if (args.length != 1) throw new IllegalStateException("Must provide class name!");
String testContent = null;
List<File> sourcePath = new ArrayList<>();
for (String sourcePaths : System.getProperty("test.src.path").split(":")) {
sourcePath.add(new File(sourcePaths));
}
JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
for (File sp : sourcePath) {
File inp = new File(sp, args[0]);
if (inp.canRead()) {
testContent = fm.getRegularFile(inp).getCharContent(true).toString();
}
}
if (testContent == null) throw new IllegalStateException();
DiagnosticListener<JavaFileObject> devNull = new DiagnosticListener<JavaFileObject>() {
@Override public void report(Diagnostic<? extends JavaFileObject> diagnostic) { }
};
JavaFileObject testFile = new TestFO(new URI("mem://" + args[0]), testContent);
JavacTask task = JavacTool.create().getTask(null,
new TestFM(fm),
devNull,
Arrays.asList("-Xjcov"),
null,
Arrays.asList(testFile));
final Trees trees = Trees.instance(task);
final CompilationUnitTree cut = task.parse().iterator().next();
task.analyze();
final List<int[]> annotations = new ArrayList<>();
new TreeScanner<Void, Void>() {
@Override
public Void visitAnnotation(AnnotationTree node, Void p) {
int endPos = (int) trees.getSourcePositions().getEndPosition(cut, node);
Assert.check(endPos >= 0);
annotations.add(new int[] {(int) trees.getSourcePositions().getStartPosition(cut, node), endPos});
return super.visitAnnotation(node, p);
}
}.scan(cut.getTypeDecls().get(0), null);
Collections.sort(annotations, new Comparator<int[]>() {
@Override public int compare(int[] o1, int[] o2) {
return o2[0] - o1[0];
}
});
for (final int[] annotation : annotations) {
StringBuilder updatedContent = new StringBuilder();
int last = testContent.length();
for (int[] toRemove : annotations) {
if (toRemove == annotation) continue;
updatedContent.insert(0, testContent.substring(toRemove[1], last));
last = toRemove[0];
}
updatedContent.insert(0, testContent.substring(0, last));
JavaFileObject updatedFile = new TestFO(new URI("mem://" + args[0]), updatedContent.toString());
JavacTask testTask = JavacTool.create().getTask(null,
new TestFM(fm),
devNull,
Arrays.asList("-processor", "Processor"),
null,
Arrays.asList(updatedFile));
try {
testTask.analyze();
} catch (Throwable e) {
System.out.println("error while processing:");
System.out.println(updatedContent);
throw e;
}
}
}
private static final class TestFO extends SimpleJavaFileObject {
private final String content;
public TestFO(URI uri, String content) {
super(uri, Kind.SOURCE);
this.content = content;
}
@Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
return content;
}
@Override public boolean isNameCompatible(String simpleName, Kind kind) {
return true;
}
}
private static final class TestFM extends ForwardingJavaFileManager<JavaFileManager> {
public TestFM(JavaFileManager fileManager) {
super(fileManager);
}
@Override
public boolean isSameFile(FileObject a, FileObject b) {
return a.equals(b);
}
}
}
\ No newline at end of file
/*
* Copyright (c) 2013, 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 8014016
* @summary Verify that annotation processors do not get invalid annotations
* @build Processor
* @run main Processor Source.java
*/
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@OnMethod
@OnField
class Class<@OnType @OnMethod @OnField T extends @OnType @OnMethod @OnField CharSequence & @OnType @OnMethod @OnField Runnable> extends @OnType @OnMethod @OnField Object {
@OnType
@OnTypeUse
@OnField
private void testMethod(@OnType @OnField @OnMethod int i) { }
@OnType
@OnMethod
private java.lang.@OnType @OnMethod @OnField String testField;
}
@Target(ElementType.TYPE)
@interface OnType {}
@Target(ElementType.METHOD)
@interface OnMethod {}
@Target(ElementType.TYPE_USE)
@interface OnTypeUse {}
@Target(ElementType.FIELD)
@interface OnField {}
/*
* Copyright (c) 2013, 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 8025693
* @summary javadoc should ignore <clinit> methods found in classes on classpath
*/
import java.io.*;
public class Test {
public static void main(String[] args) throws Exception {
new Test().run();
}
final File baseFile = new File("src/Base.java");
final String baseText =
"package p;\n" +
"public class Base { static { } }\n";
final File srcFile = new File("src/C.java");
final String srcText =
"package p;\n" +
"/** comment */\n" +
"public abstract class C extends Base { }\n";
void run() throws Exception {
File classesDir = new File("classes");
classesDir.mkdirs();
writeFile(baseFile, baseText);
String[] javacArgs = {
"-d", classesDir.getPath(),
baseFile.getPath()
};
com.sun.tools.javac.Main.compile(javacArgs);
writeFile(srcFile, srcText);
String[] args = {
"-d", "api",
"-classpath", classesDir.getPath(),
"-package", "p",
srcFile.getPath()
};
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
PrintStream prev = System.err;
System.setErr(ps);
try {
int rc = com.sun.tools.javadoc.Main.execute(args);
} finally {
System.err.flush();
System.setErr(prev);
}
String out = baos.toString();
System.out.println(out);
String errorMessage = "java.lang.IllegalArgumentException: <clinit>";
if (out.contains(errorMessage))
throw new Exception("error message found: " + errorMessage);
}
void writeFile(File file, String body) throws IOException {
file.getParentFile().mkdirs();
try (FileWriter out = new FileWriter(file)) {
out.write(body);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册