diff --git a/langtools/make/README b/langtools/make/README index 466426d8ad6466a6921b652088145dcb5f891bff..bc8873178ef5061d8486e5d9dd3ff42706080896 100644 --- a/langtools/make/README +++ b/langtools/make/README @@ -15,7 +15,7 @@ that expect to be able to build this workspace with GNU Make. System Requirements: Ant: version 1.6.5 or later - NetBeans: version 5.0 or later (optional) + NetBeans: version 6.0 or later (optional) JDK: currently version 1.5.0, although 1.6.0 is recommended OS: any system supporting the above tools diff --git a/langtools/make/build.properties b/langtools/make/build.properties index 38fd0f4705d490377ae67fbc361752144d36110a..6e792bb106d5a68d6c0980cd63ee92f3051e0b37 100644 --- a/langtools/make/build.properties +++ b/langtools/make/build.properties @@ -66,7 +66,7 @@ javac.no.jdk.warnings = -XDignore.symbol.file=true # set the following to -version to verify the versions of javac being used javac.version.opt = # in time, there should be no exceptions to -Xlint:all -javac.lint.opts = -Xlint:all,-deprecation,-fallthrough,-serial,-unchecked,-cast +javac.lint.opts = -Xlint:all -Werror # options for the task for javac javadoc.jls3.url=http://java.sun.com/docs/books/jls/ diff --git a/langtools/make/build.xml b/langtools/make/build.xml index 79bd060dd69ed6d3371c5b93383540e38b32c2e9..770f3dd040ce67e5ebbf14fc71f0814b3ec4a23f 100644 --- a/langtools/make/build.xml +++ b/langtools/make/build.xml @@ -392,6 +392,7 @@ + @@ -433,6 +434,7 @@ + @@ -471,6 +473,7 @@ + @@ -493,6 +496,7 @@ destdir="@{gensrc.dir}" includes="**/*.properties"/> - - + diff --git a/langtools/make/netbeans/README b/langtools/make/netbeans/README index 7208e598e6aec16987174b3915c91139afdb6941..58cfec07cee7e2701dbef3d12ed3dd69c3489d15 100644 --- a/langtools/make/netbeans/README +++ b/langtools/make/netbeans/README @@ -1,28 +1,39 @@ -Working on the "langtools" workspace using NetBeans. +Using NetBeans to work on the langtools repository. -This directory (make/netbeans) contains NetBeans projects that -allow you to work on the various tools using the NetBeans IDE. +Netbeans 6.0 or later is recommended. -NetBeans 5.0 or later is required and sufficient to use these -projects. This is different from other projects in OpenJDK, -which requires version 6.0 or later. +The "langtools" project in this directory allows you to +edit, run, test and debug the tools in the OpenJDK langtools +repository. -The following projects are provided: +The repository contains a number of tools: + apt, javac, javadoc and its doclets, javah and javap. -compiler: for working on the compiler, javac -javadoc: for working on the documentation tool, javadoc -doclets: for working on the standard doclets used by the - documentation tool, javadoc -javah: for working on the C header tool, javah -javap: for working on the disassembler, javap -apt: for working on the annotation processing tool, apt. - Note that this is just provided for completeness; - the tool has been superceded by new features in javac, - and work on apt itself is discouraged. +Build Properties. -However, any tool can be worked on from any project; the only difference -between these projects is the behavior of the standard NetBeans actions, -so that "Build" in the compiler project will build the compiler, etc. +To build this repository, you must set some properties for Ant. +You can set these properties in a number of ways: +- Set the properties in the Properties panel under Tool> Options> Ant. + Properties set this way will apply globally to all the langtools + repositories you may be working on. +- Create a file build.properties in the root directory of a + langtools repository, and set the properties in that file. + These properties will be specific to that repository. +To build the repository, at a minimum you must set the "boot.java.home" +property. To run the tools, you must also set "target.java.home". To +run the regression tests, you must set "jtreg.home". + +By default, the build and test targets will build and test all +of these tools. The run and debug targets will prompt you for the +name of a tool to execute. + +As an alternative, you can focus on a single tool. When you do +this, you will still see all the source code for all the tools, +but the various Ant targets will now be focussed on the selected tool. +To focus on a tool, bring up the context menu on the "langtools" +project (i.e. right-click on the project) and select "Select Tool". +This brings up a dialog which allows you to specify which tool you +wish to work on, and the arguments to use if and when you run it. diff --git a/langtools/make/netbeans/apt/README b/langtools/make/netbeans/apt/README deleted file mode 100644 index 6fa70ee080e2274dd4fac722203a8be9078b3ee6..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/apt/README +++ /dev/null @@ -1,15 +0,0 @@ -"apt" project README. - -This project is for working on the annotation processing tool (apt) -in the OpenJDK langtools component. - -The tool was provided in Java 1.5, but has been superceded by new -features in the compiler (javac) in Java 6. apt itself is now -deprecated, and any further devlopment on it is strongly discouraged. - -The main class for the tool is com.sun.tools.apt.Main. - -NetBeans 5.0 or later is required and sufficient to use this -project, and others in the OpenJDK langtools component. -This is different from other projects in OpenJDK, which -require version 6.0 or later. diff --git a/langtools/make/netbeans/apt/build.xml b/langtools/make/netbeans/apt/build.xml deleted file mode 100644 index 6b4a72e3a4a3f4e272c40a2655ae2501abe36bb3..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/apt/build.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/langtools/make/netbeans/apt/nbproject/project.xml b/langtools/make/netbeans/apt/nbproject/project.xml deleted file mode 100644 index 6987228768fd0626be7c2303f4a6549b2426ed25..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/apt/nbproject/project.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - -]> - - org.netbeans.modules.ant.freeform - - - - apt - - ../../.. - - - - - ${root} - - - - java - ${root}/src/share/classes - - - - tests - ${root}/test - - - - build - ${root}/make - - - - &standard-ide-actions-no-javadoc; - - - folder - ${root}/build/classes - build - - - - - - ${root}/src/share/classes - - - - ${root}/test - - - - ${root}/make - - - - README - - - - &standard-context-menu-items-no-javadoc; - - - - - - - ${root}/src/share/classes - ${root}/build/classes - 1.5 - - - - diff --git a/langtools/make/netbeans/common/shared.xml b/langtools/make/netbeans/common/shared.xml deleted file mode 100644 index 015a08c8b772169fa111ce2ac83d9a365c99c150..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/common/shared.xml +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - - - - - - - - - - - - Must set property 'includes' - - - - - - - - - - - - - Must set property 'run.classname' - - - - - - - - Some tests failed; see report for details. - - - - - - - - - - - - - Must set property 'debug.classname' - - - - - - - - Must set property 'jtreg.tests' - - - - - - - - Must set property 'class' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/langtools/make/netbeans/common/standard-context-menu-items-no-javadoc.ent b/langtools/make/netbeans/common/standard-context-menu-items-no-javadoc.ent deleted file mode 100644 index c40ee69c213fcaac2bbe067e815e6a0cee235301..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/common/standard-context-menu-items-no-javadoc.ent +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/langtools/make/netbeans/common/standard-ide-actions-no-javadoc.ent b/langtools/make/netbeans/common/standard-ide-actions-no-javadoc.ent deleted file mode 100644 index 912daf729a845a65a5afffed1a880b489643ef98..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/common/standard-ide-actions-no-javadoc.ent +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - build - - - - clean - - - - clean - build - - - - compile-single - ${root}/src/share/classes - - includes - ${root}/src/share/classes - \.java$ - relative-path - - , - - - - - - run - - - - run-single - - run.classname - ${root}/src/share/classes - \.java$ - java-name - - - - - - - - - - jtreg - - jtreg.tests - ${root}/test - \.(java|sh)$ - relative-path - - , - - - - - - jtreg - - - - debug-nb - - - - debug-single-nb - - debug.classname - ${root}/src/share/classes - \.java$ - java-name - - - - - - - - - - debug-jtreg-nb - - jtreg.tests - ${root}/test - \.(java|sh)$ - relative-path - - - - - - - - debug-fix - ${root}/src/share/classes - - class - ${root}/src/share/classes - \.java$ - relative-path-noext - - - - - - - - -javadoc-nb - diff --git a/langtools/make/netbeans/compiler/README b/langtools/make/netbeans/compiler/README deleted file mode 100644 index 9dc7ff118884f4c1e11b613e79d32ed63c1ee23c..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/compiler/README +++ /dev/null @@ -1,11 +0,0 @@ -"compiler" project README. - -This project is for working on the compiler tool (javac) -in the OpenJDK langtools component. - -The main class for the tool is com.sun.tools.javac.Main. - -NetBeans 5.0 or later is required and sufficient to use this -project, and others in the OpenJDK langtools component. -This is different from other projects in OpenJDK, which -require version 6.0 or later. diff --git a/langtools/make/netbeans/compiler/build.xml b/langtools/make/netbeans/compiler/build.xml deleted file mode 100644 index 1c1df801a5278d726826a56abd7f9bebf206ee2c..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/compiler/build.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/langtools/make/netbeans/compiler/nbproject/project.xml b/langtools/make/netbeans/compiler/nbproject/project.xml deleted file mode 100644 index ac52705ef99dc34114f2bd80b0837ed50027e040..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/compiler/nbproject/project.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - -]> - - org.netbeans.modules.ant.freeform - - - - compiler - - ../../.. - - - - - ${root} - - - - java - ${root}/src/share/classes - - - - tests - ${root}/test - - - - build - ${root}/make - - - - &standard-ide-actions; - - - folder - ${root}/build/classes - build - - - - - - ${root}/src/share/classes - - - - ${root}/test - - - - ${root}/make - - - - README - - - - &standard-context-menu-items; - - - - - - - ${root}/src/share/classes - ${root}/build/classes - 1.5 - - - - diff --git a/langtools/make/netbeans/doclets/README b/langtools/make/netbeans/doclets/README deleted file mode 100644 index eb7e61b652452b3fda760feef601e07a87e5840b..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/doclets/README +++ /dev/null @@ -1,16 +0,0 @@ -"doclets" project README. - -This project is for working on the standard doclets used by -the documentation tool (javadoc) in the OpenJDK langtools component. - -The doclets are invoked as part of the documentation tool (javadoc). -Using this project, you can also browse javadoc and any tools in langtools. -If you build the doclets, javadoc will be built automatically as well, -if necessary. - -The doclets are found in com.sun.tools.doclets. - -NetBeans 5.0 or later is required and sufficient to use this -project, and others in the OpenJDK langtools component. -This is different from other projects in OpenJDK, which -require version 6.0 or later. diff --git a/langtools/make/netbeans/doclets/build.xml b/langtools/make/netbeans/doclets/build.xml deleted file mode 100644 index a390161c14d8f8cbc06dfb0ef30f6bb2bb872595..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/doclets/build.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/langtools/make/netbeans/doclets/nbproject/project.xml b/langtools/make/netbeans/doclets/nbproject/project.xml deleted file mode 100644 index f0fa2f45d749c10d9ff283ebfb3c78a07216550d..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/doclets/nbproject/project.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - -]> - - org.netbeans.modules.ant.freeform - - - - doclets - - ../../.. - - - - - ${root} - - - - java - ${root}/src/share/classes - - - - tests - ${root}/test - - - - build - ${root}/make - - - - &standard-ide-actions-no-javadoc; - - - folder - ${root}/build/classes - build - - - - - - ${root}/src/share/classes - - - - ${root}/test - - - - ${root}/make - - - - README - - - - &standard-context-menu-items-no-javadoc; - - - - - - - ${root}/src/share/classes - ${root}/build/classes - 1.5 - - - - diff --git a/langtools/make/netbeans/javadoc/README b/langtools/make/netbeans/javadoc/README deleted file mode 100644 index e0027ccb397fde01989a74aa72552b43a925054b..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/javadoc/README +++ /dev/null @@ -1,16 +0,0 @@ -"javadoc" project README. - -This project is for working on the documentation tool (javadoc) -in the OpenJDK langtools component. - -javadoc is built on top of the compiler (javac). Using this -project, you can also browse javac and any tools in langtools. -If you build javadoc, javac will be built automatically as well, -if necessary. - -The main class for the tool is com.sun.tools.javadoc.Main. - -NetBeans 5.0 or later is required and sufficient to use this -project, and others in the OpenJDK langtools component. -This is different from other projects in OpenJDK, which -require version 6.0 or later. diff --git a/langtools/make/netbeans/javadoc/build.xml b/langtools/make/netbeans/javadoc/build.xml deleted file mode 100644 index ba565a6bc587205dd549001c8ea72cca09450687..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/javadoc/build.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/langtools/make/netbeans/javah/README b/langtools/make/netbeans/javah/README deleted file mode 100644 index 6e94fb1f68d003caba2acb977cedf31745253c33..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/javah/README +++ /dev/null @@ -1,21 +0,0 @@ -"javah" project README. - -This project is for working on the native header tool (javah) -in the OpenJDK langtools component. - -javah is built on top of the documentation tool (javadoc). Using this -project, you can also browse javadoc and any other tools in langtools. -If you build javah, javadoc will be built automatically as well, -if necessary. - -javah is in the process of being converted so that it runs directly on -top of the compiler, javac, using the annotation processing API, -instead of on top of the documentation tool, javadoc, using the -Doclet API. - -The main class for the tool is com.sun.tools.javah.Main. - -NetBeans 5.0 or later is required and sufficient to use this -project, and others in the OpenJDK langtools component. -This is different from other projects in OpenJDK, which -require version 6.0 or later. diff --git a/langtools/make/netbeans/javah/build.xml b/langtools/make/netbeans/javah/build.xml deleted file mode 100644 index 578cd1458a91f264b97b28b44ae2d7694b848389..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/javah/build.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/langtools/make/netbeans/javah/nbproject/project.xml b/langtools/make/netbeans/javah/nbproject/project.xml deleted file mode 100644 index d4db76f39be50e9ecfca8a930accc4687bc28166..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/javah/nbproject/project.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - -]> - - org.netbeans.modules.ant.freeform - - - - javah - - ../../.. - - - - - ${root} - - - - java - ${root}/src/share/classes - - - - tests - ${root}/test - - - - build - ${root}/make - - - - &standard-ide-actions-no-javadoc; - - - folder - ${root}/build/classes - build - - - - - - ${root}/src/share/classes - - - - ${root}/test - - - - ${root}/make - - - - README - - - - &standard-context-menu-items-no-javadoc; - - - - - - - ${root}/src/share/classes - ${root}/build/classes - 1.5 - - - - diff --git a/langtools/make/netbeans/javap/README b/langtools/make/netbeans/javap/README deleted file mode 100644 index fb08ece3ee74278a9d40d3c15775dceb23b436c0..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/javap/README +++ /dev/null @@ -1,11 +0,0 @@ -"javap" project README. - -This project is for working on the disassembler tool (javap) -in the OpenJDK langtools component. - -The main class for the tool is sun.tools.javap.Main. - -NetBeans 5.0 or later is required and sufficient to use this -project, and others in the OpenJDK langtools component. -This is different from other projects in OpenJDK, which -require version 6.0 or later. diff --git a/langtools/make/netbeans/javap/build.xml b/langtools/make/netbeans/javap/build.xml deleted file mode 100644 index 818a933d5e4e6d53e97c253211fdafbbe1faf7e1..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/javap/build.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/langtools/make/netbeans/javap/nbproject/project.xml b/langtools/make/netbeans/javap/nbproject/project.xml deleted file mode 100644 index 692e6726cf8cf197a4d74b03af3fb49e2bc92e61..0000000000000000000000000000000000000000 --- a/langtools/make/netbeans/javap/nbproject/project.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - -]> - - org.netbeans.modules.ant.freeform - - - - javap - - ../../.. - - - - - ${root} - - - - java - ${root}/src/share/classes - - - - tests - ${root}/test - - - - build - ${root}/make - - - - &standard-ide-actions-no-javadoc; - - - folder - ${root}/build/classes - build - - - - - - ${root}/src/share/classes - - - - ${root}/test - - - - ${root}/make - - - - README - - - - &standard-context-menu-items-no-javadoc; - - - - - - - ${root}/src/share/classes - ${root}/build/classes - 1.5 - - - - diff --git a/langtools/make/netbeans/langtools/build.xml b/langtools/make/netbeans/langtools/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..8f2b95f303103ae7def7ca02ae7e87cf6ebfb868 --- /dev/null +++ b/langtools/make/netbeans/langtools/build.xml @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set property 'includes' + + + + + + + + + + + + + + Must set property 'run.classname' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see report for details. + + + + + + + + + + + + + Must set property 'debug.classname' + + + + + + + Must set property 'jtreg.tests' + + + + + + + + Must set property 'class' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/langtools/make/netbeans/javadoc/nbproject/project.xml b/langtools/make/netbeans/langtools/nbproject/project.xml similarity index 94% rename from langtools/make/netbeans/javadoc/nbproject/project.xml rename to langtools/make/netbeans/langtools/nbproject/project.xml index 61ebeb3b7af75951b511cd554165f7ca5033f01e..e750960055652817563b3436ee6df603fabf669e 100644 --- a/langtools/make/netbeans/javadoc/nbproject/project.xml +++ b/langtools/make/netbeans/langtools/nbproject/project.xml @@ -1,6 +1,6 @@ - + + ]> org.netbeans.modules.ant.freeform - javadoc + langtools ../../.. diff --git a/langtools/make/netbeans/common/standard-context-menu-items.ent b/langtools/make/netbeans/langtools/nbproject/standard-context-menu-items.ent similarity index 95% rename from langtools/make/netbeans/common/standard-context-menu-items.ent rename to langtools/make/netbeans/langtools/nbproject/standard-context-menu-items.ent index f6e1a96bb8487fdbebb39bfcf85190fef437c02a..ab0568a009dad33a356e6449b5e142b57506fe38 100644 --- a/langtools/make/netbeans/common/standard-context-menu-items.ent +++ b/langtools/make/netbeans/langtools/nbproject/standard-context-menu-items.ent @@ -1,6 +1,6 @@ + + + + diff --git a/langtools/make/netbeans/common/standard-ide-actions.ent b/langtools/make/netbeans/langtools/nbproject/standard-ide-actions.ent similarity index 92% rename from langtools/make/netbeans/common/standard-ide-actions.ent rename to langtools/make/netbeans/langtools/nbproject/standard-ide-actions.ent index 912daf729a845a65a5afffed1a880b489643ef98..3081fdfcdf0eb08c7c9207cb6a5cf6de179b2a4e 100644 --- a/langtools/make/netbeans/common/standard-ide-actions.ent +++ b/langtools/make/netbeans/langtools/nbproject/standard-ide-actions.ent @@ -108,11 +108,11 @@ - debug-nb + debug - debug-single-nb + debug-single debug.classname ${root}/src/share/classes @@ -130,7 +130,7 @@ --> - debug-jtreg-nb + debug-jtreg jtreg.tests ${root}/test @@ -157,5 +157,17 @@ - -javadoc-nb + javadoc + + + + select-tool + + + + test-select-tool-1 + + + + test-select-tool-2 diff --git a/langtools/make/tools/SelectTool/SelectToolTask.java b/langtools/make/tools/SelectTool/SelectToolTask.java new file mode 100644 index 0000000000000000000000000000000000000000..0646c306e8a7f514f028d510fb99b16d1a761628 --- /dev/null +++ b/langtools/make/tools/SelectTool/SelectToolTask.java @@ -0,0 +1,284 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import javax.swing.SwingUtilities; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; + +/** + * Task to allow the user to control langtools tools built when using NetBeans. + * + * There are two primary modes. + * 1) Property mode. In this mode, property names are provided to get values + * that may be specified by the user, either directly in a GUI dialog, or + * read from a properties file. If the GUI dialog is invoked, values may + * optionally be set for future use. + * 2) Setup mode. In this mode, no property names are provided, and the GUI + * is invoked to allow the user to set or reset values for use in property mode. + */ +public class SelectToolTask extends Task { + /** + * Set the location of the private properties file used to keep the retain + * user preferences for this repository. + */ + public void setPropertyFile(File propertyFile) { + this.propertyFile = propertyFile; + } + + /** + * Set the name of the property which will be set to the name of the + * selected tool, if any. If no tool is selected, the property will + * remain unset. + */ + public void setToolProperty(String toolProperty) { + this.toolProperty = toolProperty; + } + + /** + * Set the name of the property which will be set to the execution args of the + * selected tool, if any. The args default to an empty string. + */ + public void setArgsProperty(String argsProperty) { + this.argsProperty = argsProperty; + } + + /** + * Specify whether or not to pop up a dialog if the user has not specified + * a default value for a property. + */ + public void setAskIfUnset(boolean askIfUnset) { + this.askIfUnset = askIfUnset; + } + + @Override + public void execute() { + Project p = getProject(); + + Properties props = readProperties(propertyFile); + toolName = props.getProperty("tool.name"); + if (toolName != null) { + toolArgs = props.getProperty(toolName + ".args", ""); + } + + if (toolProperty == null || + askIfUnset && (toolName == null + || (argsProperty != null && toolArgs == null))) { + showGUI(props); + } + + // finally, return required values, if any + if (toolProperty != null && !(toolName == null || toolName.equals(""))) { + p.setProperty(toolProperty, toolName); + + if (argsProperty != null && toolArgs != null) + p.setProperty(argsProperty, toolArgs); + } + } + + void showGUI(Properties fileProps) { + Properties guiProps = new Properties(fileProps); + JOptionPane p = createPane(guiProps); + p.createDialog("Select Tool").setVisible(true); + + toolName = (String) toolChoice.getSelectedItem(); + toolArgs = argsField.getText(); + + if (defaultCheck.isSelected()) { + if (toolName.equals("")) { + fileProps.remove("tool.name"); + } else { + fileProps.put("tool.name", toolName); + fileProps.put(toolName + ".args", toolArgs); + } + writeProperties(propertyFile, fileProps); + } + } + + JOptionPane createPane(final Properties props) { + JPanel body = new JPanel(new GridBagLayout()); + GridBagConstraints lc = new GridBagConstraints(); + lc.insets.right = 10; + lc.insets.bottom = 3; + GridBagConstraints fc = new GridBagConstraints(); + fc.anchor = GridBagConstraints.WEST; + fc.gridx = 1; + fc.gridwidth = GridBagConstraints.REMAINDER; + fc.insets.bottom = 3; + + JLabel toolLabel = new JLabel("Tool:"); + body.add(toolLabel, lc); + String[] toolChoices = { "apt", "javac", "javadoc", "javah", "javap" }; + if (true || toolProperty == null) { + // include empty value in setup mode + List l = new ArrayList(Arrays.asList(toolChoices)); + l.add(0, ""); + toolChoices = l.toArray(new String[l.size()]); + } + toolChoice = new JComboBox(toolChoices); + if (toolName != null) + toolChoice.setSelectedItem(toolName); + toolChoice.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + String tn = (String) e.getItem(); + argsField.setText(getDefaultArgsForTool(props, tn)); + if (toolProperty != null) + okButton.setEnabled(!tn.equals("")); + } + }); + body.add(toolChoice, fc); + + argsField = new JTextField(getDefaultArgsForTool(props, toolName), 40); + if (toolProperty == null || argsProperty != null) { + JLabel argsLabel = new JLabel("Args:"); + body.add(argsLabel, lc); + body.add(argsField, fc); + argsField.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent e) { + } + public void focusLost(FocusEvent e) { + String toolName = (String) toolChoice.getSelectedItem(); + if (toolName.length() > 0) + props.put(toolName + ".args", argsField.getText()); + } + }); + } + + defaultCheck = new JCheckBox("Set as default"); + if (toolProperty == null) + defaultCheck.setSelected(true); + else + body.add(defaultCheck, fc); + + final JOptionPane p = new JOptionPane(body); + okButton = new JButton("OK"); + okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals(""))); + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p); + d.setVisible(false); + } + }); + p.setOptions(new Object[] { okButton }); + + return p; + } + + Properties readProperties(File file) { + Properties p = new Properties(); + if (file != null && file.exists()) { + Reader in = null; + try { + in = new BufferedReader(new FileReader(file)); + p.load(in); + in.close(); + } catch (IOException e) { + throw new BuildException("error reading property file", e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + throw new BuildException("cannot close property file", e); + } + } + } + } + return p; + } + + void writeProperties(File file, Properties p) { + if (file != null) { + Writer out = null; + try { + File dir = file.getParentFile(); + if (dir != null && !dir.exists()) + dir.mkdirs(); + out = new BufferedWriter(new FileWriter(file)); + p.store(out, "langtools properties"); + out.close(); + } catch (IOException e) { + throw new BuildException("error writing property file", e); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + throw new BuildException("cannot close property file", e); + } + } + } + } + } + + String getDefaultArgsForTool(Properties props, String tn) { + return (tn == null || tn.equals("")) ? "" : props.getProperty(tn + ".args", ""); + } + + // Ant task parameters + private boolean askIfUnset; + private String toolProperty; + private String argsProperty; + private File propertyFile; + + // GUI components + private JComboBox toolChoice; + private JTextField argsField; + private JCheckBox defaultCheck; + private JButton okButton; + + // Result values for the client + private String toolName; + private String toolArgs; +} diff --git a/langtools/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java b/langtools/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java index 582b21c2ee9c4ce7faff0a1b0bd5696639a9cb19..f14dc60e6e3fccc80026b8deefb62109e40da832 100644 --- a/langtools/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java +++ b/langtools/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java @@ -26,6 +26,7 @@ package com.sun.tools.apt.comp; public class AnnotationProcessingError extends Error { + private static final long serialVersionUID = 3279196183341719287L; AnnotationProcessingError(Throwable cause) { super(cause); } diff --git a/langtools/src/share/classes/com/sun/tools/apt/comp/Apt.java b/langtools/src/share/classes/com/sun/tools/apt/comp/Apt.java index abd09f5bf9e3976d1e2a287dfec73a74855e4812..d01887b68884e8819a8f325ee57f5ab8e9faee83 100644 --- a/langtools/src/share/classes/com/sun/tools/apt/comp/Apt.java +++ b/langtools/src/share/classes/com/sun/tools/apt/comp/Apt.java @@ -316,8 +316,13 @@ public class Apt extends ListBuffer> { } providers = list.iterator(); - } else - providers = sun.misc.Service.providers(AnnotationProcessorFactory.class, aptCL); + } else { + @SuppressWarnings("unchecked") + Iterator iter = + sun.misc.Service.providers(AnnotationProcessorFactory.class, aptCL); + providers = iter; + + } } java.util.Map> factoryToAnnotation = diff --git a/langtools/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java b/langtools/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java index cbbbf8675cf712421b1fb3797cc0df4478f8e64c..64a83ddb2c456465e5d648a38326ae118ef98146 100644 --- a/langtools/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java +++ b/langtools/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java @@ -26,4 +26,6 @@ package com.sun.tools.apt.comp; -public class UsageMessageNeededException extends RuntimeException {} +public class UsageMessageNeededException extends RuntimeException { + private static final long serialVersionUID = -3265159608992825840L; +} diff --git a/langtools/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java index 4b632d2d4ee404466f5a87dfa2b6d19048f040b7..433a7dedf5129499627927b250b203de2ce04c1a 100644 --- a/langtools/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java +++ b/langtools/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java @@ -233,6 +233,7 @@ public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler { ListBuffer classes = new ListBuffer(); try { + JavacFileManager fm = (JavacFileManager)fileManager; //parse all files ListBuffer trees = new ListBuffer(); for (List l = filenames; l.nonEmpty(); l = l.tail) { @@ -250,7 +251,8 @@ public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler { continue; } } - trees.append(parse(l.head)); + JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next(); + trees.append(parse(fo)); } //enter symbols for all files diff --git a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java b/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java index ae3a2258e6be61af3f922679f1d5ba82108fb073..403ea6ffb514f27cc9b09d7e4969374eb1692f08 100644 --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java +++ b/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java @@ -30,6 +30,8 @@ import com.sun.mirror.apt.RoundCompleteEvent; import com.sun.mirror.apt.RoundState; public class RoundCompleteEventImpl extends RoundCompleteEvent { + private static final long serialVersionUID = 7067621446720784300L; + public RoundCompleteEventImpl(AnnotationProcessorEnvironment source, RoundState rs) { super(source, rs); diff --git a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java b/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java index 64727fda4c15a30c8601c7254f5288cfd351ba87..9505eb2230da3dc320012ae830c360698e04eb4f 100644 --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java +++ b/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java @@ -252,6 +252,7 @@ class AnnotationProxyMaker { */ private void typeMismatch(final Method method, final Attribute attr) { value = new ExceptionProxy() { + private static final long serialVersionUID = 8473323277815075163L; public String toString() { return ""; // eg: @Anno(value=) } @@ -270,6 +271,7 @@ class AnnotationProxyMaker { * type. */ private static class MirroredTypeExceptionProxy extends ExceptionProxy { + private static final long serialVersionUID = 6662035281599933545L; private MirroredTypeException ex; @@ -311,6 +313,7 @@ class AnnotationProxyMaker { * types. */ private static class MirroredTypesExceptionProxy extends ExceptionProxy { + private static final long serialVersionUID = -6670822532616693951L; private MirroredTypesException ex; diff --git a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java b/langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java index f96e01e0cd8e98d3e7da7191c72c400871280d65..3d6a9fcaa806cc241d15701ac8d430468c4b5cf1 100644 --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java +++ b/langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java @@ -64,7 +64,7 @@ public class TypeVariableImpl extends TypeMirrorImpl implements TypeVariable { * {@inheritDoc} */ public TypeParameterDeclaration getDeclaration() { - TypeSymbol sym = (TypeSymbol) type.tsym; + TypeSymbol sym = type.tsym; return env.declMaker.getTypeParameterDeclaration(sym); } diff --git a/langtools/src/share/classes/com/sun/tools/classfile/Annotation.java b/langtools/src/share/classes/com/sun/tools/classfile/Annotation.java index 9138132c6369d3f611b7110a39f6a6bbebdc8e66..37423cacc67ed0dc11e284564336f28672a1ca3a 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/Annotation.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/Annotation.java @@ -37,6 +37,7 @@ import java.io.IOException; */ public class Annotation { static class InvalidAnnotation extends AttributeException { + private static final long serialVersionUID = -4620480740735772708L; InvalidAnnotation(String msg) { super(msg); } diff --git a/langtools/src/share/classes/com/sun/tools/classfile/AttributeException.java b/langtools/src/share/classes/com/sun/tools/classfile/AttributeException.java index ee3decd947aebda11026127d8dba2137255e56e1..55d23f9c63b0a9312e9038430bb655c71af0f015 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/AttributeException.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/AttributeException.java @@ -32,6 +32,7 @@ package com.sun.tools.classfile; * deletion without notice. */ public class AttributeException extends Exception { + private static final long serialVersionUID = -4231486387714867770L; AttributeException() { } AttributeException(String msg) { diff --git a/langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java b/langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java index c3d8dff0fdffea9021741fac0aa43a987b6fe94a..ce99e119ade12a014fa8215143ccf278230da34a 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java @@ -37,6 +37,7 @@ import java.io.IOException; */ public class Code_attribute extends Attribute { public class InvalidIndex extends AttributeException { + private static final long serialVersionUID = -8904527774589382802L; InvalidIndex(int index) { this.index = index; } diff --git a/langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java b/langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java index f6a0bda55b00c40e103fdb1dd2f94b76730235c4..b9acd9640d9ddc62b2c346602e7ad2b1d5ce5cbd 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java @@ -38,6 +38,7 @@ import java.io.IOException; public class ConstantPool { public class InvalidIndex extends ConstantPoolException { + private static final long serialVersionUID = -4350294289300939730L; InvalidIndex(int index) { super(index); } @@ -50,6 +51,7 @@ public class ConstantPool { } public class UnexpectedEntry extends ConstantPoolException { + private static final long serialVersionUID = 6986335935377933211L; UnexpectedEntry(int index, int expected_tag, int found_tag) { super(index); this.expected_tag = expected_tag; @@ -67,6 +69,7 @@ public class ConstantPool { } public class InvalidEntry extends ConstantPoolException { + private static final long serialVersionUID = 1000087545585204447L; InvalidEntry(int index, int tag) { super(index); this.tag = tag; @@ -82,6 +85,7 @@ public class ConstantPool { } public class EntryNotFound extends ConstantPoolException { + private static final long serialVersionUID = 2885537606468581850L; EntryNotFound(Object value) { super(-1); this.value = value; diff --git a/langtools/src/share/classes/com/sun/tools/classfile/ConstantPoolException.java b/langtools/src/share/classes/com/sun/tools/classfile/ConstantPoolException.java index 03a89b9d0801287e52919fa1e26ddbb129b456f5..31d3473e6ca37d770ba43ae7d3302d5d4728afa8 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/ConstantPoolException.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/ConstantPoolException.java @@ -33,6 +33,7 @@ package com.sun.tools.classfile; * deletion without notice. */ public class ConstantPoolException extends Exception { + private static final long serialVersionUID = -2324397349644754565L; ConstantPoolException(int index) { this.index = index; } diff --git a/langtools/src/share/classes/com/sun/tools/classfile/Descriptor.java b/langtools/src/share/classes/com/sun/tools/classfile/Descriptor.java index 510fe09f4a71d58fc0a398a28a16921125063873..e446955399f23227d82b4cffdafacba3b42357d8 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/Descriptor.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/Descriptor.java @@ -38,6 +38,7 @@ import java.io.IOException; */ public class Descriptor { public class InvalidDescriptor extends DescriptorException { + private static final long serialVersionUID = 1L; InvalidDescriptor(String desc) { this.desc = desc; this.index = -1; diff --git a/langtools/src/share/classes/com/sun/tools/classfile/DescriptorException.java b/langtools/src/share/classes/com/sun/tools/classfile/DescriptorException.java index 97d0538c74cd61d96ee1ffb2e8a4cbf29971fef8..fad9a2ff3611cf11007d3aac664291f0ecdd2e68 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/DescriptorException.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/DescriptorException.java @@ -33,4 +33,5 @@ package com.sun.tools.classfile; * deletion without notice. */ public class DescriptorException extends Exception { + private static final long serialVersionUID = 2411890273788901032L; } diff --git a/langtools/src/share/classes/com/sun/tools/classfile/StackMapTable_attribute.java b/langtools/src/share/classes/com/sun/tools/classfile/StackMapTable_attribute.java index 4f4fd93bf27c938d55d9e10b89fbe2920a3ec368..26a9b6f973601a0989cb7bd2d4f42c7efb3f61ac 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/StackMapTable_attribute.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/StackMapTable_attribute.java @@ -37,6 +37,7 @@ import java.io.IOException; */ public class StackMapTable_attribute extends Attribute { static class InvalidStackMap extends AttributeException { + private static final long serialVersionUID = -5659038410855089780L; InvalidStackMap(String msg) { super(msg); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java index 524bd2472a3134ffef9cb31b938f956949ff4611..70d487da2ba4c4e940be704c75424768958eb7d2 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java @@ -493,4 +493,14 @@ public class ConfigurationImpl extends Configuration { public Comparator getMemberComparator() { return null; } + + /** + * {@inheritDoc} + */ + public Locale getLocale() { + if (root instanceof com.sun.tools.javadoc.RootDocImpl) + return ((com.sun.tools.javadoc.RootDocImpl)root).getLocale(); + else + return Locale.getDefault(); + } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java index 630ed3669c4b12bcb7a617d66650bddcee3306ee..d7e7ee1696e8d95a58cf74b858b581ee72f9ca2f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java @@ -119,7 +119,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { */ protected void generateIndex() { for (int i = 0; i < groupList.size(); i++) { - String groupname = (String)groupList.get(i); + String groupname = groupList.get(i); List list = groupPackageMap.get(groupname); if (list != null && list.size() > 0) { printIndexContents(list.toArray(new PackageDoc[list.size()]), diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java index 8644af9a22f18ac668c8c86cabdd6b305958bdd9..d4cdd39b1cecbb70b09d8fa0250b5dcd1ed09f72 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java @@ -25,12 +25,11 @@ package com.sun.tools.doclets.formats.html.markup; -import com.sun.tools.doclets.internal.toolkit.*; - -import com.sun.javadoc.*; import java.io.*; import java.util.*; -import com.sun.tools.doclets.internal.toolkit.util.*; + +import com.sun.javadoc.*; +import com.sun.tools.doclets.internal.toolkit.*; /** @@ -56,8 +55,9 @@ public abstract class HtmlDocWriter extends HtmlWriter { super(configuration, null, configuration.destDirName + filename, configuration.docencoding); + // use File to normalize file separators configuration.message.notice("doclet.Generating_0", - configuration.destDirName + filename); + new File(configuration.destDirName, filename)); } public HtmlDocWriter(Configuration configuration, @@ -65,10 +65,10 @@ public abstract class HtmlDocWriter extends HtmlWriter { super(configuration, configuration.destDirName + path, filename, configuration.docencoding); + // use File to normalize file separators configuration.message.notice("doclet.Generating_0", - configuration.destDirName + - ((path.length() > 0)? - path + File.separator: "") + filename); + new File(configuration.destDirName, + ((path.length() > 0)? path + File.separator: "") + filename)); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java index 21fb7e642b0a113344e90b9348ebbf6454f4ffbd..cdafe1be907a98398d7d0c570ee4e3a1675efdab 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java @@ -85,7 +85,7 @@ public class HtmlWriter extends PrintWriter { * Print <HTML> tag. Add a newline character at the end. */ public void html() { - println(""); + println(""); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java index 11b37b344982b2c38ca73a9b8b2fc7748195a9ed..eb8960f4c659a8fa1932d5af43d466fe2cac35b0 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java @@ -706,6 +706,11 @@ public abstract class Configuration { new FileInputStream(new File(builderXMLPath)); } + /** + * Return the Locale for this document. + */ + public abstract Locale getLocale(); + /** * Return the comparator that will be used to sort member documentation. * To no do any sorting, return null. diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java index 7f025b6ff5b7453b52999a80180207e015806692..636db90d02a5ba45f50b64b37767cde8a490f28c 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java @@ -402,7 +402,7 @@ public class SerializedFormBuilder extends AbstractBuilder { public void buildFieldSerializationOverview(ClassDoc classDoc) { if (classDoc.definesSerializableFields()) { FieldDoc serialPersistentField = - (FieldDoc)((Util.asList(classDoc.serializableFields()).get(0))); + Util.asList(classDoc.serializableFields()).get(0); String comment = serialPersistentField.commentText(); if (comment.length() > 0) { fieldWriter.writeHeader( diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletAbortException.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletAbortException.java index 906cc011705af422c7a673452a35e81aa405dc49..c08965e5b7dc304d7ae419e0f70a377a9d90dd98 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletAbortException.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletAbortException.java @@ -26,6 +26,7 @@ package com.sun.tools.doclets.internal.toolkit.util; public class DocletAbortException extends RuntimeException { + private static final long serialVersionUID = -9131058909576418984L; public DocletAbortException() { } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java index 4055b914822d753fd89ac34380b55b95eaca2d76..9f0b6417d6c97658e1f3025b399eda849efe092a 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java @@ -80,47 +80,15 @@ public class MessageRetriever { this.resourcelocation = resourcelocation; } - /** - * get and format message string from resource - * - * @param key selects message from resource - */ - public String getText(String key) { - return getText(key, (String)null); - } - - /** - * Get and format message string from resource - * - * @param key selects message from resource - * @param a1 Argument, to be repalced in the message. - */ - public String getText(String key, String a1) { - return getText(key, a1, null); - } - - /** - * Get and format message string from resource - * - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - */ - public String getText(String key, String a1, String a2) { - return getText(key, a1, a2, null); - } - /** * Get and format message string from resource * * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - * @param a3 third argument to be replaced in the message. + * @param args arguments to be replaced in the message. * @throws MissingResourceException when the key does not * exist in the properties file. */ - public String getText(String key, String a1, String a2, String a3) throws MissingResourceException { + public String getText(String key, Object... args) throws MissingResourceException { if (messageRB == null) { try { messageRB = ResourceBundle.getBundle(resourcelocation); @@ -130,7 +98,7 @@ public class MessageRetriever { } } String message = messageRB.getString(key); - return MessageFormat.format(message, a1, a2, a3); + return MessageFormat.format(message, args); } /** @@ -195,127 +163,20 @@ public class MessageRetriever { * * @param pos the position of the source * @param key selects message from resource + * @param args arguments to be replaced in the message. */ - public void error(SourcePosition pos, String key) { - printError(pos, getText(key)); + public void error(SourcePosition pos, String key, Object... args) { + printError(pos, getText(key, args)); } /** * Print error message, increment error count. * * @param key selects message from resource + * @param args arguments to be replaced in the message. */ - public void error(String key) { - printError(getText(key)); - } - - /** - * Print error message, increment error count. - * - * @param pos the position of the source - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - */ - public void error(SourcePosition pos, String key, String a1) { - printError(pos, getText(key, a1)); - } - - /** - * Print error message, increment error count. - * - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - */ - public void error(String key, String a1) { - printError(getText(key, a1)); - } - - /** - * Print error message, increment error count. - * - * @param pos the position of the source - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - */ - public void error(SourcePosition pos, String key, String a1, String a2) { - printError(pos, getText(key, a1, a2)); - } - - /** - * Print error message, increment error count. - * - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - */ - public void error(String key, String a1, String a2) { - printError(getText(key, a1, a2)); - } - - /** - * Print error message, increment error count. - * - * @param pos the position of the source - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - * @param a3 third argument to be replaced in the message. - */ - public void error(SourcePosition pos, String key, String a1, String a2, String a3) { - printError(pos, getText(key, a1, a2, a3)); - } - - /** - * Print error message, increment error count. - * - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - * @param a3 third argument to be replaced in the message. - */ - public void error(String key, String a1, String a2, String a3) { - printError(getText(key, a1, a2, a3)); - } - - /** - * Print warning message, increment warning count. - * - * @param pos the position of the source - * @param key selects message from resource - */ - public void warning(SourcePosition pos, String key) { - printWarning(pos, getText(key)); - } - - /** - * Print warning message, increment warning count. - * - * @param key selects message from resource - */ - public void warning(String key) { - printWarning(getText(key)); - } - - /** - * Print warning message, increment warning count. - * - * @param pos the position of the source - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - */ - public void warning(SourcePosition pos, String key, String a1) { - printWarning(pos, getText(key, a1)); - } - - /** - * Print warning message, increment warning count. - * - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - */ - public void warning(String key, String a1) { - printWarning(getText(key, a1)); + public void error(String key, Object... args) { + printError(getText(key, args)); } /** @@ -323,109 +184,20 @@ public class MessageRetriever { * * @param pos the position of the source * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. + * @param args arguments to be replaced in the message. */ - public void warning(SourcePosition pos, String key, String a1, String a2) { - printWarning(pos, getText(key, a1, a2)); + public void warning(SourcePosition pos, String key, Object... args) { + printWarning(pos, getText(key, args)); } /** * Print warning message, increment warning count. * * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - */ - public void warning(String key, String a1, String a2) { - printWarning(getText(key, a1, a2)); - } - - /** - * Print warning message, increment warning count. - * - * @param pos the position of the source - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - * @param a3 third argument to be replaced in the message. - */ - public void warning(SourcePosition pos, String key, String a1, String a2, String a3) { - printWarning(pos, getText(key, a1, a2, a3)); - } - - /** - * Print warning message, increment warning count. - * - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - * @param a3 third argument to be replaced in the message. - */ - public void warning(String key, String a1, String a2, String a3) { - printWarning(getText(key, a1, a2, a3)); - } - - /** - * Print a message. - * - * @param pos the position of the source - * @param key selects message from resource - */ - public void notice(SourcePosition pos, String key) { - printNotice(pos, getText(key)); - } - - /** - * Print a message. - * - * @param key selects message from resource - */ - public void notice(String key) { - printNotice(getText(key)); - } - - /** - * Print a message. - * @param pos the position of the source - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - */ - public void notice(SourcePosition pos, String key, String a1) { - printNotice(pos, getText(key, a1)); - } - - /** - * Print a message. - * - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - */ - public void notice(String key, String a1) { - printNotice(getText(key, a1)); - } - - /** - * Print a message. - * - * @param pos the position of the source - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - */ - public void notice(SourcePosition pos, String key, String a1, String a2) { - printNotice(pos, getText(key, a1, a2)); - } - - /** - * Print a message. - * - * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. + * @param args arguments to be replaced in the message. */ - public void notice(String key, String a1, String a2) { - printNotice(getText(key, a1, a2)); + public void warning(String key, Object... args) { + printWarning(getText(key, args)); } /** @@ -433,23 +205,19 @@ public class MessageRetriever { * * @param pos the position of the source * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - * @param a3 third argument to be replaced in the message. + * @param args arguments to be replaced in the message. */ - public void notice(SourcePosition pos, String key, String a1, String a2, String a3) { - printNotice(pos, getText(key, a1, a2, a3)); + public void notice(SourcePosition pos, String key, Object... args) { + printNotice(pos, getText(key, args)); } /** * Print a message. * * @param key selects message from resource - * @param a1 first argument to be replaced in the message. - * @param a2 second argument to be replaced in the message. - * @param a3 third argument to be replaced in the message. + * @param args arguments to be replaced in the message. */ - public void notice(String key, String a1, String a2, String a3) { - printNotice(getText(key, a1, a2, a3)); + public void notice(String key, Object... args) { + printNotice(getText(key, args)); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java index 67a82e8a3b3cfd557d9efcb22a95241d09e1a110..3de2951e06233b250b79f3b95cc54314d3792442 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java @@ -25,10 +25,12 @@ package com.sun.tools.doclets.internal.toolkit.util; -import com.sun.tools.doclets.internal.toolkit.*; -import com.sun.javadoc.*; import java.io.*; import java.util.*; +import javax.tools.FileObject; + +import com.sun.javadoc.*; +import com.sun.tools.doclets.internal.toolkit.*; /** * Converts Java Source Code to HTML. @@ -123,16 +125,27 @@ public class SourceToHTMLConverter { if (cd == null || outputdir == null) { return; } - File file; - SourcePosition sp = cd.position(); - if (sp == null || (file = sp.file()) == null) { - return; - } try { + SourcePosition sp = cd.position(); + if (sp == null) + return; + Reader r; + // temp hack until we can update SourcePosition API. + if (sp instanceof com.sun.tools.javadoc.SourcePositionImpl) { + FileObject fo = ((com.sun.tools.javadoc.SourcePositionImpl) sp).fileObject(); + if (fo == null) + return; + r = fo.openReader(true); + } else { + File file = sp.file(); + if (file == null) + return; + r = new FileReader(file); + } + LineNumberReader reader = new LineNumberReader(r); int lineno = 1; String line; StringBuffer output = new StringBuffer(); - LineNumberReader reader = new LineNumberReader(new FileReader(file)); try { while ((line = reader.readLine()) != null) { output.append(formatLine(line, configuration.sourcetab, lineno)); @@ -142,7 +155,7 @@ public class SourceToHTMLConverter { reader.close(); } output = addLineNumbers(output.toString()); - output.insert(0, getHeader()); + output.insert(0, getHeader(configuration)); output.append(getFooter()); writeToFile(output.toString(), outputdir, cd.name(), configuration); } catch (Exception e){ @@ -192,10 +205,11 @@ public class SourceToHTMLConverter { /** * Get the header. + * @param configuration the Doclet configuration * @return the header to the output file */ - protected static String getHeader() { - StringBuffer result = new StringBuffer("" + DocletConstants.NL); + protected static String getHeader(Configuration configuration) { + StringBuffer result = new StringBuffer("" + DocletConstants.NL); result.append("" + DocletConstants.NL); result.append("
" + DocletConstants.NL);
         return result.toString();
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
index 9b7b668b6c0dd95ca4b3ffd5d8d5fa9da7e65116..1d5eb19c22e43c1fc2852b64bc215b527e599c6b 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
@@ -25,10 +25,11 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
+import java.io.*;
+import java.util.*;
+
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
-import java.util.*;
-import java.io.*;
 
 /**
  * Utilities Class for Doclets.
@@ -579,7 +580,7 @@ public class Util {
      * @param docencoding Encoding to be used for this file.
      * @exception IOException Exception raised by the FileWriter is passed on
      * to next level.
-     * @exception UnSupportedEncodingException Exception raised by the
+     * @exception UnsupportedEncodingException Exception raised by the
      * OutputStreamWriter is passed on to next level.
      * @return Writer Writer for the file getting generated.
      * @see java.io.FileOutputStream
@@ -598,9 +599,7 @@ public class Util {
             fos = new FileOutputStream(filename);
         }
         if (docencoding == null) {
-            OutputStreamWriter oswriter = new OutputStreamWriter(fos);
-            docencoding = oswriter.getEncoding();
-            return oswriter;
+            return new OutputStreamWriter(fos);
         } else {
             return new OutputStreamWriter(fos, docencoding);
         }
diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
index 3f4911bb06ca3d9b4b3643270c92c5351ec8341c..3556ee6328cf7c17e940418a6e61f7cbc3ef6e82 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
@@ -471,6 +471,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         private int value;
     };
     protected class CompileStates extends HashMap,CompileState> {
+        private static final long serialVersionUID = 1812267524140424433L;
         boolean isDone(Env env, CompileState cs) {
             CompileState ecs = get(env);
             return ecs != null && ecs.isDone(cs);
diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java
index e8165090b4eb7d16d12aeb4bd53e4d220b8cbbbc..804448b97de91095cb15f2ba5918fec1fe3ed9f2 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java
@@ -338,13 +338,13 @@ public class Main {
                 return EXIT_CMDERR;
             }
 
-            List filenames;
+            List files;
             try {
-                filenames = processArgs(CommandLine.parse(args));
-                if (filenames == null) {
+                files = processArgs(CommandLine.parse(args));
+                if (files == null) {
                     // null signals an error in options, abort
                     return EXIT_CMDERR;
-                } else if (filenames.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) {
+                } else if (files.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) {
                     // it is allowed to compile nothing if just asking for help or version info
                     if (options.get("-help") != null
                         || options.get("-X") != null
@@ -380,12 +380,14 @@ public class Main {
             comp = JavaCompiler.instance(context);
             if (comp == null) return EXIT_SYSERR;
 
-            if (!filenames.isEmpty()) {
+            Log log = Log.instance(context);
+
+            if (!files.isEmpty()) {
                 // add filenames to fileObjects
                 comp = JavaCompiler.instance(context);
                 List otherFiles = List.nil();
                 JavacFileManager dfm = (JavacFileManager)fileManager;
-                for (JavaFileObject fo : dfm.getJavaFileObjectsFromFiles(filenames))
+                for (JavaFileObject fo : dfm.getJavaFileObjectsFromFiles(files))
                     otherFiles = otherFiles.prepend(fo);
                 for (JavaFileObject fo : otherFiles)
                     fileObjects = fileObjects.prepend(fo);
@@ -394,6 +396,16 @@ public class Main {
                          classnames.toList(),
                          processors);
 
+            if (log.expectDiagKeys != null) {
+                if (log.expectDiagKeys.size() == 0) {
+                    Log.printLines(log.noticeWriter, "all expected diagnostics found");
+                    return EXIT_OK;
+                } else {
+                    Log.printLines(log.noticeWriter, "expected diagnostic keys not found: " + log.expectDiagKeys);
+                    return EXIT_ERROR;
+                }
+            }
+
             if (comp.errorCount() != 0 ||
                 options.get("-Werror") != null && comp.warningCount() != 0)
                 return EXIT_ERROR;
diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
index ef48f23984fa474877e2813a9bc91e8852bb4cec..a1bd2da6e555db89e5f330bc0e1348a882c8593d 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
@@ -863,13 +863,13 @@ public class JavacParser implements Parser {
                         accept(GT);
                         t = F.at(pos1).TypeApply(t, args.toList());
                         checkGenerics();
-                        t = bracketsOpt(toP(t));
                         while (S.token() == DOT) {
                             S.nextToken();
                             mode = TYPE;
                             t = toP(F.at(S.pos()).Select(t, ident()));
                             t = typeArgumentsOpt(t);
                         }
+                        t = bracketsOpt(toP(t));
                     } else if ((mode & EXPR) != 0) {
                         mode = EXPR;
                         t = F.at(pos1).Binary(op, t, term2Rest(t1, TreeInfo.shiftPrec));
diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
index 345e2628c960e84bc1cf5c94cb11937fd0442834..02102452cd2252afb4a69c5b9612a4c8b94006f3 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
@@ -61,6 +61,7 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
      * @param opts list of command-line options
      * @param msgs JavacMessages object used for i18n
      */
+    @SuppressWarnings("fallthrough")
     BasicDiagnosticFormatter(Options opts, JavacMessages msgs) {
         super(msgs, opts, true);
         initAvailableFormats();
diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java
index e9d21f712d31bdde966ad808e09b29cbd6f56e29..e7359a3c2831bc397307f404684474f5c7dda87d 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java
@@ -26,6 +26,7 @@
 package com.sun.tools.javac.util;
 
 import java.io.*;
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -96,6 +97,11 @@ public class Log extends AbstractLog {
      */
     private DiagnosticFormatter diagFormatter;
 
+    /**
+     * Keys for expected diagnostics
+     */
+    public Set expectDiagKeys;
+
     /**
      * JavacMessages object used for localization
      */
@@ -123,9 +129,13 @@ public class Log extends AbstractLog {
         this.diagFormatter = rawDiagnostics ? new RawDiagnosticFormatter(options) :
                                               new BasicDiagnosticFormatter(options, messages);
         @SuppressWarnings("unchecked") // FIXME
-        DiagnosticListener diagListener =
+        DiagnosticListener dl =
             context.get(DiagnosticListener.class);
-        this.diagListener = diagListener;
+        this.diagListener = dl;
+
+        String ek = options.get("expectKeys");
+        if (ek != null)
+            expectDiagKeys = new HashSet(Arrays.asList(ek.split(", *")));
     }
     // where
         private int getIntOption(Options options, String optionName, int defaultValue) {
@@ -291,6 +301,9 @@ public class Log extends AbstractLog {
      * reported so far, the diagnostic may be handed off to writeDiagnostic.
      */
     public void report(JCDiagnostic diagnostic) {
+        if (expectDiagKeys != null)
+            expectDiagKeys.remove(diagnostic.getCode());
+
         switch (diagnostic.getType()) {
         case FRAGMENT:
             throw new IllegalArgumentException();
diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
index 18328a053963608eea933818c9f2a9f5d86e0ae4..e3f065650d1207704272bf79e1fdd194f4646146 100644
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
@@ -25,42 +25,48 @@
 
 package com.sun.tools.javadoc;
 
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+import javax.tools.FileObject;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
 import com.sun.javadoc.*;
 
 import static com.sun.javadoc.LanguageVersion.*;
 
-import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.Name;
-import com.sun.tools.javac.util.Position;
-
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Kinds;
-import com.sun.tools.javac.code.TypeTags;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.code.Type.ClassType;
 import com.sun.tools.javac.code.Scope;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.ClassType;
+import com.sun.tools.javac.code.TypeTags;
 
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Env;
 
 import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
 import com.sun.tools.javac.tree.JCTree.JCImport;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.tree.TreeInfo;
 
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
+import com.sun.tools.javac.util.Position;
+
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
 
-import java.io.File;
-import java.util.Set;
-import java.util.HashSet;
-import java.lang.reflect.Modifier;
-
 /**
  * Represents a java class and provides access to information
  * about the class, the class' comment and tags, and the
@@ -271,16 +277,41 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
      */
     public PackageDoc containingPackage() {
         PackageDocImpl p = env.getPackageDoc(tsym.packge());
-        SourcePosition po = position();
-        if (po != null && p.setDocPath == false && p.zipDocPath == null) {
-            //Set the package path if possible
-            File packageDir = po.file().getParentFile();
-            if (packageDir != null
-                && (new File(packageDir, "package.html")).exists()) {
-                p.setDocPath(packageDir.getPath());
-            } else {
-                p.setDocPath(null);
+        if (p.setDocPath == false) {
+            FileObject docPath;
+            try {
+                Location location = env.fileManager.hasLocation(StandardLocation.SOURCE_PATH)
+                    ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;
+
+                docPath = env.fileManager.getFileForInput(
+                        location, p.qualifiedName(), "package.html");
+            } catch (IOException e) {
+                docPath = null;
             }
+
+            if (docPath == null) {
+                // fall back on older semantics of looking in same directory as
+                // source file for this class
+                SourcePosition po = position();
+                if (env.fileManager instanceof StandardJavaFileManager &&
+                        po instanceof SourcePositionImpl) {
+                    URI uri = ((SourcePositionImpl) po).filename.toUri();
+                    if ("file".equals(uri.getScheme())) {
+                        File f = new File(uri.getPath());
+                        File dir = f.getParentFile();
+                        if (dir != null) {
+                            File pf = new File(dir, "package.html");
+                            if (pf.exists()) {
+                                StandardJavaFileManager sfm = (StandardJavaFileManager) env.fileManager;
+                                docPath = sfm.getJavaFileObjects(pf).iterator().next();
+                            }
+                        }
+
+                    }
+                }
+            }
+
+            p.setDocPath(docPath);
         }
         return p;
     }
@@ -1251,7 +1282,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
      */
     public SourcePosition position() {
         if (tsym.sourcefile == null) return null;
-        return SourcePositionImpl.make(tsym.sourcefile.toString(),
+        return SourcePositionImpl.make(tsym.sourcefile,
                                        (tree==null) ? Position.NOPOS : tree.pos,
                                        lineMap);
     }
diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/Comment.java b/langtools/src/share/classes/com/sun/tools/javadoc/Comment.java
index af4322e9a3c757ca3bc5de98eefcd65097154690..6ce71e306002bc7e469cb170bb8dd0cacadcb2d8 100644
--- a/langtools/src/share/classes/com/sun/tools/javadoc/Comment.java
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/Comment.java
@@ -74,6 +74,7 @@ class Comment {
          * the tag text.
          * 
*/ + @SuppressWarnings("fallthrough") class CommentStringParser { /** * The entry point to the comment string parser diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java b/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java index d8ddd701be71401c7732817be2be466ba47c59af..aeb39bf27587d2b42b8ecfdba6bf4a28cda3b7ee 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java @@ -25,8 +25,9 @@ package com.sun.tools.javadoc; -import java.util.*; import java.lang.reflect.Modifier; +import java.util.*; +import javax.tools.JavaFileManager; import com.sun.javadoc.*; @@ -40,7 +41,6 @@ import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Position; - /** * Holds the environment for a run of javadoc. * Holds only the information needed throughout the @@ -103,6 +103,7 @@ public class DocEnv { Check chk; Types types; + JavaFileManager fileManager; /** Allow documenting from class files? */ boolean docClasses = false; @@ -133,6 +134,7 @@ public class DocEnv { externalizableSym = reader.enterClass(names.fromString("java.io.Externalizable")); chk = Check.instance(context); types = Types.instance(context); + fileManager = context.get(JavaFileManager.class); // Default. Should normally be reset with setLocale. this.doclocale = new DocLocale(this, "", breakiterator); diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/DocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/DocImpl.java index 3d3f7c6299885bfa79e4cc66619461dc8ba5ab90..636f9e852118fad8693ceeea2cc5735b1530464d 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/DocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocImpl.java @@ -25,11 +25,13 @@ package com.sun.tools.javadoc; -import com.sun.javadoc.*; - import java.io.InputStream; import java.io.IOException; import java.text.CollationKey; +import javax.tools.FileObject; + +import com.sun.javadoc.*; + import com.sun.tools.javac.util.Position; /** @@ -43,7 +45,7 @@ import com.sun.tools.javac.util.Position; * @author Atul M Dambalkar * @author Neal Gafter (rewrite) */ -abstract class DocImpl implements Doc, Comparable { +public abstract class DocImpl implements Doc, Comparable { /** * Doc environment @@ -163,7 +165,7 @@ abstract class DocImpl implements Doc, Comparable { /** * Utility for subclasses which read HTML documentation files. */ - String readHTMLDocumentation(InputStream input, String filename) throws IOException { + String readHTMLDocumentation(InputStream input, FileObject filename) throws IOException { int filesize = input.available(); byte[] filecontents = new byte[filesize]; input.read(filecontents, 0, filesize); diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java index 4162db4b1c1159c9f29c175346e5b81fb4c4afe1..7647ac032119712f92951f636b71de739b5ad81e 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java @@ -25,20 +25,18 @@ package com.sun.tools.javadoc; +import java.lang.reflect.Modifier; +import java.text.CollationKey; + import com.sun.javadoc.*; -import com.sun.tools.javac.util.List; -import com.sun.tools.javac.util.ListBuffer; -import com.sun.tools.javac.util.Position; import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.Type; -import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.*; +import com.sun.tools.javac.code.Type; import com.sun.tools.javac.tree.JCTree.JCMethodDecl; - -import java.text.CollationKey; - -import java.lang.reflect.Modifier; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.javac.util.Position; /** * Represents a method or constructor of a java class. @@ -267,7 +265,7 @@ public abstract class ExecutableMemberDocImpl */ public SourcePosition position() { if (sym.enclClass().sourcefile == null) return null; - return SourcePositionImpl.make(sym.enclClass().sourcefile.toString(), + return SourcePositionImpl.make(sym.enclClass().sourcefile, (tree==null) ? 0 : tree.pos, lineMap); } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java index 4e7fe4a196ec7a14fada9c991fb363ec28961500..4da1e1b819b2976e7d8af3aa874ec8504d9edb38 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java @@ -25,6 +25,8 @@ package com.sun.tools.javadoc; +import java.lang.reflect.Modifier; + import com.sun.javadoc.*; import static com.sun.javadoc.LanguageVersion.*; @@ -38,9 +40,6 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.util.Position; -import java.lang.reflect.Modifier; - - /** * Represents a field in a java class. * @@ -260,7 +259,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc { */ public SourcePosition position() { if (sym.enclClass().sourcefile == null) return null; - return SourcePositionImpl.make(sym.enclClass().sourcefile.toString(), + return SourcePositionImpl.make(sym.enclClass().sourcefile, (tree==null) ? 0 : tree.pos, lineMap); } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java index 12303e042e6e3151f9be42d10fee8eecf2afb10e..dbda1435c3bf842f09d999bf27eda50a59eba84b 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java @@ -25,18 +25,13 @@ package com.sun.tools.javadoc; +import java.util.EnumSet; +import javax.tools.JavaFileObject; + import com.sun.tools.javac.code.Symbol.PackageSymbol; -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.file.ZipArchive.ZipFileObject; -import com.sun.tools.javac.file.Old199; -import com.sun.tools.javac.file.ZipFileIndexArchive; import com.sun.tools.javac.jvm.ClassReader; import com.sun.tools.javac.util.Context; -import java.io.File; -import java.util.EnumSet; -import javax.tools.JavaFileObject; - /** Javadoc uses an extended class reader that records package.html entries * @author Neal Gafter */ @@ -82,32 +77,7 @@ class JavadocClassReader extends ClassReader { */ @Override protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) { - CharSequence fileName = Old199.getName(fo); - if (docenv != null && fileName.equals("package.html")) { - if (fo instanceof ZipFileObject) { - ZipFileObject zfo = (ZipFileObject) fo; - String zipName = zfo.getZipName(); - String entryName = zfo.getZipEntryName(); - int lastSep = entryName.lastIndexOf("/"); - String classPathName = entryName.substring(0, lastSep + 1); - docenv.getPackageDoc(pack).setDocPath(zipName, classPathName); - } - else if (fo instanceof ZipFileIndexArchive.ZipFileIndexFileObject) { - ZipFileIndexArchive.ZipFileIndexFileObject zfo = (ZipFileIndexArchive.ZipFileIndexFileObject) fo; - String zipName = zfo.getZipName(); - String entryName = zfo.getZipEntryName(); - if (File.separatorChar != '/') { - entryName = entryName.replace(File.separatorChar, '/'); - } - - int lastSep = entryName.lastIndexOf("/"); - String classPathName = entryName.substring(0, lastSep + 1); - docenv.getPackageDoc(pack).setDocPath(zipName, classPathName); - } - else { - File fileDir = new File(Old199.getPath(fo)).getParentFile(); - docenv.getPackageDoc(pack).setDocPath(fileDir.getAbsolutePath()); - } - } + if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML)) + docenv.getPackageDoc(pack).setDocPath(fo); } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java index 30c4c74e56c7be7b538243b7d8be3e397077d5d2..2cb3ab3288d56ea852860fb1dd7a6503a3358cef 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java @@ -25,17 +25,29 @@ package com.sun.tools.javadoc; -import java.io.*; - +import java.io.File; +import java.io.IOException; import java.util.Collection; - -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.comp.*; -import com.sun.tools.javac.file.Paths; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import javax.tools.JavaFileManager.Location; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; + +import com.sun.tools.javac.code.Symbol.CompletionFailure; +import com.sun.tools.javac.comp.Annotate; import com.sun.tools.javac.parser.DocCommentScanner; -import com.sun.tools.javac.tree.*; -import com.sun.tools.javac.tree.JCTree.*; -import com.sun.tools.javac.util.*; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCClassDecl; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; +import com.sun.tools.javac.util.Abort; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.javac.util.Position; /** @@ -53,7 +65,6 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { final JavadocClassReader reader; final JavadocEnter enter; final Annotate annotate; - private final Paths paths; /** * Construct a new JavaCompiler processor, using appropriately @@ -66,7 +77,6 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { reader = JavadocClassReader.instance0(context); enter = JavadocEnter.instance0(context); annotate = Annotate.instance(context); - paths = Paths.instance(context); } /** @@ -120,7 +130,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { boolean quiet) throws IOException { docenv = DocEnv.instance(context); docenv.showAccess = filter; - docenv.quiet = quiet; + docenv.quiet = quiet; docenv.breakiterator = breakiterator; docenv.setLocale(doclocale); docenv.setEncoding(encoding); @@ -133,12 +143,14 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { ListBuffer packTrees = new ListBuffer(); try { + StandardJavaFileManager fm = (StandardJavaFileManager) docenv.fileManager; for (List it = javaNames; it.nonEmpty(); it = it.tail) { String name = it.head; if (!docClasses && name.endsWith(".java") && new File(name).exists()) { + JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next(); docenv.notice("main.Loading_source_file", name); - JCCompilationUnit tree = parse(name); - classTrees.append(tree); + JCCompilationUnit tree = parse(fo); + classTrees.append(tree); } else if (isValidPackageName(name)) { names = names.append(name); } else if (name.endsWith(".java")) { @@ -151,12 +163,14 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { if (!docClasses) { // Recursively search given subpackages. If any packages //are found, add them to the list. - searchSubPackages(subPackages, names, excludedPackages); + Map> packageFiles = + searchSubPackages(subPackages, names, excludedPackages); // Parse the packages for (List packs = names.toList(); packs.nonEmpty(); packs = packs.tail) { // Parse sources ostensibly belonging to package. - parsePackageClasses(packs.head, packTrees, excludedPackages); + String packageName = packs.head; + parsePackageClasses(packageName, packageFiles.get(packageName), packTrees, excludedPackages); } if (messager.nerrors() != 0) return null; @@ -167,7 +181,8 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { } } catch (Abort ex) {} - if (messager.nerrors() != 0) return null; + if (messager.nerrors() != 0) + return null; if (docClasses) return new RootDocImpl(docenv, javaNames, options); @@ -185,66 +200,129 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { return isValidClassName(s); } - - private final static char pathSep = File.pathSeparatorChar; - /** * search all directories in path for subdirectory name. Add all * .java files found in such a directory to args. */ private void parsePackageClasses(String name, - ListBuffer trees, - List excludedPackages) - throws IOException { + Iterable files, + ListBuffer trees, + List excludedPackages) + throws IOException { if (excludedPackages.contains(name)) { return; } + boolean hasFiles = false; docenv.notice("main.Loading_source_files_for_package", name); - name = name.replace('.', File.separatorChar); - for (File pathname : paths.sourceSearchPath()) { - File f = new File(pathname, name); - String names[] = f.list(); - // if names not null, then found directory with source files - if (names != null) { - String dir = f.getAbsolutePath(); - if (!dir.endsWith(File.separator)) - dir = dir + File.separator; - for (int j = 0; j < names.length; j++) { - if (isValidJavaSourceFile(names[j])) { - String fn = dir + names[j]; - // messager.notice("main.Loading_source_file", fn); - trees.append(parse(fn)); - hasFiles = true; - } + + if (files == null) { + Location location = docenv.fileManager.hasLocation(StandardLocation.SOURCE_PATH) + ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH; + ListBuffer lb = new ListBuffer(); + for (JavaFileObject fo: docenv.fileManager.list( + location, name, EnumSet.of(JavaFileObject.Kind.SOURCE), false)) { + String binaryName = docenv.fileManager.inferBinaryName(location, fo); + String simpleName = getSimpleName(binaryName); + if (isValidClassName(simpleName)) { + lb.append(fo); } } + files = lb.toList(); + } + + for (JavaFileObject fo : files) { + // messager.notice("main.Loading_source_file", fn); + trees.append(parse(fo)); + hasFiles = true; } - if (!hasFiles) + + if (!hasFiles) { messager.warning(null, "main.no_source_files_for_package", - name.replace(File.separatorChar, '.')); + name.replace(File.separatorChar, '.')); + } } /** * Recursively search all directories in path for subdirectory name. * Add all packages found in such a directory to packages list. */ + private Map> searchSubPackages( + List subPackages, + ListBuffer packages, + List excludedPackages) + throws IOException { + Map> packageFiles = + new HashMap>(); + + Map includedPackages = new HashMap(); + includedPackages.put("", true); + for (String p: excludedPackages) + includedPackages.put(p, false); + + if (docenv.fileManager.hasLocation(StandardLocation.SOURCE_PATH)) { + searchSubPackages(subPackages, + includedPackages, + packages, packageFiles, + StandardLocation.SOURCE_PATH, + EnumSet.of(JavaFileObject.Kind.SOURCE)); + searchSubPackages(subPackages, + includedPackages, + packages, packageFiles, + StandardLocation.CLASS_PATH, + EnumSet.of(JavaFileObject.Kind.CLASS)); + } else { + searchSubPackages(subPackages, + includedPackages, + packages, packageFiles, + StandardLocation.CLASS_PATH, + EnumSet.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS)); + } + return packageFiles; + } + private void searchSubPackages(List subPackages, - ListBuffer packages, - List excludedPackages) { - // FIXME: This search path is bogus. - // Only the effective source path should be searched for sources. - // Only the effective class path should be searched for classes. - // Should the bootclasspath/extdirs also be searched for classes? - java.util.List pathnames = new java.util.ArrayList(); - if (paths.sourcePath() != null) - for (File elt : paths.sourcePath()) - pathnames.add(elt); - for (File elt : paths.userClassPath()) - pathnames.add(elt); - - for (String subPackage : subPackages) - searchSubPackage(subPackage, packages, excludedPackages, pathnames); + Map includedPackages, + ListBuffer packages, + Map> packageFiles, + StandardLocation location, Set kinds) + throws IOException { + for (String subPackage: subPackages) { + if (!isIncluded(subPackage, includedPackages)) + continue; + + for (JavaFileObject fo: docenv.fileManager.list(location, subPackage, kinds, true)) { + String binaryName = docenv.fileManager.inferBinaryName(location, fo); + String packageName = getPackageName(binaryName); + String simpleName = getSimpleName(binaryName); + if (isIncluded(packageName, includedPackages) && isValidClassName(simpleName)) { + List list = packageFiles.get(packageName); + list = (list == null ? List.of(fo) : list.prepend(fo)); + packageFiles.put(packageName, list); + if (!packages.contains(packageName)) + packages.add(packageName); + } + } + } + } + + private String getPackageName(String name) { + int lastDot = name.lastIndexOf("."); + return (lastDot == -1 ? "" : name.substring(0, lastDot)); + } + + private String getSimpleName(String name) { + int lastDot = name.lastIndexOf("."); + return (lastDot == -1 ? name : name.substring(lastDot + 1)); + } + + private boolean isIncluded(String packageName, Map includedPackages) { + Boolean b = includedPackages.get(packageName); + if (b == null) { + b = isIncluded(getPackageName(packageName), includedPackages); + includedPackages.put(packageName, b); + } + return b; } /** diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java b/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java index 1933862a5c792aa5e540d0090bdf74c2393d9a7a..4419fc2ea185a7bf74678cdd8810a51c3cdcc7d9 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java @@ -111,6 +111,7 @@ public class Messager extends Log implements DocErrorReporter { * @param warnWriter Stream for warnings * @param noticeWriter Stream for other messages */ + @SuppressWarnings("deprecation") protected Messager(Context context, String programName, PrintWriter errWriter, diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java index 426123eba255f5642afd4c9042024269737e935d..97e1b09b66e56f1e4c4ed2e7de407c0f8ac21ae6 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java @@ -25,30 +25,23 @@ package com.sun.tools.javadoc; -import com.sun.javadoc.*; - -import java.io.File; import java.io.InputStream; -import java.io.FileInputStream; import java.io.IOException; -import java.util.zip.ZipFile; -import java.util.zip.ZipEntry; +import javax.tools.FileObject; + +import com.sun.javadoc.*; import com.sun.tools.javac.code.Attribute; import com.sun.tools.javac.code.Scope; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.PackageSymbol; -import com.sun.tools.javac.comp.AttrContext; -import com.sun.tools.javac.comp.Env; import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Position; -import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; - - /** * Represents a java package. Provides access to information * about the package, the package's comment and tags, and the @@ -63,14 +56,10 @@ import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; public class PackageDocImpl extends DocImpl implements PackageDoc { - private static final String PACKAGE_HTML_FILE_NAME = "package.html"; - protected PackageSymbol sym; private JCCompilationUnit tree = null; // for source position - public String docPath = null; - public String zipDocPath = null; - public String zipDocEntry = null; + public FileObject docPath = null; private boolean foundDoc; // found a doc comment in either // package.html or package-info.java @@ -108,30 +97,16 @@ public class PackageDocImpl extends DocImpl implements PackageDoc { * Do lazy initialization of "documentation" string. */ String documentation() { - if (documentation != null) return documentation; - if (zipDocPath != null) { - try { - ZipFile f = new ZipFile(zipDocPath); - ZipEntry entry = f.getEntry(zipDocEntry); - if (entry != null) { - InputStream s = f.getInputStream(entry); - return (documentation = readHTMLDocumentation(s, - zipDocPath + File.separatorChar + zipDocEntry)); - } - } catch (IOException exc) { - documentation = ""; - env.error(null, "javadoc.File_Read_Error", - zipDocPath + File.separatorChar + zipDocEntry); - } - } + if (documentation != null) + return documentation; if (docPath != null) { // read from file try { - InputStream s = new FileInputStream(docPath); + InputStream s = docPath.openInputStream(); documentation = readHTMLDocumentation(s, docPath); } catch (IOException exc) { documentation = ""; - env.error(null, "javadoc.File_Read_Error", docPath); + env.error(null, "javadoc.File_Read_Error", docPath.getName()); } } else { // no doc file to be had @@ -363,24 +338,12 @@ public class PackageDocImpl extends DocImpl implements PackageDoc { /** * set doc path for an unzipped directory */ - public void setDocPath(String path) { + public void setDocPath(FileObject path) { setDocPath = true; if (path == null) return; - String newDocPath = path + File.separatorChar + PACKAGE_HTML_FILE_NAME; - if (!newDocPath.equals(docPath)) { - docPath = newDocPath; - checkDoc(); - } - } - - /** - * set the doc path for zipped directory - */ - public void setDocPath(String path, String entry) { - if (!path.equals(zipDocPath)) { - zipDocPath = path; - zipDocEntry = entry + PACKAGE_HTML_FILE_NAME; + if (!path.equals(docPath)) { + docPath = path; checkDoc(); } } @@ -409,7 +372,7 @@ public class PackageDocImpl extends DocImpl implements PackageDoc { */ public SourcePosition position() { return (tree != null) - ? SourcePositionImpl.make(tree.sourcefile + "", tree.pos, tree.lineMap) + ? SourcePositionImpl.make(tree.sourcefile, tree.pos, tree.lineMap) : SourcePositionImpl.make(docPath, Position.NOPOS, null); } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java index 8595151cc32ddbdfe3dc0c66435cefacdc468da5..e39f0b3e1d4c55a1b0a0f52b0aa9b880917f888c 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java @@ -26,13 +26,13 @@ package com.sun.tools.javadoc; import java.io.IOException; -import java.io.FileInputStream; -import java.io.File; +import java.util.Locale; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; import com.sun.javadoc.*; import com.sun.tools.javac.tree.JCTree.JCClassDecl; -import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Position; @@ -307,10 +307,13 @@ public class RootDocImpl extends DocImpl implements RootDoc { * Return the path of the overview file and null if it does not exist. * @return the path of the overview file and null if it does not exist. */ - private String getOverviewPath() { + private JavaFileObject getOverviewPath() { for (String[] opt : options) { if (opt[0].equals("-overview")) { - return opt[1]; + if (env.fileManager instanceof StandardJavaFileManager) { + StandardJavaFileManager fm = (StandardJavaFileManager) env.fileManager; + return fm.getJavaFileObjects(opt[1]).iterator().next(); + } } } return null; @@ -322,7 +325,7 @@ public class RootDocImpl extends DocImpl implements RootDoc { protected String documentation() { if (documentation == null) { int cnt = options.length(); - String overviewPath = getOverviewPath(); + JavaFileObject overviewPath = getOverviewPath(); if (overviewPath == null) { // no doc file to be had documentation = ""; @@ -330,11 +333,11 @@ public class RootDocImpl extends DocImpl implements RootDoc { // read from file try { documentation = readHTMLDocumentation( - new FileInputStream(overviewPath), + overviewPath.openInputStream(), overviewPath); } catch (IOException exc) { documentation = ""; - env.error(null, "javadoc.File_Read_Error", overviewPath); + env.error(null, "javadoc.File_Read_Error", overviewPath.getName()); } } } @@ -346,9 +349,16 @@ public class RootDocImpl extends DocImpl implements RootDoc { * no position is available. */ public SourcePosition position() { - String path; + JavaFileObject path; return ((path = getOverviewPath()) == null) ? null : SourcePositionImpl.make(path, Position.NOPOS, null); } + + /** + * Return the locale provided by the user or the default locale value. + */ + public Locale getLocale() { + return env.doclocale.locale; + } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java index 2225dd5337f4c7eb8d7839bcf427404570be3282..0e666b83f6dd5107777a8883ddb20c93339c6976 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java @@ -25,11 +25,12 @@ package com.sun.tools.javadoc; +import java.io.File; +import javax.tools.FileObject; + import com.sun.javadoc.SourcePosition; import com.sun.tools.javac.util.Position; -import java.io.File; - /** * A source position: filename, line number, and column number. * @@ -37,15 +38,21 @@ import java.io.File; * @author Neal M Gafter * @author Michael Van De Vanter (position representation changed to char offsets) */ -class SourcePositionImpl implements SourcePosition { - String filename; +public class SourcePositionImpl implements SourcePosition { + FileObject filename; int position; Position.LineMap lineMap; /** The source file. Returns null if no file information is * available. */ public File file() { - return (filename == null) ? null : new File(filename); + return (filename == null) ? null : new File(filename.getName()); + } + + /** The source file. Returns null if no file information is + * available. */ + public FileObject fileObject() { + return filename; } /** The line in the source file. The first line is numbered 1; @@ -71,7 +78,7 @@ class SourcePositionImpl implements SourcePosition { } } - private SourcePositionImpl(String file, int position, + private SourcePositionImpl(FileObject file, int position, Position.LineMap lineMap) { super(); this.filename = file; @@ -79,16 +86,27 @@ class SourcePositionImpl implements SourcePosition { this.lineMap = lineMap; } - public static SourcePosition make(String file, int pos, + public static SourcePosition make(FileObject file, int pos, Position.LineMap lineMap) { if (file == null) return null; return new SourcePositionImpl(file, pos, lineMap); } public String toString() { + // Backwards compatibility hack. ZipFileObjects use the format + // zipfile(zipentry) but javadoc has been using zipfile/zipentry + String fn = filename.toString(); + if (fn.endsWith(")")) { + int paren = fn.lastIndexOf("("); + if (paren != -1) + fn = fn.substring(0, paren) + + File.separatorChar + + fn.substring(paren + 1, fn.length() - 1); + } + if (position == Position.NOPOS) - return filename; + return fn; else - return filename + ":" + line(); + return fn + ":" + line(); } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java b/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java index 9e1a00ef3fddc7690b95609d7a856efccd2fc2d3..ec1bb1e800205f831a8945b11578f9cbb601954e 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java @@ -51,6 +51,7 @@ public class TypeMaker { * @param errToClassDoc if true, ERROR type results in a ClassDoc; * false preserves legacy behavior */ + @SuppressWarnings("fallthrough") public static com.sun.javadoc.Type getType(DocEnv env, Type t, boolean errToClassDoc) { if (env.legacyDoclet) { diff --git a/langtools/src/share/classes/com/sun/tools/javah/Gen.java b/langtools/src/share/classes/com/sun/tools/javah/Gen.java index 3ab6f961299e062a45c78ea1bc675e5cd779d9d5..1f0bb5ebd8337122ab0f04feba8af7b99d62fc13 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/Gen.java +++ b/langtools/src/share/classes/com/sun/tools/javah/Gen.java @@ -342,6 +342,6 @@ public abstract class Gen { fields.addAll(Arrays.asList(cd.fields())); } - return (FieldDoc[]) fields.toArray(new FieldDoc[fields.size()]); + return fields.toArray(new FieldDoc[fields.size()]); } } diff --git a/langtools/src/share/classes/com/sun/tools/javap/InternalError.java b/langtools/src/share/classes/com/sun/tools/javap/InternalError.java index 5397e7d267dccabd02b44ab0a36edfc59777ee3f..cc3903e0f1bfd57cef33ba47bdc4654076913ffd 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/InternalError.java +++ b/langtools/src/share/classes/com/sun/tools/javap/InternalError.java @@ -32,6 +32,7 @@ package com.sun.tools.javap; * deletion without notice. */ public class InternalError extends Error { + private static final long serialVersionUID = 8114054446416187030L; InternalError(Throwable t, Object... args) { super("Internal error", t); this.args = args; diff --git a/langtools/src/share/classes/javax/lang/model/type/MirroredTypeException.java b/langtools/src/share/classes/javax/lang/model/type/MirroredTypeException.java index bf5904b8a615090c378f05363204ecab64ddbb21..db729c59550ccf3c035f331050893534c3cf722c 100644 --- a/langtools/src/share/classes/javax/lang/model/type/MirroredTypeException.java +++ b/langtools/src/share/classes/javax/lang/model/type/MirroredTypeException.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2009 Sun Microsystems, Inc. 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 +25,8 @@ package javax.lang.model.type; - +import java.io.ObjectInputStream; +import java.io.IOException; import java.lang.annotation.Annotation; import javax.lang.model.element.Element; @@ -67,4 +68,13 @@ public class MirroredTypeException extends RuntimeException { public TypeMirror getTypeMirror() { return type; } + + /** + * Explicitly set all transient fields. + */ + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + s.defaultReadObject(); + type = null; + } } diff --git a/langtools/src/share/classes/javax/lang/model/type/MirroredTypesException.java b/langtools/src/share/classes/javax/lang/model/type/MirroredTypesException.java index 4ed0383d5ea4795724c47597582a53e6c99dfcc8..54efe41a7c9facd0642ca2830391882cc8000aff 100644 --- a/langtools/src/share/classes/javax/lang/model/type/MirroredTypesException.java +++ b/langtools/src/share/classes/javax/lang/model/type/MirroredTypesException.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2009 Sun Microsystems, Inc. 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,12 +25,12 @@ package javax.lang.model.type; - import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.List; import java.util.Collections; - +import java.io.ObjectInputStream; +import java.io.IOException; import javax.lang.model.element.Element; @@ -49,8 +49,7 @@ public class MirroredTypesException extends RuntimeException { private static final long serialVersionUID = 269; - // Should this be non-final for a custum readObject method? - private final transient List types; // cannot be serialized + private transient List types; // cannot be serialized /** * Constructs a new MirroredTypesException for the specified types. @@ -58,7 +57,9 @@ public class MirroredTypesException extends RuntimeException { * @param types the types being accessed */ public MirroredTypesException(List types) { - super("Attempt to access Class objects for TypeMirrors " + types); + super("Attempt to access Class objects for TypeMirrors " + + (types = // defensive copy + new ArrayList(types)).toString() ); this.types = Collections.unmodifiableList(types); } @@ -72,4 +73,13 @@ public class MirroredTypesException extends RuntimeException { public List getTypeMirrors() { return types; } + + /** + * Explicitly set all transient fields. + */ + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + s.defaultReadObject(); + types = null; + } } diff --git a/langtools/src/share/classes/sun/tools/javap/JavapPrinter.java b/langtools/src/share/classes/sun/tools/javap/JavapPrinter.java index a587ddc5d150649bec278c6c6c613faccf671e75..af5978aec267b94ba72c9ebf3c9612aebbbc0993 100644 --- a/langtools/src/share/classes/sun/tools/javap/JavapPrinter.java +++ b/langtools/src/share/classes/sun/tools/javap/JavapPrinter.java @@ -719,6 +719,7 @@ public class JavapPrinter { /** * Print constant pool entry information. */ + @SuppressWarnings("fallthrough") public int PrintlnConstantEntry(int cpx) { int size=1; byte tag=0; @@ -757,6 +758,7 @@ public class JavapPrinter { case CONSTANT_LONG: case CONSTANT_DOUBLE: size=2; + // fall through default: out.println(str+";"); } diff --git a/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java b/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java new file mode 100644 index 0000000000000000000000000000000000000000..4588d070b7e0279544688dbd7271dfbd13076933 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java @@ -0,0 +1,93 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6786682 + * @summary This test verifies the use of lang attribute by . + * @author Bhavesh Patel + * @library ../lib/ + * @build JavadocTester + * @build TestHtmlTag + * @run main TestHtmlTag + */ + +import java.util.Locale; + +public class TestHtmlTag extends JavadocTester { + + private static final String BUG_ID = "6786682"; + private static final String[][] TEST1 = { + {BUG_ID + FS + "pkg1" + FS + "C1.html", ""}, + {BUG_ID + FS + "pkg1" + FS + "package-summary.html", ""}}; + private static final String[][] NEGATED_TEST1 = { + {BUG_ID + FS + "pkg1" + FS + "C1.html", ""}}; + private static final String[][] TEST2 = { + {BUG_ID + FS + "pkg2" + FS + "C2.html", ""}, + {BUG_ID + FS + "pkg2" + FS + "package-summary.html", ""}}; + private static final String[][] NEGATED_TEST2 = { + {BUG_ID + FS + "pkg2" + FS + "C2.html", ""}}; + private static final String[][] TEST3 = { + {BUG_ID + FS + "pkg1" + FS + "C1.html", ""}, + {BUG_ID + FS + "pkg1" + FS + "package-summary.html", ""}}; + private static final String[][] NEGATED_TEST3 = { + {BUG_ID + FS + "pkg1" + FS + "C1.html", ""}}; + + private static final String[] ARGS1 = + new String[] { + "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"}; + private static final String[] ARGS2 = + new String[] { + "-locale", "ja", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg2"}; + private static final String[] ARGS3 = + new String[] { + "-locale", "en_US", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"}; + + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String[] args) { + TestHtmlTag tester = new TestHtmlTag(); + run(tester, ARGS1, TEST1, NEGATED_TEST1); + run(tester, ARGS2, TEST2, NEGATED_TEST2); + run(tester, ARGS3, TEST3, NEGATED_TEST3); + tester.printSummary(); + } + + /** + * {@inheritDoc} + */ + public String getBugId() { + return BUG_ID; + } + + /** + * {@inheritDoc} + */ + public String getBugName() { + return getClass().getName(); + } +} diff --git a/langtools/test/com/sun/javadoc/testHtmlTag/pkg1/C1.java b/langtools/test/com/sun/javadoc/testHtmlTag/pkg1/C1.java new file mode 100644 index 0000000000000000000000000000000000000000..5fb4bc8a30e40ce23cc360111292bf2ed67ced1e --- /dev/null +++ b/langtools/test/com/sun/javadoc/testHtmlTag/pkg1/C1.java @@ -0,0 +1,33 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package pkg1; + +public class C1 { + + public void method(int param1, int param2) { + + } +} diff --git a/langtools/test/com/sun/javadoc/testHtmlTag/pkg2/C2.java b/langtools/test/com/sun/javadoc/testHtmlTag/pkg2/C2.java new file mode 100644 index 0000000000000000000000000000000000000000..2bd9d323be8ca473c4de6ed3bc658e1d2dce2901 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testHtmlTag/pkg2/C2.java @@ -0,0 +1,31 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package pkg2; + +/** + * Comments: Class 2 + */ +public class C2 {} diff --git a/langtools/test/tools/javac/T6794959.java b/langtools/test/tools/javac/T6794959.java new file mode 100644 index 0000000000000000000000000000000000000000..d2ca623c9c14e5f8e058c4d9c47223cc8db50aaa --- /dev/null +++ b/langtools/test/tools/javac/T6794959.java @@ -0,0 +1,36 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6794959 + * @summary add new switch -XDexpectKeys=key,key,... + * @compile T6794959.java + * @compile/fail -XDfailcomplete=java.lang.String T6794959.java + * @compile -XDfailcomplete=java.lang.String -XDexpectKeys=compiler.err.cant.resolve.location T6794959.java + * @compile/fail -XDexpectKeys=compiler.err.cant.resolve.location T6794959.java + */ + +class T6794959 { + String s; +} diff --git a/langtools/test/tools/javac/cast/6795580/T6795580.java b/langtools/test/tools/javac/cast/6795580/T6795580.java new file mode 100644 index 0000000000000000000000000000000000000000..9539e32e0df94e6d6bf894b7d797ef6ab7a0d00a --- /dev/null +++ b/langtools/test/tools/javac/cast/6795580/T6795580.java @@ -0,0 +1,80 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @author Maurizio Cimadamore + * @bug 6795580 + * @summary parser confused by square brackets in qualified generic cast + * @compile/fail/ref=T6795580.out -XDrawDiagnostics T6795580.java + */ + +class T6795580 { + class Outer { + class Inner {} + } + + void cast1(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast2(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast3(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast4(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast5(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast6(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast7(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast8(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast9(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast10(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast11(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } +} \ No newline at end of file diff --git a/langtools/test/tools/javac/cast/6795580/T6795580.out b/langtools/test/tools/javac/cast/6795580/T6795580.out new file mode 100644 index 0000000000000000000000000000000000000000..f754e1dc2c5351cde251574d57600a58cb49acb4 --- /dev/null +++ b/langtools/test/tools/javac/cast/6795580/T6795580.out @@ -0,0 +1,8 @@ +T6795580.java:54:57: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:58:60: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:62:67: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:66:59: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:70:62: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:74:57: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:78:60: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +7 errors diff --git a/langtools/test/tools/javac/generics/rawOverride/6557199/T6557199.java b/langtools/test/tools/javac/generics/rawOverride/6557199/T6557199.java new file mode 100644 index 0000000000000000000000000000000000000000..abd31a0ba1ffb5709b90add7e5f254ced4d26d82 --- /dev/null +++ b/langtools/test/tools/javac/generics/rawOverride/6557199/T6557199.java @@ -0,0 +1,44 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6557199 + * @summary Fails to reject bad override of generic method + * @author Maurizio Cimadamore + * @compile/fail/ref=T6557199.out T6557199.java -XDrawDiagnostics + */ + +class T6557199 { + static class X { + public static X test() { + return null; + } + } + + static class B extends X { + public static B test() { + return null; + } + } +} diff --git a/langtools/test/tools/javac/generics/rawOverride/6557199/T6557199.out b/langtools/test/tools/javac/generics/rawOverride/6557199/T6557199.out new file mode 100644 index 0000000000000000000000000000000000000000..ee5b74bad50ebd4e768d36f8a426299a8ac8160c --- /dev/null +++ b/langtools/test/tools/javac/generics/rawOverride/6557199/T6557199.out @@ -0,0 +1,2 @@ +T6557199.java:40:25: compiler.err.prob.found.req: (- compiler.misc.override.incompatible.ret: (- compiler.misc.cant.override: test(), T6557199.B, test(), T6557199.X)), T6557199.B, T6557199.X +1 error