diff --git a/langtools/.hgignore b/langtools/.hgignore index e05f09317c534232825c66bc8532870f226b3463..e742c8561149047ca39062f42e7f48c59a1ecbbd 100644 --- a/langtools/.hgignore +++ b/langtools/.hgignore @@ -1,5 +1,6 @@ ^build/ ^dist/ +^.idea /nbproject/private/ ^.hgtip .DS_Store diff --git a/langtools/make/build.xml b/langtools/make/build.xml index b612a22715e3cca1f54d433742af02f9ed221736..a8a6ffe410467c9a492a1c695c984dedfe498adc 100644 --- a/langtools/make/build.xml +++ b/langtools/make/build.xml @@ -752,6 +752,17 @@ /> </target> + <!-- + **** IDE support + --> + + <target name="idea"> + <mkdir dir=".idea"/> + <copy todir=".idea" > + <fileset dir="make/intellij" includes="**"/> + </copy> + <replace file=".idea/ant.xml" token="@@@" value="${jtreg.home}"/> + </target> <!-- **** Check targets. diff --git a/langtools/make/intellij/ant.xml b/langtools/make/intellij/ant.xml new file mode 100644 index 0000000000000000000000000000000000000000..dee4939b60cd5e3c6f7391ea31a4cca54b7bf94a --- /dev/null +++ b/langtools/make/intellij/ant.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="AntConfiguration"> + <buildFile url="file://$PROJECT_DIR$/.idea/build.xml"> + <properties> + <property name="boot.java.home" value="$JDKPath$" /> + <property name="jtreg.tests" value="$FilePath$" /> + <property name="target.java.home" value="$JDKPath$" /> + <property name="jtreg.home" value="@@@" /> + <property name="javac.debuglevel" value="source,lines,vars" /> + <property name="jtreg.jpda.jvmargs" value="-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5900,suspend=y" /> + </properties> + <executeOn event="afterCompilation" target="build-all-classes" /> + </buildFile> + </component> +</project> + + diff --git a/langtools/make/intellij/build.xml b/langtools/make/intellij/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..24bdb3d46543a5db77e17fc5b5ae76f63627be0c --- /dev/null +++ b/langtools/make/intellij/build.xml @@ -0,0 +1,36 @@ +<!-- importing.xml --> +<project name="langtools" basedir=".."> + <import file="../make/build.xml"/> + + <target name="jtreg-debug" depends="build-all-tools,-def-jtreg"> + <exec-target target="jtreg-debug-internal"/> + </target> + + <target name="jtreg-debug-internal" depends="build-all-tools,-def-jtreg"> + <sequential> + <sleep seconds="2"/> + <jtreg-tool name="all" tests="${jtreg.tests}" jpda.jvmargs="${jtreg.jpda.jvmargs}"/> + </sequential> + </target> + + <macrodef name="exec-target"> + <attribute name="antfile" default="${ant.file}" /> + <attribute name="target" /> + <sequential> + <java classname="org.apache.tools.ant.Main" fork="true" spawn="true"> + <arg value="-f"/> + <arg value="@{antfile}"/> + <arg value="-Dboot.java.home=${boot.java.home}"/> + <arg value="-Dtarget.java.home=${target.java.home}"/> + <arg value="-Djtreg.home=${jtreg.home}"/> + <arg value="-Djtreg.tests=${jtreg.tests}"/> + <arg value="-Djtreg.jpda.jvmargs=${jtreg.jpda.jvmargs}"/> + <arg value="@{target}"/> + <classpath> + <pathelement path="${java.class.path}"/> + </classpath> + </java> + </sequential> + </macrodef> +</project> + diff --git a/langtools/make/intellij/codeStyleSettings.xml b/langtools/make/intellij/codeStyleSettings.xml new file mode 100644 index 0000000000000000000000000000000000000000..076a0fb657ca59973e94011f7d69d0cf17f63963 --- /dev/null +++ b/langtools/make/intellij/codeStyleSettings.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectCodeStyleSettingsManager"> + <option name="PER_PROJECT_SETTINGS"> + <value> + <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" /> + <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" /> + <option name="RIGHT_MARGIN" value="80" /> + <XML> + <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> + </XML> + </value> + </option> + <option name="USE_PER_PROJECT_SETTINGS" value="true" /> + </component> +</project> + diff --git a/langtools/make/intellij/compiler.xml b/langtools/make/intellij/compiler.xml new file mode 100644 index 0000000000000000000000000000000000000000..83881c52d346afe90793271b056fb835348672bc --- /dev/null +++ b/langtools/make/intellij/compiler.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CompilerConfiguration"> + <option name="DEFAULT_COMPILER" value="Javac" /> + <excludeFromCompile> + <directory url="file://$PROJECT_DIR$/test" includeSubdirectories="true" /> + </excludeFromCompile> + <resourceExtensions /> + <wildcardResourcePatterns> + <entry name="!?*.java" /> + <entry name="!?*.form" /> + <entry name="!?*.class" /> + <entry name="!?*.groovy" /> + <entry name="!?*.scala" /> + <entry name="!?*.flex" /> + <entry name="!?*.kt" /> + <entry name="!?*.clj" /> + </wildcardResourcePatterns> + <annotationProcessing> + <profile default="true" name="Default" enabled="false"> + <processorPath useClasspath="true" /> + </profile> + </annotationProcessing> + </component> + <component name="JavacSettings"> + <option name="DEBUGGING_INFO" value="false" /> + <option name="ADDITIONAL_OPTIONS_STRING" value="-Xlint:all -Werror" /> + </component> +</project> + diff --git a/langtools/make/intellij/inspectionProfiles/langtools.xml b/langtools/make/intellij/inspectionProfiles/langtools.xml new file mode 100644 index 0000000000000000000000000000000000000000..48316e07259064a340170c34865b25e67831967b --- /dev/null +++ b/langtools/make/intellij/inspectionProfiles/langtools.xml @@ -0,0 +1,26 @@ +<component name="InspectionProjectProfileManager"> + <profile version="1.0" is_locked="false"> + <option name="myName" value="langtools" /> + <option name="myLocal" value="false" /> + <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false"> + <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" /> + <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" /> + </inspection_tool> + <inspection_tool class="MismatchedCollectionQueryUpdate" enabled="false" level="WARNING" enabled_by_default="false"> + <option name="queryNames"> + <value /> + </option> + <option name="updateNames"> + <value /> + </option> + </inspection_tool> + <inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true"> + <option name="processCode" value="false" /> + <option name="processLiterals" value="false" /> + <option name="processComments" value="false" /> + </inspection_tool> + <inspection_tool class="SuspiciousMethodCalls" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="REPORT_CONVERTIBLE_METHOD_CALLS" value="false" /> + </inspection_tool> + </profile> +</component> diff --git a/langtools/make/intellij/inspectionProfiles/profiles_settings.xml b/langtools/make/intellij/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..a7b1624fa99190420b45d3615f197bc6dca6663d --- /dev/null +++ b/langtools/make/intellij/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ +<component name="InspectionProjectProfileManager"> + <settings> + <option name="PROJECT_PROFILE" value="langtools" /> + <option name="USE_PROJECT_PROFILE" value="true" /> + <version value="1.0" /> + </settings> +</component> diff --git a/langtools/make/intellij/langtools.iml b/langtools/make/intellij/langtools.iml new file mode 100644 index 0000000000000000000000000000000000000000..1b6c00b880962da0bbfb71b7497a8ca26c02d0d2 --- /dev/null +++ b/langtools/make/intellij/langtools.iml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/build/gensrc" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/share/classes" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" /> + </content> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="inheritedJdk" /> + </component> +</module> + diff --git a/langtools/make/intellij/misc.xml b/langtools/make/intellij/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..6428d6a8e2b0ff7128563438b1cf721fe432da31 --- /dev/null +++ b/langtools/make/intellij/misc.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="EntryPointsManager"> + <entry_points version="2.0" /> + </component> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true"> + <output url="file://$PROJECT_DIR$/build/intellij" /> + </component> +</project> + diff --git a/langtools/make/intellij/modules.xml b/langtools/make/intellij/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..a1884d5a0d7f951d470011294f3c2d14ea3ea636 --- /dev/null +++ b/langtools/make/intellij/modules.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/langtools.iml" filepath="$PROJECT_DIR$/.idea/langtools.iml" /> + </modules> + </component> +</project> + diff --git a/langtools/make/intellij/vcs.xml b/langtools/make/intellij/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..94ad9258305dc1952d039f4252b74adaefb2cca9 --- /dev/null +++ b/langtools/make/intellij/vcs.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$" vcs="hg4idea" /> + </component> +</project> + diff --git a/langtools/make/intellij/workspace.xml b/langtools/make/intellij/workspace.xml new file mode 100644 index 0000000000000000000000000000000000000000..8348254caa5952f877b6809a20e5ae1145e40d22 --- /dev/null +++ b/langtools/make/intellij/workspace.xml @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ChangeListManager"> + <ignored path=".idea/" /> + </component> + <component name="CompilerWorkspaceConfiguration"> + <option name="MAKE_PROJECT_ON_SAVE" value="true" /> + </component> + <component name="RunManager" selected="Application.javac"> + <configuration default="false" name="javac" type="Application" factoryName="Application"> + <option name="MAIN_CLASS_NAME" value="com.sun.tools.javac.Main" /> + <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build/classes" /> + <option name="PROGRAM_PARAMETERS" value="" /> + <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> + <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> + <option name="ALTERNATIVE_JRE_PATH" value="" /> + <option name="ENABLE_SWING_INSPECTOR" value="false" /> + <option name="ENV_VARIABLES" /> + <option name="PASS_PARENT_ENVS" value="true" /> + <module name="langtools" /> + <envs /> + <method /> + </configuration> + <configuration default="false" name="javadoc" type="Application" factoryName="Application"> + <option name="MAIN_CLASS_NAME" value="com.sun.tools.javadoc.Main" /> + <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build/classes" /> + <option name="PROGRAM_PARAMETERS" value="" /> + <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> + <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> + <option name="ALTERNATIVE_JRE_PATH" value="" /> + <option name="ENABLE_SWING_INSPECTOR" value="false" /> + <option name="ENV_VARIABLES" /> + <option name="PASS_PARENT_ENVS" value="true" /> + <module name="langtools" /> + <envs /> + <method /> + </configuration> + <configuration default="false" name="javap" type="Application" factoryName="Application"> + <option name="MAIN_CLASS_NAME" value="com.sun.tools.javap.Main" /> + <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build/classes" /> + <option name="PROGRAM_PARAMETERS" value="" /> + <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> + <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> + <option name="ALTERNATIVE_JRE_PATH" value="" /> + <option name="ENABLE_SWING_INSPECTOR" value="false" /> + <option name="ENV_VARIABLES" /> + <option name="PASS_PARENT_ENVS" value="true" /> + <module name="langtools" /> + <envs /> + <method /> + </configuration> + <configuration default="false" name="javah" type="Application" factoryName="Application"> + <option name="MAIN_CLASS_NAME" value="com.sun.tools.javah.Main" /> + <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build/classes" /> + <option name="PROGRAM_PARAMETERS" value="" /> + <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> + <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> + <option name="ALTERNATIVE_JRE_PATH" value="" /> + <option name="ENABLE_SWING_INSPECTOR" value="false" /> + <option name="ENV_VARIABLES" /> + <option name="PASS_PARENT_ENVS" value="true" /> + <module name="langtools" /> + <envs /> + <method /> + </configuration> + <configuration default="false" name="jdeps" type="Application" factoryName="Application"> + <option name="MAIN_CLASS_NAME" value="com.sun.tools.jdeps.Main" /> + <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build/classes" /> + <option name="PROGRAM_PARAMETERS" value="" /> + <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> + <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> + <option name="ALTERNATIVE_JRE_PATH" value="" /> + <option name="ENABLE_SWING_INSPECTOR" value="false" /> + <option name="ENV_VARIABLES" /> + <option name="PASS_PARENT_ENVS" value="true" /> + <module name="langtools" /> + <envs /> + <method /> + </configuration> + <configuration default="false" name="sjavac" type="Application" factoryName="Application"> + <option name="MAIN_CLASS_NAME" value="com.sun.tools.sjavac.Main" /> + <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build/classes" /> + <option name="PROGRAM_PARAMETERS" value="" /> + <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> + <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> + <option name="ALTERNATIVE_JRE_PATH" value="" /> + <option name="ENABLE_SWING_INSPECTOR" value="false" /> + <option name="ENV_VARIABLES" /> + <option name="PASS_PARENT_ENVS" value="true" /> + <module name="langtools" /> + <envs /> + <method /> + </configuration> + <configuration default="false" name="jtreg (remote)" type="Remote" factoryName="Remote" singleton="true"> + <option name="USE_SOCKET_TRANSPORT" value="true" /> + <option name="SERVER_MODE" value="true" /> + <option name="SHMEM_ADDRESS" /> + <option name="HOST" value="localhost" /> + <option name="PORT" value="5900" /> + <RunnerSettings RunnerId="Debug"> + <option name="DEBUG_PORT" value="5900" /> + <option name="TRANSPORT" value="0" /> + <option name="LOCAL" value="false" /> + </RunnerSettings> + <ConfigurationWrapper RunnerId="Debug" /> + <method> + <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="jtreg-debug" /> + </method> + <method /> + </configuration> + <list size="7"> + <item index="0" class="java.lang.String" itemvalue="Application.javac" /> + <item index="1" class="java.lang.String" itemvalue="Application.javadoc" /> + <item index="2" class="java.lang.String" itemvalue="Application.javap" /> + <item index="3" class="java.lang.String" itemvalue="Application.javah" /> + <item index="4" class="java.lang.String" itemvalue="Application.jdeps" /> + <item index="5" class="java.lang.String" itemvalue="Application.sjavac" /> + <item index="6" class="java.lang.String" itemvalue="Remote.jtreg" /> + </list> + </component> + <component name="antWorkspaceConfiguration"> + <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" /> + <option name="FILTER_TARGETS" value="false" /> + <buildFile url="file://$PROJECT_DIR$/.idea/build.xml"> + <runInBackground value="false" /> + <targetFilters> + <filter targetName="build-all-tools" isVisible="true" /> + <filter targetName="build-all-classes" isVisible="true" /> + <filter targetName="clean" isVisible="true" /> + <filter targetName="jtreg" isVisible="true" /> + <filter targetName="jtreg-debug" isVisible="true" /> + <filter targetName="checkstyle" isVisible="true" /> + </targetFilters> + <viewClosedWhenNoErrors value="false" /> + <expanded value="false" /> + </buildFile> + </component> +</project> + diff --git a/langtools/src/share/classes/com/sun/javadoc/AnnotatedType.java b/langtools/src/share/classes/com/sun/javadoc/AnnotatedType.java index c39260e0faf827c44f3df41f19190e596f6d6cac..01d07dbaa166ad774358543df36aaac5470a8c8c 100644 --- a/langtools/src/share/classes/com/sun/javadoc/AnnotatedType.java +++ b/langtools/src/share/classes/com/sun/javadoc/AnnotatedType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,15 @@ package com.sun.javadoc; */ public interface AnnotatedType extends Type { + /** + * Returns the annotations associated with this type. + * @return the annotations associated with this type + */ AnnotationDesc[] annotations(); + /** + * Returns the underlying type. + * @return the underlying type + */ Type underlyingType(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java index 254042ebdb6019cd8d93b70fe2ee949863caa07e..86d236f92951c7712d9d6dee19701281d07d788b 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,10 +35,36 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface AttributeTree extends DocTree { + /** + * The kind of an attribute value. + */ @jdk.Exported - enum ValueKind { EMPTY, UNQUOTED, SINGLE, DOUBLE } + enum ValueKind { + /** The attribute value is empty. */ + EMPTY, + /** The attribute value is not enclosed in quotes. */ + UNQUOTED, + /** The attribute value is enclosed in single quotation marks. */ + SINGLE, + /** The attribute value is enclosed in double quotation marks. */ + DOUBLE + } + /** + * Returns the name of the attribute. + * @return the name of the attribute + */ Name getName(); + + /** + * Returns the kind of the attribute. + * @return the kind of the attribute. + */ ValueKind getValueKind(); + + /** + * Returns the value of the attribute, or {@code null} if the kind is EMPTY. + * @return the value of the attribute. + */ List<? extends DocTree> getValue(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java index 5df14f3b623e818ac116d40996fc33df6e5acbcf..4dce58feff9b1d1e9fbd5bf0817a09492cd29540 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface AuthorTree extends BlockTagTree { + /** + * Returns the name of the author. + * @return the name + */ List<? extends DocTree> getName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java index 9f709398924065d35c168cc647e51d83e4c5d9e7..2284f01057f35c55ff69ed04235ac1d9aad1954c 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,5 +33,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface BlockTagTree extends DocTree { + /** + * Returns the name of the tag. + * @return the name of the tag + */ String getTagName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java index c821c121cb56dc18906e87a33d3063397fb8f9dd..346b15427147fa3f4900224a467b6b87c9716ddc 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,10 @@ package com.sun.source.doctree; */ @jdk.Exported public interface CommentTree extends DocTree { + /** + * Returns the text of the comment. + * @return the comment text + */ String getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java index 6757f43cc7a9da8fef3f309182a9c51f0f0edb33..bfcebcf739343f097bed3d159aa49ec754f087b2 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface DeprecatedTree extends BlockTagTree { + /** + * Returns the description explaining why an item is deprecated. + * @return the description + */ List<? extends DocTree> getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java index 8c55e694c4e999fb3f3f1e9ec640bf3be9368a40..f00fbb30576cbde0ed6e89a8d9ec84c40d472526 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,22 @@ import java.util.List; */ @jdk.Exported public interface DocCommentTree extends DocTree { + /** + * Returns the first sentence of a documentation comment. + * @return the first sentence of a documentation comment + */ List<? extends DocTree> getFirstSentence(); + + /** + * Returns the body of a documentation comment, + * appearing after the first sentence, and before any block tags. + * @return the body of a documentation comment + */ List<? extends DocTree> getBody(); + + /** + * Returns the block tags for a documentation comment. + * @return the block tags of a documentation comment + */ List<? extends DocTree> getBlockTags(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocTree.java b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java index 3c6e70810ea887475fdbfe6ec563161c93b41a5d..5d728ee1aab16f2149aed50104531d3e6525ff7d 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/DocTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface DocTree { + /** + * Enumerates all kinds of trees. + */ @jdk.Exported enum Kind { /** @@ -227,6 +230,9 @@ public interface DocTree { */ OTHER; + /** + * The name of the tag, if any, associated with this kind of node. + */ public final String tagName; Kind() { @@ -239,7 +245,7 @@ public interface DocTree { } /** - * Gets the kind of this tree. + * Returns the kind of this tree. * * @return the kind of this tree. */ @@ -251,6 +257,9 @@ public interface DocTree { * * @param <R> result type of this operation. * @param <D> type of additional data. + * @param visitor the visitor to be called + * @param data a parameter value to be passed to the visitor method + * @return the value returned from the visitor method */ <R, D> R accept(DocTreeVisitor<R,D> visitor, D data); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java index 67e67f881ff6814c0c118b174bf36f4ffe56b797..fdfa116fc632273e499aff54ebf2d559b17ffd7e 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,33 +56,238 @@ package com.sun.source.doctree; */ @jdk.Exported public interface DocTreeVisitor<R,P> { + + /** + * Visits an AttributeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitAttribute(AttributeTree node, P p); + + /** + * Visits an AuthorTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitAuthor(AuthorTree node, P p); + + /** + * Visits a CommentTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitComment(CommentTree node, P p); + + /** + * Visits a DeprecatedTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitDeprecated(DeprecatedTree node, P p); + + /** + * Visits a DocCommentTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitDocComment(DocCommentTree node, P p); + + /** + * Visits a DocRootTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitDocRoot(DocRootTree node, P p); + + /** + * Visits an EndElementTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitEndElement(EndElementTree node, P p); + + /** + * Visits an EntityTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitEntity(EntityTree node, P p); + + /** + * Visits an ErroneousTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitErroneous(ErroneousTree node, P p); + + /** + * Visits an IdentifierTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitIdentifier(IdentifierTree node, P p); + + /** + * Visits an InheritDocTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitInheritDoc(InheritDocTree node, P p); + + /** + * Visits a LinkTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitLink(LinkTree node, P p); + + /** + * Visits an LiteralTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitLiteral(LiteralTree node, P p); + + /** + * Visits a ParamTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitParam(ParamTree node, P p); + + /** + * Visits a ReferenceTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitReference(ReferenceTree node, P p); + + /** + * Visits a ReturnTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitReturn(ReturnTree node, P p); + + /** + * Visits a SeeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSee(SeeTree node, P p); + + /** + * Visits a SerialTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSerial(SerialTree node, P p); + + /** + * Visits a SerialDataTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSerialData(SerialDataTree node, P p); + + /** + * Visits a SerialFieldTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSerialField(SerialFieldTree node, P p); + + /** + * Visits a SinceTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSince(SinceTree node, P p); + + /** + * Visits a StartElementTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitStartElement(StartElementTree node, P p); + + /** + * Visits a TextTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitText(TextTree node, P p); + + /** + * Visits a ThrowsTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitThrows(ThrowsTree node, P p); + + /** + * Visits an UnknownBlockTagTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitUnknownBlockTag(UnknownBlockTagTree node, P p); + + /** + * Visits an UnknownInlineTagTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitUnknownInlineTag(UnknownInlineTagTree node, P p); + + /** + * Visits a ValueTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitValue(ValueTree node, P p); + + /** + * Visits a VersionTreeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitVersion(VersionTree node, P p); + + /** + * Visits an unknown type of DocTree node. + * This can occur if the set of tags evolves and new kinds + * of nodes are added to the {@code DocTree} hierarchy. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitOther(DocTree node, P p); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java index 9e201b0a12419d78233ea3aa5b2874526058c41f..e54e3082d08bc0ea3c93950e2504ac21171137f3 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,5 +37,9 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface EndElementTree extends DocTree { + /** + * Returns the name of this element. + * @return the name + */ Name getName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java index d9bbed850723877b85686c4948fc335051364b5e..5431fd7057c227e9f4a2a438797970cfb91b5683 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,11 +32,17 @@ import javax.lang.model.element.Name; * A tree node for an HTML entity. * * <p> - * & name ; + * & name ; <br> + * & # digits ; <br> + * & #X hex-digits ; * * @since 1.8 */ @jdk.Exported public interface EntityTree extends DocTree { + /** + * Returns the name or value of the entity. + * @return the name or value of the entity + */ Name getName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java index ea5e632176091096de23d67cd8df4184f6280366..1ece1e62887c9ffa9f3a30d7e2230d7430a449ec 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ import javax.tools.JavaFileObject; @jdk.Exported public interface ErroneousTree extends TextTree { /** - * Gets a diagnostic object giving details about + * Returns a diagnostic object giving details about * the reason the body text is in error. * * @return a diagnostic diff --git a/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java index 73419d7e972df1c48b61496979f29bf2c8682ce7..a82bf142976283284d185ae45207f1a41858601d 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,5 +37,9 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface IdentifierTree extends DocTree { + /** + * Returns the name of the identifier. + * @return the name + */ Name getName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java index 7b8ec247099040dfa9968e158c5b0bd6bdb585b1..6cbf1fc425883e8dd3cad8559f8bd67e7e25e028 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,5 +33,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface InlineTagTree extends DocTree { + /** + * Returns the name of the tag. + * @return the name of the tag + */ String getTagName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java index ba7d6e972a78c290a6d7e0c7ecfab20af3e509e8..1f4a0a12ded328bd964ac735dcd102829ed1c7b9 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,6 +38,15 @@ import java.util.List; */ @jdk.Exported public interface LinkTree extends InlineTagTree { + /** + * Returns the reference of a link. + * @return the reference + */ ReferenceTree getReference(); + + /** + * Returns the label, if any, of the link. + * @return the label + */ List<? extends DocTree> getLabel(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java index 6c5d0d839e102c672f38504e7b9fe670715ccf1e..91727ccd4028b764e3fab1be57a1a96c5c1b6b07 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,5 +36,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface LiteralTree extends InlineTagTree { + /** + * Returns the body of the {@code @code} or {@code @literal} tag. + * @return the body of the tag + */ TextTree getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java index 67935315373f70100916ce492fb95fb480b2f44b..b721783e4939cb77a26ad95547983bcf5985b776 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,21 @@ import java.util.List; */ @jdk.Exported public interface ParamTree extends BlockTagTree { + /** + * Returns true if this is documenting a type parameter. + * @return true if this is documenting a type parameter + */ boolean isTypeParameter(); + + /** + * Returns the name of the parameter. + * @return the name of the parameter + */ IdentifierTree getName(); + + /** + * Returns the description of the parameter. + * @return the description + */ List<? extends DocTree> getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java index 76a0311eaeb633bb87ac46e2f7049541c7a16ef1..ab62303670254a6fc3c24454f4097e5db84413ef 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,14 +26,20 @@ package com.sun.source.doctree; /** - * A tree node to a reference to a Java language element. + * A tree node for a reference to a Java language element. * * <p> * package.class#field + * package.class#method(<i>arg-types</i>) * * @since 1.8 */ @jdk.Exported public interface ReferenceTree extends DocTree { + /** + * Returns the signature of the Java language element being referenced, + * as found in {@code @see} and similar nodes. + * @return the signature. + */ String getSignature(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java index 72bdf5b915a91460c244ae017e5377608d649a2f..305c92c19dc10571a45f102e7812a3385414a059 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface ReturnTree extends BlockTagTree { + /** + * Returns the description of the return value of a method. + * @return the description + */ List<? extends DocTree> getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java index 1ddac77edb9d0cbaf581118b93f5ffe2449e2440..4ff81c0f6ec1cbb4fbf4b01957759d9a72fa1ddc 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,5 +40,9 @@ import java.util.List; */ @jdk.Exported public interface SeeTree extends BlockTagTree { + /** + * Returns the reference. + * @return the reference + */ List<? extends DocTree> getReference(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java index b281e372641d70380892a09a888f54f9c56caa55..90757595c6640247bd968dfb30c5cc5c279c03a0 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface SerialDataTree extends BlockTagTree { + /** + * Returns the description of the serial data. + * @return the description + */ List<? extends DocTree> getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java index 6ea77bab7527b9696e8d823b9045e919558d5484..ff7c25a919d349b481ea0438002880900b5096f6 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,21 @@ import java.util.List; */ @jdk.Exported public interface SerialFieldTree extends BlockTagTree { + /** + * Returns the name of the serial field. + * @return the name of the serial field + */ IdentifierTree getName(); + + /** + * Returns the type of the serial field. + * @return the type of the serial field + */ ReferenceTree getType(); + + /** + * Returns the description of the serial field. + * @return the description of the serial field + */ List<? extends DocTree> getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java index 3812569cdac05d755b0151cb3f6010b5545339f1..04feab793b32c25eb9f498a2f6cb771fcb6fd368 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,5 +37,10 @@ import java.util.List; */ @jdk.Exported public interface SerialTree extends BlockTagTree { + /** + * Returns the description of the field, or the word + * "include" or "exclude". + * @return the description of the field + */ List<? extends DocTree> getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java index d21be4c52fd1270108d3fd6618bd03da77e19520..074aebd4cfffe582b552aacadf4652ea02dcad5e 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface SinceTree extends BlockTagTree { + /** + * Returns the text explaining the availability of the item being documented. + * @return the text + */ List<? extends DocTree> getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java index 1bac6e566d56c43de710f71d40326c18622fe14f..34f98e8ec710f77703404b5ce4bbb5b358ce8ae1 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,22 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface StartElementTree extends DocTree { + /** + * Returns the name of the element. + * @return the name + */ Name getName(); + + /** + * Returns any attributes defined by this element. + * @return the attributes + */ List<? extends DocTree> getAttributes(); + + /** + * Returns true if this is a self-closing element, + * as indicated by a "/" before the closing ">". + * @return true if this is a self-closing element + */ boolean isSelfClosing(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/TextTree.java b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java index 1d03109eb8a66aeeddef53c14081012c43c64bd7..f2adf029dfccaa2d0a2a89b3844ffb81b80f5c48 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/TextTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,5 +32,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface TextTree extends DocTree { + /** + * Returns the text. + * @return the text + */ String getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java index cde8360c7dc3f2ee71f25431a21650a263800eb2..1f34046958205e2bdd4f48bd7c043734586f560d 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,16 @@ import java.util.List; */ @jdk.Exported public interface ThrowsTree extends BlockTagTree { + /** + * Returns a name of the exception being documented. + * @return the name of the exception + */ ReferenceTree getExceptionName(); + + /** + * Returns the description of the reasons why the + * exception may be thrown. + * @return the description + */ List<? extends DocTree> getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java index 701cdbfabd16f1f2185aec21467142306476429c..47739a6b791f75a92a2dab0218f2d1e6189ae91f 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface UnknownBlockTagTree extends BlockTagTree { + /** + * Returns the content of an unrecognized block tag. + * @return the content + */ List<? extends DocTree> getContent(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java index a67b6e8c19219380bf79b88b8e350ed4f7c0e5a9..9a0eb294976193cb4758a3bf6ee7804b5b0929a2 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface UnknownInlineTagTree extends InlineTagTree { + /** + * Returns the content of an unrecognized inline tag. + * @return the content + */ List<? extends DocTree> getContent(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java index bc7f2f91f9bc3b09c6b946d17fa45943324a9983..5c792b5bb1d68c409bb34cc8324cf96bcbd92330 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,5 +35,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface ValueTree extends InlineTagTree { + /** + * Returns the reference to the value. + * @return the reference + */ ReferenceTree getReference(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java index b54ddeb7ff3683901be2bb7b4f4502d7df1ac212..eee4237aab806c24eaa67abf287d450087a67866 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,5 +38,9 @@ import java.util.List; */ @jdk.Exported public interface VersionTree extends BlockTagTree { + /** + * Returns the body of the tag. + * @return the body + */ List<? extends DocTree> getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java index 37fc95b93cd4855cb0c502089e1c77f60a68c5bc..d84fcd60730c007ddd20166bef07c8551e475fe2 100644 --- a/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ package com.sun.source.tree; import java.util.List; /** - * A tree node for an annotated type + * A tree node for an annotated type. * * For example: * <pre> @@ -43,6 +43,15 @@ import java.util.List; */ @jdk.Exported public interface AnnotatedTypeTree extends ExpressionTree { + /** + * Returns the annotations associated with this type expression. + * @return the annotations + */ List<? extends AnnotationTree> getAnnotations(); + + /** + * Returns the underlying type with which the annotations are associated. + * @return the underlying type + */ ExpressionTree getUnderlyingType(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java b/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java index 01c6c42dbf3a09ea71c7453665f7cae3e040a857..b47cdbced84fb66e03e1f1e2b0181a5c4e875ba6 100644 --- a/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,15 @@ import java.util.List; */ @jdk.Exported public interface AnnotationTree extends ExpressionTree { + /** + * Returns the annotation type. + * @return the annotation type + */ Tree getAnnotationType(); + + /** + * Returns the arguments, if any, for the annotation. + * @return the arguments for the annotation type + */ List<? extends ExpressionTree> getArguments(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java b/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java index a8c969985ff61ebb2270ac7f1f468cba604671b0..515aee06d5f2e76f2e588fe1748f05afdeb5e3de 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,15 @@ package com.sun.source.tree; */ @jdk.Exported public interface ArrayAccessTree extends ExpressionTree { + /** + * Returns the expression for the array being accessed. + * @return the array + */ ExpressionTree getExpression(); + + /** + * Returns the expression for the index. + * @return the index + */ ExpressionTree getIndex(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java index c253a3b69c9a78d76d9a045009f471c877516fe4..d7d8ceb55d827a0b2322d4957bef8495436da95b 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,5 +41,9 @@ package com.sun.source.tree; */ @jdk.Exported public interface ArrayTypeTree extends Tree { + /** + * Returns the element type of this array type. + * @return the element type + */ Tree getType(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/AssertTree.java b/langtools/src/share/classes/com/sun/source/tree/AssertTree.java index f2c824ea0a4493c4b4918be3518b866a708d6a6c..080bc3ee5f70121dd84f0ee030f39b171516307c 100644 --- a/langtools/src/share/classes/com/sun/source/tree/AssertTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/AssertTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for an 'assert' statement. + * A tree node for an {@code assert} statement. * * For example: * <pre> @@ -43,6 +43,15 @@ package com.sun.source.tree; */ @jdk.Exported public interface AssertTree extends StatementTree { + /** + * Returns the condition being asserted. + * @return the condition + */ ExpressionTree getCondition(); + + /** + * Returns the detail expression. + * @return the detail expression + */ ExpressionTree getDetail(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java b/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java index 63f671f40d640fbb8ce2936655252a904288f20e..5ce69d24e8f7e28280734920d883c005ba509f3d 100644 --- a/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,15 @@ package com.sun.source.tree; */ @jdk.Exported public interface AssignmentTree extends ExpressionTree { + /** + * Returns the variable being assigned to. + * @return the variable + */ ExpressionTree getVariable(); + + /** + * Returns the expression being assigned to the variable. + * @return the expression + */ ExpressionTree getExpression(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java b/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java index f280fc1140a0a87f55ff1dc02bec7c7f7812376c..8f0d155f3344cbd45ffe6e1f90482eb62dc5290a 100644 --- a/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,15 @@ package com.sun.source.tree; */ @jdk.Exported public interface BinaryTree extends ExpressionTree { + /** + * Returns the left (first) operand of the expression. + * @return the left operand + */ ExpressionTree getLeftOperand(); + + /** + * Returns the right (second) operand of the expression. + * @return the right operand + */ ExpressionTree getRightOperand(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/BlockTree.java b/langtools/src/share/classes/com/sun/source/tree/BlockTree.java index 8d15bd7ed6e04734fa0f34ba1f2546bbf241e4bb..4b5721e1aa30e5321bfb9375f5826ba711186c1a 100644 --- a/langtools/src/share/classes/com/sun/source/tree/BlockTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/BlockTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,15 @@ import java.util.List; */ @jdk.Exported public interface BlockTree extends StatementTree { + /** + * Returns true if and only if this is a static initializer block. + * @return true if this is a static initializer block + */ boolean isStatic(); + + /** + * Returns the statements comprising this block. + * @return the statements + */ List<? extends StatementTree> getStatements(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/BreakTree.java b/langtools/src/share/classes/com/sun/source/tree/BreakTree.java index c51731bbeb47482f59bd5209e1e0c63b7b0fd523..4f900a62ba83ded3060c9619aced9fdebc2c84fa 100644 --- a/langtools/src/share/classes/com/sun/source/tree/BreakTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/BreakTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ package com.sun.source.tree; import javax.lang.model.element.Name; /** - * A tree node for a 'break' statement. + * A tree node for a {@code break} statement. * * For example: * <pre> @@ -45,5 +45,9 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface BreakTree extends StatementTree { + /** + * Returns the label for this {@code break} statement. + * @return the label + */ Name getLabel(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/CaseTree.java b/langtools/src/share/classes/com/sun/source/tree/CaseTree.java index 01e61c3fa801782c531d9edc05c0c460ec073b03..6aa374f1cb5a0d2a6656655fce23d172c2fe99d3 100644 --- a/langtools/src/share/classes/com/sun/source/tree/CaseTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/CaseTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ package com.sun.source.tree; import java.util.List; /** - * A tree node for a 'case' in a 'switch' statement. + * A tree node for a {@code case} in a {@code switch} statement. * * For example: * <pre> @@ -48,8 +48,15 @@ import java.util.List; @jdk.Exported public interface CaseTree extends Tree { /** - * @return null if and only if this Case is {@code default:} + * Returns the expression for the case, or + * {@code null} if this is the default case. + * @return the expression for the case, or null */ ExpressionTree getExpression(); + + /** + * Returns the statements labeled by the case. + * @return the statements labeled by the case + */ List<? extends StatementTree> getStatements(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/CatchTree.java b/langtools/src/share/classes/com/sun/source/tree/CatchTree.java index f2a5452e3a9d25b7b43c080c0b7e4e3e21b21b9d..b91a94dce5b8bb320ddbde1105af89d8baf7f9c4 100644 --- a/langtools/src/share/classes/com/sun/source/tree/CatchTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/CatchTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for a 'catch' block in a 'try' statement. + * A tree node for a {@code catch} block in a {@code try} statement. * * For example: * <pre> @@ -42,6 +42,18 @@ package com.sun.source.tree; */ @jdk.Exported public interface CatchTree extends Tree { + /** + * Returns the catch variable. + * A multi-catch variable will have a + * {@link UnionTypeTree UnionTypeTree} + * as the type of the variable. + * @return the catch variable + */ VariableTree getParameter(); + + /** + * Returns the catch block. + * @return the catch block + */ BlockTree getBlock(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ClassTree.java b/langtools/src/share/classes/com/sun/source/tree/ClassTree.java index 9a2303f18bc12bea4d50fa186a4a4e607d916ded..3a7f5b34440d7d781d508c8a9da8120be64a88a0 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ClassTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ClassTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,10 +50,41 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface ClassTree extends StatementTree { + /** + * Returns the modifiers, including any annotations, + * for this type declaration. + * @return the modifiers + */ ModifiersTree getModifiers(); + + /** + * Returns the simple name of this type declaration. + * @return the simple name + */ Name getSimpleName(); + + /** + * Returns any type parameters of this type declaration. + * @return the type parameters + */ List<? extends TypeParameterTree> getTypeParameters(); + + /** + * Returns the supertype of this type declaration, + * or {@code null} if none is provided. + * @return the supertype + */ Tree getExtendsClause(); + + /** + * Returns the interfaces implemented by this type declaration. + * @return the interfaces + */ List<? extends Tree> getImplementsClause(); + + /** + * Returns the members declared in this type declaration. + * @return the members + */ List<? extends Tree> getMembers(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java b/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java index d401a31bfa5034a3e3d6b4fa60e525589efbc38a..fa3e57458144687c77356c2fcca299414aabc951 100644 --- a/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,21 +39,53 @@ import javax.tools.JavaFileObject; */ @jdk.Exported public interface CompilationUnitTree extends Tree { + /** + * Returns the annotations listed on any package declaration + * at the head of this compilation unit, or {@code null} if there + * is no package declaration. + * @return the package annotations + */ List<? extends AnnotationTree> getPackageAnnotations(); + + /** + * Returns the name contained in any package declaration + * at the head of this compilation unit, or {@code null} if there + * is no package declaration. + * @return the package name + */ ExpressionTree getPackageName(); /** - * Return the PackageTree associated with this compilation unit. + * Returns the package tree associated with this compilation unit, + * or {@code null} if there is no package declaration. + * @return the package tree * @since 1.9 */ PackageTree getPackage(); + + /** + * Returns the import declarations appearing in this compilation unit. + * @return the import declarations + */ List<? extends ImportTree> getImports(); + + /** + * Returns the type declarations appearing in this compilation unit. + * The list may also include empty statements resulting from + * extraneous semicolons. + * @return the type declarations + */ List<? extends Tree> getTypeDecls(); + + /** + * Returns the file object containing the source for this compilation unit. + * @return the file object + */ JavaFileObject getSourceFile(); /** - * Gets the line map for this compilation unit, if available. - * Returns null if the line map is not available. + * Returns the line map for this compilation unit, if available. + * Returns {@code null} if the line map is not available. * @return the line map for this compilation unit */ LineMap getLineMap(); diff --git a/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java b/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java index d3dca973ecc2c3d25f47d3a89eeeef80925f22ad..e4db62bb053340d291b3f6e324d329fd378695fa 100644 --- a/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,15 @@ package com.sun.source.tree; */ @jdk.Exported public interface CompoundAssignmentTree extends ExpressionTree { + /** + * Returns the variable on the left hand side of the compound assignment. + * @return the variable + */ ExpressionTree getVariable(); + + /** + * Returns the expression on the right hand side of the compound assignment. + * @return the expression + */ ExpressionTree getExpression(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java b/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java index b50a6a3595542187e126d13e77c80f820be535c3..fa3dd83769a2aa02d8394c9fc9ce857043960f1d 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,21 @@ package com.sun.source.tree; */ @jdk.Exported public interface ConditionalExpressionTree extends ExpressionTree { + /** + * Returns the condition. + * @return the condition + */ ExpressionTree getCondition(); + + /** + * Returns the expression to be evaluated if the condition is true. + * @return the expression to be evaluated if the condition is true + */ ExpressionTree getTrueExpression(); + + /** + * Returns the expression to be evaluated if the condition is false. + * @return the expression to be evaluated if the condition is false + */ ExpressionTree getFalseExpression(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java b/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java index 6dd9992b2c6b2f737e77ffd9660c1d528517a598..2f6f3fa46e662161e16686690ea89ad7995a5e38 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ package com.sun.source.tree; import javax.lang.model.element.Name; /** - * A tree node for a 'continue' statement. + * A tree node for a {@code continue} statement. * * For example: * <pre> @@ -44,5 +44,9 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface ContinueTree extends StatementTree { + /** + * Returns the label for this {@code continue} statement. + * @return the label + */ Name getLabel(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java b/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java index ef59fbe0cc7fa833667aaf719faf35e141c63ac3..2aeac4b26cae9f959efc5bfee39d37fff2b8d356 100644 --- a/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for a 'do' statement. + * A tree node for a {@code do} statement. * * For example: * <pre> @@ -43,6 +43,15 @@ package com.sun.source.tree; */ @jdk.Exported public interface DoWhileLoopTree extends StatementTree { + /** + * Returns the condition of the loop. + * @return the condition + */ ExpressionTree getCondition(); + + /** + * Returns the body of the loop. + * @return the body of the loop + */ StatementTree getStatement(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java b/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java index 943b762bb99e541e37895618674fd83909e5a5d8..f9619f897ba277ea749cce22ffa4d54efc2e384b 100644 --- a/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for an "enhanced" 'for' loop statement. + * A tree node for an "enhanced" {@code for} loop statement. * * For example: * <pre> @@ -42,7 +42,21 @@ package com.sun.source.tree; */ @jdk.Exported public interface EnhancedForLoopTree extends StatementTree { + /** + * Returns the control variable for the loop. + * @return the control variable + */ VariableTree getVariable(); + + /** + * Returns the expression yielding the values for the control variable. + * @return the expression + */ ExpressionTree getExpression(); + + /** + * Returns the body of the loop. + * @return the body of the loop + */ StatementTree getStatement(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java b/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java index 36748b46749cfb050b266946ab06575671c4dbb7..b56c3ee448c408b7efe35af9d5027460185e5f5a 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,5 +36,9 @@ import java.util.List; */ @jdk.Exported public interface ErroneousTree extends ExpressionTree { + /** + * Returns any trees that were saved in this node. + * @return the trees + */ List<? extends Tree> getErrorTrees(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java b/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java index 3eab1f80e3050a54df78b14323f15daa227dfc87..7ae8c2265d970fda5d3cdff7bb25d0b15aac55c1 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,5 +41,9 @@ package com.sun.source.tree; */ @jdk.Exported public interface ExpressionStatementTree extends StatementTree { + /** + * Returns the expression constituting this statement. + * @return the expression + */ ExpressionTree getExpression(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java b/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java index baa9c11b821717ed1e519f903fecd878aca54a13..e42daffe8f603f890480bf3d45e43cf2094a11c0 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ package com.sun.source.tree; import java.util.List; /** - * A tree node for a basic 'for' loop statement. + * A tree node for a basic {@code for} loop statement. * * For example: * <pre> @@ -44,8 +44,30 @@ import java.util.List; */ @jdk.Exported public interface ForLoopTree extends StatementTree { + /** + * Returns any initializers of the {@code for} statement. + * The result will be an empty list if there are + * no initializers + * @return the initializers + */ List<? extends StatementTree> getInitializer(); + + /** + * Returns the condition of the {@code for} statement. + * May be {@code null} if there is no condition. + * @return the condition + */ ExpressionTree getCondition(); + + /** + * Returns any update expressions of the {@code for} statement. + * @return the update expressions + */ List<? extends ExpressionStatementTree> getUpdate(); + + /** + * Returns the body of the {@code for} statement. + * @return the body + */ StatementTree getStatement(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java b/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java index 2a1c484ae43889c5ccaf77e2158db1ac477ebdec..3f2a2f49249503b7cfabab78ed1c115e6764b671 100644 --- a/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,5 +43,9 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface IdentifierTree extends ExpressionTree { + /** + * Returns the name of the identifier. + * @return the name + */ Name getName(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/IfTree.java b/langtools/src/share/classes/com/sun/source/tree/IfTree.java index 227d9185510e319e0a57fe51b13ce51c7174bdf0..f5790c7ea93366133ea1e9d6ea0819bc542987c6 100644 --- a/langtools/src/share/classes/com/sun/source/tree/IfTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/IfTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for an 'if' statement. + * A tree node for an {@code if} statement. * * For example: * <pre> @@ -47,10 +47,22 @@ package com.sun.source.tree; */ @jdk.Exported public interface IfTree extends StatementTree { + /** + * Returns the condition of the if-statement. + * @return the condition + */ ExpressionTree getCondition(); + + /** + * Returns the statement to be executed if the condition is true + * @return the statement to be executed if the condition is true + */ StatementTree getThenStatement(); + /** - * @return null if this if statement has no else branch. + * Returns the statement to be executed if the condition is false, + * or {@code null} if there is no such statement. + * @return the statement to be executed if the condition is false */ StatementTree getElseStatement(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ImportTree.java b/langtools/src/share/classes/com/sun/source/tree/ImportTree.java index 46cd1a89fd67c9df87b3085328b0006a69b45f54..dfd57e5496b5cb532cb8d61e22aed26557d690a4 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ImportTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ImportTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,10 +43,19 @@ package com.sun.source.tree; */ @jdk.Exported public interface ImportTree extends Tree { + /** + * Returns true if this is a static import declaration. + * @return true if this is a static import + */ boolean isStatic(); + /** - * @return a qualified identifier ending in "*" if and only if - * this is an import-on-demand. + * Returns the qualified identifier for the declaration(s) + * being imported. + * If this is an import-on-demand declaration, the + * qualified identifier will end in "*". + * @return a qualified identifier, ending in "*" if and only if + * this is an import-on-demand */ Tree getQualifiedIdentifier(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java b/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java index b8e81006e0d4b871d4448fb4b5f5fdc55b8b305c..7766482daf13d3ebcf5b59d5c0a96c800f56cc1f 100644 --- a/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for an 'instanceof' expression. + * A tree node for an {@code instanceof} expression. * * For example: * <pre> @@ -41,6 +41,15 @@ package com.sun.source.tree; */ @jdk.Exported public interface InstanceOfTree extends ExpressionTree { + /** + * Returns the expression to be tested. + * @return the expression + */ ExpressionTree getExpression(); + + /** + * Returns the type for which to check. + * @return the type + */ Tree getType(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java index 147571ed7fcac876bcc40b9fe155d75fc1f76884..0b2790a784e2f711e33942d3c25a91c50cd00916 100644 --- a/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,5 +36,9 @@ import java.util.List; */ @jdk.Exported public interface IntersectionTypeTree extends Tree { + /** + * Returns the bounds of the type. + * @return the bounds + */ List<? extends Tree> getBounds(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java b/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java index 424cc20b3fa4d62fe23f12f0c09939ed8c927240..3fe724e01f7e6333ee439c76d95210494860a8ca 100644 --- a/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,15 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface LabeledStatementTree extends StatementTree { + /** + * Returns the label. + * @return the label + */ Name getLabel(); + + /** + * Returns the statement that is labeled. + * @return the statement + */ StatementTree getStatement(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java b/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java index 9854cc248edec45e40d9de3153eae7ba45482cc5..9f3c988d1cb2c67fcb06bb6849ba5687f99bb474 100644 --- a/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,8 +41,11 @@ import java.util.List; public interface LambdaExpressionTree extends ExpressionTree { /** - * Lambda expressions come in two forms: (i) expression lambdas, whose body - * is an expression, and (ii) statement lambdas, whose body is a block + * Lambda expressions come in two forms: + * <ul compact> + * <li> expression lambdas, whose body is an expression, and + * <li> statement lambdas, whose body is a block + * </ul> */ @jdk.Exported public enum BodyKind { @@ -52,7 +55,21 @@ public interface LambdaExpressionTree extends ExpressionTree { STATEMENT } + /** + * Returns the parameters of this lambda expression. + * @return the parameters + */ List<? extends VariableTree> getParameters(); + + /** + * Returns the body of the lambda expression. + * @return the body + */ Tree getBody(); + + /** + * Returns the kind of the body of the lambda expression. + * @return the kind of the body + */ BodyKind getBodyKind(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/LineMap.java b/langtools/src/share/classes/com/sun/source/tree/LineMap.java index f8b2ccab58855d1e3a3d18bbf9a615954118be65..7a396d1270f79ba98d0dd3f7dd35070b69e2d2b3 100644 --- a/langtools/src/share/classes/com/sun/source/tree/LineMap.java +++ b/langtools/src/share/classes/com/sun/source/tree/LineMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ package com.sun.source.tree; @jdk.Exported public interface LineMap { /** - * Find the start position of a line. + * Finds the start position of a line. * * @param line line number (beginning at 1) * @return position of first character in line @@ -45,7 +45,7 @@ public interface LineMap { long getStartPosition(long line); /** - * Find the position corresponding to a (line,column). + * Finds the position corresponding to a (line,column). * * @param line line number (beginning at 1) * @param column tab-expanded column number (beginning 1) @@ -58,7 +58,7 @@ public interface LineMap { long getPosition(long line, long column); /** - * Find the line containing a position; a line termination + * Finds the line containing a position; a line termination * character is on the line it terminates. * * @param pos character offset of the position @@ -67,7 +67,7 @@ public interface LineMap { long getLineNumber(long pos); /** - * Find the column for a character position. + * Finds the column for a character position. * Tab characters preceding the position on the same line * will be expanded when calculating the column number. * diff --git a/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java b/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java index b166051765dd84fadda1ec6357665833cce0d1c0..4c8fa521e815338b80f6c435dd65c5f3d6ac5661 100644 --- a/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,5 +42,10 @@ package com.sun.source.tree; */ @jdk.Exported public interface LiteralTree extends ExpressionTree { + /** + * Returns the value of the literal expression. + * The value will be a boxed primitive value, a String, or {@code null}. + * @return the value + */ Object getValue(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java b/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java index 939c0c6f8e2f6d4b9cd0837545ee1b2459dab930..23c77bfb21cb4d101c1010f7cd985d2902830123 100644 --- a/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,13 +48,33 @@ public interface MemberReferenceTree extends ExpressionTree { */ @jdk.Exported public enum ReferenceMode { - /** enum constant for method references */ + /** enum constant for method references. */ INVOKE, - /** enum constant for constructor references */ + /** enum constant for constructor references. */ NEW } + + /** + * Returns the mode of the reference. + * @return the mode + */ ReferenceMode getMode(); + + /** + * Returns the qualifier expression for the reference. + * @return the qualifier expression + */ ExpressionTree getQualifierExpression(); + + /** + * Returns the name of the reference. + * @return the name + */ Name getName(); + + /** + * Returns the type arguments for the reference. + * @return the type arguments + */ List<? extends ExpressionTree> getTypeArguments(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java b/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java index d40a6a31060f32dfe7a4729046bd377b947e7c6a..dac747208fcafa751290986c1e82806ee52d7bcd 100644 --- a/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,15 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface MemberSelectTree extends ExpressionTree { + /** + * Returns the expression for which a member is to be selected. + * @return the expression. + */ ExpressionTree getExpression(); + + /** + * Returns the name of the member to be selected. + * @return the member + */ Name getIdentifier(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java b/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java index 1b6ae1332ab216e1270472c78fc9397bd039660c..3e7088b6dd03c2c6bcce5542996e6eab241b1ca7 100644 --- a/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,21 @@ import java.util.List; */ @jdk.Exported public interface MethodInvocationTree extends ExpressionTree { + /** + * Returns the type arguments for this method invocation. + * @return the type arguments + */ List<? extends Tree> getTypeArguments(); + + /** + * Returns the expression identifying the method to be invoked. + * @return the method selection expression + */ ExpressionTree getMethodSelect(); + + /** + * Returns the arguments for the method invocation. + * @return the arguments + */ List<? extends ExpressionTree> getArguments(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java index bef5d8b3e0b5ea3cd4241ac80cb21763cbf8825d..f16c521953b98acbacbf11bf3ac8a6d724ef0d6a 100644 --- a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,21 +48,63 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface MethodTree extends Tree { + /** + * Returns the modifiers, including any annotations for the method being declared. + * @return the modifiers + */ ModifiersTree getModifiers(); + + /** + * Returns the name of the method being declared. + * @return the name + */ Name getName(); + + /** + * Returns the return type of the method being declared. + * Returns {@code null} for a constructor. + * @return the return type + */ Tree getReturnType(); + + /** + * Returns the type parameters of the method being declared. + * @return the type parameters + */ List<? extends TypeParameterTree> getTypeParameters(); + + /** + * Returns the parameters of the method being declared. + * @return the parameters + */ List<? extends VariableTree> getParameters(); /** - * Return an explicit receiver parameter ("this" parameter). + * Return an explicit receiver parameter ("this" parameter), + * or {@code null} if none. * * @return an explicit receiver parameter ("this" parameter) * @since 1.8 */ VariableTree getReceiverParameter(); + /** + * Returns the exceptions listed as being thrown by this method. + * @return the exceptions + */ List<? extends ExpressionTree> getThrows(); + + /** + * Returns the method body, or {@code null} if this is an abstract or native method. + * @return the method body + */ BlockTree getBody(); + + /** + * Returns the default value, if this is an element within + * an annotation type declaration. + * Returns {@code null} otherwise. + * @return the default value + */ Tree getDefaultValue(); // for annotation types } diff --git a/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java b/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java index ea22e06b777e44e09167786b7e19dfd2359039d6..1dd45fb0ebc92c9eeabfe18813ecc292fa0b3ea9 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,15 @@ import javax.lang.model.element.Modifier; */ @jdk.Exported public interface ModifiersTree extends Tree { + /** + * Returns the flags in this modifiers tree. + * @return the flags + */ Set<Modifier> getFlags(); + + /** + * Returns the annotations in this modifiers tree. + * @return the annotations + */ List<? extends AnnotationTree> getAnnotations(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java b/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java index 01236e71516eedcf7ace58bb2fb7784dafa446dd..beea5bb23f3dad51f70b7a8f93263837fd177b46 100644 --- a/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,9 +45,37 @@ import java.util.List; */ @jdk.Exported public interface NewArrayTree extends ExpressionTree { + /** + * Returns the base type of the expression. + * May be {@code null} for an array initializer expression. + * @return the base type + */ Tree getType(); + + /** + * Returns the dimension expressions for the type. + * + * @return the dimension expressions + */ List<? extends ExpressionTree> getDimensions(); + + /** + * Returns the initializer expressions. + * + * @return the initializer expressions + */ List<? extends ExpressionTree> getInitializers(); + + /** + * Returns the annotations on the base type. + * @return the annotations + */ List<? extends AnnotationTree> getAnnotations(); + + /** + * Returns the annotations on each of the dimension + * expressions. + * @return the annotations on the dimensions expressions + */ List<? extends List<? extends AnnotationTree>> getDimAnnotations(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java b/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java index a30cb30f9a6992c18e56142aca534a904dcef5f2..b82faaf9669c632680f2aca2dc6c11a0cd90dc7a 100644 --- a/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,9 +50,34 @@ import java.util.List; */ @jdk.Exported public interface NewClassTree extends ExpressionTree { + /** + * Returns the enclosing expression, or {@code null} if none. + * @return the enclosing expression + */ ExpressionTree getEnclosingExpression(); + + /** + * Returns the type arguments for the object being created. + * @return the type arguments + */ List<? extends Tree> getTypeArguments(); + + /** + * Returns the name of the class being instantiated. + * @return the name + */ ExpressionTree getIdentifier(); + + /** + * Returns the arguments for the constructor to be invoked. + * @return the arguments + */ List<? extends ExpressionTree> getArguments(); + + /** + * Returns the class body if an anonymous class is being + * instantiated, and {@code null} otherwise. + * @return the class body + */ ClassTree getClassBody(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/PackageTree.java b/langtools/src/share/classes/com/sun/source/tree/PackageTree.java index c2d822e8b05f8b49078badb75bfbed8b3391ad56..8d722f6afb2d72d9b9048ead2df788301a178a1b 100644 --- a/langtools/src/share/classes/com/sun/source/tree/PackageTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/PackageTree.java @@ -37,6 +37,15 @@ import java.util.List; */ @jdk.Exported public interface PackageTree extends Tree { + /** + * Returns the annotations associated with this package declaration. + * @return the annotations + */ List<? extends AnnotationTree> getAnnotations(); + + /** + * Returns the name of the package being declared. + * @return the name + */ ExpressionTree getPackageName(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java index d054dbd3be8eefca56adf11d2a9a786adae88bc0..99f5b751289dc58d6af2f17c4eaca11c35121e1c 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,15 @@ import java.util.List; */ @jdk.Exported public interface ParameterizedTypeTree extends Tree { + /** + * Returns the base type. + * @return the base type + */ Tree getType(); + + /** + * Returns the type arguments. + * @return the type arguments + */ List<? extends Tree> getTypeArguments(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java b/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java index 7c9392421ed14c68e5020dac2faa2829ca499f73..02eb7b3cc012db68ef232dafc27690b4a4f57356 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,5 +42,9 @@ package com.sun.source.tree; */ @jdk.Exported public interface ParenthesizedTree extends ExpressionTree { + /** + * Returns the expression within the parentheses. + * @return the expression + */ ExpressionTree getExpression(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java index 1c07a0378751cbf72f0f9ad0c54a699c78471e1d..4d509a7fb4ea1a9c3018d6d6b097314d5190291f 100644 --- a/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,5 +43,9 @@ import javax.lang.model.type.TypeKind; */ @jdk.Exported public interface PrimitiveTypeTree extends Tree { + /** + * Returns the kind of this primitive type. + * @return the kind of the type + */ TypeKind getPrimitiveTypeKind(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java b/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java index 8fa16800e37352bb572fab36f47890d5591d2aa2..6f58574436eb04ce9ce2219a63cce75872b5b778 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for a 'return' statement. + * A tree node for a {@code return} statement. * * For example: * <pre> @@ -42,5 +42,9 @@ package com.sun.source.tree; */ @jdk.Exported public interface ReturnTree extends StatementTree { + /** + * Returns the expression to be returned. + * @return the expression + */ ExpressionTree getExpression(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/Scope.java b/langtools/src/share/classes/com/sun/source/tree/Scope.java index 071ec963f580a799a5aa1cd7a4598be4a9edff94..e30d927975519c0b812d098915f6b1d320fed7bb 100644 --- a/langtools/src/share/classes/com/sun/source/tree/Scope.java +++ b/langtools/src/share/classes/com/sun/source/tree/Scope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,21 +52,25 @@ import javax.lang.model.element.TypeElement; public interface Scope { /** * Returns the enclosing scope. + * @return the enclosing scope */ public Scope getEnclosingScope(); /** - * Returns the innermost type element containing the position of this scope + * Returns the innermost type element containing the position of this scope. + * @return the innermost enclosing type element */ public TypeElement getEnclosingClass(); /** * Returns the innermost executable element containing the position of this scope. + * @return the innermost enclosing method declaration */ public ExecutableElement getEnclosingMethod(); /** * Returns the elements directly contained in this scope. + * @return the elements contained in this scope */ public Iterable<? extends Element> getLocalElements(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java b/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java index cc1dbdd2697816a5ad91a742eb52b862ba8bc152..76e90885ead4de8c7454f00552b8aad576aaa059 100644 --- a/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ package com.sun.source.tree; import java.util.List; /** - * A tree node for a 'switch' statement. + * A tree node for a {@code switch} statement. * * For example: * <pre> @@ -45,6 +45,15 @@ import java.util.List; */ @jdk.Exported public interface SwitchTree extends StatementTree { + /** + * Returns the expression for the {@code switch} statement. + * @return the expression + */ ExpressionTree getExpression(); + + /** + * Returns the cases for the {@code switch} statement. + * @return the cases + */ List<? extends CaseTree> getCases(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java b/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java index afdd12612ce387dc435450e4001e285d3b432ce3..cb72cf731c8a7461f69ff7b043171a7818ff8218 100644 --- a/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for a 'synchronized' statement. + * A tree node for a {@code synchronized} statement. * * For example: * <pre> @@ -42,6 +42,15 @@ package com.sun.source.tree; */ @jdk.Exported public interface SynchronizedTree extends StatementTree { + /** + * Returns the expression on which to synchronize. + * @return the expression + */ ExpressionTree getExpression(); + + /** + * Returns the block of the {@code synchronized} statement. + * @return the block + */ BlockTree getBlock(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java b/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java index 8348168c46ce9d94b53183cc604de84058766915..af319f3ffe981b6bc2a84f248f38de33f41bb6c1 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for a 'throw' statement. + * A tree node for a {@code throw} statement. * * For example: * <pre> @@ -41,5 +41,9 @@ package com.sun.source.tree; */ @jdk.Exported public interface ThrowTree extends StatementTree { + /** + * Returns the expression to be thrown. + * @return the expression + */ ExpressionTree getExpression(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/Tree.java b/langtools/src/share/classes/com/sun/source/tree/Tree.java index de3166dc5ada8ac301af0810179ff049b814a3b6..8c6b08803ad3be6500e64663dbe5c18763e29386 100644 --- a/langtools/src/share/classes/com/sun/source/tree/Tree.java +++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,10 @@ public interface Tree { */ @jdk.Exported public enum Kind { - + /** + * Used for instances of {@link AnnotatedTypeTree} + * representing annotated types. + */ ANNOTATED_TYPE(AnnotatedTypeTree.class), /** @@ -613,6 +616,10 @@ public interface Tree { associatedInterface = intf; } + /** + * Returns the associated interface type that uses this kind. + * @return the associated interface + */ public Class<? extends Tree> asInterface() { return associatedInterface; } @@ -621,7 +628,7 @@ public interface Tree { } /** - * Gets the kind of this tree. + * Returns the kind of this tree. * * @return the kind of this tree. */ @@ -633,6 +640,9 @@ public interface Tree { * * @param <R> result type of this operation. * @param <D> type of additional data. + * @param visitor the visitor to be called + * @param data a value to be passed to the visitor + * @return the result returned from calling the visitor */ <R,D> R accept(TreeVisitor<R,D> visitor, D data); } diff --git a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java index db1f32af9ee00231bd7514b0d7989ddd2d49ddcb..8f63188537a8ee39e69dc4e92eeeb3c6656be1cb 100644 --- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,58 +58,437 @@ package com.sun.source.tree; */ @jdk.Exported public interface TreeVisitor<R,P> { + /** + * Visits an AnnotatedTypeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitAnnotatedType(AnnotatedTypeTree node, P p); + + /** + * Visits an AnnotatedTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitAnnotation(AnnotationTree node, P p); + + /** + * Visits a MethodInvocationTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitMethodInvocation(MethodInvocationTree node, P p); + + /** + * Visits an AssertTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitAssert(AssertTree node, P p); + + /** + * Visits an AssignmentTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitAssignment(AssignmentTree node, P p); + + /** + * Visits a CompoundAssignmentTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitCompoundAssignment(CompoundAssignmentTree node, P p); + + /** + * Visits a BinaryTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitBinary(BinaryTree node, P p); + + /** + * Visits a BlockTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitBlock(BlockTree node, P p); + + /** + * Visits a BreakTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitBreak(BreakTree node, P p); + + /** + * Visits a CaseTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitCase(CaseTree node, P p); + + /** + * Visits a CatchTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitCatch(CatchTree node, P p); + + /** + * Visits a ClassTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitClass(ClassTree node, P p); + + /** + * Visits a ConditionalExpressionTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitConditionalExpression(ConditionalExpressionTree node, P p); + + /** + * Visits a ContinueTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitContinue(ContinueTree node, P p); + + /** + * Visits a DoWhileTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitDoWhileLoop(DoWhileLoopTree node, P p); + + /** + * Visits an ErroneousTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitErroneous(ErroneousTree node, P p); + + /** + * Visits an ExpressionStatementTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitExpressionStatement(ExpressionStatementTree node, P p); + + /** + * Visits an EnhancedForLoopTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitEnhancedForLoop(EnhancedForLoopTree node, P p); + + /** + * Visits a ForLoopTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitForLoop(ForLoopTree node, P p); + + /** + * Visits an IdentifierTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitIdentifier(IdentifierTree node, P p); + + /** + * Visits an IfTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitIf(IfTree node, P p); + + /** + * Visits an ImportTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitImport(ImportTree node, P p); + + /** + * Visits an ArrayAccessTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitArrayAccess(ArrayAccessTree node, P p); + + /** + * Visits a LabeledStatementTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitLabeledStatement(LabeledStatementTree node, P p); + + /** + * Visits a LiteralTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitLiteral(LiteralTree node, P p); + + /** + * Visits a MethodTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitMethod(MethodTree node, P p); + + /** + * Visits a ModifiersTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitModifiers(ModifiersTree node, P p); + + /** + * Visits a NewArrayTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitNewArray(NewArrayTree node, P p); + + /** + * Visits a NewClassTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitNewClass(NewClassTree node, P p); + + /** + * Visits a LambdaExpressionTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitLambdaExpression(LambdaExpressionTree node, P p); + + /** + * Visits a PackageTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitPackage(PackageTree node, P p); + + /** + * Visits a ParenthesizedTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitParenthesized(ParenthesizedTree node, P p); + + /** + * Visits a ReturnTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitReturn(ReturnTree node, P p); + + /** + * Visits a MemberSelectTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitMemberSelect(MemberSelectTree node, P p); + + /** + * Visits a MemberReferenceTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitMemberReference(MemberReferenceTree node, P p); + + /** + * Visits an EmptyStatementTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitEmptyStatement(EmptyStatementTree node, P p); + + /** + * Visits a SwitchTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSwitch(SwitchTree node, P p); + + /** + * Visits a SynchronizedTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSynchronized(SynchronizedTree node, P p); + + /** + * Visits a ThrowTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitThrow(ThrowTree node, P p); + + /** + * Visits a CompilationUnitTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitCompilationUnit(CompilationUnitTree node, P p); + + /** + * Visits a TryTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitTry(TryTree node, P p); + + /** + * Visits a ParameterizedTypeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitParameterizedType(ParameterizedTypeTree node, P p); + + /** + * Visits a UnionTypeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitUnionType(UnionTypeTree node, P p); + + /** + * Visits an IntersectionTypeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitIntersectionType(IntersectionTypeTree node, P p); + + /** + * Visits an ArrayTypeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitArrayType(ArrayTypeTree node, P p); + + /** + * Visits a TypeCastTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitTypeCast(TypeCastTree node, P p); + + /** + * Visits a PrimitiveTypeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitPrimitiveType(PrimitiveTypeTree node, P p); + + /** + * Visits a TypeParameterTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitTypeParameter(TypeParameterTree node, P p); + + /** + * Visits an InstanceOfTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitInstanceOf(InstanceOfTree node, P p); + + /** + * Visits a UnaryTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitUnary(UnaryTree node, P p); + + /** + * Visits a VariableTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitVariable(VariableTree node, P p); + + /** + * Visits a WhileLoopTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitWhileLoop(WhileLoopTree node, P p); + + /** + * Visits a WildcardTypeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitWildcard(WildcardTree node, P p); + + /** + * Visits an unknown type of Tree node. + * This can occur if the language evolves and new kinds + * of nodes are added to the {@code Tree} hierarchy. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitOther(Tree node, P p); } diff --git a/langtools/src/share/classes/com/sun/source/tree/TryTree.java b/langtools/src/share/classes/com/sun/source/tree/TryTree.java index 2ca79cfa82e4cce23c8b1c767a2520577159d968..a02e2e5f0bec6e50d8af61633ab4dc4401af1d91 100644 --- a/langtools/src/share/classes/com/sun/source/tree/TryTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/TryTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ package com.sun.source.tree; import java.util.List; /** - * A tree node for a 'try' statement. + * A tree node for a {@code try} statement. * * For example: * <pre> @@ -47,8 +47,33 @@ import java.util.List; */ @jdk.Exported public interface TryTree extends StatementTree { + /** + * Returns the block of the {@code try} statement. + * @return the block + */ BlockTree getBlock(); + + /** + * Returns any catch blocks provided in the {@code try} statement. + * The result will be an empty list if there are no + * catch blocks. + * @return the catch blocks + */ List<? extends CatchTree> getCatches(); + + /** + * Returns the finally block provided in the {@code try} statement, + * or {@code null} if there is none. + * @return the finally block + */ BlockTree getFinallyBlock(); + + + /** + * Returns any resource declarations provided in the {@code try} statement. + * The result will be an empty list if there are no + * resource declarations. + * @return the resource declarations + */ List<? extends Tree> getResources(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java b/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java index 6464e4bdc1180c5833799a0e8ae034e9946609e0..23d14e86a6f23255dba3e0b7aaa89bf65c5977a0 100644 --- a/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,15 @@ package com.sun.source.tree; */ @jdk.Exported public interface TypeCastTree extends ExpressionTree { + /** + * Returns the target type of the cast. + * @return the cast + */ Tree getType(); + + /** + * Returns the expression being cast. + * @return the expression + */ ExpressionTree getExpression(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java index 2737dff3f966a7a4e7920b94750bb537b1137407..5ffd552ac3daf6e2e62b79191a6d596d590c23fd 100644 --- a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,11 +48,20 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface TypeParameterTree extends Tree { + /** + * Returns the name of the type parameter. + * @return the name + */ Name getName(); + + /** + * Returns the bounds of the type parameter. + * @return the bounds + */ List<? extends Tree> getBounds(); /** - * Return annotations on the type parameter declaration. + * Returns annotations on the type parameter declaration. * * Annotations need Target meta-annotations of * {@link java.lang.annotation.ElementType#TYPE_PARAMETER} or diff --git a/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java b/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java index 3dfbedd46cee59fbb34187ce83f1eb34d56c2833..c9ad921034578b5e9c5645c10492f91842aab24e 100644 --- a/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,5 +44,9 @@ package com.sun.source.tree; */ @jdk.Exported public interface UnaryTree extends ExpressionTree { + /** + * Returns the expression that is the operand of the unary operator. + * @return the expression + */ ExpressionTree getExpression(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java index 97da031feb59c03b1127efa68d3f70ba3d4c5276..544366844d29333a18e42fb6c57df70c650a6ee7 100644 --- a/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,8 @@ package com.sun.source.tree; import java.util.List; /** - * A tree node for a union type expression in a multicatch var declaration. + * A tree node for a union type expression in a multicatch + * variable declaration. * * @author Maurizio Cimadamore * @@ -36,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface UnionTypeTree extends Tree { + /** + * Returns the alternative type expressions. + * @return the alternative type expressions + */ List<? extends Tree> getTypeAlternatives(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/VariableTree.java b/langtools/src/share/classes/com/sun/source/tree/VariableTree.java index de60550b0b80cb3b126187084803b472d91e33f9..203178b5976ea281296077c3a366b6c990dba7b0 100644 --- a/langtools/src/share/classes/com/sun/source/tree/VariableTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/VariableTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,9 +44,35 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface VariableTree extends StatementTree { + /** + * Returns the modifiers, including any annotations, on the declaration. + * @return the modifiers + */ ModifiersTree getModifiers(); + + /** + * Returns the name of the variable being declared. + * @return the name + */ Name getName(); + + /** + * Returns the qualified identifier for the name being "declared". + * This is only used in certain cases for the receiver of a + * method declaration. Returns {@code null} in all other cases. + * @return the qualified identifier of a receiver declaration + */ ExpressionTree getNameExpression(); + + /** + * Returns the type of the variable being declared. + * @return the type + */ Tree getType(); + + /** + * Returns the initializer for the variable, or {@code null} if none. + * @return the initializer + */ ExpressionTree getInitializer(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java b/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java index 30dcf30cc101dec8d33a554bfd18b31f980c0f71..e59a8d27a147ef41bde7c3a180ae996e44b7efbd 100644 --- a/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for a 'while' loop statement. + * A tree node for a {@code while} loop statement. * * For example: * <pre> @@ -43,6 +43,15 @@ package com.sun.source.tree; */ @jdk.Exported public interface WhileLoopTree extends StatementTree { + /** + * Returns the condition of the loop. + * @return the condition + */ ExpressionTree getCondition(); + + /** + * Returns the body of the loop. + * @return the body of the loop + */ StatementTree getStatement(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java b/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java index 4b87891798bdedce0c7f4bf13d91531e62ed6069..3fad97bdec254eb0163c4a81f70c78422da84141 100644 --- a/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,5 +46,9 @@ package com.sun.source.tree; */ @jdk.Exported public interface WildcardTree extends Tree { + /** + * Returns the bound of the wildcard. + * @return the bound + */ Tree getBound(); } diff --git a/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java b/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java index dc0eaa464234150e49a3408fc1feeca62234776d..a6d5c8d9f9b618632616e275ea42d5bee43f3019 100644 --- a/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java +++ b/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ import com.sun.source.tree.CompilationUnitTree; public interface DocSourcePositions extends SourcePositions { /** - * Gets the starting position of the tree within the comment within the file. If tree is not found within + * Returns the starting position of the tree within the comment within the file. If tree is not found within * file, or if the starting position is not available, * return {@link javax.tools.Diagnostic#NOPOS}. * The given tree should be under the given comment tree, and the given documentation @@ -64,7 +64,7 @@ public interface DocSourcePositions extends SourcePositions { long getStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree); /** - * Gets the ending position of the tree within the comment within the file. If tree is not found within + * Returns the ending position of the tree within the comment within the file. If tree is not found within * file, or if the ending position is not available, * return {@link javax.tools.Diagnostic#NOPOS}. * The given tree should be under the given comment tree, and the given documentation diff --git a/langtools/src/share/classes/com/sun/source/util/DocTreePath.java b/langtools/src/share/classes/com/sun/source/util/DocTreePath.java index 3a801aae76122da62f5b49f489cd5d4a39a92ee3..b2b53ff33474a6c1994a3426a65bed155a76e45d 100644 --- a/langtools/src/share/classes/com/sun/source/util/DocTreePath.java +++ b/langtools/src/share/classes/com/sun/source/util/DocTreePath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,16 +38,23 @@ import java.util.Iterator; @jdk.Exported public class DocTreePath implements Iterable<DocTree> { /** - * Gets a documentation tree path for a tree node within a compilation unit. - * @return null if the node is not found + * Returns a documentation tree path for a tree node within a compilation unit, + * or {@code null} if the node is not found. + * @param treePath the path for the node with which the doc comment is associated + * @param doc the doc comment associated with the node + * @param target a node within the doc comment + * @return a path identifying the target within the tree */ public static DocTreePath getPath(TreePath treePath, DocCommentTree doc, DocTree target) { return getPath(new DocTreePath(treePath, doc), target); } /** - * Gets a documentation tree path for a tree node within a subtree identified by a DocTreePath object. - * @return null if the node is not found + * Returns a documentation tree path for a tree node within a subtree + * identified by a DocTreePath object, or {@code null} if the node is not found. + * @param path a path identifying a node within a doc comment tree + * @param target a node to be located within the given node + * @return a path identifying the target node */ public static DocTreePath getPath(DocTreePath path, DocTree target) { path.getClass(); @@ -100,6 +107,8 @@ public class DocTreePath implements Iterable<DocTree> { /** * Creates a DocTreePath for a child node. + * @param p the parent node + * @param t the child node */ public DocTreePath(DocTreePath p, DocTree t) { if (t.getKind() == DocTree.Kind.DOC_COMMENT) { @@ -113,31 +122,31 @@ public class DocTreePath implements Iterable<DocTree> { } /** - * Get the TreePath associated with this path. - * @return TreePath for this DocTreePath + * Returns the TreePath associated with this path. + * @return the TreePath for this DocTreePath */ public TreePath getTreePath() { return treePath; } /** - * Get the DocCommentTree associated with this path. - * @return DocCommentTree for this DocTreePath + * Returns the DocCommentTree associated with this path. + * @return the DocCommentTree for this DocTreePath */ public DocCommentTree getDocComment() { return docComment; } /** - * Get the leaf node for this path. - * @return DocTree for this DocTreePath + * Returns the leaf node for this path. + * @return the DocTree for this DocTreePath */ public DocTree getLeaf() { return leaf; } /** - * Get the path for the enclosing node, or null if there is no enclosing node. + * Returns the path for the enclosing node, or {@code null} if there is no enclosing node. * @return DocTreePath of parent */ public DocTreePath getParentPath() { diff --git a/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java b/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java index d069a34961966c7b957e7fcd0e92d8b2e0407800..42d8414e7038b3a088f4b93a8ceb9406f6d0451f 100644 --- a/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java +++ b/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,10 @@ import com.sun.source.doctree.DocTree; @jdk.Exported public class DocTreePathScanner<R, P> extends DocTreeScanner<R, P> { /** - * Scan a tree from a position identified by a TreePath. + * Scans a tree from a position identified by a tree path. + * @param path the path + * @param p a value to be passed to visitor methods + * @return the result returned from the main visitor method */ public R scan(DocTreePath path, P p) { this.path = path; @@ -51,8 +54,11 @@ public class DocTreePathScanner<R, P> extends DocTreeScanner<R, P> { } /** - * Scan a single node. + * Scans a single node. * The current path is updated for the duration of the scan. + * @param tree the tree to be scanned + * @param p a value to be passed to visitor methods + * @return the result returned from the main visitor method */ @Override public R scan(DocTree tree, P p) { @@ -69,8 +75,9 @@ public class DocTreePathScanner<R, P> extends DocTreeScanner<R, P> { } /** - * Get the current path for the node, as built up by the currently + * Returns the current path for the node, as built up by the currently * active set of scan calls. + * @return the current path */ public DocTreePath getCurrentPath() { return path; diff --git a/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java index 19f0b09a6707bbc49d9a0cdeca0fd70062cc200a..55fe6e145419b7dac9909e0d6f5ef471f6dfab38 100644 --- a/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java +++ b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ import com.sun.source.doctree.*; * <p>The default implementation of the visitXYZ methods will determine * a result as follows: * <ul> - * <li>If the node being visited has no children, the result will be null. + * <li>If the node being visited has no children, the result will be {@code null}. * <li>If the node being visited has one child, the result will be the * result of calling {@code scan} on that child. The child may be a simple node * or itself a list of nodes. @@ -71,7 +71,10 @@ import com.sun.source.doctree.*; public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> { /** - * Scan a single node. + * Scans a single node. + * @param node the node to be scanned + * @param p a parameter value passed to the visit method + * @return the result value from the visit method */ public R scan(DocTree node, P p) { return (node == null) ? null : node.accept(this, p); @@ -82,7 +85,11 @@ public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> { } /** - * Scan a list of nodes. + * Scans a sequence of nodes. + * @param nodes the nodes to be scanned + * @param p a parameter value to be passed to the visit method for each node + * @return the combined return value from the visit methods. + * The values are combined using the {@link #reduce reduce} method. */ public R scan(Iterable<? extends DocTree> nodes, P p) { R r = null; @@ -104,6 +111,9 @@ public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> { * Reduces two results into a combined result. * The default implementation is to return the first parameter. * The general contract of the method is that it may take any action whatsoever. + * @param r1 the first of the values to be combined + * @param r2 the second of the values to be combined + * @return the result of combining the two parameters */ public R reduce(R r1, R r2) { return r1; @@ -114,26 +124,61 @@ public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> { * Visitor methods ****************************************************************************/ + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitAttribute(AttributeTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitAuthor(AuthorTree node, P p) { return scan(node.getName(), p); } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitComment(CommentTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitDeprecated(DeprecatedTree node, P p) { return scan(node.getBody(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitDocComment(DocCommentTree node, P p) { R r = scan(node.getFirstSentence(), p); @@ -142,36 +187,85 @@ public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitDocRoot(DocRootTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitEndElement(EndElementTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitEntity(EntityTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitErroneous(ErroneousTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitIdentifier(IdentifierTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitInheritDoc(InheritDocTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitLink(LinkTree node, P p) { R r = scan(node.getReference(), p); @@ -179,11 +273,25 @@ public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitLiteral(LiteralTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitParam(ParamTree node, P p) { R r = scan(node.getName(), p); @@ -191,31 +299,73 @@ public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitReference(ReferenceTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitReturn(ReturnTree node, P p) { return scan(node.getDescription(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitSee(SeeTree node, P p) { return scan(node.getReference(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitSerial(SerialTree node, P p) { return scan(node.getDescription(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitSerialData(SerialDataTree node, P p) { return scan(node.getDescription(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitSerialField(SerialFieldTree node, P p) { R r = scan(node.getName(), p); @@ -224,21 +374,49 @@ public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitSince(SinceTree node, P p) { return scan(node.getBody(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitStartElement(StartElementTree node, P p) { return scan(node.getAttributes(), p); } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitText(TextTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitThrows(ThrowsTree node, P p) { R r = scan(node.getExceptionName(), p); @@ -246,26 +424,61 @@ public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) { return scan(node.getContent(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) { return scan(node.getContent(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitValue(ValueTree node, P p) { return scan(node.getReference(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitVersion(VersionTree node, P p) { return scan(node.getBody(), p); } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitOther(DocTree node, P p) { return null; diff --git a/langtools/src/share/classes/com/sun/source/util/DocTrees.java b/langtools/src/share/classes/com/sun/source/util/DocTrees.java index b8d076a4d89f5020bb5c04c8073343c021634232..2000a117b8b8be775e98f689b65e09cce1968a1e 100644 --- a/langtools/src/share/classes/com/sun/source/util/DocTrees.java +++ b/langtools/src/share/classes/com/sun/source/util/DocTrees.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,8 +40,9 @@ import javax.tools.Diagnostic; @jdk.Exported public abstract class DocTrees extends Trees { /** - * Gets a DocTrees object for a given CompilationTask. + * Returns a DocTrees object for a given CompilationTask. * @param task the compilation task for which to get the Trees object + * @return the DocTrees object * @throws IllegalArgumentException if the task does not support the Trees API. */ public static DocTrees instance(CompilationTask task) { @@ -49,8 +50,9 @@ public abstract class DocTrees extends Trees { } /** - * Gets a DocTrees object for a given ProcessingEnvironment. + * Returns a DocTrees object for a given ProcessingEnvironment. * @param env the processing environment for which to get the Trees object + * @return the DocTrees object * @throws IllegalArgumentException if the env does not support the Trees API. */ public static DocTrees instance(ProcessingEnvironment env) { @@ -60,17 +62,26 @@ public abstract class DocTrees extends Trees { } /** - * Gets the doc comment tree, if any, for the Tree node identified by a given TreePath. - * Returns null if no doc comment was found. + * Returns the doc comment tree, if any, for the Tree node identified by a given TreePath. + * Returns {@code null} if no doc comment was found. + * @param path the path for the tree node + * @return the doc comment tree */ public abstract DocCommentTree getDocCommentTree(TreePath path); /** - * Gets the language model element referred to by the leaf node of the given - * {@link DocTreePath}, or null if unknown. + * Returns the language model element referred to by the leaf node of the given + * {@link DocTreePath}, or {@code null} if unknown. + * @param path the path for the tree node + * @return the element */ public abstract Element getElement(DocTreePath path); + /** + * Returns a utility object for accessing the source positions + * of documentation tree nodes. + * @return the utility object + */ public abstract DocSourcePositions getSourcePositions(); /** @@ -80,6 +91,7 @@ public abstract class DocTrees extends Trees { * @param kind the kind of message * @param msg the message, or an empty string if none * @param t the tree to use as a position hint + * @param c the doc comment tree to use as a position hint * @param root the compilation unit that contains tree */ public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg, diff --git a/langtools/src/share/classes/com/sun/source/util/JavacTask.java b/langtools/src/share/classes/com/sun/source/util/JavacTask.java index b515ddb8e2a54b349f2987c7d8ce3344db212acf..d115f3977bed3b48494a51c04995a7163a6e9e49 100644 --- a/langtools/src/share/classes/com/sun/source/util/JavacTask.java +++ b/langtools/src/share/classes/com/sun/source/util/JavacTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ import com.sun.tools.javac.util.Context; public abstract class JavacTask implements CompilationTask { /** - * Get the {@code JavacTask} for a {@code ProcessingEnvironment}. + * Returns the {@code JavacTask} for a {@code ProcessingEnvironment}. * If the compiler is being invoked using a * {@link javax.tools.JavaCompiler.CompilationTask CompilationTask}, * then that task will be returned. @@ -70,7 +70,7 @@ public abstract class JavacTask implements CompilationTask { } /** - * Parse the specified files returning a list of abstract syntax trees. + * Parses the specified files returning a list of abstract syntax trees. * * @return a list of abstract syntax trees * @throws IOException if an unhandled I/O error occurred in the compiler. @@ -80,7 +80,7 @@ public abstract class JavacTask implements CompilationTask { throws IOException; /** - * Complete all analysis. + * Completes all analysis. * * @return a list of elements that were analyzed * @throws IOException if an unhandled I/O error occurred in the compiler. @@ -89,7 +89,7 @@ public abstract class JavacTask implements CompilationTask { public abstract Iterable<? extends Element> analyze() throws IOException; /** - * Generate code. + * Generates code. * * @return a list of files that were generated * @throws IOException if an unhandled I/O error occurred in the compiler. @@ -98,7 +98,7 @@ public abstract class JavacTask implements CompilationTask { public abstract Iterable<? extends JavaFileObject> generate() throws IOException; /** - * The specified listener will receive notification of events + * Sets a specified listener to receive notification of events * describing the progress of this compilation task. * * If another listener is receiving notifications as a result of a prior @@ -108,46 +108,54 @@ public abstract class JavacTask implements CompilationTask { * any listener that has been previously set, followed by {@code addTaskListener} * for the new listener. * + * @param taskListener the task listener * @throws IllegalStateException if the specified listener has already been added. */ public abstract void setTaskListener(TaskListener taskListener); /** - * The specified listener will receive notification of events + * Adds a specified listener so that it receives notification of events * describing the progress of this compilation task. * * This method may be called at any time before or during the compilation. * + * @param taskListener the task listener * @throws IllegalStateException if the specified listener has already been added. * @since 1.8 */ public abstract void addTaskListener(TaskListener taskListener); /** - * The specified listener will no longer receive notification of events - * describing the progress of this compilation task. + * Removes the specified listener so that it no longer receives + * notification of events describing the progress of this + * compilation task. * * This method may be called at any time before or during the compilation. * + * @param taskListener the task listener * @since 1.8 */ public abstract void removeTaskListener(TaskListener taskListener); /** - * Get a type mirror of the tree node determined by the specified path. + * Returns a type mirror of the tree node determined by the specified path. * This method has been superceded by methods on * {@link com.sun.source.util.Trees Trees}. + * @param path the path + * @return the type mirror * @see com.sun.source.util.Trees#getTypeMirror */ public abstract TypeMirror getTypeMirror(Iterable<? extends Tree> path); /** - * Get a utility object for dealing with program elements. + * Returns a utility object for dealing with program elements. + * @return the utility object for dealing with program elements */ public abstract Elements getElements(); /** - * Get a utility object for dealing with type mirrors. + * Returns a utility object for dealing with type mirrors. + * @return the utility object for dealing with type mirrors */ public abstract Types getTypes(); } diff --git a/langtools/src/share/classes/com/sun/source/util/Plugin.java b/langtools/src/share/classes/com/sun/source/util/Plugin.java index 06f2dafce7ce12518d4f95828b7ae0c90714ee23..ccfacfae20478ad41e283b826d29d4511a80a686 100644 --- a/langtools/src/share/classes/com/sun/source/util/Plugin.java +++ b/langtools/src/share/classes/com/sun/source/util/Plugin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,13 +51,13 @@ import javax.tools.StandardLocation; @jdk.Exported public interface Plugin { /** - * Get the user-friendly name of this plug-in. + * Returns the user-friendly name of this plug-in. * @return the user-friendly name of the plug-in */ String getName(); /** - * Initialize the plug-in for a given compilation task. + * Initializes the plug-in for a given compilation task. * @param task The compilation task that has just been started * @param args Arguments, if any, for the plug-in */ diff --git a/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java index 3072c2769028c18f84f123b7ded2c2dc49cfe3e1..13bce1293df582b6247be54a73a01300e14fed90 100644 --- a/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,28 +30,63 @@ import com.sun.source.doctree.*; /** * A simple visitor for tree nodes. * + * @param <R> the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param <P> the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * * @since 1.8 */ @jdk.Exported public class SimpleDocTreeVisitor<R,P> implements DocTreeVisitor<R, P> { + /** + * The default value, returned by the {@link #defaultAction default action}. + */ protected final R DEFAULT_VALUE; + /** + * Creates a visitor, with a DEFAULT_VALUE of {@code null}. + */ protected SimpleDocTreeVisitor() { DEFAULT_VALUE = null; } + /** + * Creates a visitor, with a specified DEFAULT_VALUE. + * @param defaultValue the default value to be returned by the default action. + */ protected SimpleDocTreeVisitor(R defaultValue) { DEFAULT_VALUE = defaultValue; } + /** + * The default action, used by all visit methods that are not overridden. + * @param node the node being visited + * @param p the parameter value passed to the visit method + * @return the result value to be returned from the visit method + */ protected R defaultAction(DocTree node, P p) { return DEFAULT_VALUE; } + /** + * Invokes the appropriate visit method specific to the type of the node. + * @param node the node on which to dispatch + * @param p a parameter to be passed to the appropriate visit method + * @return the value returns from the appropriate visit method + */ public final R visit(DocTree node, P p) { return (node == null) ? null : node.accept(this, p); } + /** + * Invokes the appropriate visit method on each of a sequence of nodes. + * @param nodes the nodes on which to dispatch + * @param p a parameter value to be passed to each appropriate visit method + * @return the value return from the last of the visit methods, or null + * if none were called. + */ public final R visit(Iterable<? extends DocTree> nodes, P p) { R r = null; if (nodes != null) { @@ -61,118 +96,350 @@ public class SimpleDocTreeVisitor<R,P> implements DocTreeVisitor<R, P> { return r; } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAttribute(AttributeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAuthor(AuthorTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitComment(CommentTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitDeprecated(DeprecatedTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitDocComment(DocCommentTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitDocRoot(DocRootTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitEndElement(EndElementTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitEntity(EntityTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitErroneous(ErroneousTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitIdentifier(IdentifierTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitInheritDoc(InheritDocTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitLink(LinkTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitLiteral(LiteralTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitParam(ParamTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitReference(ReferenceTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitReturn(ReturnTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSee(SeeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSerial(SerialTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSerialData(SerialDataTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSerialField(SerialFieldTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSince(SinceTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitStartElement(StartElementTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitText(TextTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitThrows(ThrowsTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitValue(ValueTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitVersion(VersionTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitOther(DocTree node, P p) { return defaultAction(node, p); } diff --git a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java index 19599456959c1958a9c3a01885d8025d6d3cae0e..28bd802f25302d79034a1e6ed652fe900b8fd5f6 100644 --- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,29 +30,64 @@ import com.sun.source.tree.*; /** * A simple visitor for tree nodes. * + * @param <R> the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param <P> the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * * @author Peter von der Ahé * @since 1.6 */ @jdk.Exported public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> { + /** + * The default value, returned by the {@link #defaultAction default action}. + */ protected final R DEFAULT_VALUE; + /** + * Creates a visitor, with a DEFAULT_VALUE of {@code null}. + */ protected SimpleTreeVisitor() { DEFAULT_VALUE = null; } + /** + * Creates a visitor, with a specified DEFAULT_VALUE. + * @param defaultValue the default value to be returned by the default action. + */ protected SimpleTreeVisitor(R defaultValue) { DEFAULT_VALUE = defaultValue; } + /** + * The default action, used by all visit methods that are not overridden. + * @param node the node being visited + * @param p the parameter value passed to the visit method + * @return the result value to be returned from the visit method + */ protected R defaultAction(Tree node, P p) { return DEFAULT_VALUE; } + /** + * Invokes the appropriate visit method specific to the type of the node. + * @param node the node on which to dispatch + * @param p a parameter to be passed to the appropriate visit method + * @return the value returns from the appropriate visit method + */ public final R visit(Tree node, P p) { return (node == null) ? null : node.accept(this, p); } + /** + * Invokes the appropriate visit method on each of a sequence of nodes. + * @param nodes the nodes on which to dispatch + * @param p a parameter value to be passed to each appropriate visit method + * @return the value return from the last of the visit methods, or null + * if none were called. + */ public final R visit(Iterable<? extends Tree> nodes, P p) { R r = null; if (nodes != null) @@ -61,218 +96,650 @@ public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitCompilationUnit(CompilationUnitTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitPackage(PackageTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitImport(ImportTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitClass(ClassTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitMethod(MethodTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitVariable(VariableTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitEmptyStatement(EmptyStatementTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitBlock(BlockTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitDoWhileLoop(DoWhileLoopTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitWhileLoop(WhileLoopTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitForLoop(ForLoopTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitLabeledStatement(LabeledStatementTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSwitch(SwitchTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitCase(CaseTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSynchronized(SynchronizedTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitTry(TryTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitCatch(CatchTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitConditionalExpression(ConditionalExpressionTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitIf(IfTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitExpressionStatement(ExpressionStatementTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitBreak(BreakTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitContinue(ContinueTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitReturn(ReturnTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitThrow(ThrowTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAssert(AssertTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitMethodInvocation(MethodInvocationTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitNewClass(NewClassTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitNewArray(NewArrayTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitLambdaExpression(LambdaExpressionTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitParenthesized(ParenthesizedTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAssignment(AssignmentTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitCompoundAssignment(CompoundAssignmentTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitUnary(UnaryTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitBinary(BinaryTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitTypeCast(TypeCastTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitInstanceOf(InstanceOfTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitArrayAccess(ArrayAccessTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitMemberSelect(MemberSelectTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitMemberReference(MemberReferenceTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitIdentifier(IdentifierTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitLiteral(LiteralTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitPrimitiveType(PrimitiveTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitArrayType(ArrayTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitParameterizedType(ParameterizedTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitUnionType(UnionTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitIntersectionType(IntersectionTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitTypeParameter(TypeParameterTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitWildcard(WildcardTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitModifiers(ModifiersTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAnnotation(AnnotationTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAnnotatedType(AnnotatedTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitErroneous(ErroneousTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitOther(Tree node, P p) { return defaultAction(node, p); } diff --git a/langtools/src/share/classes/com/sun/source/util/SourcePositions.java b/langtools/src/share/classes/com/sun/source/util/SourcePositions.java index 9c4d02d0ec6da3590c94114b2ecdb490b2fdc1b0..7a2054b3469dcee0cde52d0063671b66d4160e1c 100644 --- a/langtools/src/share/classes/com/sun/source/util/SourcePositions.java +++ b/langtools/src/share/classes/com/sun/source/util/SourcePositions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import com.sun.source.tree.*; public interface SourcePositions { /** - * Gets the starting position of tree within file. If tree is not found within + * Returns the starting position of tree within file. If tree is not found within * file, or if the starting position is not available, * return {@link javax.tools.Diagnostic#NOPOS}. * The returned position must be at the start of the yield of this tree, that @@ -58,7 +58,7 @@ public interface SourcePositions { long getStartPosition(CompilationUnitTree file, Tree tree); /** - * Gets the ending position of tree within file. If tree is not found within + * Returns the ending position of tree within file. If tree is not found within * file, or if the ending position is not available, * return {@link javax.tools.Diagnostic#NOPOS}. * The returned position must be at the end of the yield of this tree, diff --git a/langtools/src/share/classes/com/sun/source/util/TaskEvent.java b/langtools/src/share/classes/com/sun/source/util/TaskEvent.java index 5ecde4d40369269cf203be66cdd5adfaf48ed234..9ead33e0aeb10fb3f4c4d85472f62a77eaeee790 100644 --- a/langtools/src/share/classes/com/sun/source/util/TaskEvent.java +++ b/langtools/src/share/classes/com/sun/source/util/TaskEvent.java @@ -79,18 +79,45 @@ public final class TaskEvent COMPILATION, } + /** + * Creates a task event for a given kind. + * The source file, compilation unit and type element + * are all set to {@code null}. + * @param kind the kind of the event + */ public TaskEvent(Kind kind) { this(kind, null, null, null); } + /** + * Creates a task event for a given kind and source file. + * The compilation unit and type element are both set to {@code null}. + * @param kind the kind of the event + * @param sourceFile the source file + */ public TaskEvent(Kind kind, JavaFileObject sourceFile) { this(kind, sourceFile, null, null); } + /** + * Creates a task event for a given kind and compilation unit. + * The source file is set from the compilation unit, + * and the type element is set to {@code null}. + * @param kind the kind of the event + * @param unit the compilation unit + */ public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); } + /** + * Creates a task event for a given kind, compilation unit + * and type element. + * The source file is set from the compilation unit. + * @param kind the kind of the event + * @param unit the compilation unit + * @param clazz the type element + */ public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); } @@ -102,22 +129,42 @@ public final class TaskEvent this.clazz = clazz; } + /** + * Returns the kind for this event. + * @return the kind + */ public Kind getKind() { return kind; } + /** + * Returns the source file for this event. + * May be {@code null}. + * @return the source file + */ public JavaFileObject getSourceFile() { return file; } + /** + * Returns the compilation unit for this event. + * May be {@code null}. + * @return the compilation unit + */ public CompilationUnitTree getCompilationUnit() { return unit; } + /** + * Returns the type element for this event. + * May be {@code null}. + * @return the type element + */ public TypeElement getTypeElement() { return clazz; } + @Override public String toString() { return "TaskEvent[" + kind + "," diff --git a/langtools/src/share/classes/com/sun/source/util/TaskListener.java b/langtools/src/share/classes/com/sun/source/util/TaskListener.java index 97f31fb5966a6d2dfef1ce09b0b1a70d0382761a..7c8f81a607655c2bd61f008b99dd5eed66a8c84a 100644 --- a/langtools/src/share/classes/com/sun/source/util/TaskListener.java +++ b/langtools/src/share/classes/com/sun/source/util/TaskListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,15 @@ package com.sun.source.util; @jdk.Exported public interface TaskListener { + /** + * Invoked when an event has begun. + * @param e the event + */ public void started(TaskEvent e); + /** + * Invoked when an event has been completed. + * @param e the event + */ public void finished(TaskEvent e); } diff --git a/langtools/src/share/classes/com/sun/source/util/TreePath.java b/langtools/src/share/classes/com/sun/source/util/TreePath.java index 8c7cb028de5138aa8bb81cc427e8a65846e0e067..3178944a4f638f5501b129ffc550273aacb119f1 100644 --- a/langtools/src/share/classes/com/sun/source/util/TreePath.java +++ b/langtools/src/share/classes/com/sun/source/util/TreePath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,16 +39,22 @@ import com.sun.source.tree.*; @jdk.Exported public class TreePath implements Iterable<Tree> { /** - * Gets a tree path for a tree node within a compilation unit. - * @return null if the node is not found + * Returns a tree path for a tree node within a compilation unit, + * or {@code null} if the node is not found. + * @param unit the compilation unit to search + * @param target the node to locate + * @return the tree path */ public static TreePath getPath(CompilationUnitTree unit, Tree target) { return getPath(new TreePath(unit), target); } /** - * Gets a tree path for a tree node within a subtree identified by a TreePath object. - * @return null if the node is not found + * Returns a tree path for a tree node within a subtree identified by a TreePath object. + * Returns {@code null} if the node is not found. + * @param path the path in which to search + * @param target the node to locate + * @return the tree path of the target node */ public static TreePath getPath(TreePath path, Tree target) { path.getClass(); @@ -85,41 +91,47 @@ public class TreePath implements Iterable<Tree> { /** * Creates a TreePath for a root node. + * @param node the root node */ - public TreePath(CompilationUnitTree t) { - this(null, t); + public TreePath(CompilationUnitTree node) { + this(null, node); } /** * Creates a TreePath for a child node. + * @param path the parent path + * @param tree the child node */ - public TreePath(TreePath p, Tree t) { - if (t.getKind() == Tree.Kind.COMPILATION_UNIT) { - compilationUnit = (CompilationUnitTree) t; + public TreePath(TreePath path, Tree tree) { + if (tree.getKind() == Tree.Kind.COMPILATION_UNIT) { + compilationUnit = (CompilationUnitTree) tree; parent = null; } else { - compilationUnit = p.compilationUnit; - parent = p; + compilationUnit = path.compilationUnit; + parent = path; } - leaf = t; + leaf = tree; } /** - * Get the compilation unit associated with this path. + * Returns the compilation unit associated with this path. + * @return the compilation unit */ public CompilationUnitTree getCompilationUnit() { return compilationUnit; } /** - * Get the leaf node for this path. + * Returns the leaf node for this path. + * @return the leaf node */ public Tree getLeaf() { return leaf; } /** - * Get the path for the enclosing node, or null if there is no enclosing node. + * Returns the path for the enclosing node, or {@code null} if there is no enclosing node. + * @return the path for the enclosing node */ public TreePath getParentPath() { return parent; diff --git a/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java b/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java index 967bcfd809b61cd52d3e4b22e7f109650c0df7ed..a07f829096c0893c19193adc0372710019f67d7c 100644 --- a/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java +++ b/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,10 @@ import com.sun.source.tree.*; public class TreePathScanner<R, P> extends TreeScanner<R, P> { /** - * Scan a tree from a position identified by a TreePath. + * Scans a tree from a position identified by a TreePath. + * @param path the path identifying the node to be scanned + * @param p a parameter value passed to visit methods + * @return the result value from the visit method */ public R scan(TreePath path, P p) { this.path = path; @@ -54,8 +57,9 @@ public class TreePathScanner<R, P> extends TreeScanner<R, P> { } /** - * Scan a single node. + * Scans a single node. * The current path is updated for the duration of the scan. + * @return the result value from the visit method */ @Override public R scan(Tree tree, P p) { @@ -72,8 +76,9 @@ public class TreePathScanner<R, P> extends TreeScanner<R, P> { } /** - * Get the current path for the node, as built up by the currently + * Returns the current path for the node, as built up by the currently * active set of scan calls. + * @return the current path */ public TreePath getCurrentPath() { return path; diff --git a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java index a14cad476c447b27adb7159f922f625b9f43dbf4..275d9c8fb9c3a7e693052128d91d9ca45bd3b46e 100644 --- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java +++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ import com.sun.source.tree.*; * <p>The default implementation of the visitXYZ methods will determine * a result as follows: * <ul> - * <li>If the node being visited has no children, the result will be null. + * <li>If the node being visited has no children, the result will be {@code null}. * <li>If the node being visited has one child, the result will be the * result of calling {@code scan} on that child. The child may be a simple node * or itself a list of nodes. @@ -64,6 +64,12 @@ import com.sun.source.tree.*; * } * </pre> * + * @param <R> the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param <P> the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * * @author Peter von der Ahé * @author Jonathan Gibbons * @since 1.6 @@ -71,17 +77,26 @@ import com.sun.source.tree.*; @jdk.Exported public class TreeScanner<R,P> implements TreeVisitor<R,P> { - /** Scan a single node. + /** + * Scans a single node. + * @param tree the node to be scanned + * @param p a parameter value passed to the visit method + * @return the result value from the visit method */ - public R scan(Tree node, P p) { - return (node == null) ? null : node.accept(this, p); + public R scan(Tree tree, P p) { + return (tree == null) ? null : tree.accept(this, p); } private R scanAndReduce(Tree node, P p, R r) { return reduce(scan(node, p), r); } - /** Scan a list of nodes. + /** + * Scans a sequence of nodes. + * @param nodes the nodes to be scanned + * @param p a parameter value to be passed to the visit method for each node + * @return the combined return value from the visit methods. + * The values are combined using the {@link #reduce reduce} method. */ public R scan(Iterable<? extends Tree> nodes, P p) { R r = null; @@ -103,6 +118,9 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { * Reduces two results into a combined result. * The default implementation is to return the first parameter. * The general contract of the method is that it may take any action whatsoever. + * @param r1 the first of the values to be combined + * @param r2 the second of the values to be combined + * @return the result of combining the two parameters */ public R reduce(R r1, R r2) { return r1; @@ -113,6 +131,14 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { * Visitor methods ****************************************************************************/ + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitCompilationUnit(CompilationUnitTree node, P p) { R r = scan(node.getPackage(), p); r = scanAndReduce(node.getImports(), p, r); @@ -120,16 +146,40 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitPackage(PackageTree node, P p) { R r = scan(node.getAnnotations(), p); r = scanAndReduce(node.getPackageName(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitImport(ImportTree node, P p) { return scan(node.getQualifiedIdentifier(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitClass(ClassTree node, P p) { R r = scan(node.getModifiers(), p); r = scanAndReduce(node.getTypeParameters(), p, r); @@ -139,6 +189,14 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitMethod(MethodTree node, P p) { R r = scan(node.getModifiers(), p); r = scanAndReduce(node.getReturnType(), p, r); @@ -151,6 +209,14 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitVariable(VariableTree node, P p) { R r = scan(node.getModifiers(), p); r = scanAndReduce(node.getType(), p, r); @@ -159,26 +225,66 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitEmptyStatement(EmptyStatementTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitBlock(BlockTree node, P p) { return scan(node.getStatements(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitDoWhileLoop(DoWhileLoopTree node, P p) { R r = scan(node.getStatement(), p); r = scanAndReduce(node.getCondition(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitWhileLoop(WhileLoopTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getStatement(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitForLoop(ForLoopTree node, P p) { R r = scan(node.getInitializer(), p); r = scanAndReduce(node.getCondition(), p, r); @@ -187,6 +293,14 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) { R r = scan(node.getVariable(), p); r = scanAndReduce(node.getExpression(), p, r); @@ -194,28 +308,68 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitLabeledStatement(LabeledStatementTree node, P p) { return scan(node.getStatement(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitSwitch(SwitchTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getCases(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitCase(CaseTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getStatements(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitSynchronized(SynchronizedTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getBlock(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitTry(TryTree node, P p) { R r = scan(node.getResources(), p); r = scanAndReduce(node.getBlock(), p, r); @@ -224,12 +378,28 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitCatch(CatchTree node, P p) { R r = scan(node.getParameter(), p); r = scanAndReduce(node.getBlock(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitConditionalExpression(ConditionalExpressionTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getTrueExpression(), p, r); @@ -237,6 +407,14 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitIf(IfTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getThenStatement(), p, r); @@ -244,32 +422,88 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitExpressionStatement(ExpressionStatementTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitBreak(BreakTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitContinue(ContinueTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitReturn(ReturnTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitThrow(ThrowTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitAssert(AssertTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getDetail(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitMethodInvocation(MethodInvocationTree node, P p) { R r = scan(node.getTypeArguments(), p); r = scanAndReduce(node.getMethodSelect(), p, r); @@ -277,6 +511,14 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitNewClass(NewClassTree node, P p) { R r = scan(node.getEnclosingExpression(), p); r = scanAndReduce(node.getIdentifier(), p, r); @@ -286,6 +528,14 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitNewArray(NewArrayTree node, P p) { R r = scan(node.getType(), p); r = scanAndReduce(node.getDimensions(), p, r); @@ -297,126 +547,326 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitLambdaExpression(LambdaExpressionTree node, P p) { R r = scan(node.getParameters(), p); r = scanAndReduce(node.getBody(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitParenthesized(ParenthesizedTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitAssignment(AssignmentTree node, P p) { R r = scan(node.getVariable(), p); r = scanAndReduce(node.getExpression(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitCompoundAssignment(CompoundAssignmentTree node, P p) { R r = scan(node.getVariable(), p); r = scanAndReduce(node.getExpression(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitUnary(UnaryTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitBinary(BinaryTree node, P p) { R r = scan(node.getLeftOperand(), p); r = scanAndReduce(node.getRightOperand(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitTypeCast(TypeCastTree node, P p) { R r = scan(node.getType(), p); r = scanAndReduce(node.getExpression(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitInstanceOf(InstanceOfTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getType(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitArrayAccess(ArrayAccessTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getIndex(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitMemberSelect(MemberSelectTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitMemberReference(MemberReferenceTree node, P p) { R r = scan(node.getQualifierExpression(), p); r = scanAndReduce(node.getTypeArguments(), p, r); return r; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitIdentifier(IdentifierTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitLiteral(LiteralTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitPrimitiveType(PrimitiveTypeTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitArrayType(ArrayTypeTree node, P p) { return scan(node.getType(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitParameterizedType(ParameterizedTypeTree node, P p) { R r = scan(node.getType(), p); r = scanAndReduce(node.getTypeArguments(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitUnionType(UnionTypeTree node, P p) { return scan(node.getTypeAlternatives(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitIntersectionType(IntersectionTypeTree node, P p) { return scan(node.getBounds(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitTypeParameter(TypeParameterTree node, P p) { R r = scan(node.getAnnotations(), p); r = scanAndReduce(node.getBounds(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitWildcard(WildcardTree node, P p) { return scan(node.getBound(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitModifiers(ModifiersTree node, P p) { return scan(node.getAnnotations(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitAnnotation(AnnotationTree node, P p) { R r = scan(node.getAnnotationType(), p); r = scanAndReduce(node.getArguments(), p, r); return r; } - public R visitAnnotatedType(AnnotatedTypeTree node, P p) { - R r = scan(node.getAnnotations(), p); - r = scanAndReduce(node.getUnderlyingType(), p, r); - return r; - } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override + public R visitAnnotatedType(AnnotatedTypeTree node, P p) { + R r = scan(node.getAnnotations(), p); + r = scanAndReduce(node.getUnderlyingType(), p, r); + return r; + } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitOther(Tree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitErroneous(ErroneousTree node, P p) { return null; } diff --git a/langtools/src/share/classes/com/sun/source/util/Trees.java b/langtools/src/share/classes/com/sun/source/util/Trees.java index 50e02045a03d046bd0aea099b28c870089f8392c..5e464c71de30697bcf44d6954042e4dc2d9b4b37 100644 --- a/langtools/src/share/classes/com/sun/source/util/Trees.java +++ b/langtools/src/share/classes/com/sun/source/util/Trees.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,9 +54,10 @@ import com.sun.source.tree.Tree; @jdk.Exported public abstract class Trees { /** - * Gets a Trees object for a given CompilationTask. + * Returns a Trees object for a given CompilationTask. * @param task the compilation task for which to get the Trees object * @throws IllegalArgumentException if the task does not support the Trees API. + * @return the Trees object */ public static Trees instance(CompilationTask task) { String taskClassName = task.getClass().getName(); @@ -67,9 +68,10 @@ public abstract class Trees { } /** - * Gets a Trees object for a given ProcessingEnvironment. + * Returns a Trees object for a given ProcessingEnvironment. * @param env the processing environment for which to get the Trees object * @throws IllegalArgumentException if the env does not support the Trees API. + * @return the Trees object */ public static Trees instance(ProcessingEnvironment env) { if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) @@ -84,95 +86,129 @@ public abstract class Trees { argType = Class.forName(argType.getName(), false, cl); Method m = c.getMethod("instance", argType); return (Trees) m.invoke(null, arg); - } catch (Throwable e) { + } catch (ReflectiveOperationException e) { throw new AssertionError(e); } } /** - * Gets a utility object for obtaining source positions. + * Returns a utility object for obtaining source positions. + * @return the utility object for obtaining source positions */ public abstract SourcePositions getSourcePositions(); /** - * Gets the Tree node for a given Element. - * Returns null if the node can not be found. + * Returns the Tree node for a given Element. + * Returns {@code null} if the node can not be found. + * @param element the element + * @return the tree node */ public abstract Tree getTree(Element element); /** - * Gets the ClassTree node for a given TypeElement. - * Returns null if the node can not be found. + * Returns the ClassTree node for a given TypeElement. + * Returns {@code null} if the node can not be found. + * @param element the element + * @return the class tree node */ public abstract ClassTree getTree(TypeElement element); /** - * Gets the MethodTree node for a given ExecutableElement. - * Returns null if the node can not be found. + * Returns the MethodTree node for a given ExecutableElement. + * Returns {@code null} if the node can not be found. + * @param method the executable element + * @return the method tree node */ public abstract MethodTree getTree(ExecutableElement method); /** - * Gets the Tree node for an AnnotationMirror on a given Element. - * Returns null if the node can not be found. + * Returns the Tree node for an AnnotationMirror on a given Element. + * Returns {@code null} if the node can not be found. + * @param e the element + * @param a the annotation mirror + * @return the tree node */ public abstract Tree getTree(Element e, AnnotationMirror a); /** - * Gets the Tree node for an AnnotationValue for an AnnotationMirror on a given Element. - * Returns null if the node can not be found. + * Returns the Tree node for an AnnotationValue for an AnnotationMirror on a given Element. + * Returns {@code null} if the node can not be found. + * @param e the element + * @param a the annotation mirror + * @param v the annotation value + * @return the tree node */ public abstract Tree getTree(Element e, AnnotationMirror a, AnnotationValue v); /** - * Gets the path to tree node within the specified compilation unit. + * Returns the path to tree node within the specified compilation unit. + * @param unit the compilation unit + * @param node the tree node + * @return the tree path */ public abstract TreePath getPath(CompilationUnitTree unit, Tree node); /** - * Gets the TreePath node for a given Element. - * Returns null if the node can not be found. + * Returns the TreePath node for a given Element. + * Returns {@code null} if the node can not be found. + * @param e the element + * @return the tree path */ public abstract TreePath getPath(Element e); /** - * Gets the TreePath node for an AnnotationMirror on a given Element. - * Returns null if the node can not be found. + * Returns the TreePath node for an AnnotationMirror on a given Element. + * Returns {@code null} if the node can not be found. + * @param e the element + * @param a the annotation mirror + * @return the tree path */ public abstract TreePath getPath(Element e, AnnotationMirror a); /** - * Gets the TreePath node for an AnnotationValue for an AnnotationMirror on a given Element. - * Returns null if the node can not be found. + * Returns the TreePath node for an AnnotationValue for an AnnotationMirror on a given Element. + * Returns {@code null} if the node can not be found. + * @param e the element + * @param a the annotation mirror + * @param v the annotation value + * @return the tree path */ public abstract TreePath getPath(Element e, AnnotationMirror a, AnnotationValue v); /** - * Gets the Element for the Tree node identified by a given TreePath. - * Returns null if the element is not available. + * Returns the Element for the Tree node identified by a given TreePath. + * Returns {@code null} if the element is not available. + * @param path the tree path + * @return the element * @throws IllegalArgumentException is the TreePath does not identify * a Tree node that might have an associated Element. */ public abstract Element getElement(TreePath path); /** - * Gets the TypeMirror for the Tree node identified by a given TreePath. - * Returns null if the TypeMirror is not available. + * Returns the TypeMirror for the Tree node identified by a given TreePath. + * Returns {@code null} if the TypeMirror is not available. + * @param path the tree path + * @return the type mirror * @throws IllegalArgumentException is the TreePath does not identify * a Tree node that might have an associated TypeMirror. */ public abstract TypeMirror getTypeMirror(TreePath path); /** - * Gets the Scope for the Tree node identified by a given TreePath. - * Returns null if the Scope is not available. + * Returns the Scope for the Tree node identified by a given TreePath. + * Returns {@code null} if the Scope is not available. + * @param path the tree path + * @return the scope */ public abstract Scope getScope(TreePath path); /** - * Gets the doc comment, if any, for the Tree node identified by a given TreePath. - * Returns null if no doc comment was found. + * Returns the doc comment, if any, for the Tree node identified by a given TreePath. + * Returns {@code null} if no doc comment was found. * @see DocTrees#getDocCommentTree(TreePath) + * @param path the tree path + * @return the doc comment */ public abstract String getDocComment(TreePath path); @@ -195,7 +231,7 @@ public abstract class Trees { public abstract boolean isAccessible(Scope scope, Element member, DeclaredType type); /** - * Gets the original type from the ErrorType object. + * Returns the original type from the ErrorType object. * @param errorType The errorType for which we want to get the original type. * @return javax.lang.model.type.TypeMirror corresponding to the original type, replaced by the ErrorType. */ @@ -215,7 +251,7 @@ public abstract class Trees { com.sun.source.tree.CompilationUnitTree root); /** - * Gets the lub of an exception parameter declared in a catch clause. + * Returns the lub of an exception parameter declared in a catch clause. * @param tree the tree for the catch clause * @return The lub of the exception parameter */ diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java index 479e3ba39f873d305a4e5e3f02326e70f6b6b353..7c818ab61877c7ccadce3258b2afb141f763de60 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java @@ -99,7 +99,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { } /** - * Gets each package name as a separate link. + * Returns each package name as a separate link. * * @param pd PackageDoc * @return content for the package link diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java index c5caa90a10c46170b0460d1de1ab25c62b2458f5..e9df15378d74eced7946f61a8a6046f50dc949bb 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,7 +101,7 @@ public class ProfileIndexFrameWriter extends AbstractProfileIndexWriter { } /** - * Gets each profile name as a separate link. + * Returns each profile name as a separate link. * * @param profileName the profile being documented * @return content for the profile link diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java index 4804d962209b65355ed03f82680b5fc9ed3c28b2..f536e14b2d9bdfa7496a606a9e644243d1c70ba7 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java @@ -104,7 +104,7 @@ public class ProfilePackageIndexFrameWriter extends AbstractProfileIndexWriter { } /** - * Gets each package name as a separate link. + * Returns each package name as a separate link. * * @param pd PackageDoc * @param profileName the name of the profile being documented 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 f546229aba46d20d6b96fe5699326f363b67c7c4..b70c612533a747f28257112eed95b56077274627 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 @@ -812,21 +812,24 @@ public class Util { collator.setStrength(caseSensitive ? Collator.TERTIARY : Collator.SECONDARY); return collator.compare(s1, s2); } + /** - * A comparator for index file uses, + * A comparator for index file presentations, * 1. this sorts first on simple names - * 2. if equal, case insensitive comparison of Parameter types - * 3. if equal, case sensitive comparison of Parameter types - * 4. if equal, compare the FQNs of the entities - * 5. if equal, then compare the DocKinds ex: Package, Interface etc. + * 2. if equal, then compare the DocKind ex: Package, Interface etc. + * 3a. if equal and if the type is of ExecutableMemberDoc(Constructor, Fields), + * a case insensitive comparison of parameter types + * 3b. if equal, a case sensitive comparison of parameter types + * 4. finally, if equal, compare the FQNs of the entities * @return a comparator for index file use */ public static Comparator<Doc> makeComparatorForIndexUse() { return new Util.DocComparator<Doc>() { /** - * compare two given Doc entities, first sort on name, if - * applicable on the method's parameter types, and finally on the - * fully qualified name of the entity. + * Compare two given Doc entities, first sort on name, then on the kinds, + * then on the parameters only if the type is an instance of ExecutableMemberDocs, + * the parameters are compared ignoring the case first, then a case sensitive comparison, + * and finally the fully qualified names. * * @param d1 - a Doc element. * @param d2 - a Doc element. @@ -838,7 +841,11 @@ public class Util { if (result != 0) { return result; } - if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) { + result = compareDocKinds(d1, d2); + if (result != 0) { + return result; + } + if (hasParameters(d1)) { Parameter[] param1 = ((ExecutableMemberDoc) d1).parameters(); Parameter[] param2 = ((ExecutableMemberDoc) d2).parameters(); result = compareParameters(false, param1, param2); @@ -846,31 +853,28 @@ public class Util { return result; } result = compareParameters(true, param1, param2); + if (result != 0) { + return result; + } } - if (result != 0) { - return result; - } - result = compareFullyQualifiedNames(d1, d2); - if (result != 0) { - return result; - } - return compareDocKinds(d1, d2); + return compareFullyQualifiedNames(d1, d2); } }; } - /** - * Comparator for ClassUse representations, this sorts on member names, - * fully qualified member names and then the parameter types if applicable, - * and finally the Doc kinds ie. package, class, interface etc. + * Comparator for ClassUse presentations, and sorts as follows: + * 1. member names + * 2. then fully qualified member names + * 3. then parameter types if applicable + * 4. finally the Doc kinds ie. package, class, interface etc. * @return a comparator to sort classes and members for class use */ public static Comparator<Doc> makeComparatorForClassUse() { return new Util.DocComparator<Doc>() { /** - * compare two given Doc entities, first sort on name, and if - * applicable on the fully qualified name, and finally if applicable - * on the parameter types. + * Compare two given Doc entities, first sort on name, and if + * applicable on the fully qualified name, and if applicable + * on the parameter types, and finally the DocKind. * @param d1 - a Doc element. * @param d2 - a Doc element. * @return a negative integer, zero, or a positive integer as the first @@ -885,7 +889,7 @@ public class Util { if (result != 0) { return result; } - if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) { + if (hasParameters(d1) && hasParameters(d2)) { Parameter[] param1 = ((ExecutableMemberDoc) d1).parameters(); Parameter[] param2 = ((ExecutableMemberDoc) d2).parameters(); result = compareParameters(false, param1, param2); @@ -898,53 +902,54 @@ public class Util { } }; } - - /** * A general purpose comparator to sort Doc entities, basically provides the building blocks * for creating specific comparators for an use-case. * @param <T> a Doc entity */ static abstract class DocComparator<T extends Doc> implements Comparator<Doc> { - static enum DocKinds { + static enum DocKind { PACKAGE, - FIELD, + CLASS, ENUM, - ANNOTATION, INTERFACE, - CLASS, + ANNOTATION, + FIELD, CONSTRUCTOR, METHOD }; - private DocKinds getValue(Doc d) { + boolean hasParameters(Doc d) { + return d instanceof ExecutableMemberDoc; + } + DocKind getDocKind(Doc d) { if (d.isAnnotationType() || d.isAnnotationTypeElement()) { - return DocKinds.ANNOTATION; + return DocKind.ANNOTATION; } else if (d.isEnum() || d.isEnumConstant()) { - return DocKinds.ENUM; + return DocKind.ENUM; } else if (d.isField()) { - return DocKinds.FIELD; + return DocKind.FIELD; } else if (d.isInterface()) { - return DocKinds.INTERFACE; + return DocKind.INTERFACE; } else if (d.isClass()) { - return DocKinds.CLASS; + return DocKind.CLASS; } else if (d.isConstructor()) { - return DocKinds.CONSTRUCTOR; + return DocKind.CONSTRUCTOR; } else if (d.isMethod()) { - return DocKinds.METHOD; + return DocKind.METHOD; } else { - return DocKinds.PACKAGE; + return DocKind.PACKAGE; } } /** * Compares two Doc entities' kinds, and these are ordered as defined in - * the DocKinds enumeration. + * the DocKind enumeration. * @param d1 the first Doc object * @param d2 the second Doc object * @return a negative integer, zero, or a positive integer as the first * argument is less than, equal to, or greater than the second. */ protected int compareDocKinds(Doc d1, Doc d2) { - return getValue(d1).compareTo(getValue(d2)); + return getDocKind(d1).compareTo(getDocKind(d2)); } /** * Compares two parameter arrays by comparing each Type of the parameter in the array, diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java index 9d9ad45c5a4632e156b667709fe343c3aa286804..6f413af5708a07c6b2d530e8dd73bde629d8c867 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java @@ -126,6 +126,9 @@ public class JavacTaskImpl extends BasicJavacTask { initContext(); notYetEntered = new HashMap<>(); compilerMain.setAPIMode(true); + compiler = JavaCompiler.instance(context); + compiler.keepComments = true; + compiler.genEndPos = true; result = compilerMain.compile(args, classNames, context, fileObjects, processors); cleanup(); return result; diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java index 56296d458c653412e447fdadf67ac684edf125e5..d9c2c248bcbe373d76c87d9e4fafd1f1310b63c6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -854,7 +854,7 @@ public class JavacTrees extends DocTrees { } /** - * Gets the original type from the ErrorType object. + * Returns the original type from the ErrorType object. * @param errorType The errorType for which we want to get the original type. * @returns TypeMirror corresponding to the original type, replaced by the ErrorType. * noType (type.tag == NONE) is returned if there is no original type. diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java index a4d09cd869915ada452150ea46da1779662ccb3d..6621805c6a5d40c1456e6bf2f205070395cffa77 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java @@ -240,6 +240,9 @@ public enum Source { public boolean allowPostApplicabilityVarargsAccessCheck() { return compareTo(JDK1_8) >= 0; } + public boolean allowPrivateSafeVarargs() { + return compareTo(JDK1_9) >= 0; + } public static SourceVersion toSourceVersion(Source source) { switch(source) { case JDK1_2: diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index ba653114d7829dd3661aae2fa74e523942f98f48..e1831b284db1a4f487f87cf2b4c3707b93b1efb5 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -626,7 +626,7 @@ public class Types { * (ii) perform functional interface bridge calculation. */ public ClassSymbol makeFunctionalInterfaceClass(Env<AttrContext> env, Name name, List<Type> targets, long cflags) { - if (targets.isEmpty() || !isFunctionalInterface(targets.head)) { + if (targets.isEmpty()) { return null; } Symbol descSym = findDescriptorSymbol(targets.head.tsym); @@ -2315,7 +2315,7 @@ public class Types { public Type visitType(Type t, Void ignored) { // A note on wildcards: there is no good way to // determine a supertype for a super bounded wildcard. - return null; + return Type.noType; } @Override @@ -2482,7 +2482,7 @@ public class Types { return false; return t.isRaw() || - supertype(t) != null && isDerivedRaw(supertype(t)) || + supertype(t) != Type.noType && isDerivedRaw(supertype(t)) || isDerivedRaw(interfaces(t)); } @@ -2967,6 +2967,12 @@ public class Types { return t; } + @Override + public Type visitUndetVar(UndetVar t, Void ignored) { + //do nothing - we should not replace inside undet variables + return t; + } + @Override public Type visitClassType(ClassType t, Void ignored) { if (!t.isCompound()) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 97f123f2b45f4b39375df226543e6cd340209150..fb17574a987b50b2c88423547ae1e553e912fb80 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -249,36 +249,30 @@ public class Attr extends JCTree.Visitor { */ Type check(final JCTree tree, final Type found, final int ownkind, final ResultInfo resultInfo) { InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext(); - Type owntype = found; - if (!owntype.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) { - if (allowPoly && inferenceContext.free(found)) { - if ((ownkind & ~resultInfo.pkind) == 0) { - owntype = resultInfo.check(tree, inferenceContext.asUndetVar(owntype)); - } else { - log.error(tree.pos(), "unexpected.type", - kindNames(resultInfo.pkind), - kindName(ownkind)); - owntype = types.createErrorType(owntype); - } + Type owntype; + if (!found.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) { + if ((ownkind & ~resultInfo.pkind) != 0) { + log.error(tree.pos(), "unexpected.type", + kindNames(resultInfo.pkind), + kindName(ownkind)); + owntype = types.createErrorType(found); + } else if (allowPoly && inferenceContext.free(found)) { + //delay the check if there are inference variables in the found type + //this means we are dealing with a partially inferred poly expression + owntype = resultInfo.pt; inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), new FreeTypeListener() { @Override public void typesInferred(InferenceContext inferenceContext) { ResultInfo pendingResult = - resultInfo.dup(inferenceContext.asInstType(resultInfo.pt)); + resultInfo.dup(inferenceContext.asInstType(resultInfo.pt)); check(tree, inferenceContext.asInstType(found), ownkind, pendingResult); } }); - return tree.type = resultInfo.pt; } else { - if ((ownkind & ~resultInfo.pkind) == 0) { - owntype = resultInfo.check(tree, owntype); - } else { - log.error(tree.pos(), "unexpected.type", - kindNames(resultInfo.pkind), - kindName(ownkind)); - owntype = types.createErrorType(owntype); - } + owntype = resultInfo.check(tree, found); } + } else { + owntype = found; } tree.type = owntype; return owntype; @@ -2472,6 +2466,7 @@ public class Attr extends JCTree.Visitor { currentTarget = infer.instantiateFunctionalInterface(that, currentTarget, explicitParamTypes, resultInfo.checkContext); } + currentTarget = types.removeWildcards(currentTarget); lambdaType = types.findDescriptorType(currentTarget); } else { currentTarget = Type.recoveryType; @@ -2894,7 +2889,7 @@ public class Attr extends JCTree.Visitor { resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && isSerializable(currentTarget); if (currentTarget != Type.recoveryType) { - currentTarget = targetChecker.visit(currentTarget, that); + currentTarget = types.removeWildcards(targetChecker.visit(currentTarget, that)); desc = types.findDescriptorType(currentTarget); } else { currentTarget = Type.recoveryType; @@ -3135,10 +3130,19 @@ public class Attr extends JCTree.Visitor { if (checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && pt != Type.recoveryType) { //check that functional interface class is well-formed - ClassSymbol csym = types.makeFunctionalInterfaceClass(env, - names.empty, List.of(fExpr.targets.head), ABSTRACT); - if (csym != null) { - chk.checkImplementations(env.tree, csym, csym); + try { + /* Types.makeFunctionalInterfaceClass() may throw an exception + * when it's executed post-inference. See the listener code + * above. + */ + ClassSymbol csym = types.makeFunctionalInterfaceClass(env, + names.empty, List.of(fExpr.targets.head), ABSTRACT); + if (csym != null) { + chk.checkImplementations(env.tree, csym, csym); + } + } catch (Types.FunctionDescriptorLookupError ex) { + JCDiagnostic cause = ex.getDiagnostic(); + resultInfo.checkContext.report(env.tree, cause); } } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 2857b4d595757991e6684d8ed7c724d94187be2a..44275993165858c2af89854cbed5c352781282be 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -127,6 +127,7 @@ public class Check { allowSimplifiedVarargs = source.allowSimplifiedVarargs(); allowDefaultMethods = source.allowDefaultMethods(); allowStrictMethodClashCheck = source.allowStrictMethodClashCheck(); + allowPrivateSafeVarargs = source.allowPrivateSafeVarargs(); complexInference = options.isSet("complexinference"); warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); @@ -181,6 +182,10 @@ public class Check { */ boolean allowStrictMethodClashCheck; + /** Switch: can the @SafeVarargs annotation be applied to private methods? + */ + boolean allowPrivateSafeVarargs; + /** Switch: -complexinference option set? */ boolean complexInference; @@ -266,6 +271,14 @@ public class Check { log.warning(LintCategory.STATIC, pos, msg, args); } + /** Warn about division by integer constant zero. + * @param pos Position to be used for error reporting. + */ + void warnDivZero(DiagnosticPosition pos) { + if (lint.isEnabled(LintCategory.DIVZERO)) + log.warning(LintCategory.DIVZERO, pos, "div.zero"); + } + /** * Report any deferred diagnostics. */ @@ -534,8 +547,8 @@ public class Check { Type checkType(final DiagnosticPosition pos, final Type found, final Type req, final CheckContext checkContext) { final Infer.InferenceContext inferenceContext = checkContext.inferenceContext(); - if (inferenceContext.free(req)) { - inferenceContext.addFreeTypeListener(List.of(req), new FreeTypeListener() { + if (inferenceContext.free(req) || inferenceContext.free(found)) { + inferenceContext.addFreeTypeListener(List.of(req, found), new FreeTypeListener() { @Override public void typesInferred(InferenceContext inferenceContext) { checkType(pos, inferenceContext.asInstType(found), inferenceContext.asInstType(req), checkContext); @@ -816,8 +829,10 @@ public class Check { if (varargElemType != null) { log.error(tree, "varargs.invalid.trustme.anno", - syms.trustMeType.tsym, - diags.fragment("varargs.trustme.on.virtual.varargs", m)); + syms.trustMeType.tsym, + allowPrivateSafeVarargs ? + diags.fragment("varargs.trustme.on.virtual.varargs", m) : + diags.fragment("varargs.trustme.on.virtual.varargs.final.only", m)); } else { log.error(tree, "varargs.invalid.trustme.anno", @@ -840,7 +855,8 @@ public class Check { private boolean isTrustMeAllowedOnMethod(Symbol s) { return (s.flags() & VARARGS) != 0 && (s.isConstructor() || - (s.flags() & (STATIC | FINAL)) != 0); + (s.flags() & (STATIC | FINAL | + (allowPrivateSafeVarargs ? PRIVATE : 0) )) != 0); } Type checkMethod(final Type mtype, @@ -2684,7 +2700,7 @@ public class Check { checkClassBounds(pos, seensofar, it); } Type st = types.supertype(type); - if (st != null) checkClassBounds(pos, seensofar, st); + if (st != Type.noType) checkClassBounds(pos, seensofar, st); } /** Enter interface into into set. @@ -3385,15 +3401,19 @@ public class Check { * @param operator The operator for the expression * @param operand The right hand operand for the expression */ - void checkDivZero(DiagnosticPosition pos, Symbol operator, Type operand) { + void checkDivZero(final DiagnosticPosition pos, Symbol operator, Type operand) { if (operand.constValue() != null - && lint.isEnabled(LintCategory.DIVZERO) && operand.getTag().isSubRangeOf(LONG) && ((Number) (operand.constValue())).longValue() == 0) { int opc = ((OperatorSymbol)operator).opcode; if (opc == ByteCodes.idiv || opc == ByteCodes.imod || opc == ByteCodes.ldiv || opc == ByteCodes.lmod) { - log.warning(LintCategory.DIVZERO, pos, "div.zero"); + deferredLintHandler.report(new DeferredLintHandler.LintLogger() { + @Override + public void report() { + warnDivZero(pos); + } + }); } } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index ef37f09749315bf7a905d55d97b9d107c2c68c65..9275ea4429b91f0e884d326d3ba0787cd17daa1a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -953,7 +953,7 @@ public class DeferredAttr extends JCTree.Visitor { LambdaReturnScanner() { super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP, - FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); + FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java index d554e0e2cc93cc76ba81115275782c3d66d47608..8ad5c17fbd442e88698ecaeafec73fe600dfe65f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java @@ -354,6 +354,7 @@ public class Infer { Type to, Attr.ResultInfo resultInfo, InferenceContext inferenceContext) { inferenceContext.solve(List.of(from.qtype), new Warner()); + inferenceContext.notifyChange(); Type capturedType = resultInfo.checkContext.inferenceContext() .cachedCapture(tree, from.inst, false); if (types.isConvertible(capturedType, @@ -450,7 +451,7 @@ public class Infer { class ImplicitArgType extends DeferredAttr.DeferredTypeMap { public ImplicitArgType(Symbol msym, Resolve.MethodResolutionPhase phase) { - rs.deferredAttr.super(AttrMode.SPECULATIVE, msym, phase); + (rs.deferredAttr).super(AttrMode.SPECULATIVE, msym, phase); } public Type apply(Type t) { @@ -518,6 +519,8 @@ public class Infer { //or if it's not a subtype of the original target, issue an error checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface)); } + //propagate constraints as per JLS 18.2.1 + checkContext.compatible(owntype, funcInterface, types.noWarnings); return owntype; } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index d4680eb9ff5a6984a252807deeda4b53135c652b..b222285d75ad8a789cc6d3ad81f1dc388d0bf3c9 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -320,7 +320,9 @@ public class LambdaToMethod extends TreeTranslator { ListBuffer<JCExpression> syntheticInits = new ListBuffer<>(); - if (!sym.isStatic()) { + if (localContext.methodReferenceReceiver != null) { + syntheticInits.append(localContext.methodReferenceReceiver); + } else if (!sym.isStatic()) { syntheticInits.append(makeThis( sym.owner.enclClass().asType(), localContext.owner.enclClass())); @@ -363,17 +365,10 @@ public class LambdaToMethod extends TreeTranslator { //first determine the method symbol to be used to generate the sam instance //this is either the method reference symbol, or the bridged reference symbol - Symbol refSym = localContext.needsBridge() - ? localContext.bridgeSym - : localContext.isSignaturePolymorphic() + Symbol refSym = localContext.isSignaturePolymorphic() ? localContext.sigPolySym : tree.sym; - //build the bridge method, if needed - if (localContext.needsBridge()) { - bridgeMemberReference(tree, localContext); - } - //the qualifying expression is treated as a special captured arg JCExpression init; switch(tree.kind) { @@ -743,54 +738,51 @@ public class LambdaToMethod extends TreeTranslator { // </editor-fold> /** - * Generate an adapter method "bridge" for a method reference which cannot - * be used directly. + * Converts a method reference which cannot be used directly into a lambda */ - private class MemberReferenceBridger { + private class MemberReferenceToLambda { private final JCMemberReference tree; private final ReferenceTranslationContext localContext; + private final Symbol owner; private final ListBuffer<JCExpression> args = new ListBuffer<>(); private final ListBuffer<JCVariableDecl> params = new ListBuffer<>(); - MemberReferenceBridger(JCMemberReference tree, ReferenceTranslationContext localContext) { + private JCExpression receiverExpression = null; + + MemberReferenceToLambda(JCMemberReference tree, ReferenceTranslationContext localContext, Symbol owner) { this.tree = tree; this.localContext = localContext; + this.owner = owner; } - /** - * Generate the bridge - */ - JCMethodDecl bridge() { + JCLambda lambda() { int prevPos = make.pos; try { make.at(tree); Type samDesc = localContext.bridgedRefSig(); List<Type> samPTypes = samDesc.getParameterTypes(); - //an extra argument is prepended to the signature of the bridge in case - //the member reference is an instance method reference (in which case - //the receiver expression is passed to the bridge itself). - Type recType = null; + // an extra argument is prepended in the case where the member + // reference is an unbound instance method reference (in which + // case the receiver expression in passed. + VarSymbol rcvr; switch (tree.kind) { - case IMPLICIT_INNER: - recType = tree.sym.owner.type.getEnclosingType(); - break; case BOUND: - recType = tree.getQualifierExpression().type; + rcvr = addParameter("rec$", tree.getQualifierExpression().type, false); + receiverExpression = attr.makeNullCheck(tree.getQualifierExpression()); break; case UNBOUND: - recType = samPTypes.head; + rcvr = addParameter("rec$", samPTypes.head, false); samPTypes = samPTypes.tail; break; + default: + rcvr = null; + break; } - //generate the parameter list for the bridged member reference - the - //bridge signature will match the signature of the target sam descriptor - - VarSymbol rcvr = (recType == null) - ? null - : addParameter("rec$", recType, false); + // generate the parameter list for the coverted member reference. + // the signature will match the signature of the target sam descriptor List<Type> refPTypes = tree.sym.type.getParameterTypes(); int refSize = refPTypes.size(); @@ -809,60 +801,46 @@ public class LambdaToMethod extends TreeTranslator { addParameter("xva$" + i, tree.varargsElement, true); } - //generate the bridge method declaration - JCMethodDecl bridgeDecl = make.MethodDef(make.Modifiers(localContext.bridgeSym.flags()), - localContext.bridgeSym.name, - make.QualIdent(samDesc.getReturnType().tsym), - List.<JCTypeParameter>nil(), - params.toList(), - tree.sym.type.getThrownTypes() == null - ? List.<JCExpression>nil() - : make.Types(tree.sym.type.getThrownTypes()), - null, - null); - bridgeDecl.sym = (MethodSymbol) localContext.bridgeSym; - bridgeDecl.type = localContext.bridgeSym.type = - types.createMethodTypeWithParameters(samDesc, TreeInfo.types(params.toList())); - - //bridge method body generation - this can be either a method call or a + //body generation - this can be either a method call or a //new instance creation expression, depending on the member reference kind - JCExpression bridgeExpr = (tree.getMode() == ReferenceMode.INVOKE) - ? bridgeExpressionInvoke(makeReceiver(rcvr)) - : bridgeExpressionNew(); + JCExpression expr = (tree.getMode() == ReferenceMode.INVOKE) + ? expressionInvoke(rcvr) + : expressionNew(); - //the body is either a return expression containing a method call, - //or the method call itself, depending on whether the return type of - //the bridge is non-void/void. - bridgeDecl.body = makeLambdaExpressionBody(bridgeExpr, bridgeDecl); - - return bridgeDecl; + JCLambda slam = make.Lambda(params.toList(), expr); + slam.targets = tree.targets; + slam.type = tree.type; + slam.pos = tree.pos; + return slam; } finally { make.at(prevPos); } } - //where - private JCExpression makeReceiver(VarSymbol rcvr) { - if (rcvr == null) return null; - JCExpression rcvrExpr = make.Ident(rcvr); - Type rcvrType = tree.sym.enclClass().type; - if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) { - rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType); - } - return rcvrExpr; + + JCExpression getReceiverExpression() { + return receiverExpression; + } + + private JCExpression makeReceiver(VarSymbol rcvr) { + if (rcvr == null) return null; + JCExpression rcvrExpr = make.Ident(rcvr); + Type rcvrType = tree.sym.enclClass().type; + if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) { + rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType); } + return rcvrExpr; + } /** - * determine the receiver of the bridged method call - the receiver can - * be either the synthetic receiver parameter or a type qualifier; the - * original qualifier expression is never used here, as it might refer - * to symbols not available in the static context of the bridge + * determine the receiver of the method call - the receiver can + * be a type qualifier, the synthetic receiver parameter or 'super'. */ - private JCExpression bridgeExpressionInvoke(JCExpression rcvr) { + private JCExpression expressionInvoke(VarSymbol rcvr) { JCExpression qualifier = tree.sym.isStatic() ? make.Type(tree.sym.owner.type) : (rcvr != null) ? - rcvr : + makeReceiver(rcvr) : tree.getQualifierExpression(); //create the qualifier expression @@ -881,10 +859,9 @@ public class LambdaToMethod extends TreeTranslator { } /** - * the enclosing expression is either 'null' (no enclosing type) or set - * to the first bridge synthetic parameter + * Lambda body to use for a 'new'. */ - private JCExpression bridgeExpressionNew() { + private JCExpression expressionNew() { if (tree.kind == ReferenceKind.ARRAY_CTOR) { //create the array creation expression JCNewArray newArr = make.NewArray( @@ -894,15 +871,10 @@ public class LambdaToMethod extends TreeTranslator { newArr.type = tree.getQualifierExpression().type; return newArr; } else { - JCExpression encl = null; - switch (tree.kind) { - case UNBOUND: - case IMPLICIT_INNER: - encl = make.Ident(params.first()); - } - //create the instance creation expression - JCNewClass newClass = make.NewClass(encl, + //note that method reference syntax does not allow an explicit + //enclosing class (so the enclosing class is null) + JCNewClass newClass = make.NewClass(null, List.<JCExpression>nil(), make.Type(tree.getQualifierExpression().type), convertArgs(tree.sym, args.toList(), tree.varargsElement), @@ -916,7 +888,8 @@ public class LambdaToMethod extends TreeTranslator { } private VarSymbol addParameter(String name, Type p, boolean genArg) { - VarSymbol vsym = new VarSymbol(0, names.fromString(name), p, localContext.bridgeSym); + VarSymbol vsym = new VarSymbol(PARAMETER | SYNTHETIC, names.fromString(name), p, owner); + vsym.pos = tree.pos; params.append(make.VarDef(vsym, null)); if (genArg) { args.append(make.Ident(vsym)); @@ -925,15 +898,6 @@ public class LambdaToMethod extends TreeTranslator { } } - /** - * Bridges a member reference - this is needed when: - * * Var args in the referenced method need to be flattened away - * * super is used - */ - private void bridgeMemberReference(JCMemberReference tree, ReferenceTranslationContext localContext) { - kInfo.addMethod(new MemberReferenceBridger(tree, localContext).bridge()); - } - private MethodType typeToMethodType(Type mt) { Type type = types.erasure(mt); return new MethodType(type.getParameterTypes(), @@ -1252,9 +1216,25 @@ public class LambdaToMethod extends TreeTranslator { @Override public void visitLambda(JCLambda tree) { + analyzeLambda(tree, "lambda.stat"); + } + + private void analyzeLambda(JCLambda tree, JCExpression methodReferenceReceiver) { + // Translation of the receiver expression must occur first + JCExpression rcvr = translate(methodReferenceReceiver); + LambdaTranslationContext context = analyzeLambda(tree, "mref.stat.1"); + if (rcvr != null) { + context.methodReferenceReceiver = rcvr; + } + } + + private LambdaTranslationContext analyzeLambda(JCLambda tree, String statKey) { List<Frame> prevStack = frameStack; try { - LambdaTranslationContext context = (LambdaTranslationContext)makeLambdaContext(tree); + LambdaTranslationContext context = new LambdaTranslationContext(tree); + if (dumpLambdaToMethodStats) { + log.note(tree, statKey, context.needsAltMetafactory(), context.translatedSym); + } frameStack = frameStack.prepend(new Frame(tree)); for (JCVariableDecl param : tree.params) { context.addSymbol(param.sym, PARAM); @@ -1263,6 +1243,7 @@ public class LambdaToMethod extends TreeTranslator { contextMap.put(tree, context); super.visitLambda(tree); context.complete(); + return context; } finally { frameStack = prevStack; @@ -1351,47 +1332,24 @@ public class LambdaToMethod extends TreeTranslator { * information added in the LambdaToMethod pass will have the wrong * signature. Hooks between Lower and LambdaToMethod have been added to * handle normal "new" in this case. This visitor converts potentially - * effected method references into a lambda containing a normal "new" of - * the class. + * affected method references into a lambda containing a normal + * expression. * * @param tree */ @Override public void visitReference(JCMemberReference tree) { - if (tree.getMode() == ReferenceMode.NEW - && tree.kind != ReferenceKind.ARRAY_CTOR - && tree.sym.owner.isLocal()) { - MethodSymbol consSym = (MethodSymbol) tree.sym; - List<Type> ptypes = ((MethodType) consSym.type).getParameterTypes(); - Type classType = consSym.owner.type; - - // Build lambda parameters - // partially cloned from TreeMaker.Params until 8014021 is fixed - Symbol owner = owner(); - ListBuffer<JCVariableDecl> paramBuff = new ListBuffer<>(); - int i = 0; - for (List<Type> l = ptypes; l.nonEmpty(); l = l.tail) { - JCVariableDecl param = make.Param(make.paramName(i++), l.head, owner); - param.sym.pos = tree.pos; - paramBuff.append(param); - } - List<JCVariableDecl> params = paramBuff.toList(); - - // Make new-class call - JCNewClass nc = makeNewClass(classType, make.Idents(params)); - nc.pos = tree.pos; - - // Make lambda holding the new-class call - JCLambda slam = make.Lambda(params, nc); - slam.targets = tree.targets; - slam.type = tree.type; - slam.pos = tree.pos; - - // Now it is a lambda, process as such - visitLambda(slam); + ReferenceTranslationContext rcontext = new ReferenceTranslationContext(tree); + contextMap.put(tree, rcontext); + if (rcontext.needsConversionToLambda()) { + // Convert to a lambda, and process as such + MemberReferenceToLambda conv = new MemberReferenceToLambda(tree, rcontext, owner()); + analyzeLambda(conv.lambda(), conv.getReceiverExpression()); } else { super.visitReference(tree); - contextMap.put(tree, makeReferenceContext(tree)); + if (dumpLambdaToMethodStats) { + log.note(tree, "mref.stat", rcontext.needsAltMetafactory(), null); + } } } @@ -1646,14 +1604,6 @@ public class LambdaToMethod extends TreeTranslator { } } - private TranslationContext<JCLambda> makeLambdaContext(JCLambda tree) { - return new LambdaTranslationContext(tree); - } - - private TranslationContext<JCMemberReference> makeReferenceContext(JCMemberReference tree) { - return new ReferenceTranslationContext(tree); - } - private class Frame { final JCTree tree; List<Symbol> locals; @@ -1773,6 +1723,13 @@ public class LambdaToMethod extends TreeTranslator { */ final Set<Symbol> freeVarProcessedLocalClasses; + /** + * For method references converted to lambdas. The method + * reference receiver expression. Must be treated like a captured + * variable. + */ + JCExpression methodReferenceReceiver; + LambdaTranslationContext(JCLambda tree) { super(tree); Frame frame = frameStack.head; @@ -1792,9 +1749,6 @@ public class LambdaToMethod extends TreeTranslator { // This symbol will be filled-in in complete this.translatedSym = makePrivateSyntheticMethod(0, null, null, owner.enclClass()); - if (dumpLambdaToMethodStats) { - log.note(tree, "lambda.stat", needsAltMetafactory(), translatedSym); - } translatedSymbols = new EnumMap<>(LambdaSymbolKind.class); translatedSymbols.put(PARAM, new LinkedHashMap<Symbol, Symbol>()); @@ -1992,7 +1946,11 @@ public class LambdaToMethod extends TreeTranslator { // If instance access isn't needed, make it static. // Interface instance methods must be default methods. // Lambda methods are private synthetic. + // Inherit ACC_STRICT from the enclosing method, or, for clinit, + // from the class. translatedSym.flags_field = SYNTHETIC | LAMBDA_METHOD | + owner.flags_field & STRICTFP | + owner.owner.flags_field & STRICTFP | PRIVATE | (thisReferenced? (inInterface? DEFAULT : 0) : STATIC); @@ -2007,6 +1965,13 @@ public class LambdaToMethod extends TreeTranslator { for (Symbol thisSym : getSymbolMap(CAPTURED_VAR).values()) { params.append(make.VarDef((VarSymbol) thisSym, null)); } + if (methodReferenceReceiver != null) { + params.append(make.VarDef( + make.Modifiers(PARAMETER|FINAL), + names.fromString("$rcvr$"), + make.Type(methodReferenceReceiver.type), + null)); + } for (Symbol thisSym : getSymbolMap(PARAM).values()) { params.append(make.VarDef((VarSymbol) thisSym, null)); } @@ -2034,102 +1999,33 @@ public class LambdaToMethod extends TreeTranslator { * and the used by the main translation routines in order to adjust method * references (i.e. in case a bridge is needed) */ - private class ReferenceTranslationContext extends TranslationContext<JCMemberReference> { + private final class ReferenceTranslationContext extends TranslationContext<JCMemberReference> { final boolean isSuper; - final Symbol bridgeSym; final Symbol sigPolySym; ReferenceTranslationContext(JCMemberReference tree) { super(tree); this.isSuper = tree.hasKind(ReferenceKind.SUPER); - this.bridgeSym = needsBridge() - ? makePrivateSyntheticMethod(isSuper ? 0 : STATIC, - referenceBridgeName(), null, - owner.enclClass()) - : null; this.sigPolySym = isSignaturePolymorphic() ? makePrivateSyntheticMethod(tree.sym.flags(), tree.sym.name, bridgedRefSig(), tree.sym.enclClass()) : null; - if (dumpLambdaToMethodStats) { - String key = bridgeSym == null ? - "mref.stat" : "mref.stat.1"; - log.note(tree, key, needsAltMetafactory(), bridgeSym); - } } /** * Get the opcode associated with this method reference */ int referenceKind() { - return LambdaToMethod.this.referenceKind(needsBridge() - ? bridgeSym - : tree.sym); + return LambdaToMethod.this.referenceKind(tree.sym); } boolean needsVarArgsConversion() { return tree.varargsElement != null; } - /** - * Generate a disambiguating string to increase stability (important - * if serialized) - * - * @return String to differentiate synthetic lambda method names - */ - private String referenceBridgeDisambiguation() { - StringBuilder buf = new StringBuilder(); - // Append the enclosing method signature to differentiate - // overloaded enclosing methods. - if (owner.type != null) { - buf.append(typeSig(owner.type)); - buf.append(":"); - } - - // Append qualifier type - buf.append(classSig(tree.sym.owner.type)); - - // Note static/instance - buf.append(tree.sym.isStatic()? " S " : " I "); - - // Append referenced signature - buf.append(typeSig(tree.sym.erasure(types))); - - return buf.toString(); - } - - /** - * Construct a unique stable name for the method reference bridge - * - * @return Name to use for the synthetic method name - */ - private Name referenceBridgeName() { - StringBuilder buf = new StringBuilder(); - // Append lambda ID, this is semantically significant - buf.append(names.lambda); - // Note that it is a method reference bridge - buf.append("MR$"); - // Append the enclosing method name - buf.append(enclosingMethodName()); - buf.append('$'); - // Append the referenced method name - buf.append(syntheticMethodNameComponent(tree.sym.name)); - buf.append('$'); - // Append a hash of the disambiguating string : enclosing method - // signature, etc. - String disam = referenceBridgeDisambiguation(); - buf.append(Integer.toHexString(disam.hashCode())); - buf.append('$'); - // The above appended name components may not be unique, append - // a count based on the above name components. - buf.append(syntheticMethodNameCounts.getIndex(buf)); - String result = buf.toString(); - return names.fromString(result); - } - /** * @return Is this an array operation like clone() */ @@ -2165,13 +2061,16 @@ public class LambdaToMethod extends TreeTranslator { } /** - * Does this reference needs a bridge (i.e. var args need to be - * expanded or "super" is used) + * Does this reference need to be converted to a lambda + * (i.e. var args need to be expanded or "super" is used) */ - final boolean needsBridge() { + final boolean needsConversionToLambda() { return isSuper || needsVarArgsConversion() || isArrayOp() || isPrivateInOtherClass() || - !receiverAccessible(); + !receiverAccessible() || + (tree.getMode() == ReferenceMode.NEW && + tree.kind != ReferenceKind.ARRAY_CTOR && + (tree.sym.owner.isLocal() || tree.sym.owner.isInner())); } Type generatedRefSig() { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index f8ab31094503d8589bdae92dc2ce35f140dff953..40dfa0696dd1425ad5c50e41c4fb9592dfaa93e5 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -958,9 +958,10 @@ public class Resolve { } public boolean compatible(Type found, Type req, Warner warn) { + InferenceContext inferenceContext = deferredAttrContext.inferenceContext; return strict ? - types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn) : - types.isConvertible(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn); + types.isSubtypeUnchecked(inferenceContext.asUndetVar(found), inferenceContext.asUndetVar(req), warn) : + types.isConvertible(inferenceContext.asUndetVar(found), inferenceContext.asUndetVar(req), warn); } public void report(DiagnosticPosition pos, JCDiagnostic details) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java index 03ab51fec48d5a1fe6a5b54ae3fbd5d31c76e6b5..780c788c4dd97bc030a795e82e70a389132cc480 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -866,90 +866,6 @@ public class TransTypes extends TreeTranslator { return types.erasure(t); } - private boolean boundsRestricted(ClassSymbol c) { - Type st = types.supertype(c.type); - if (st.isParameterized()) { - List<Type> actuals = st.allparams(); - List<Type> formals = st.tsym.type.allparams(); - while (!actuals.isEmpty() && !formals.isEmpty()) { - Type actual = actuals.head; - Type formal = formals.head; - - if (!types.isSameType(types.erasure(actual), - types.erasure(formal))) - return true; - - actuals = actuals.tail; - formals = formals.tail; - } - } - return false; - } - - private List<JCTree> addOverrideBridgesIfNeeded(DiagnosticPosition pos, - final ClassSymbol c) { - ListBuffer<JCTree> buf = new ListBuffer<>(); - if (c.isInterface() || !boundsRestricted(c)) - return buf.toList(); - Type t = types.supertype(c.type); - Scope s = t.tsym.members(); - if (s.elems != null) { - for (Symbol sym : s.getElements(new NeedsOverridBridgeFilter(c))) { - - MethodSymbol m = (MethodSymbol)sym; - MethodSymbol member = (MethodSymbol)m.asMemberOf(c.type, types); - MethodSymbol impl = m.implementation(c, types, false); - - if ((impl == null || impl.owner != c) && - !types.isSameType(member.erasure(types), m.erasure(types))) { - addOverrideBridges(pos, m, member, c, buf); - } - } - } - return buf.toList(); - } - // where - class NeedsOverridBridgeFilter implements Filter<Symbol> { - - ClassSymbol c; - - NeedsOverridBridgeFilter(ClassSymbol c) { - this.c = c; - } - public boolean accepts(Symbol s) { - return s.kind == MTH && - !s.isConstructor() && - s.isInheritedIn(c, types) && - (s.flags() & FINAL) == 0 && - (s.flags() & (SYNTHETIC | OVERRIDE_BRIDGE)) != SYNTHETIC; - } - } - - private void addOverrideBridges(DiagnosticPosition pos, - MethodSymbol impl, - MethodSymbol member, - ClassSymbol c, - ListBuffer<JCTree> bridges) { - Type implErasure = impl.erasure(types); - long flags = (impl.flags() & AccessFlags) | SYNTHETIC | BRIDGE | OVERRIDE_BRIDGE; - member = new MethodSymbol(flags, member.name, member.type, c); - JCMethodDecl md = make.MethodDef(member, null); - JCExpression receiver = make.Super(types.supertype(c.type).tsym.erasure(types), c); - Type calltype = erasure(impl.type.getReturnType()); - JCExpression call = - make.Apply(null, - make.Select(receiver, impl).setType(calltype), - translateArgs(make.Idents(md.params), - implErasure.getParameterTypes(), null)) - .setType(calltype); - JCStatement stat = (member.getReturnType().hasTag(VOID)) - ? make.Exec(call) - : make.Return(coerce(call, member.erasure(types).getReturnType())); - md.body = make.Block(0, List.of(stat)); - c.members().enter(member); - bridges.append(md); - } - /************************************************************************** * main method *************************************************************************/ @@ -1007,8 +923,6 @@ public class TransTypes extends TreeTranslator { make.at(tree.pos); if (addBridges) { ListBuffer<JCTree> bridges = new ListBuffer<>(); - if (false) //see CR: 6996415 - bridges.appendList(addOverrideBridgesIfNeeded(tree, c)); if (allowInterfaceBridges || (tree.sym.flags() & INTERFACE) == 0) { addBridges(tree.pos(), c, bridges); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java index b933b4632b6e7c1a65067e093fee3a40dee0b836..cd4b55590572c5bc2eaba76c5535f9e50759c9bd 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java @@ -1953,12 +1953,12 @@ public class Code { } } - public void closeRange(char end) { - if (isLastRangeInitialized()) { + public void closeRange(char length) { + if (isLastRangeInitialized() && length > 0) { Range range = lastRange(); if (range != null) { if (range.length == Character.MAX_VALUE) { - range.length = end; + range.length = length; } } } else { @@ -2022,7 +2022,7 @@ public class Code { } if (localVar.sym == aliveLocal && localVar.lastRange() != null) { char length = (char)(closingCP - localVar.lastRange().start_pc); - if (length > 0 && length < Character.MAX_VALUE) { + if (length < Character.MAX_VALUE) { localVar.closeRange(length); } } @@ -2093,7 +2093,7 @@ public class Code { lvar[adr].isLastRangeInitialized()) { LocalVar v = lvar[adr]; char length = (char)(curCP() - v.lastRange().start_pc); - if (length > 0 && length < Character.MAX_VALUE) { + if (length < Character.MAX_VALUE) { lvar[adr] = v.dup(); v.closeRange(length); putVar(v); diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java index 2ee148947b66979d692be412783b968da7e897c0..1eb989d81eceb19f7527badfab15123d7144c0d9 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -2766,7 +2766,7 @@ public class Gen extends JCTree.Visitor { boolean trackVar(VarSymbol var) { return (var.owner.kind == MTH && - (var.flags() & (PARAMETER | HASINIT)) == 0 && + (var.flags() & PARAMETER) == 0 && analyzer.trackable(var)); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java index 2b3f11beefab08fb24c8eea3692682a50649e9f6..17409cca18006df2b039f0d3c829f9df58237286 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java @@ -693,7 +693,6 @@ public class DocCommentParser { int p = bp; nextChar(); Name name = null; - boolean checkSemi = false; if (ch == '#') { int namep = bp; nextChar(); 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 52c18418e55fe4bae79211d1f2066a2be69def4e..25bbf6dfdf4a41e2c1f329fb68bdd5c6b3740455 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 @@ -412,9 +412,16 @@ public class JavacParser implements Parser { case ELSE: case FINALLY: case CATCH: + case THIS: + case SUPER: + case NEW: if (stopAtStatement) return; break; + case ASSERT: + if (stopAtStatement && allowAsserts) + return ; + break; } nextToken(); } @@ -2374,8 +2381,8 @@ public class JavacParser implements Parser { ListBuffer<JCStatement> stats = variableDeclarators(mods, t, new ListBuffer<JCStatement>()); // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon - storeEnd(stats.last(), token.endPos); accept(SEMI); + storeEnd(stats.last(), S.prevToken().endPos); return stats.toList(); } } @@ -2412,13 +2419,14 @@ public class JavacParser implements Parser { ListBuffer<JCStatement> stats = variableDeclarators(mods, t, new ListBuffer<JCStatement>()); // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon - storeEnd(stats.last(), token.endPos); accept(SEMI); + storeEnd(stats.last(), S.prevToken().endPos); return stats.toList(); } else { // This Exec is an "ExpressionStatement"; it subsumes the terminating semicolon - JCExpressionStatement expr = to(F.at(pos).Exec(checkExprStat(t))); + t = checkExprStat(t); accept(SEMI); + JCExpressionStatement expr = toP(F.at(pos).Exec(t)); return List.<JCStatement>of(expr); } } @@ -2497,8 +2505,8 @@ public class JavacParser implements Parser { JCStatement body = parseStatementAsBlock(); accept(WHILE); JCExpression cond = parExpression(); - JCDoWhileLoop t = to(F.at(pos).DoLoop(body, cond)); accept(SEMI); + JCDoWhileLoop t = toP(F.at(pos).DoLoop(body, cond)); return t; } case TRY: { @@ -2546,29 +2554,29 @@ public class JavacParser implements Parser { case RETURN: { nextToken(); JCExpression result = token.kind == SEMI ? null : parseExpression(); - JCReturn t = to(F.at(pos).Return(result)); accept(SEMI); + JCReturn t = toP(F.at(pos).Return(result)); return t; } case THROW: { nextToken(); JCExpression exc = parseExpression(); - JCThrow t = to(F.at(pos).Throw(exc)); accept(SEMI); + JCThrow t = toP(F.at(pos).Throw(exc)); return t; } case BREAK: { nextToken(); Name label = LAX_IDENTIFIER.accepts(token.kind) ? ident() : null; - JCBreak t = to(F.at(pos).Break(label)); accept(SEMI); + JCBreak t = toP(F.at(pos).Break(label)); return t; } case CONTINUE: { nextToken(); Name label = LAX_IDENTIFIER.accepts(token.kind) ? ident() : null; - JCContinue t = to(F.at(pos).Continue(label)); accept(SEMI); + JCContinue t = toP(F.at(pos).Continue(label)); return t; } case SEMI: @@ -2593,8 +2601,8 @@ public class JavacParser implements Parser { nextToken(); message = parseExpression(); } - JCAssert t = to(F.at(pos).Assert(assertion, message)); accept(SEMI); + JCAssert t = toP(F.at(pos).Assert(assertion, message)); return t; } /* else fall through to default case */ @@ -2609,8 +2617,9 @@ public class JavacParser implements Parser { return F.at(pos).Labelled(prevToken.name(), stat); } else { // This Exec is an "ExpressionStatement"; it subsumes the terminating semicolon - JCExpressionStatement stat = to(F.at(pos).Exec(checkExprStat(expr))); + expr = checkExprStat(expr); accept(SEMI); + JCExpressionStatement stat = toP(F.at(pos).Exec(expr)); return stat; } } @@ -3513,8 +3522,8 @@ public class JavacParser implements Parser { List<JCTree> defs = variableDeclaratorsRest(pos, mods, type, name, isInterface, dc, new ListBuffer<JCTree>()).toList(); - storeEnd(defs.last(), token.endPos); accept(SEMI); + storeEnd(defs.last(), S.prevToken().endPos); return defs; } else { pos = token.pos; diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 658a97dce223210e18b55c17b586e8c1ac1659a5..5df19716849934af518af4fa42cee6e1aba3b005 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -1101,6 +1101,10 @@ compiler.misc.varargs.trustme.on.non.varargs.meth=\ # 0: symbol compiler.misc.varargs.trustme.on.virtual.varargs=\ + Instance method {0} is neither final nor private. + +# 0: symbol +compiler.misc.varargs.trustme.on.virtual.varargs.final.only=\ Instance method {0} is not final. # 0: type, 1: symbol kind, 2: symbol diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties index 2504451a37ec082660119ce8098d6dba8acf9551..ee06c76477910c294c19014de3e15a9bc34a38ee 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties @@ -102,8 +102,6 @@ com.sun.imageio.plugins.jpeg = tiger legacy com.sun.imageio.plugins.png = tiger legacy com.sun.imageio.plugins.wbmp = tiger legacy com.sun.imageio.spi = tiger legacy -com.sun.java.browser.dom = tiger legacy -com.sun.java.browser.net = tiger legacy com.sun.java.swing = tiger legacy com.sun.java.swing.plaf.gtk = tiger legacy com.sun.java.swing.plaf.gtk.icons = tiger legacy diff --git a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java index c1a45e76e2d07d984a2f5bd26b3163f7ad795916..589032f06aeb4da81a4d24f841617600e85df16d 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java +++ b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java @@ -490,7 +490,6 @@ public class CreateSymbols extends AbstractProcessor { "org.xml.sax", "org.xml.sax.ext", "org.xml.sax.helpers", - "com.sun.java.browser.dom", "org.w3c.dom", "org.w3c.dom.bootstrap", "org.w3c.dom.ls", diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java index 463d7b84142349d616f9198b3ff88189c93eb7f8..1c52c0f6858415c7bbd001e88471bdc232cb0739 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java @@ -656,6 +656,10 @@ public class TreeInfo { if (that.packge == sym) result = that; else super.visitTopLevel(that); } + public void visitPackageDef(JCPackageDecl that) { + if (that.packge == sym) result = that; + else super.visitPackageDef(that); + } public void visitClassDef(JCClassDecl that) { if (that.sym == sym) result = that; else super.visitClassDef(that); diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/JavacMessages.java b/langtools/src/share/classes/com/sun/tools/javac/util/JavacMessages.java index 7a6f97e9ed0a85c7aa54985894658e03c4455e5b..37b74b03ed514a8f67c4b45877cf26ccf144ca0f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/JavacMessages.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/JavacMessages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -153,7 +153,7 @@ public class JavacMessages implements Messages { /** - * Gets a localized string from the compiler's default bundle. + * Returns a localized string from the compiler's default bundle. */ // used to support legacy Log.getLocalizedString static String getDefaultLocalizedString(String key, Object... args) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java b/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java index 27cf3df50f0eca3fc78022f0a9e9b854ce3c0829..7b9980f3e4ed3f953305a8caec9b7635cf6db81a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; * about conditions that would otherwise merit a warning. Such processing * is done when the condition is detected, and in those cases, no call is * made on any API to generate a warning at all. In consequence, this handler only - * gets to handle those warnings that JLS says must be generated. + * Returns to handle those warnings that JLS says must be generated. * * <p><b>This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java index f198591d668bfb00d123b7df75df65b271dc6374..3fcdadcd706111a7318f57681ff03d47afb06175 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -142,7 +142,7 @@ public class RichDiagnosticFormatter extends } /** - * Gets the type/symbol printer used by this formatter. + * Returns the type/symbol printer used by this formatter. * @return type/symbol rich printer */ protected RichPrinter getRichPrinter() { diff --git a/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java b/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java index 1f4adc0c82c5262dccf442179a17abe9df4a50b9..7bcebc515dc66c9723734c1a41e5203f8ba1c7cc 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java +++ b/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,7 +86,7 @@ public interface NativeHeaderTool extends Tool, OptionChecker { Iterable<String> classes); /** - * Gets a new instance of the standard file manager implementation + * Returns a new instance of the standard file manager implementation * for this tool. The file manager will use the given diagnostic * listener for producing any non-fatal diagnostics. Fatal errors * will be signalled with the appropriate exceptions. diff --git a/langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java b/langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java index 8f7a588b4dacb1c29f7d412cbb1f6c72f12ff75c..d425e42b0fbb37bc4c20c716a1fa60f0f0bb4489 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java +++ b/langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,7 +87,7 @@ public interface DisassemblerTool extends Tool, OptionChecker { Iterable<String> classes); /** - * Gets a new instance of the standard file manager implementation + * Returns a new instance of the standard file manager implementation * for this tool. The file manager will use the given diagnostic * listener for producing any non-fatal diagnostics. Fatal errors * will be signalled with the appropriate exceptions. diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/CleanProperties.java b/langtools/src/share/classes/com/sun/tools/sjavac/CleanProperties.java index 346853c9faff4523f93f52159cbbb46b9ee81913..3c39532b7bf0cbaa43891ac32c973cc943592491 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/CleanProperties.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/CleanProperties.java @@ -36,6 +36,7 @@ import java.util.Map; import java.util.Properties; import com.sun.tools.sjavac.options.Options; +import com.sun.tools.sjavac.server.JavacService; /** * The clean properties transform should not be necessary. @@ -56,7 +57,8 @@ public class CleanProperties implements Transformer // Any extra information is ignored for clean properties. } - public boolean transform(Map<String,Set<URI>> pkgSrcs, + public boolean transform(JavacService javacService, + Map<String,Set<URI>> pkgSrcs, Set<URI> visibleSrcs, Map<URI,Set<String>> visibleClasses, Map<String,Set<String>> oldPackageDependencies, diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java b/langtools/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java index f66e8952c1e9d652173d3f52a0425fdf9d7b62b0..93346c6ad521cc6936dc06ada6abc81923d6f556 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java @@ -25,15 +25,18 @@ package com.sun.tools.sjavac; +import java.io.File; import java.io.PrintStream; import java.net.URI; import java.util.Arrays; +import java.util.Collections; import java.util.Random; import java.util.Set; import java.util.Map; import com.sun.tools.sjavac.options.Options; -import com.sun.tools.sjavac.server.JavacServer; +import com.sun.tools.sjavac.server.CompilationResult; +import com.sun.tools.sjavac.server.JavacService; import com.sun.tools.sjavac.server.SysInfo; /** @@ -64,9 +67,10 @@ public class CompileJavaPackages implements Transformer { args = a; } - public boolean transform(Map<String,Set<URI>> pkgSrcs, - Set<URI> visibleSources, - Map<URI,Set<String>> visibleClasses, + public boolean transform(final JavacService javacService, + Map<String,Set<URI>> pkgSrcs, + final Set<URI> visibleSources, + final Map<URI,Set<String>> visibleClasses, Map<String,Set<String>> oldPackageDependents, URI destRoot, final Map<String,Set<URI>> packageArtifacts, @@ -75,24 +79,25 @@ public class CompileJavaPackages implements Transformer { int debugLevel, boolean incremental, int numCores, - PrintStream out, - PrintStream err) + final PrintStream out, + final PrintStream err) { boolean rc = true; boolean concurrentCompiles = true; // Fetch the id. - String id = Util.extractStringOption("id", args.getServerConf()); - if (id == null || id.equals("")) { + String idOpt = Util.extractStringOption("id", args.getServerConf()); + if (idOpt == null || idOpt.equals("")) { // No explicit id set. Create a random id so that the requests can be // grouped properly in the server. - id = "id"+(((new Random()).nextLong())&Long.MAX_VALUE); + idOpt = "id"+(((new Random()).nextLong())&Long.MAX_VALUE); } + final String id = idOpt; // Only keep portfile and sjavac settings.. String psServerSettings = Util.cleanSubOptions(Util.set("portfile","sjavac","background","keepalive"), args.getServerConf()); // Get maximum heap size from the server! - SysInfo sysinfo = JavacServer.connectGetSysInfo(psServerSettings, out, err); + SysInfo sysinfo = javacService.getSysInfo(); if (sysinfo.numCores == -1) { Log.error("Could not query server for sysinfo!"); return false; @@ -201,13 +206,10 @@ public class CompileJavaPackages implements Transformer { } // The return values for each chunked compile. - final int[] rn = new int[numCompiles]; + final CompilationResult[] rn = new CompilationResult[numCompiles]; // The requets, might or might not run as a background thread. final Thread[] requests = new Thread[numCompiles]; - final Set<URI> fvisible_sources = visibleSources; - final Map<URI,Set<String>> fvisible_classes = visibleClasses; - long start = System.currentTimeMillis(); for (int i=0; i<numCompiles; ++i) { @@ -215,23 +217,20 @@ public class CompileJavaPackages implements Transformer { final CompileChunk cc = compileChunks[i]; // Pass the num_cores and the id (appended with the chunk number) to the server. - final String cleanedServerSettings = psServerSettings+",poolsize="+numCores+",id="+id+"-"+ii; - final PrintStream fout = out; - final PrintStream ferr = err; + final String cleanedServerSettings = psServerSettings+",poolsize="+numCores+",id="+id+"-"+i; - requests[ii] = new Thread() { + requests[i] = new Thread() { @Override public void run() { - rn[ii] = JavacServer.useServer(cleanedServerSettings, - args.prepJavacArgs(), - cc.srcs, - fvisible_sources, - fvisible_classes, - packageArtifacts, - packageDependencies, - packagePubapis, - null, - fout, ferr); + rn[ii] = javacService.compile("n/a", + id + "-" + ii, + args.prepJavacArgs(), + Collections.<File>emptyList(), + cc.srcs, + visibleSources); + packageArtifacts.putAll(rn[ii].packageArtifacts); + packageDependencies.putAll(rn[ii].packageDependencies); + packagePubapis.putAll(rn[ii].packagePubapis); } }; @@ -253,7 +252,7 @@ public class CompileJavaPackages implements Transformer { else { requests[ii].run(); // If there was an error, then stop early when running single threaded. - if (rn[i] != 0) { + if (rn[i].returnCode != 0) { return false; } } @@ -269,7 +268,7 @@ public class CompileJavaPackages implements Transformer { // Check the return values. for (int i=0; i<numCompiles; ++i) { if (compileChunks[i].srcs.size() > 0) { - if (rn[i] != 0) { + if (rn[i].returnCode != 0) { rc = false; } } diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/CompileProperties.java b/langtools/src/share/classes/com/sun/tools/sjavac/CompileProperties.java index 48213c47991f98b2f71deb1526c944f88171f8e9..4658f96b9dc985da0bcb2381b66366f11aae8f5c 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/CompileProperties.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/CompileProperties.java @@ -38,6 +38,7 @@ import java.util.HashSet; import java.util.Map; import com.sun.tools.sjavac.options.Options; +import com.sun.tools.sjavac.server.JavacService; /** * Compile properties transform a properties file into a Java source file. @@ -63,7 +64,8 @@ public class CompileProperties implements Transformer public void setExtra(Options a) { } - public boolean transform(Map<String,Set<URI>> pkgSrcs, + public boolean transform(JavacService javacService, + Map<String,Set<URI>> pkgSrcs, Set<URI> visibleSrcs, Map<URI,Set<String>> visibleClasses, Map<String,Set<String>> oldPackageDependents, diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/CopyFile.java b/langtools/src/share/classes/com/sun/tools/sjavac/CopyFile.java index a791ef0f28ba0c3f9ca7a5fd61caa8e24de1fcd1..3d32229eea6e1c8c1d5c524b7e57f4215c78f44c 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/CopyFile.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/CopyFile.java @@ -32,6 +32,7 @@ import java.util.HashSet; import java.util.Map; import com.sun.tools.sjavac.options.Options; +import com.sun.tools.sjavac.server.JavacService; /** * The copy file transform simply copies a matching file from -src to -d . @@ -50,7 +51,8 @@ public class CopyFile implements Transformer { public void setExtra(Options a) { } - public boolean transform(Map<String,Set<URI>> pkgSrcs, + public boolean transform(JavacService javacService, + Map<String,Set<URI>> pkgSrcs, Set<URI> visibleSrcs, Map<URI,Set<String>> visibleClasses, Map<String,Set<String>> oldPackageDependents, diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/JavacState.java b/langtools/src/share/classes/com/sun/tools/sjavac/JavacState.java index 1ec71c2bf566fa6e0b986ce748195969b861932d..aa26025ea5aabcfd920b1aa95134d6633399ee5d 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/JavacState.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/JavacState.java @@ -40,6 +40,7 @@ import java.util.*; import com.sun.tools.sjavac.options.Options; import com.sun.tools.sjavac.options.SourceLocation; +import com.sun.tools.sjavac.server.JavacService; /** * The javac state class maintains the previous (prev) and the current (now) @@ -625,7 +626,7 @@ public class JavacState sr.put(e.getKey(), e.getValue()); } } - perform(binDir, sr); + perform(null, binDir, sr); } /** @@ -641,20 +642,21 @@ public class JavacState sr.put(e.getKey(), e.getValue()); } - perform(gensrcDir, sr); + perform(null, gensrcDir, sr); } /** * Compile all the java sources. Return true, if it needs to be called again! */ - public boolean performJavaCompilations(Options args, + public boolean performJavaCompilations(JavacService javacService, + Options args, Set<String> recentlyCompiled, boolean[] rcValue) { Map<String,Transformer> suffixRules = new HashMap<>(); suffixRules.put(".java", compileJavaPackages); compileJavaPackages.setExtra(args); - rcValue[0] = perform(binDir, suffixRules); + rcValue[0] = perform(javacService, binDir, suffixRules); recentlyCompiled.addAll(taintedPackages()); clearTaintedPackages(); boolean again = !packagesWithChangedPublicApis.isEmpty(); @@ -684,7 +686,9 @@ public class JavacState * For all packages, find all sources belonging to the package, group the sources * based on their transformers and apply the transformers on each source code group. */ - private boolean perform(File outputDir, Map<String,Transformer> suffixRules) + private boolean perform(JavacService javacService, + File outputDir, + Map<String,Transformer> suffixRules) { boolean rc = true; // Group sources based on transforms. A source file can only belong to a single transform. @@ -709,7 +713,8 @@ public class JavacState Map<String,String> packagePublicApis = Collections.synchronizedMap(new HashMap<String, String>()); - boolean r = t.transform(srcs, + boolean r = t.transform(javacService, + srcs, visibleSrcs, visibleClasses, prev.dependents(), diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/Main.java b/langtools/src/share/classes/com/sun/tools/sjavac/Main.java index dc97eae6e119d61d369e21679d105097fe6b7323..3ec46f60af42615b96d888fc2c3d76eafa79a458 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/Main.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/Main.java @@ -33,7 +33,9 @@ import java.nio.file.Files; import com.sun.tools.sjavac.options.Options; import com.sun.tools.sjavac.options.SourceLocation; +import com.sun.tools.sjavac.server.JavacService; import com.sun.tools.sjavac.server.JavacServer; +import com.sun.tools.sjavac.server.JavacServiceClient; /** * The main class of the smart javac wrapper tool. @@ -339,7 +341,12 @@ public class Main { do { // Clean out artifacts in tainted packages. javac_state.deleteClassArtifactsInTaintedPackages(); - again = javac_state.performJavaCompilations(options, recently_compiled, rc); + // Create a JavacService to delegate the actual compilation to. + // Currently sjavac always connects to a server through a socket + // regardless if sjavac runs as a background service or not. + // This will most likely change in the future. + JavacService javacService = new JavacServiceClient(options.getServerConf()); + again = javac_state.performJavaCompilations(javacService, options, recently_compiled, rc); if (!rc[0]) break; } while (again); // Only update the state if the compile went well. diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/Transformer.java b/langtools/src/share/classes/com/sun/tools/sjavac/Transformer.java index 125a02659d45e2912147353378a8fb55923d9121..9922c7ad9412c1886288940addaa4669236b48ad 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/Transformer.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/Transformer.java @@ -31,6 +31,7 @@ import java.util.Set; import java.util.Map; import com.sun.tools.sjavac.options.Options; +import com.sun.tools.sjavac.server.JavacService; /** * The transform interface is used to transform content inside a package, from one form to another. @@ -82,7 +83,8 @@ public interface Transformer * If num_cores is set to a non-zero value. The transform should attempt to use no more than these * number of threads for heavy work. */ - boolean transform(Map<String,Set<URI>> pkgSrcs, + boolean transform(JavacService javacService, + Map<String,Set<URI>> pkgSrcs, Set<URI> visibleSources, Map<URI,Set<String>> visibleClasses, Map<String,Set<String>> oldPackageDependencies, diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/Util.java b/langtools/src/share/classes/com/sun/tools/sjavac/Util.java index 146bb1722456ff01b5b6148a912d5316c5074e04..5039051977b7a616d3ac4c5c8eddb0afbd04f5a1 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/Util.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/Util.java @@ -26,6 +26,8 @@ package com.sun.tools.sjavac; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.nio.file.Path; import java.util.Arrays; import java.util.HashSet; @@ -67,17 +69,32 @@ public class Util { } public static String extractStringOption(String opName, String s) { + return extractStringOption(opName, s, null); + } + + public static String extractStringOption(String opName, String s, String deflt) { int p = s.indexOf(opName+"="); - if (p == -1) return null; + if (p == -1) return deflt; p+=opName.length()+1; int pe = s.indexOf(',', p); if (pe == -1) pe = s.length(); return s.substring(p, pe); } + public static boolean extractBooleanOption(String opName, String s, boolean deflt) { + String str = extractStringOption(opName, s); + return "true".equals(str) ? true + : "false".equals(str) ? false + : deflt; + } + public static int extractIntOption(String opName, String s) { + return extractIntOption(opName, s, 0); + } + + public static int extractIntOption(String opName, String s, int deflt) { int p = s.indexOf(opName+"="); - if (p == -1) return 0; + if (p == -1) return deflt; p+=opName.length()+1; int pe = s.indexOf(',', p); if (pe == -1) pe = s.length(); diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java b/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java index 4f49543352c426aa4e8e0bd9285a11e127170679..0599a8106fe2190e9475c8db865a7819f38dbc9d 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,8 +29,6 @@ import java.util.StringTokenizer; import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.code.Symbol.ClassSymbol; -import com.sun.tools.sjavac.server.CompilerThread; -import java.io.File; /** Subclass to Resolve that overrides collect. * @@ -44,16 +42,16 @@ public class JavaCompilerWithDeps extends JavaCompiler { /** The dependency database */ protected Dependencies deps; - protected CompilerThread compilerThread; + protected JavacServiceImpl javacService; - public JavaCompilerWithDeps(Context context, CompilerThread t) { + public JavaCompilerWithDeps(Context context, JavacServiceImpl jsi) { super(context); deps = Dependencies.instance(context); - compilerThread = t; + javacService = jsi; needRootClasses = true; } - public static void preRegister(Context context, final CompilerThread t) { + public static void preRegister(Context context, final JavacServiceImpl t) { context.put(compilerKey, new Context.Factory<JavaCompiler>() { public JavaCompiler make(Context c) { JavaCompiler instance = new JavaCompilerWithDeps(c, t); @@ -99,7 +97,7 @@ public class JavaCompilerWithDeps extends JavaCompiler { // Now check if the truncated uri ends with the path. (It does not == failure!) if (path.length() > 0 && !path.equals("/unnamed package/") && !pp.endsWith(path)) { - compilerThread.logError("Error: The source file "+sym.sourcefile.getName()+ + javacService.logError("Error: The source file "+sym.sourcefile.getName()+ " is located in the wrong package directory, because it contains the class "+ sym.getQualifiedName()); } diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavacServiceImpl.java b/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavacServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..d7dcdc109fc626806f6a73ab25dd3d4862679166 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavacServiceImpl.java @@ -0,0 +1,121 @@ +package com.sun.tools.sjavac.comp; + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.net.URI; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import javax.tools.JavaCompiler.CompilationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; + +import com.sun.tools.javac.api.JavacTaskImpl; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.sjavac.Util; +import com.sun.tools.sjavac.server.CompilationResult; +import com.sun.tools.sjavac.server.JavacServer; +import com.sun.tools.sjavac.server.JavacService; +import com.sun.tools.sjavac.server.SysInfo; + +public class JavacServiceImpl implements JavacService { + + JavacServer javacServer; + private ThreadLocal<Boolean> forcedExit; + + public JavacServiceImpl(JavacServer javacServer) { + this.javacServer = javacServer; + + } + + public void logError(String msg) { +// stderr.println(msg); + forcedExit.set(true); + } + + @Override + public SysInfo getSysInfo() { + return new SysInfo(Runtime.getRuntime().availableProcessors(), + Runtime.getRuntime().maxMemory()); + } + + @Override + public CompilationResult compile(String protocolId, + String invocationId, + String[] args, + List<File> explicitSources, + Set<URI> sourcesToCompile, + Set<URI> visibleSources) { + + JavacTool compiler = JavacTool.create(); + StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); + SmartFileManager smartFileManager = new SmartFileManager(fileManager); + Context context = new Context(); + ResolveWithDeps.preRegister(context); + AttrWithDeps.preRegister(context); + JavaCompilerWithDeps.preRegister(context, this); + + // Now setup the actual compilation.... + CompilationResult compilationResult = new CompilationResult(0); + + // First deal with explicit source files on cmdline and in at file. + ListBuffer<JavaFileObject> compilationUnits = new ListBuffer<>(); + for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(explicitSources)) { + compilationUnits.append(i); + } + // Now deal with sources supplied as source_to_compile. + ListBuffer<File> sourcesToCompileFiles = new ListBuffer<>(); + for (URI u : sourcesToCompile) { + sourcesToCompileFiles.append(new File(u)); + } + for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(sourcesToCompileFiles)) { + compilationUnits.append(i); + } + // Log the options to be used. + StringBuilder options = new StringBuilder(); + for (String s : args) { + options.append(">").append(s).append("< "); + } + javacServer.log(protocolId+" <"+invocationId+"> options "+options.toString()); + + forcedExit.set(false); + // Create a new logger. + StringWriter stdoutLog = new StringWriter(); + StringWriter stderrLog = new StringWriter(); + PrintWriter stdout = new PrintWriter(stdoutLog); + PrintWriter stderr = new PrintWriter(stderrLog); + com.sun.tools.javac.main.Main.Result rc = com.sun.tools.javac.main.Main.Result.OK; + try { + if (compilationUnits.size() > 0) { + smartFileManager.setVisibleSources(visibleSources); + smartFileManager.cleanArtifacts(); + smartFileManager.setLog(stdout); + + + // Do the compilation! + CompilationTask task = compiler.getTask(stderr, smartFileManager, null, Arrays.asList(args), null, compilationUnits, context); + rc = ((JavacTaskImpl) task).doCall(); + smartFileManager.flush(); + } + } catch (Exception e) { + stderr.println(e.getMessage()); + forcedExit.set(true); + } + + compilationResult.packageArtifacts = smartFileManager.getPackageArtifacts(); + + Dependencies deps = Dependencies.instance(context); + compilationResult.packageDependencies = deps.getDependencies(); + compilationResult.packagePubapis = deps.getPubapis(); + + compilationResult.stdout = stdoutLog.toString(); + compilationResult.stderr = stderrLog.toString(); + compilationResult.returnCode = rc.exitCode == 0 && forcedExit.get() ? -1 : rc.exitCode; + + return compilationResult; + } +} diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java b/langtools/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java index 8ab2998c8acd6bc78977f15431836e86d76ec021..43baf12caeb0e7eafe6e77ac60fa3adb74a93257 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,17 +25,21 @@ package com.sun.tools.sjavac.comp; -import com.sun.tools.javac.util.ListBuffer; import java.io.IOException; import java.io.PrintWriter; import java.net.URI; -import java.util.Set; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.HashMap; +import java.util.Set; + import javax.tools.*; import javax.tools.JavaFileObject.Kind; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.util.BaseFileManager; +import com.sun.tools.javac.util.ListBuffer; + /** * Intercepts reads and writes to the file system to gather * information about what artifacts are generated. @@ -76,6 +80,15 @@ public class SmartFileManager extends ForwardingJavaFileManager<JavaFileManager> stdout = pw; } + /** + * Set whether or not to use ct.sym as an alternate to rt.jar. + */ + public void setSymbolFileEnabled(boolean b) { + if (!(fileManager instanceof JavacFileManager)) + throw new IllegalStateException(); + ((JavacFileManager) fileManager).setSymbolFileEnabled(b); + } + public Map<String,Set<URI>> getPackageArtifacts() { return packageArtifacts; } diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilationResult.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilationResult.java new file mode 100644 index 0000000000000000000000000000000000000000..731cd34a5b3ed07dd6000f111fa5fb4ed00880df --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilationResult.java @@ -0,0 +1,30 @@ +package com.sun.tools.sjavac.server; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class CompilationResult { + + // Return code constants + public final static int ERROR_BUT_TRY_AGAIN = -4712; + public final static int ERROR_FATAL = -1; + + public int returnCode; + public Map<String, Set<URI>> packageArtifacts = new HashMap<>(); + public Map<String, Set<String>> packageDependencies = new HashMap<>(); + public Map<String, String> packagePubapis = new HashMap<>(); + public SysInfo sysinfo; + public String stdout; + public String stderr; + + public CompilationResult(int returnCode) { + this.returnCode = returnCode; + this.sysinfo = new SysInfo(-1, -1); + } + + public void setReturnCode(int returnCode) { + this.returnCode = returnCode; + } +} diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java index d881a4889c1cb4290a1f41736085b38b535a8744..38e2399ee71493bcb7696032d5d1f77d900da86e 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,8 @@ import java.util.concurrent.Semaphore; import java.util.Stack; import java.util.concurrent.Future; +import com.sun.tools.sjavac.comp.JavacServiceImpl; + /** The compiler pool maintains compiler threads. * * <p><b>This is NOT part of any supported API. @@ -147,7 +149,7 @@ public class CompilerPool { public CompilerThread grabCompilerThread() throws InterruptedException { available.acquire(); if (compilers.empty()) { - return new CompilerThread(this); + return new CompilerThread(this, new JavacServiceImpl(javacServer)); } return compilers.pop(); } diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java index c3873c3409e3a6a748478d39694e2dd2038be43b..59bff44c207c8ee903fe6efba29b85b1d03efa47 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java @@ -44,19 +44,18 @@ import java.util.Set; import java.util.concurrent.Future; import javax.tools.JavaCompiler.CompilationTask; -import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import com.sun.tools.javac.api.JavacTaskImpl; -import com.sun.tools.javac.util.BaseFileManager; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.ListBuffer; -import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Options; import com.sun.tools.javac.util.StringUtils; import com.sun.tools.sjavac.comp.AttrWithDeps; import com.sun.tools.sjavac.comp.Dependencies; import com.sun.tools.sjavac.comp.JavaCompilerWithDeps; +import com.sun.tools.sjavac.comp.JavacServiceImpl; import com.sun.tools.sjavac.comp.ResolveWithDeps; import com.sun.tools.sjavac.comp.SmartFileManager; @@ -73,6 +72,7 @@ import com.sun.tools.sjavac.comp.SmartFileManager; public class CompilerThread implements Runnable { private JavacServer javacServer; private CompilerPool compilerPool; + private JavacServiceImpl javacServiceImpl; private List<Future<?>> subTasks; // Communicating over this socket. @@ -87,9 +87,10 @@ public class CompilerThread implements Runnable { // If true, then this thread is serving a request. private boolean inUse = false; - CompilerThread(CompilerPool cp) { + CompilerThread(CompilerPool cp, JavacServiceImpl javacServiceImpl) { compilerPool = cp; javacServer = cp.getJavacServer(); + this.javacServiceImpl = javacServiceImpl; } /** @@ -133,7 +134,7 @@ public class CompilerThread implements Runnable { context = new Context(); ResolveWithDeps.preRegister(context); AttrWithDeps.preRegister(context); - JavaCompilerWithDeps.preRegister(context, this); + JavaCompilerWithDeps.preRegister(context, javacServiceImpl); subTasks = new ArrayList<>(); } @@ -320,6 +321,7 @@ public class CompilerThread implements Runnable { // Do the compilation! CompilationTask task = compiler.getTask(stderr, smartFileManager, null, the_options, null, compilationUnits, context); + smartFileManager.setSymbolFileEnabled(!Options.instance(context).isSet("ignore.symbol.file")); rc = ((JavacTaskImpl) task).doCall(); while (numActiveSubTasks()>0) { diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java index 2592a42396548fc0f501fb817f7af1a438806434..c181be9d5669037f1705de9092b9b31298f7ec71 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java @@ -24,30 +24,22 @@ */ package com.sun.tools.sjavac.server; -import java.io.BufferedReader; import java.io.File; import java.io.IOException; -import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.FileNotFoundException; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; import java.util.HashMap; import java.util.Map; import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; -import java.net.SocketAddress; import java.util.ArrayList; import java.util.Random; import com.sun.tools.sjavac.Util; import com.sun.tools.sjavac.ProblemException; import java.io.*; -import java.util.*; /** * The JavacServer class contains methods both to setup a server that responds to requests and methods to connect to this server. @@ -73,8 +65,6 @@ public class JavacServer { // Though usually only one javac server is started by a client. private static Map<String, PortFile> allPortFiles; private static Map<String, Long> maxServerMemory; - final static int ERROR_FATAL = -1; - final static int ERROR_BUT_TRY_AGAIN = -4712; final static String PROTOCOL_COOKIE_VERSION = "----THE-COOKIE-V2----"; final static String PROTOCOL_CWD = "----THE-CWD----"; final static String PROTOCOL_ID = "----THE-ID----"; @@ -99,7 +89,7 @@ public class JavacServer { /** * Acquire the port file. Synchronized since several threads inside an smart javac wrapper client acquires the same port file at the same time. */ - private static synchronized PortFile getPortFile(String filename) throws FileNotFoundException { + public static synchronized PortFile getPortFile(String filename) throws FileNotFoundException { if (allPortFiles == null) { allPortFiles = new HashMap<>(); } @@ -179,17 +169,12 @@ public class JavacServer { // and stderr are redirected already. // The pool size is a limit the number of concurrent compiler threads used. // The server might use less than these to avoid memory problems. - int poolsize = Util.extractIntOption("poolsize", settings); - if (poolsize <= 0) { - // If not set, default to the number of cores. - poolsize = Runtime.getRuntime().availableProcessors(); - } + int defaultPoolSize = Runtime.getRuntime().availableProcessors(); + int poolsize = Util.extractIntOption("poolsize", settings, defaultPoolSize); // How many seconds of inactivity will the server accept before quitting? - int keepalive = Util.extractIntOption("keepalive", settings); - if (keepalive <= 0) { - keepalive = 120; - } + int keepalive = Util.extractIntOption("keepalive", settings, 120); + // The port file is locked and the server port and cookie is written into it. PortFile portFile = getPortFile(portfile); JavacServer s; @@ -219,134 +204,6 @@ public class JavacServer { } } - /** - * Dispatch a compilation request to a javac server. - * - * @param args are the command line args to javac and is allowed to contain source files, @file and other command line options to javac. - * - * The generated classes, h files and other artifacts from the javac invocation are stored by the javac server to disk. - * - * @param sources_to_compile The sources to compile. - * - * @param visibleSources If visible sources has a non zero size, then visible_sources are the only files in the file system that the javac server can see! - * (Sources to compile are always visible.) The visible sources are those supplied by the (filtered) -sourcepath - * - * @param visibleClasses If visible classes for a specific root/jar has a non zero size, then visible_classes are the only class files that the javac server - * can see, in that root/jar. It maps from a classpath root or a jar file to the set of visible classes for that root/jar. - * - * The server return meta data about the build in the following parameters. - * @param package_artifacts, map from package name to set of created artifacts for that package. - * @param package_dependencies, map from package name to set of packages that it depends upon. - * @param package_pubapis, map from package name to unique string identifying its pub api. - */ - public static int useServer(String settings, String[] args, - Set<URI> sourcesToCompile, - Set<URI> visibleSources, - Map<URI, Set<String>> visibleClasses, - Map<String, Set<URI>> packageArtifacts, - Map<String, Set<String>> packageDependencies, - Map<String, String> packagePubapis, - SysInfo sysinfo, - PrintStream out, - PrintStream err) { - try { - // The id can perhaps be used in the future by the javac server to reuse the - // JavaCompiler instance for several compiles using the same id. - String id = Util.extractStringOption("id", settings); - String portfile = Util.extractStringOption("portfile", settings); - String logfile = Util.extractStringOption("logfile", settings); - String stdouterrfile = Util.extractStringOption("stdouterrfile", settings); - String background = Util.extractStringOption("background", settings); - if (background == null || !background.equals("false")) { - background = "true"; - } - // The sjavac option specifies how the server part of sjavac is spawned. - // If you have the experimental sjavac in your path, you are done. If not, you have - // to point to a com.sun.tools.sjavac.Main that supports --startserver - // for example by setting: sjavac=java%20-jar%20...javac.jar%com.sun.tools.sjavac.Main - String sjavac = Util.extractStringOption("sjavac", settings); - int poolsize = Util.extractIntOption("poolsize", settings); - int keepalive = Util.extractIntOption("keepalive", settings); - - if (keepalive <= 0) { - // Default keepalive for server is 120 seconds. - // I.e. it will accept 120 seconds of inactivity before quitting. - keepalive = 120; - } - if (portfile == null) { - err.println("No portfile was specified!"); - return -1; - } - if (logfile == null) { - logfile = portfile + ".javaclog"; - } - if (stdouterrfile == null) { - stdouterrfile = portfile + ".stdouterr"; - } - // Default to sjavac and hope it is in the path. - if (sjavac == null) { - sjavac = "sjavac"; - } - - int attempts = 0; - int rc = -1; - do { - PortFile port_file = getPortFile(portfile); - synchronized (port_file) { - port_file.lock(); - port_file.getValues(); - port_file.unlock(); - } - if (!port_file.containsPortInfo()) { - String cmd = fork(sjavac, port_file.getFilename(), logfile, poolsize, keepalive, err, stdouterrfile, background); - - if (background.equals("true") && !port_file.waitForValidValues()) { - // Ouch the server did not start! Lets print its stdouterrfile and the command used. - printFailedAttempt(cmd, stdouterrfile, err); - // And give up. - return -1; - } - } - rc = connectAndCompile(port_file, id, args, sourcesToCompile, visibleSources, - packageArtifacts, packageDependencies, packagePubapis, sysinfo, - out, err); - // Try again until we manage to connect. Any error after that - // will cause the compilation to fail. - if (rc == ERROR_BUT_TRY_AGAIN) { - // We could not connect to the server. Try again. - attempts++; - try { - Thread.sleep(WAIT_BETWEEN_CONNECT_ATTEMPTS * 1000); - } catch (InterruptedException e) { - } - } - } while (rc == ERROR_BUT_TRY_AGAIN && attempts < MAX_NUM_CONNECT_ATTEMPTS); - return rc; - } catch (Exception e) { - e.printStackTrace(err); - return -1; - } - } - - private static void printFailedAttempt(String cmd, String f, PrintStream err) { - err.println("---- Failed to start javac server with this command -----"); - err.println(cmd); - try { - BufferedReader in = new BufferedReader(new FileReader(f)); - err.println("---- stdout/stderr output from attempt to start javac server -----"); - for (;;) { - String l = in.readLine(); - if (l == null) { - break; - } - err.println(l); - } - err.println("------------------------------------------------------------------"); - } catch (Exception e) { - err.println("The stdout/stderr output in file " + f + " does not exist and the server did not start."); - } - } - /** * Spawn the server instance. */ @@ -367,15 +224,15 @@ public class JavacServer { /** * Fork a background process. Returns the command line used that can be printed if something failed. */ - private static String fork(String sjavac, String portfile, String logfile, int poolsize, int keepalive, - final PrintStream err, String stdouterrfile, String background) + public static String fork(String sjavac, String portfile, String logfile, int poolsize, int keepalive, + final PrintStream err, String stdouterrfile, boolean background) throws IOException, ProblemException { if (stdouterrfile != null && stdouterrfile.trim().equals("")) { stdouterrfile = null; } final String startserver = "--startserver:portfile=" + portfile + ",logfile=" + logfile + ",stdouterrfile=" + stdouterrfile + ",poolsize=" + poolsize + ",keepalive="+ keepalive; - if (background.equals("true")) { + if (background) { sjavac += "%20" + startserver; sjavac = sjavac.replaceAll("%20", " "); sjavac = sjavac.replaceAll("%2C", ","); @@ -420,243 +277,6 @@ public class JavacServer { return ""; } - /** - * Expect this key on the next line read from the reader. - */ - private static boolean expect(BufferedReader in, String key) throws IOException { - String s = in.readLine(); - if (s != null && s.equals(key)) { - return true; - } - return false; - } - - /** - * Make a request to the server only to get the maximum possible heap size to use for compilations. - * - * @param port_file The port file used to synchronize creation of this server. - * @param id The identify of the compilation. - * @param out Standard out information. - * @param err Standard err information. - * @return The maximum heap size in bytes. - */ - public static SysInfo connectGetSysInfo(String serverSettings, PrintStream out, PrintStream err) { - SysInfo sysinfo = new SysInfo(-1, -1); - String id = Util.extractStringOption("id", serverSettings); - String portfile = Util.extractStringOption("portfile", serverSettings); - try { - PortFile pf = getPortFile(portfile); - useServer(serverSettings, new String[0], - new HashSet<URI>(), - new HashSet<URI>(), - new HashMap<URI, Set<String>>(), - new HashMap<String, Set<URI>>(), - new HashMap<String, Set<String>>(), - new HashMap<String, String>(), - sysinfo, out, err); - } catch (Exception e) { - e.printStackTrace(err); - } - return sysinfo; - } - - /** - * Connect and compile using the javac server settings and the args. When using more advanced features, the sources_to_compile and visible_sources are - * supplied to the server and meta data is returned in package_artifacts, package_dependencies and package_pubapis. - */ - private static int connectAndCompile(PortFile portFile, String id, String[] args, - Set<URI> sourcesToCompile, - Set<URI> visibleSources, - Map<String, Set<URI>> packageArtifacts, - Map<String, Set<String>> packageDependencies, - Map<String, String> packagePublicApis, - SysInfo sysinfo, - PrintStream out, - PrintStream err) { - int rc = -3; - try { - int port = portFile.containsPortInfo() ? portFile.getPort() : 0; - if (port == 0) { - return ERROR_BUT_TRY_AGAIN; - } - long cookie = portFile.getCookie(); - - // Acquire the localhost/127.0.0.1 address. - InetAddress addr = InetAddress.getByName(null); - SocketAddress sockaddr = new InetSocketAddress(addr, port); - Socket sock = new Socket(); - int timeoutMs = CONNECTION_TIMEOUT * 1000; - try { - sock.connect(sockaddr, timeoutMs); - } catch (java.net.ConnectException e) { - err.println("Could not connect to javac server found in portfile: " + portFile.getFilename() + " " + e); - return ERROR_BUT_TRY_AGAIN; - } - if (!sock.isConnected()) { - err.println("Could not connect to javac server found in portfile: " + portFile.getFilename()); - return ERROR_BUT_TRY_AGAIN; - } - BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream())); - PrintWriter sockout = new PrintWriter(sock.getOutputStream()); - - sockout.println(PROTOCOL_COOKIE_VERSION); - sockout.println("" + cookie); - sockout.println(PROTOCOL_CWD); - sockout.println(System.getProperty("user.dir")); - sockout.println(PROTOCOL_ID); - sockout.println(id); - sockout.println(PROTOCOL_ARGS); - for (String s : args) { - StringBuffer buf = new StringBuffer(); - String[] paths = s.split(File.pathSeparator); - int c = 0; - for (String path : paths) { - File f = new File(path); - if (f.isFile() || f.isDirectory()) { - buf.append(f.getAbsolutePath()); - c++; - if (c < paths.length) { - buf.append(File.pathSeparator); - } - } else { - buf = new StringBuffer(s); - break; - } - } - sockout.println(buf.toString()); - } - sockout.println(PROTOCOL_SOURCES_TO_COMPILE); - for (URI uri : sourcesToCompile) { - sockout.println(uri.toString()); - } - sockout.println(PROTOCOL_VISIBLE_SOURCES); - for (URI uri : visibleSources) { - sockout.println(uri.toString()); - } - sockout.println(PROTOCOL_END); - sockout.flush(); - - StringBuffer stdout = new StringBuffer(); - StringBuffer stderr = new StringBuffer(); - - if (!expect(in, PROTOCOL_STDOUT)) { - return ERROR_FATAL; - } - // Load stdout - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_STDERR)) { - break; - } - stdout.append(l); - stdout.append('\n'); - } - // Load stderr - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_PACKAGE_ARTIFACTS)) { - break; - } - stderr.append(l); - stderr.append('\n'); - } - // Load the package artifacts - Set<URI> lastUriSet = null; - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_PACKAGE_DEPENDENCIES)) { - break; - } - if (l.length() > 1 && l.charAt(0) == '+') { - String pkg = l.substring(1); - lastUriSet = new HashSet<>(); - packageArtifacts.put(pkg, lastUriSet); - } else if (l.length() > 1 && lastUriSet != null) { - lastUriSet.add(new URI(l.substring(1))); - } - } - // Load package dependencies - Set<String> lastPackageSet = null; - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_PACKAGE_PUBLIC_APIS)) { - break; - } - if (l.length() > 1 && l.charAt(0) == '+') { - String pkg = l.substring(1); - lastPackageSet = new HashSet<>(); - packageDependencies.put(pkg, lastPackageSet); - } else if (l.length() > 1 && lastPackageSet != null) { - lastPackageSet.add(l.substring(1)); - } - } - // Load package pubapis - Map<String, StringBuffer> tmp = new HashMap<>(); - StringBuffer lastPublicApi = null; - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_SYSINFO)) { - break; - } - if (l.length() > 1 && l.charAt(0) == '+') { - String pkg = l.substring(1); - lastPublicApi = new StringBuffer(); - tmp.put(pkg, lastPublicApi); - } else if (l.length() > 1 && lastPublicApi != null) { - lastPublicApi.append(l.substring(1)); - lastPublicApi.append("\n"); - } - } - for (String p : tmp.keySet()) { - assert (packagePublicApis.get(p) == null); - String api = tmp.get(p).toString(); - packagePublicApis.put(p, api); - } - // Now reading the max memory possible. - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_RETURN_CODE)) { - break; - } - if (l.startsWith("num_cores=") && sysinfo != null) { - sysinfo.numCores = Integer.parseInt(l.substring(10)); - } - if (l.startsWith("max_memory=") && sysinfo != null) { - sysinfo.maxMemory = Long.parseLong(l.substring(11)); - } - } - String l = in.readLine(); - if (l == null) { - err.println("No return value from the server!"); - return ERROR_FATAL; - } - rc = Integer.parseInt(l); - out.print(stdout); - err.print(stderr); - } catch (Exception e) { - e.printStackTrace(err); - } - return rc; - } - /** * Run the server thread until it exits. Either because of inactivity or because the port file has been deleted by someone else, or overtaken by some other * javac server. diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacService.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacService.java new file mode 100644 index 0000000000000000000000000000000000000000..d6f6d3af6ae6d772fddbb880efc293081e11099f --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacService.java @@ -0,0 +1,18 @@ +package com.sun.tools.sjavac.server; + +import java.io.File; +import java.net.URI; +import java.util.List; +import java.util.Set; + +public interface JavacService { + + SysInfo getSysInfo(); + + CompilationResult compile(String protocolId, + String invocationId, + String[] args, + List<File> explicitSources, + Set<URI> sourcesToCompile, + Set<URI> visibleSources); +} diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java new file mode 100644 index 0000000000000000000000000000000000000000..f9f6e2b05fa38e8535713722933799d09969ec26 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java @@ -0,0 +1,408 @@ +package com.sun.tools.sjavac.server; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketAddress; +import java.net.URI; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.sun.tools.sjavac.Util; + +import static com.sun.tools.sjavac.server.CompilationResult.ERROR_BUT_TRY_AGAIN; +import static com.sun.tools.sjavac.server.CompilationResult.ERROR_FATAL; + +public class JavacServiceClient implements JavacService { + + + // The id can perhaps be used in the future by the javac server to reuse the + // JavaCompiler instance for several compiles using the same id. + private final String id; + private final String portfile; + private final String logfile; + private final String stdouterrfile; + private final boolean background; + + // Default keepalive for server is 120 seconds. + // I.e. it will accept 120 seconds of inactivity before quitting. + private final int keepalive; + private final int poolsize; + + // The sjavac option specifies how the server part of sjavac is spawned. + // If you have the experimental sjavac in your path, you are done. If not, you have + // to point to a com.sun.tools.sjavac.Main that supports --startserver + // for example by setting: sjavac=java%20-jar%20...javac.jar%com.sun.tools.sjavac.Main + private final String sjavac; + + public JavacServiceClient(String settings) { + id = Util.extractStringOption("id", settings); + portfile = Util.extractStringOption("portfile", settings); + logfile = Util.extractStringOption("logfile", settings, portfile + ".javaclog"); + stdouterrfile = Util.extractStringOption("stdouterrfile", settings, portfile + ".stdouterr"); + background = Util.extractBooleanOption("background", settings, true); + sjavac = Util.extractStringOption("sjavac", settings, "sjavac"); + int poolsize = Util.extractIntOption("poolsize", settings); + keepalive = Util.extractIntOption("keepalive", settings, 120); + + this.poolsize = poolsize > 0 ? poolsize : Runtime.getRuntime().availableProcessors(); + } + + + /** + * Make a request to the server only to get the maximum possible heap size to use for compilations. + * + * @param port_file The port file used to synchronize creation of this server. + * @param id The identify of the compilation. + * @param out Standard out information. + * @param err Standard err information. + * @return The maximum heap size in bytes. + */ + @Override + public SysInfo getSysInfo() { + try { + CompilationResult cr = useServer(new String[0], + Collections.<URI>emptySet(), + Collections.<URI>emptySet(), + Collections.<URI, Set<String>>emptyMap()); + return cr.sysinfo; + } catch (Exception e) { + return new SysInfo(-1, -1); + } + } + + @Override + public CompilationResult compile(String protocolId, + String invocationId, + String[] args, + List<File> explicitSources, + Set<URI> sourcesToCompile, + Set<URI> visibleSources) { + // Delegate to useServer, which delegates to compileHelper + return useServer(args, sourcesToCompile, visibleSources, null); + } + + /** + * Connect and compile using the javac server settings and the args. When using more advanced features, the sources_to_compile and visible_sources are + * supplied to the server and meta data is returned in package_artifacts, package_dependencies and package_pubapis. + */ + public CompilationResult compileHelper(String id, + String[] args, + Set<URI> sourcesToCompile, + Set<URI> visibleSources) { + + CompilationResult rc = new CompilationResult(-3); + + try { + PortFile portFile = JavacServer.getPortFile(this.portfile); + + int port = portFile.containsPortInfo() ? portFile.getPort() : 0; + if (port == 0) { + return new CompilationResult(ERROR_BUT_TRY_AGAIN); + } + long cookie = portFile.getCookie(); + // Acquire the localhost/127.0.0.1 address. + InetAddress addr = InetAddress.getByName(null); + SocketAddress sockaddr = new InetSocketAddress(addr, port); + Socket sock = new Socket(); + int timeoutMs = JavacServer.CONNECTION_TIMEOUT * 1000; + try { + sock.connect(sockaddr, timeoutMs); + } catch (java.net.ConnectException e) { + rc.setReturnCode(ERROR_BUT_TRY_AGAIN); + rc.stderr = "Could not connect to javac server found in portfile: " + portFile.getFilename() + " " + e; + return rc; + } + if (!sock.isConnected()) { + rc.setReturnCode(ERROR_BUT_TRY_AGAIN); + rc.stderr = "Could not connect to javac server found in portfile: " + portFile.getFilename(); + return rc; + } + + // + // Send arguments + // + BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream())); + PrintWriter sockout = new PrintWriter(sock.getOutputStream()); + + sockout.println(JavacServer.PROTOCOL_COOKIE_VERSION); + sockout.println("" + cookie); + sockout.println(JavacServer.PROTOCOL_CWD); + sockout.println(System.getProperty("user.dir")); + sockout.println(JavacServer.PROTOCOL_ID); + sockout.println(id); + sockout.println(JavacServer.PROTOCOL_ARGS); + for (String s : args) { + StringBuffer buf = new StringBuffer(); + String[] paths = s.split(File.pathSeparator); + int c = 0; + for (String path : paths) { + File f = new File(path); + if (f.isFile() || f.isDirectory()) { + buf.append(f.getAbsolutePath()); + c++; + if (c < paths.length) { + buf.append(File.pathSeparator); + } + } else { + buf = new StringBuffer(s); + break; + } + } + sockout.println(buf.toString()); + } + sockout.println(JavacServer.PROTOCOL_SOURCES_TO_COMPILE); + for (URI uri : sourcesToCompile) { + sockout.println(uri.toString()); + } + sockout.println(JavacServer.PROTOCOL_VISIBLE_SOURCES); + for (URI uri : visibleSources) { + sockout.println(uri.toString()); + } + sockout.println(JavacServer.PROTOCOL_END); + sockout.flush(); + + // + // Receive result + // + StringBuffer stdout = new StringBuffer(); + StringBuffer stderr = new StringBuffer(); + + if (!JavacServiceClient.expect(in, JavacServer.PROTOCOL_STDOUT)) { + return new CompilationResult(ERROR_FATAL); + } + // Load stdout + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_STDERR)) { + break; + } + stdout.append(l); + stdout.append('\n'); + } + // Load stderr + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_PACKAGE_ARTIFACTS)) { + break; + } + stderr.append(l); + stderr.append('\n'); + } + // Load the package artifacts + Set<URI> lastUriSet = null; + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_PACKAGE_DEPENDENCIES)) { + break; + } + if (l.length() > 1 && l.charAt(0) == '+') { + String pkg = l.substring(1); + lastUriSet = new HashSet<>(); + rc.packageArtifacts.put(pkg, lastUriSet); + } else if (l.length() > 1 && lastUriSet != null) { + lastUriSet.add(new URI(l.substring(1))); + } + } + // Load package dependencies + Set<String> lastPackageSet = null; + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_PACKAGE_PUBLIC_APIS)) { + break; + } + if (l.length() > 1 && l.charAt(0) == '+') { + String pkg = l.substring(1); + lastPackageSet = new HashSet<>(); + rc.packageDependencies.put(pkg, lastPackageSet); + } else if (l.length() > 1 && lastPackageSet != null) { + lastPackageSet.add(l.substring(1)); + } + } + // Load package pubapis + Map<String, StringBuffer> tmp = new HashMap<>(); + StringBuffer lastPublicApi = null; + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_SYSINFO)) { + break; + } + if (l.length() > 1 && l.charAt(0) == '+') { + String pkg = l.substring(1); + lastPublicApi = new StringBuffer(); + tmp.put(pkg, lastPublicApi); + } else if (l.length() > 1 && lastPublicApi != null) { + lastPublicApi.append(l.substring(1)); + lastPublicApi.append("\n"); + } + } + for (String p : tmp.keySet()) { + //assert (packagePublicApis.get(p) == null); + String api = tmp.get(p).toString(); + rc.packagePubapis.put(p, api); + } + // Now reading the max memory possible. + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_RETURN_CODE)) { + break; + } + if (l.startsWith("num_cores=")) { + rc.sysinfo.numCores = Integer.parseInt(l.substring(10)); + } + if (l.startsWith("max_memory=")) { + rc.sysinfo.maxMemory = Long.parseLong(l.substring(11)); + } + } + String l = in.readLine(); + if (l == null) { + rc.setReturnCode(ERROR_FATAL); + rc.stderr = "No return value from the server!"; + return rc; + } + rc.setReturnCode(Integer.parseInt(l)); + rc.stdout = stdout.toString(); + rc.stderr = stderr.toString(); + } catch (Exception e) { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + rc.stderr = sw.toString(); + } + return rc; + } + + /** + * Dispatch a compilation request to a javac server. + * + * @param args are the command line args to javac and is allowed to contain source files, @file and other command line options to javac. + * + * The generated classes, h files and other artifacts from the javac invocation are stored by the javac server to disk. + * + * @param sources_to_compile The sources to compile. + * + * @param visibleSources If visible sources has a non zero size, then visible_sources are the only files in the file system that the javac server can see! + * (Sources to compile are always visible.) The visible sources are those supplied by the (filtered) -sourcepath + * + * @param visibleClasses If visible classes for a specific root/jar has a non zero size, then visible_classes are the only class files that the javac server + * can see, in that root/jar. It maps from a classpath root or a jar file to the set of visible classes for that root/jar. + * + * The server return meta data about the build in the following parameters. + * @param package_artifacts, map from package name to set of created artifacts for that package. + * @param package_dependencies, map from package name to set of packages that it depends upon. + * @param package_pubapis, map from package name to unique string identifying its pub api. + */ + public CompilationResult useServer(String[] args, + Set<URI> sourcesToCompile, + Set<URI> visibleSources, + Map<URI, Set<String>> visibleClasses) { + try { + if (portfile == null) { + CompilationResult cr = new CompilationResult(CompilationResult.ERROR_FATAL); + cr.stderr = "No portfile was specified!"; + return cr; + } + + int attempts = 0; + CompilationResult rc; + do { + PortFile port_file = JavacServer.getPortFile(portfile); + synchronized (port_file) { + port_file.lock(); + port_file.getValues(); + port_file.unlock(); + } + if (!port_file.containsPortInfo()) { + String cmd = JavacServer.fork(sjavac, port_file.getFilename(), logfile, poolsize, keepalive, System.err, stdouterrfile, background); + + if (background && !port_file.waitForValidValues()) { + // Ouch the server did not start! Lets print its stdouterrfile and the command used. + StringWriter sw = new StringWriter(); + JavacServiceClient.printFailedAttempt(cmd, stdouterrfile, new PrintWriter(sw)); + // And give up. + CompilationResult cr = new CompilationResult(ERROR_FATAL); + cr.stderr = sw.toString(); + return cr; + } + } + rc = compileHelper(id, args, sourcesToCompile, visibleSources); + // Try again until we manage to connect. Any error after that + // will cause the compilation to fail. + if (rc.returnCode == CompilationResult.ERROR_BUT_TRY_AGAIN) { + // We could not connect to the server. Try again. + attempts++; + try { + Thread.sleep(JavacServer.WAIT_BETWEEN_CONNECT_ATTEMPTS * 1000); + } catch (InterruptedException e) { + } + } + } while (rc.returnCode == ERROR_BUT_TRY_AGAIN && attempts < JavacServer.MAX_NUM_CONNECT_ATTEMPTS); + return rc; + } catch (Exception e) { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + CompilationResult cr = new CompilationResult(ERROR_FATAL); + cr.stderr = sw.toString(); + return cr; + } + } + + public static void printFailedAttempt(String cmd, String f, PrintWriter err) { + err.println("---- Failed to start javac server with this command -----"); + err.println(cmd); + try { + BufferedReader in = new BufferedReader(new FileReader(f)); + err.println("---- stdout/stderr output from attempt to start javac server -----"); + for (;;) { + String l = in.readLine(); + if (l == null) { + break; + } + err.println(l); + } + err.println("------------------------------------------------------------------"); + } catch (Exception e) { + err.println("The stdout/stderr output in file " + f + " does not exist and the server did not start."); + } + } + + /** + * Expect this key on the next line read from the reader. + */ + public static boolean expect(BufferedReader in, String key) throws IOException { + String s = in.readLine(); + if (s != null && s.equals(key)) { + return true; + } + return false; + } +} diff --git a/langtools/src/share/classes/javax/tools/Diagnostic.java b/langtools/src/share/classes/javax/tools/Diagnostic.java index 03b11fd97aa00ae475ea814b6c01c95aeb542858..dfa5ef4a39d2ab5d1ffc574dc94bf15f2e18cd3b 100644 --- a/langtools/src/share/classes/javax/tools/Diagnostic.java +++ b/langtools/src/share/classes/javax/tools/Diagnostic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,14 +92,14 @@ public interface Diagnostic<S> { public final static long NOPOS = -1; /** - * Gets the kind of this diagnostic, for example, error or + * Returns the kind of this diagnostic, for example, error or * warning. * @return the kind of this diagnostic */ Kind getKind(); /** - * Gets the source object associated with this diagnostic. + * Returns the source object associated with this diagnostic. * * @return the source object associated with this diagnostic. * {@code null} if no source object is associated with the @@ -108,7 +108,7 @@ public interface Diagnostic<S> { S getSource(); /** - * Gets a character offset from the beginning of the source object + * Returns a character offset from the beginning of the source object * associated with this diagnostic that indicates the location of * the problem. In addition, the following must be true: * @@ -122,7 +122,7 @@ public interface Diagnostic<S> { long getPosition(); /** - * Gets the character offset from the beginning of the file + * Returns the character offset from the beginning of the file * associated with this diagnostic that indicates the start of the * problem. * @@ -132,7 +132,7 @@ public interface Diagnostic<S> { long getStartPosition(); /** - * Gets the character offset from the beginning of the file + * Returns the character offset from the beginning of the file * associated with this diagnostic that indicates the end of the * problem. * @@ -142,7 +142,7 @@ public interface Diagnostic<S> { long getEndPosition(); /** - * Gets the line number of the character offset returned by + * Returns the line number of the character offset returned by * {@linkplain #getPosition()}. * * @return a line number or {@link #NOPOS} if and only if {@link @@ -151,7 +151,7 @@ public interface Diagnostic<S> { long getLineNumber(); /** - * Gets the column number of the character offset returned by + * Returns the column number of the character offset returned by * {@linkplain #getPosition()}. * * @return a column number or {@link #NOPOS} if and only if {@link @@ -160,7 +160,7 @@ public interface Diagnostic<S> { long getColumnNumber(); /** - * Gets a diagnostic code indicating the type of diagnostic. The + * Returns a diagnostic code indicating the type of diagnostic. The * code is implementation-dependent and might be {@code null}. * * @return a diagnostic code @@ -168,7 +168,7 @@ public interface Diagnostic<S> { String getCode(); /** - * Gets a localized message for the given locale. The actual + * Returns a localized message for the given locale. The actual * message is implementation-dependent. If the locale is {@code * null} use the default locale. * diff --git a/langtools/src/share/classes/javax/tools/DiagnosticCollector.java b/langtools/src/share/classes/javax/tools/DiagnosticCollector.java index 8f290f50ed3c26eff5bde7dce13b96b3ca633794..160c748bf4a7de5b010bcdf929d009357771c145 100644 --- a/langtools/src/share/classes/javax/tools/DiagnosticCollector.java +++ b/langtools/src/share/classes/javax/tools/DiagnosticCollector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ public final class DiagnosticCollector<S> implements DiagnosticListener<S> { } /** - * Gets a list view of diagnostics collected by this object. + * Returns a list view of diagnostics collected by this object. * * @return a list view of diagnostics */ diff --git a/langtools/src/share/classes/javax/tools/DocumentationTool.java b/langtools/src/share/classes/javax/tools/DocumentationTool.java index 63158ed005ed5675e288daefcc2d6b5eddc37393..2d11778c7568ac5c41cb8158aab9041c5ce4b8bf 100644 --- a/langtools/src/share/classes/javax/tools/DocumentationTool.java +++ b/langtools/src/share/classes/javax/tools/DocumentationTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,7 +83,7 @@ public interface DocumentationTool extends Tool, OptionChecker { Iterable<? extends JavaFileObject> compilationUnits); /** - * Gets a new instance of the standard file manager implementation + * Returns a new instance of the standard file manager implementation * for this tool. The file manager will use the given diagnostic * listener for producing any non-fatal diagnostics. Fatal errors * will be signaled with the appropriate exceptions. diff --git a/langtools/src/share/classes/javax/tools/FileObject.java b/langtools/src/share/classes/javax/tools/FileObject.java index 132962862f048d0a28c0a9dc2b460675b80d4588..492ca6b3cc9c9bbf2055bdb5297581d5abd0e9f3 100644 --- a/langtools/src/share/classes/javax/tools/FileObject.java +++ b/langtools/src/share/classes/javax/tools/FileObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,7 @@ public interface FileObject { URI toUri(); /** - * Gets a user-friendly name for this file object. The exact + * Returns a user-friendly name for this file object. The exact * value returned is not specified but implementations should take * care to preserve names as given by the user. For example, if * the user writes the filename {@code "BobsApp\Test.java"} on @@ -71,7 +71,7 @@ public interface FileObject { String getName(); /** - * Gets an InputStream for this file object. + * Returns an InputStream for this file object. * * @return an InputStream * @throws IllegalStateException if this file object was @@ -83,7 +83,7 @@ public interface FileObject { InputStream openInputStream() throws IOException; /** - * Gets an OutputStream for this file object. + * Returns an OutputStream for this file object. * * @return an OutputStream * @throws IllegalStateException if this file object was @@ -95,7 +95,7 @@ public interface FileObject { OutputStream openOutputStream() throws IOException; /** - * Gets a reader for this object. The returned reader will + * Returns a reader for this object. The returned reader will * replace bytes that cannot be decoded with the default * translation character. In addition, the reader may report a * diagnostic unless {@code ignoreEncodingErrors} is true. @@ -111,7 +111,7 @@ public interface FileObject { Reader openReader(boolean ignoreEncodingErrors) throws IOException; /** - * Gets the character content of this file object, if available. + * Returns the character content of this file object, if available. * Any byte that cannot be decoded will be replaced by the default * translation character. In addition, a diagnostic may be * reported unless {@code ignoreEncodingErrors} is true. @@ -127,7 +127,7 @@ public interface FileObject { CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException; /** - * Gets a Writer for this file object. + * Returns a Writer for this file object. * * @return a Writer * @throws IllegalStateException if this file object was @@ -139,7 +139,7 @@ public interface FileObject { Writer openWriter() throws IOException; /** - * Gets the time this file object was last modified. The time is + * Returns the time this file object was last modified. The time is * measured in milliseconds since the epoch (00:00:00 GMT, January * 1, 1970). * diff --git a/langtools/src/share/classes/javax/tools/JavaCompiler.java b/langtools/src/share/classes/javax/tools/JavaCompiler.java index 09c70bae48eca83a1c93e1932c64ab4213f34cfc..f36638748346ce639bc9b56eef9db475db5f5d14 100644 --- a/langtools/src/share/classes/javax/tools/JavaCompiler.java +++ b/langtools/src/share/classes/javax/tools/JavaCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -263,7 +263,7 @@ public interface JavaCompiler extends Tool, OptionChecker { Iterable<? extends JavaFileObject> compilationUnits); /** - * Gets a new instance of the standard file manager implementation + * Returns a new instance of the standard file manager implementation * for this tool. The file manager will use the given diagnostic * listener for producing any non-fatal diagnostics. Fatal errors * will be signaled with the appropriate exceptions. diff --git a/langtools/src/share/classes/javax/tools/JavaFileManager.java b/langtools/src/share/classes/javax/tools/JavaFileManager.java index d519a5c9619dcb049be7082cf73fbbcbf8829e55..e5e911ee0847bc1237ca53acc6c6fa1dbfdf8ca6 100644 --- a/langtools/src/share/classes/javax/tools/JavaFileManager.java +++ b/langtools/src/share/classes/javax/tools/JavaFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,7 +110,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { */ interface Location { /** - * Gets the name of this location. + * Returns the name of this location. * * @return a name */ @@ -127,7 +127,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { } /** - * Gets a class loader for loading plug-ins from the given + * Returns a class loader for loading plug-ins from the given * location. For example, to load annotation processors, a * compiler will request a class loader for the {@link * StandardLocation#ANNOTATION_PROCESSOR_PATH @@ -224,7 +224,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { boolean hasLocation(Location location); /** - * Gets a {@linkplain JavaFileObject file object} for input + * Returns a {@linkplain JavaFileObject file object} for input * representing the specified class of the specified kind in the * given location. * @@ -250,7 +250,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { throws IOException; /** - * Gets a {@linkplain JavaFileObject file object} for output + * Returns a {@linkplain JavaFileObject file object} for output * representing the specified class of the specified kind in the * given location. * @@ -288,7 +288,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { throws IOException; /** - * Gets a {@linkplain FileObject file object} for input + * Returns a {@linkplain FileObject file object} for input * representing the specified <a href="JavaFileManager.html#relative_name">relative * name</a> in the specified package in the given location. * @@ -332,7 +332,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { throws IOException; /** - * Gets a {@linkplain FileObject file object} for output + * Returns a {@linkplain FileObject file object} for output * representing the specified <a href="JavaFileManager.html#relative_name">relative * name</a> in the specified package in the given location. * diff --git a/langtools/src/share/classes/javax/tools/JavaFileObject.java b/langtools/src/share/classes/javax/tools/JavaFileObject.java index d331e5dcb3a4eddf763ca461bf3748eb857331ab..dba8fe49e5ceb93854ab32e3e20dbc2478053b59 100644 --- a/langtools/src/share/classes/javax/tools/JavaFileObject.java +++ b/langtools/src/share/classes/javax/tools/JavaFileObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,7 +84,7 @@ public interface JavaFileObject extends FileObject { } /** - * Gets the kind of this file object. + * Returns the kind of this file object. * * @return the kind */ diff --git a/langtools/src/share/classes/javax/tools/StandardJavaFileManager.java b/langtools/src/share/classes/javax/tools/StandardJavaFileManager.java index cd7120bd91656481118c28d584fd0460088ecd01..2b1ad4b7303b67b4a6a4f370a94a0cbacc8372ce 100644 --- a/langtools/src/share/classes/javax/tools/StandardJavaFileManager.java +++ b/langtools/src/share/classes/javax/tools/StandardJavaFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -155,7 +155,7 @@ public interface StandardJavaFileManager extends JavaFileManager { boolean isSameFile(FileObject a, FileObject b); /** - * Gets file objects representing the given files. + * Returns file objects representing the given files. * * @param files a list of files * @return a list of file objects @@ -166,7 +166,7 @@ public interface StandardJavaFileManager extends JavaFileManager { Iterable<? extends File> files); /** - * Gets file objects representing the given files. + * Returns file objects representing the given files. * Convenience method equivalent to: * * <pre> @@ -183,7 +183,7 @@ public interface StandardJavaFileManager extends JavaFileManager { Iterable<? extends JavaFileObject> getJavaFileObjects(File... files); /** - * Gets file objects representing the given file names. + * Returns file objects representing the given file names. * * @param names a list of file names * @return a list of file objects @@ -194,7 +194,7 @@ public interface StandardJavaFileManager extends JavaFileManager { Iterable<String> names); /** - * Gets file objects representing the given file names. + * Returns file objects representing the given file names. * Convenience method equivalent to: * * <pre> @@ -227,7 +227,7 @@ public interface StandardJavaFileManager extends JavaFileManager { throws IOException; /** - * Gets the path associated with the given location. + * Returns the path associated with the given location. * * @param location a location * @return a list of files or {@code null} if this location has no diff --git a/langtools/src/share/classes/javax/tools/StandardLocation.java b/langtools/src/share/classes/javax/tools/StandardLocation.java index 629c0d029d4528a0dc008a043bf941ac75863442..199f22d42f3fd800f7836f50f00e0e246717994b 100644 --- a/langtools/src/share/classes/javax/tools/StandardLocation.java +++ b/langtools/src/share/classes/javax/tools/StandardLocation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,7 @@ public enum StandardLocation implements Location { NATIVE_HEADER_OUTPUT; /** - * Gets a location object with the given name. The following + * Returns a location object with the given name. The following * property must hold: {@code locationFor(x) == * locationFor(y)} if and only if {@code x.equals(y)}. * The returned location will be an output location if and only if diff --git a/langtools/src/share/classes/javax/tools/Tool.java b/langtools/src/share/classes/javax/tools/Tool.java index 0d9593f1445fb37e4f4f40beb95bfeb4bc69451a..5ffeccd37cdea2b876006799d1da19605c717b6d 100644 --- a/langtools/src/share/classes/javax/tools/Tool.java +++ b/langtools/src/share/classes/javax/tools/Tool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,7 +63,7 @@ public interface Tool { int run(InputStream in, OutputStream out, OutputStream err, String... arguments); /** - * Gets the source versions of the Java™ programming language + * Returns the source versions of the Java™ programming language * supported by this tool. * @return a set of supported source versions */ diff --git a/langtools/src/share/classes/javax/tools/ToolProvider.java b/langtools/src/share/classes/javax/tools/ToolProvider.java index 07637a14d4b15c84711cdac7ead59293ce3ebe0f..ccd37aa6d528f559d5711e30d7f1d0891e7e0f8f 100644 --- a/langtools/src/share/classes/javax/tools/ToolProvider.java +++ b/langtools/src/share/classes/javax/tools/ToolProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,7 +93,7 @@ public class ToolProvider { = "com.sun.tools.javac.api.JavacTool"; /** - * Gets the Java™ programming language compiler provided + * Returns the Java™ programming language compiler provided * with this platform. * @return the compiler provided with this platform or * {@code null} if no compiler is provided @@ -106,7 +106,7 @@ public class ToolProvider { = "com.sun.tools.javadoc.api.JavadocTool"; /** - * Gets the Java™ programming language documentation tool provided + * Returns the Java™ programming language documentation tool provided * with this platform. * @return the documentation tool provided with this platform or * {@code null} if no documentation tool is provided diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/overview.html b/langtools/test/com/sun/javadoc/DocRootSlash/overview.html index 3ff9efd137874014e7c396ce2c887a0ab8b1ab59..fc14f0fbaf255a86b6978827ad607f60e99391b0 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/overview.html +++ b/langtools/test/com/sun/javadoc/DocRootSlash/overview.html @@ -38,7 +38,7 @@ Sub-test 29 Actual: <A HREF="{@docRoot}/../docs1/p2/package-summary.html#package Sub-test 29 Expect: <A HREF="./../docs1/p2/package-summary.html#package_description">./../docs1/p2/package-summary.html#package_description</A> <p> -<!-- ----------------------------------------------- --> +<!-- ============================================================== --> Allow docRoot to work without a trailing slash for those who had to change their comments to work with the 1.4.0 bug: @@ -60,13 +60,5 @@ Sub-test 33 Actual: <A HREF="{@docRoot}../docs1/p2/package-summary.html#package_ Sub-test 33 Expect: <A HREF=".../docs1/p2/package-summary.html#package_description">./../docs1/p2/package-summary.html#package_description</A> <p> - -Bonus links, not part of automated test (bug 4662945):<br> -Actual: <A HREF="{@docRoot}p1/package-summary.html#package_description">package description</a> {@docRoot}p1/packagesummary#package_description</A> <br> - -Actual: <A HREF="{@docRoot}/p1/package-summary.html#package_description">package description</A> {@docRoot}/p1/package-summary.html#package_description <br> - -Expect: <A HREF="./p1/package-summary.html#package_description">./p1/package-summary.html#package description</a> - </BODY> </HTML> diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java b/langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java index 84254e76fb8e7bdf173b80cfb964b131d0fb53e7..69f8df4dc4ce71c98c7926a72cff276bbfe5bce0 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java +++ b/langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java @@ -59,7 +59,7 @@ package p1; * Sub-test 7 Expect: <A HREF="../../docs1/p2/package-summary.html#package_description">../../docs1/p2/package-summary.html#package_description</A> * <p> * - * <!-- ----------------------------------------------------- --> + * <!-- =================================================================== --> * * Allow docRoot to work without a trailing slash for those who had to change their comments * to work with the 1.4.0 bug: diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html index d4ea8bec977bb01fac47de73b4e50955b604c85f..cc61652a4cf01b84ffdd932c89ef42f47818e82c 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html +++ b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html @@ -39,7 +39,7 @@ Sub-test 18 Actual: <A HREF="{@docRoot}/../docs1/p2/package-summary.html#package Sub-test 18 Expect: <A HREF="../../docs1/p2/package-summary.html#package_description">../../docs1/p2/package-summary.html#package_description</A> <p> -<!-- ------------------------------------------------ --> +<!-- ================================================================== --> Allow docRoot to work without a trailing slash for those who had to change their comments to work with the 1.4.0 bug: @@ -61,13 +61,5 @@ Sub-test 22 Actual: <A HREF="{@docRoot}../docs1/p2/package-summary.html#package_ Sub-test 22 Expect: <A HREF="..../docs1/p2/package-summary.html#package_description">../../docs1/p2/package-summary.html#package_description</A> <p> -Bonus links, not part of automated test (bug 4662945):<br> -Actual: <A HREF="{@docRoot}p1/package-summary.html#package_description">package description</a> {@docRoot}p1/packagesummary#package_description</A> <br> - -Actual: <A HREF="{@docRoot}/p1/package-summary.html#package_description">package description</A> {@docRoot}/p1/package-summary.html#package_description <br> - -Expect: <A HREF="../p1/package-summary.html#package_description">../p1/package-summary.html#package description</a> -<p> - </BODY> </HTML> diff --git a/langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html b/langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html index 88c45b3a6e49776c9575d9ad8307d0a4e18bc727..732aaabbaf1ea2cddd56fee86ceddf3f79dfc205 100644 --- a/langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html +++ b/langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html @@ -9,7 +9,6 @@ with examples of a wide variety of Java language constructs: packages, subclasses, subinterfaces, nested classes, nested interfaces, inheriting from other packages, constructors, fields, methods, and so forth. -<p> </body> </html> diff --git a/langtools/test/com/sun/javadoc/ValidHtml/overview.html b/langtools/test/com/sun/javadoc/ValidHtml/overview.html index 88c45b3a6e49776c9575d9ad8307d0a4e18bc727..732aaabbaf1ea2cddd56fee86ceddf3f79dfc205 100644 --- a/langtools/test/com/sun/javadoc/ValidHtml/overview.html +++ b/langtools/test/com/sun/javadoc/ValidHtml/overview.html @@ -9,7 +9,6 @@ with examples of a wide variety of Java language constructs: packages, subclasses, subinterfaces, nested classes, nested interfaces, inheriting from other packages, constructors, fields, methods, and so forth. -<p> </body> </html> diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java index 3ed9594cff4b7483bbdc0c7bdec66207d9186be0..2a2e6de8ed4ee19eac834d231fe65503b47950ee 100644 --- a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java +++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java @@ -250,8 +250,6 @@ public class TestHtmlDefinitionListTag extends JavadocTester { + "<dl>\n" + "<dt><span class=\"throwsLabel\">Throws:" + "</span></dt>\n" - + "<dd><code><code>" - + "IOException</code></code></dd>\n" + "<dd><code>java.io.IOException</code></dd>\n" + "</dl>", "<span class=\"deprecatedLabel\">Deprecated.</span>" @@ -358,8 +356,6 @@ public class TestHtmlDefinitionListTag extends JavadocTester { + "<dl>\n" + "<dt><span class=\"throwsLabel\">Throws:" + "</span></dt>\n" - + "<dd><code><code>" - + "IOException</code></code></dd>\n" + "<dd><code>java.io.IOException</code></dd>\n" + "</dl>", "<span class=\"deprecatedLabel\">Deprecated.</span>" diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java index 022ea741151e8f23e3d86729c39d31472bff7fa5..d44f05ac6585a5f82ef1a4f1537c7817debaecc0 100644 --- a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java +++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java @@ -76,7 +76,7 @@ public class C2 implements Serializable { * Reads the object stream. * * @param s ObjectInputStream - * @throws <code>IOException</code> + * @throws IOException * @deprecated As of JDK version 1.5, replaced by * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}. */ diff --git a/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java b/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java index 9f719a9d278c1c98d7d48b80dfad153300f26f62..de6f152d5a27f828c5e5dc5d9cf8cf2576848edc 100644 --- a/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java +++ b/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java @@ -47,7 +47,7 @@ public class TestHtmlTableStyles extends JavadocTester { checkExit(Exit.OK); checkOutput("pkg1/TestTable.html", true, - "<table border cellpadding=3 cellspacing=1>", + "<table summary=\"Summary\" border cellpadding=3 cellspacing=1>", "<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " + "cellspacing=\"0\" summary=\"Field Summary table, listing fields, " + "and an explanation\">", diff --git a/langtools/test/com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java b/langtools/test/com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java index 866c3f42ee982080d91ff7f221f7ba9dbd2b4ca1..6e1c684d0548067319b42f3978fa9bdf9ae9efe3 100644 --- a/langtools/test/com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java +++ b/langtools/test/com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java @@ -28,7 +28,7 @@ package pkg1; * should be displayed as a regular table and not have any styles that the javadoc * generated tables have. * - * <table border cellpadding=3 cellspacing=1> + * <table summary="Summary" border cellpadding=3 cellspacing=1> * <caption>Summary of test table</caption> * <tr> * <td></td> diff --git a/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java b/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java index 4416eabfb78d07b2550453240af4676fcdcaa511..155bbd532939f48ab52edea9aac92845e8f92c5d 100644 --- a/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java +++ b/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java @@ -36,20 +36,19 @@ import java.util.Locale; public class TestHtmlTag extends JavadocTester { - + private static final String defaultLanguage = Locale.getDefault().getLanguage(); public static void main(String... args) throws Exception { TestHtmlTag tester = new TestHtmlTag(); tester.runTests(); } - @Test void test_default() { - javadoc("-d", "out-default", + javadoc("-locale", defaultLanguage, + "-d", "out-default", "-sourcepath", testSrc, "pkg1"); - checkExit(Exit.OK); - String defaultLanguage = Locale.getDefault().getLanguage(); + checkExit(Exit.OK); checkOutput("pkg1/C1.html", true, "<html lang=\"" + defaultLanguage + "\">"); diff --git a/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java b/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java index 8cae5034bab15a83c1fb090225b876be2ce5d011..da4c72aa194b85340dd6d5a1de9ebb1db5f1dce7 100644 --- a/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java +++ b/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java @@ -51,9 +51,9 @@ public class TestLegacyTaglet extends JavadocTester { checkExit(Exit.OK); checkOutput("C.html", true, "This is an <u>underline</u>", - "<DT><B>To Do:</B><DD><table cellpadding=2 cellspacing=0><tr>" + + "<DT><B>To Do:</B><DD><table summary=\"Summary\" cellpadding=2 cellspacing=0><tr>" + "<td bgcolor=\"yellow\">Finish this class.</td></tr></table></DD>", - "<DT><B>To Do:</B><DD><table cellpadding=2 cellspacing=0><tr>" + + "<DT><B>To Do:</B><DD><table summary=\"Summary\" cellpadding=2 cellspacing=0><tr>" + "<td bgcolor=\"yellow\">Tag in Method.</td></tr></table></DD>"); checkOutput(Output.STDERR, false, "NullPointerException"); diff --git a/langtools/test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java b/langtools/test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java index a3c52c26b4f904375eb1496ff7d36d246266ca35..a2a0cd5541a0e652eb19e88256374258e66cb115 100644 --- a/langtools/test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java +++ b/langtools/test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java @@ -33,7 +33,7 @@ import java.util.Map; * <DL> * <DT> * <B>To Do:</B> - * <DD><table cellpadding=2 cellspacing=0><tr><td bgcolor="yellow">Fix this! + * <DD><table summary="Summary" cellpadding=2 cellspacing=0><tr><td bgcolor="yellow">Fix this! * </td></tr></table></DD> * </DL> * @@ -150,7 +150,7 @@ public class ToDoTaglet implements Taglet { */ public String toString(Tag tag) { return "<DT><B>" + HEADER + "</B><DD>" - + "<table cellpadding=2 cellspacing=0><tr><td bgcolor=\"yellow\">" + + "<table summary=\"Summary\" cellpadding=2 cellspacing=0><tr><td bgcolor=\"yellow\">" + tag.text() + "</td></tr></table></DD>\n"; } @@ -165,7 +165,7 @@ public class ToDoTaglet implements Taglet { return null; } String result = "\n<DT><B>" + HEADER + "</B><DD>"; - result += "<table cellpadding=2 cellspacing=0><tr><td bgcolor=\"yellow\">"; + result += "<table summary=\"Summary\" cellpadding=2 cellspacing=0><tr><td bgcolor=\"yellow\">"; for (int i = 0; i < tags.length; i++) { if (i > 0) { result += ", "; diff --git a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java index 98cc674525b5afeee00922fc98c3f8d04bb4a757..638b2542fd82301e8d4e9f443932d61b5be9b739 100644 --- a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java +++ b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java @@ -117,6 +117,31 @@ public class TestOrdering extends JavadocTester { checkExit(Exit.OK); checkOrder("index-all.html", composeTestVectors()); } + + @Test + void testIndexTypeClustering() { + javadoc("-d", "out-3", + "-sourcepath", testSrc("src-2"), + "-use", + "a", + "b", + "e", + "something"); + checkOrder("index-all.html", typeTestVectors); + checkExit(Exit.OK); + } + String[] typeTestVectors = { + "something</a> - package something</dt>", + "something</span></a> - Class in", + "something</span></a> - Enum in", + "something</span></a> - Interface in", + "something</span></a> - Annotation Type in", + "something</a></span> - Variable in class", + "something()</a></span> - Constructor", + "something()</a></span> - Method in class a.<a href=\"a/A.html\"", + "something()</a></span> - Method in class a.<a href=\"a/something.html\"", + "something()</a></span> - Method in class something.<a href=\"something/J.html\"" + }; String[] composeTestVectors() { List<String> testList = new ArrayList<>(); diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/a/A.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/a/A.java new file mode 100644 index 0000000000000000000000000000000000000000..603bfc12ff502cc60b71298af68f235604c15a8a --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/a/A.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package a; +/** + * A class + */ +public class A { + /** + * a method + */ + public void something() {} +} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/a/something.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/a/something.java new file mode 100644 index 0000000000000000000000000000000000000000..9869b22bd982da517c7fe219ce2e2a6fd9c82a49 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/a/something.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package a; +/** + * A class + */ +public class something { + /** + * A constructor + */ + public something() {} + /** + * a method + */ + public void something() {} +} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/b/B.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/b/B.java new file mode 100644 index 0000000000000000000000000000000000000000..5eea0f5de3d7e7de72e1eda1560c0d74379504f4 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/b/B.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package b; +/** + * Another class + */ +public class B { + /** + * a field + */ + public Object something; +} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/b/something.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/b/something.java new file mode 100644 index 0000000000000000000000000000000000000000..ea8726d205752c81e00f597c6de3ecdd6cc05196 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/b/something.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package b; +/** + * an annotation + */ +public @interface something{} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/e/something.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/e/something.java new file mode 100644 index 0000000000000000000000000000000000000000..0120a2e84fa3594ecbd212832aa8d951bb17de8e --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/e/something.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package e; +/** + * An enum + */ +public enum something {} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/something/J.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/J.java new file mode 100644 index 0000000000000000000000000000000000000000..bc1da1fea79622497d89f107838ffd551bca1932 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/J.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package something; +public class J { + /** + * a method + */ + public void something(){} +} diff --git a/langtools/test/com/sun/javadoc/testHref/pkg/C3.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/package-info.java similarity index 90% rename from langtools/test/com/sun/javadoc/testHref/pkg/C3.java rename to langtools/test/com/sun/javadoc/testOrdering/src-2/something/package-info.java index 48d0dee9cabb1a48eb6e88a473877d2b98052b54..f712a9fb5ab721f9cfaea48ed81520ccc5bef95b 100644 --- a/langtools/test/com/sun/javadoc/testHref/pkg/C3.java +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -20,10 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - -package pkg; - /** - * <action> + * A package */ -public class C3 {} +package something; diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/something/something.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/something.java new file mode 100644 index 0000000000000000000000000000000000000000..890e0c5d2bc9b2e744ce9c895a559833569ba185 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/something.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package something; +/** + * An interface + */ +public interface something {} diff --git a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java index 67893c466507b60129ff52f2f63e6f52e019e5e4..99e7cdb3d408de52f6428e99c406eb693315cf3b 100644 --- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java +++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java @@ -122,8 +122,6 @@ public class TestSerializedFormDeprecationInfo extends JavadocTester { + "<div class=\"block\">Reads the object stream.</div>\n" + "<dl>\n" + "<dt><span class=\"throwsLabel\">Throws:</span></dt>\n" - + "<dd><code><code>" - + "IOException</code></code></dd>\n" + "<dd><code>java.io.IOException</code></dd>\n" + "</dl>", "<span class=\"deprecatedLabel\">Deprecated.</span>" diff --git a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java index 022ea741151e8f23e3d86729c39d31472bff7fa5..d44f05ac6585a5f82ef1a4f1537c7817debaecc0 100644 --- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java +++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java @@ -76,7 +76,7 @@ public class C2 implements Serializable { * Reads the object stream. * * @param s ObjectInputStream - * @throws <code>IOException</code> + * @throws IOException * @deprecated As of JDK version 1.5, replaced by * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}. */ diff --git a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java index 572aa097f9418ffef08fa4db0a178163f966cb7b..3379da4098011e20e82dd250115ca75f5468a464 100644 --- a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java +++ b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java @@ -79,6 +79,23 @@ public class TestUseOption extends JavadocTester { "<a href=\"../../index.html?pkg2/class-use/C3.html\" target=\"_top\">" + "Frames</a></li>" ); + checkOutput("pkg1/class-use/UsedClass.html", true, + "that return types with arguments of type" + ); + checkOutput("pkg1/class-use/UsedClass.html", true, + "<a href=\"../../pkg1/C1.html#methodInC1ReturningType--\">methodInC1ReturningType</a>" + ); + checkOutput("pkg1/class-use/UsedInterface.html", true, + "Classes in <a href=\"../../pkg1/package-summary.html\">pkg1</a> that implement " + + "<a href=\"../../pkg1/UsedInterface.html\" title=\"interface in pkg1\">UsedInterface</a>" + ); + checkOutput("pkg1/class-use/UsedInterfaceA.html", true, + "Classes in <a href=\"../../pkg1/package-summary.html\">pkg1</a> that implement " + + "<a href=\"../../pkg1/UsedInterfaceA.html\" title=\"interface in pkg1\">UsedInterfaceA</a>" + ); + checkOutput("pkg1/class-use/UsedClass.html", false, + "methodInC1Protected" + ); } @Test diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C1.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C1.java index c763c8ff4e9f9ad597c497109d7e29249e847dd1..578609487719461d60720616f18ba515c7b4c87a 100644 --- a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C1.java +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,8 @@ package pkg1; +import java.util.List; + /** * Test 3 passes. */ @@ -40,4 +42,15 @@ public class C1 { public UsedClass methodInC1(UsedClass p) { return p; } + + public List<UsedClass> methodInC1ReturningType() { + return null; + } + + /* + * this must not appear anywhere. + */ + UsedClass methodInC1Protected(List<UsedClass> p){ + return p; + } } diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java new file mode 100644 index 0000000000000000000000000000000000000000..b4c1314572db2adcff0a36e405d411cb719a7a00 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg1; + +/** + * An implementor + * + */ +public class C10 extends UsedClass implements UsedInterface, UsedInterfaceA { + + /** + * Nothing + */ + public void doNothing() {} + + /** + * Me too + */ + public void doNothingA() {} +} diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C9.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C9.java new file mode 100644 index 0000000000000000000000000000000000000000..4b86c8908bd22b59f63a7adc7adea7961188496e --- /dev/null +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C9.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg1; + +/** + * An implementor + * + */ +public class C9 implements UsedInterface, UsedInterfaceA { + public void doNothing(){} +} diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java new file mode 100644 index 0000000000000000000000000000000000000000..7eaab2375242bff52d4c4fba2fb1a7764d004f59 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * An interface + * + */ + +package pkg1; + +public interface UsedInterface { + + /** + * Does nothing + */ + void doNothing(); +} diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java new file mode 100644 index 0000000000000000000000000000000000000000..cab6298ae67108b71e30ee8cd023959fe54c99a4 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * An interface + * + */ + +package pkg1; + +public interface UsedInterfaceA { + + /** + * Does nothing + */ + void doNothingA(); +} diff --git a/langtools/test/tools/javac/DefiniteAssignment/DASwitch.java b/langtools/test/tools/javac/DefiniteAssignment/DASwitch.java index 014fc4d4c73920ca054c6d12e6c4d197ff980d78..6cef2023cd816ca75e799223e5166e1278c7c1e1 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/DASwitch.java +++ b/langtools/test/tools/javac/DefiniteAssignment/DASwitch.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4695463 * @summary DA versus switch: javac allows reference to uninitialized variable * @author Neal Gafter (gafter) * - * @compile/fail DASwitch.java + * @compile/fail/ref=DASwitch.out -XDrawDiagnostics DASwitch.java */ public class DASwitch { diff --git a/langtools/test/tools/javac/DefiniteAssignment/DASwitch.out b/langtools/test/tools/javac/DefiniteAssignment/DASwitch.out new file mode 100644 index 0000000000000000000000000000000000000000..c8cc2feaf7894ec305f95de3ba0e7d80262674a1 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/DASwitch.out @@ -0,0 +1,2 @@ +DASwitch.java:22:32: compiler.err.var.might.not.have.been.initialized: b +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/DUParam1.java b/langtools/test/tools/javac/DefiniteAssignment/DUParam1.java index 1d3de0a051fc91015264635dd56165897fd25d4e..c55abd74e1518847c012a2a8882599735ba6e226 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/DUParam1.java +++ b/langtools/test/tools/javac/DefiniteAssignment/DUParam1.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4533915 * @summary javac should not analyze final parameters for definite assignment status * @author Neal Gafter (gafter) * - * @compile/fail DUParam1.java + * @compile/fail/ref=DUParam1.out -XDrawDiagnostics DUParam1.java */ public class DUParam1 { diff --git a/langtools/test/tools/javac/DefiniteAssignment/DUParam1.out b/langtools/test/tools/javac/DefiniteAssignment/DUParam1.out new file mode 100644 index 0000000000000000000000000000000000000000..f69bd299cc571f00c2efc11a6eef174e49192fa7 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/DUParam1.out @@ -0,0 +1,2 @@ +DUParam1.java:13:20: compiler.err.final.parameter.may.not.be.assigned: args +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/DUParam2.java b/langtools/test/tools/javac/DefiniteAssignment/DUParam2.java index 53a97515f18e1489afd8265ee5f565a0e30c5c7b..665b3d1f143167d43246bf6d42713cfc79fa9ca3 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/DUParam2.java +++ b/langtools/test/tools/javac/DefiniteAssignment/DUParam2.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4533915 * @summary javac should not analyze final parameters for definite assignment status * @author Neal Gafter (gafter) * - * @compile/fail DUParam2.java + * @compile/fail/ref=DUParam2.out -XDrawDiagnostics DUParam2.java */ public class DUParam2 { diff --git a/langtools/test/tools/javac/DefiniteAssignment/DUParam2.out b/langtools/test/tools/javac/DefiniteAssignment/DUParam2.out new file mode 100644 index 0000000000000000000000000000000000000000..9c22d101bbdebd5f369a664f295b357e15821a58 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/DUParam2.out @@ -0,0 +1,2 @@ +DUParam2.java:15:24: compiler.err.final.parameter.may.not.be.assigned: e +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_1.java b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_1.java index 5d2f3fef5966973ae30601cfbccaffaf80d8e952..6381645e2f5a635a2e77cde90addd36a8f965b43 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_1.java +++ b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_1.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4087865 4277291 * @summary Verify definite assignment of blank finals after 'this(...)' * @author William Maddox (maddox) * - * @compile/fail DefAssignAfterThis_1.java + * @compile/fail/ref=DefAssignAfterThis_1.out -XDrawDiagnostics DefAssignAfterThis_1.java */ public class DefAssignAfterThis_1 { diff --git a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_1.out b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_1.out new file mode 100644 index 0000000000000000000000000000000000000000..2220d40ffb6d01cb432ead8df73fa98b92802a22 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_1.out @@ -0,0 +1,2 @@ +DefAssignAfterThis_1.java:16:9: compiler.err.var.might.already.be.assigned: x +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_2.java b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_2.java index e7cf2ddcd0af308490dec3285959a1efe761e3d1..ed0caad74346c3141aca4cb8006b13cc261acb14 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_2.java +++ b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterThis_2.java @@ -1,28 +1,5 @@ /* - * Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4087865 * @summary Verify definite assignment of blank finals after 'this(...)' * @author William Maddox (maddox) diff --git a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry1.java b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry1.java index edfd0854495d19dda809997aef0b857f97ce6876..d15cfa70b2cfa9f242f3d8e25e34bb06c393769c 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry1.java +++ b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry1.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 4240487 * @summary Verify that we keep track of init/uninits in Try statement * without finalizer. * - * @compile/fail DefAssignAfterTry1.java + * @compile/fail/ref=DefAssignAfterTry1.out -XDrawDiagnostics DefAssignAfterTry1.java */ class E1 extends Exception {} diff --git a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry1.out b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry1.out new file mode 100644 index 0000000000000000000000000000000000000000..9c6a216d9dabe75bd96f380d597f9ba2ba4ae815 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry1.out @@ -0,0 +1,2 @@ +DefAssignAfterTry1.java:28:28: compiler.err.var.might.not.have.been.initialized: i +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry2.java b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry2.java index 80b8afe7bbbc74f326dbf0c01a4bc17761c258d3..6af6748ef50e9969f3567855771582b8e3890eb7 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry2.java +++ b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry2.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 4240487 * @summary Verify that we keep track of init/uninits in Try statement * without finalizer. * - * @compile/fail DefAssignAfterTry2.java + * @compile/fail/ref=DefAssignAfterTry2.out -XDrawDiagnostics DefAssignAfterTry2.java */ class E1 extends Exception {} diff --git a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry2.out b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry2.out new file mode 100644 index 0000000000000000000000000000000000000000..99c290e966c1f5985af84217c91b4b115df3cc07 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry2.out @@ -0,0 +1,2 @@ +DefAssignAfterTry2.java:32:28: compiler.err.var.might.not.have.been.initialized: i +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry3.java b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry3.java index ee78b5aac975ad9a98697821d72e387eb5055be2..955d83de816ce2febe8ca749e59080df7716efdb 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry3.java +++ b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry3.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 4240487 * @summary Verify that we keep track of init/uninits in Try statement * without finalizer. * - * @compile/fail DefAssignAfterTry3.java + * @compile/fail/ref=DefAssignAfterTry3.out -XDrawDiagnostics DefAssignAfterTry3.java */ class E1 extends Exception {} diff --git a/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry3.out b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry3.out new file mode 100644 index 0000000000000000000000000000000000000000..118f2fc4f770df4e561e7b84ba22b79db91debff --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/DefAssignAfterTry3.out @@ -0,0 +1,2 @@ +DefAssignAfterTry3.java:32:28: compiler.err.var.might.not.have.been.initialized: i +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4704365.java b/langtools/test/tools/javac/DefiniteAssignment/T4704365.java index e2a56a9f5c2800f4d9e189088b32b5e5550a9537..c7b991a2f7311c3758fa2a840a7f1db1a6291613 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/T4704365.java +++ b/langtools/test/tools/javac/DefiniteAssignment/T4704365.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4704365 * @summary definite assignment status within the case expression * @author Neal Gafter (gafter) * - * @compile/fail T4704365.java + * @compile/fail/ref=T4704365.out -XDrawDiagnostics T4704365.java */ class T4704365 { diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4704365.out b/langtools/test/tools/javac/DefiniteAssignment/T4704365.out new file mode 100644 index 0000000000000000000000000000000000000000..ad6cf02d7503b71755b226aec5b1723181d7f417 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/T4704365.out @@ -0,0 +1,2 @@ +T4704365.java:16:14: compiler.err.var.might.not.have.been.initialized: i +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4717164.java b/langtools/test/tools/javac/DefiniteAssignment/T4717164.java index 029bbe820c109557f760bafa8094116553b2655e..7cdfa9fab92650fa8ea1a9770265bc95921a02de 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/T4717164.java +++ b/langtools/test/tools/javac/DefiniteAssignment/T4717164.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4717164 * @summary missing catch not reachable error when nested try-finally returns in finally * @author Neal Gafter (gafter) * - * @compile/fail T4717164.java + * @compile/fail/ref=T4717164.out -XDrawDiagnostics T4717164.java */ class T4717164 { diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4717164.out b/langtools/test/tools/javac/DefiniteAssignment/T4717164.out new file mode 100644 index 0000000000000000000000000000000000000000..4053ce7a50f706d6b6f7647d5706e9a9b635605a --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/T4717164.out @@ -0,0 +1,2 @@ +T4717164.java:20:11: compiler.err.except.never.thrown.in.try: java.lang.ClassNotFoundException +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4717165.java b/langtools/test/tools/javac/DefiniteAssignment/T4717165.java index cdfb602e88afbe221a43dfaa6bab5c35fbc6e1b0..669bc4e67ca7d3c94d784de7f66fcba20990b4f3 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/T4717165.java +++ b/langtools/test/tools/javac/DefiniteAssignment/T4717165.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4717165 * @summary when can a statement complete normally? (break&continue versus finally) * @author Neal Gafter (gafter) * - * @compile/fail T4717165.java + * @compile/fail/ref=T4717165.out -XDrawDiagnostics T4717165.java */ class T4717165 { diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4717165.out b/langtools/test/tools/javac/DefiniteAssignment/T4717165.out new file mode 100644 index 0000000000000000000000000000000000000000..c69a69f8cb7f1a508fe347024855a8c981a45bb2 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/T4717165.out @@ -0,0 +1,2 @@ +T4717165.java:18:9: compiler.err.unreachable.stmt +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4718142.java b/langtools/test/tools/javac/DefiniteAssignment/T4718142.java index d60c2de83e86445027c9aef872d057747d445524..d6e218992ec3a3c8043d40c1b7b09c6690a692bc 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/T4718142.java +++ b/langtools/test/tools/javac/DefiniteAssignment/T4718142.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4718142 * @summary DU analysis not conservative for try-finally * @author Neal Gafter (gafter) * - * @compile/fail T4718142.java + * @compile/fail/ref=T4718142.out -XDrawDiagnostics T4718142.java */ class T4718142 { diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4718142.out b/langtools/test/tools/javac/DefiniteAssignment/T4718142.out new file mode 100644 index 0000000000000000000000000000000000000000..9c0dd0ce902ed4f09af243aaf62c1b489eedf7c6 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/T4718142.out @@ -0,0 +1,2 @@ +T4718142.java:20:17: compiler.err.var.might.be.assigned.in.loop: i +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4718142a.java b/langtools/test/tools/javac/DefiniteAssignment/T4718142a.java index 8548c8b87eec1da8d40ef6b1b4f6f15519cc1e20..d70fc227b6c5bec8866aa5dd996a3237b8912441 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/T4718142a.java +++ b/langtools/test/tools/javac/DefiniteAssignment/T4718142a.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4718142 * @summary DU analysis not conservative for try-finally * @author Neal Gafter (gafter) * - * @compile/fail T4718142a.java + * @compile/fail/ref=T4718142a.out -XDrawDiagnostics T4718142a.java */ class T4718142a { diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4718142a.out b/langtools/test/tools/javac/DefiniteAssignment/T4718142a.out new file mode 100644 index 0000000000000000000000000000000000000000..6d24c7dc1be3ac74da229f2e9eaa8543964a0973 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/T4718142a.out @@ -0,0 +1,2 @@ +T4718142a.java:18:21: compiler.err.var.might.be.assigned.in.loop: i +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4718708.java b/langtools/test/tools/javac/DefiniteAssignment/T4718708.java index f4ef6e4832b14a002c6eafb7ea928c8b737f9e40..3fc3d06c1cc86be5aa921fede6b2a9ee27870680 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/T4718708.java +++ b/langtools/test/tools/javac/DefiniteAssignment/T4718708.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4718708 * @summary bug in DU analysis of while loop * @author Neal Gafter (gafter) * - * @compile/fail T4718708.java + * @compile/fail/ref=T4718708.out -XDrawDiagnostics T4718708.java */ class T4718708 { diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4718708.out b/langtools/test/tools/javac/DefiniteAssignment/T4718708.out new file mode 100644 index 0000000000000000000000000000000000000000..167d646639119fb0b0b4f6a6669ef54cba640863 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/T4718708.out @@ -0,0 +1,2 @@ +T4718708.java:14:13: compiler.err.var.might.be.assigned.in.loop: i +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4721062a.java b/langtools/test/tools/javac/DefiniteAssignment/T4721062a.java index 5612230915711be0d821f5d3179a286d2a4d2a49..8a4764973ecbecbb3ef226b6421f2c1f3da59ba6 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/T4721062a.java +++ b/langtools/test/tools/javac/DefiniteAssignment/T4721062a.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4721062 * @summary DA treatment of return statements in constructors * @author Neal Gafter (gafter) * - * @compile/fail T4721062a.java + * @compile/fail/ref=T4721062a.out -XDrawDiagnostics T4721062a.java */ class T4721062a { diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4721062a.out b/langtools/test/tools/javac/DefiniteAssignment/T4721062a.out new file mode 100644 index 0000000000000000000000000000000000000000..684cbadd1a1e9a372cc934294ce4af6117db38e8 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/T4721062a.out @@ -0,0 +1,2 @@ +T4721062a.java:14:13: compiler.err.var.might.not.have.been.initialized: i +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4721062b.java b/langtools/test/tools/javac/DefiniteAssignment/T4721062b.java index ad3b8e1ae59c1be96f0f8fbcff00abad9947e5c1..dddce7713e6cb2b4298d3f27df3d764cb38ff191 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/T4721062b.java +++ b/langtools/test/tools/javac/DefiniteAssignment/T4721062b.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4721062 * @summary DA treatment of return statements in constructors * @author Neal Gafter (gafter) * - * @compile/fail T4721062b.java + * @compile/fail/ref=T4721062b.out -XDrawDiagnostics T4721062b.java */ class T4721062b { diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4721062b.out b/langtools/test/tools/javac/DefiniteAssignment/T4721062b.out new file mode 100644 index 0000000000000000000000000000000000000000..84604eb594ddd0552063c2d80c7131691a859c8c --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/T4721062b.out @@ -0,0 +1,2 @@ +T4721062b.java:14:13: compiler.err.var.might.not.have.been.initialized: i +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4725725.java b/langtools/test/tools/javac/DefiniteAssignment/T4725725.java index 7f1bebd64deceeb0f947bf6f405668394c468ea4..12d6e170f20140e0ecd37bdf9f2a6f0a796f7766 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/T4725725.java +++ b/langtools/test/tools/javac/DefiniteAssignment/T4725725.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4725725 * @summary missing DA error in anonymous ctor * @author Neal Gafter (gafter) * - * @compile/fail T4725725.java + * @compile/fail/ref=T4725725.out -XDrawDiagnostics T4725725.java */ class T4725725 { diff --git a/langtools/test/tools/javac/DefiniteAssignment/T4725725.out b/langtools/test/tools/javac/DefiniteAssignment/T4725725.out new file mode 100644 index 0000000000000000000000000000000000000000..0cf348713b4b5f489b6d4462359e479c51b78b06 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/T4725725.out @@ -0,0 +1,2 @@ +T4725725.java:13:21: compiler.err.var.might.not.have.been.initialized: x +1 error diff --git a/langtools/test/tools/javac/DefiniteAssignment/UncaughtException.java b/langtools/test/tools/javac/DefiniteAssignment/UncaughtException.java index cf2535e73cf5aa4bda54f8bcf8cd012745b9f14c..f43bbea96f0f8485d3d4a08676546314cb90afc1 100644 --- a/langtools/test/tools/javac/DefiniteAssignment/UncaughtException.java +++ b/langtools/test/tools/javac/DefiniteAssignment/UncaughtException.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4053998 * @summary Compiler used to not notice the uncaught checked exception. * @author turnidge * - * @compile/fail UncaughtException.java + * @compile/fail/ref=UncaughtException.out -XDrawDiagnostics UncaughtException.java */ interface I { diff --git a/langtools/test/tools/javac/DefiniteAssignment/UncaughtException.out b/langtools/test/tools/javac/DefiniteAssignment/UncaughtException.out new file mode 100644 index 0000000000000000000000000000000000000000..bb4a752e8f749980ee65e4e89504449ef3ec4036 --- /dev/null +++ b/langtools/test/tools/javac/DefiniteAssignment/UncaughtException.out @@ -0,0 +1,2 @@ +UncaughtException.java:20:1: compiler.err.override.meth.doesnt.throw: (compiler.misc.cant.implement: throwCheckedException(), A, throwCheckedException(), I), java.lang.Throwable +1 error diff --git a/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java b/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java index d3728e15610becd05cc216427cd5e4bbb49e508b..3074de4229f0c49ad80a9e81afcf9a579238c98d 100644 --- a/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java +++ b/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java @@ -138,7 +138,7 @@ public class WrongLNTForLambdaTest { checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Foo.class").toUri()), "$deserializeLambda$", deserializeExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), - "Foo.class").toUri()), "lambda$MR$variablesInLambdas$notify$8bc4f5bd$1", lambdaBridgeExpectedLNT); + "Foo.class").toUri()), "lambda$variablesInLambdas$3", lambdaBridgeExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Foo.class").toUri()), "assignLambda", assignmentExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), diff --git a/langtools/test/tools/javac/assert/DU1.java b/langtools/test/tools/javac/assert/DU1.java index a3a4716c28f57a6c1edb96a6cb60cf40b6cd9466..a33fc0cb2d751fd6bea6d9ea4683097d446c5cdf 100644 --- a/langtools/test/tools/javac/assert/DU1.java +++ b/langtools/test/tools/javac/assert/DU1.java @@ -1,33 +1,9 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4468510 * @summary Check correct DU computation for assertions. * @author gafter - * - * @compile/fail DU1.java + * @compile/fail/ref=DU1.out -XDrawDiagnostics DU1.java */ class DU1 { diff --git a/langtools/test/tools/javac/assert/DU1.out b/langtools/test/tools/javac/assert/DU1.out new file mode 100644 index 0000000000000000000000000000000000000000..d0cf01a0241291d2b271f8b89ba0a4df581f15ed --- /dev/null +++ b/langtools/test/tools/javac/assert/DU1.out @@ -0,0 +1,2 @@ +DU1.java:16:9: compiler.err.var.might.already.be.assigned: i +1 error diff --git a/langtools/test/tools/javac/assert/DU2.java b/langtools/test/tools/javac/assert/DU2.java index 5758335e2c9b62e0727672b5b66bdddd48a51c38..ae27ccea12d7bcf3bccd94ea6e833773e672fb0d 100644 --- a/langtools/test/tools/javac/assert/DU2.java +++ b/langtools/test/tools/javac/assert/DU2.java @@ -1,33 +1,9 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4468510 * @summary Check correct DU computation for assertions. * @author gafter - * - * @compile/fail DU2.java + * @compile/fail/ref=DU2.out -XDrawDiagnostics DU2.java */ class DU2 { diff --git a/langtools/test/tools/javac/assert/DU2.out b/langtools/test/tools/javac/assert/DU2.out new file mode 100644 index 0000000000000000000000000000000000000000..a9f2a50dd1e49a5731cac968ff2b33e5632333fc --- /dev/null +++ b/langtools/test/tools/javac/assert/DU2.out @@ -0,0 +1,2 @@ +DU2.java:14:9: compiler.err.var.might.already.be.assigned: i +1 error diff --git a/langtools/test/tools/javac/boxing/Boxing2.java b/langtools/test/tools/javac/boxing/Boxing2.java index 8ab1d51d04e3bd615237aa670f4de605279af116..83fe924435f1adc69a97dc406d30e24577e4c212 100644 --- a/langtools/test/tools/javac/boxing/Boxing2.java +++ b/langtools/test/tools/javac/boxing/Boxing2.java @@ -1,33 +1,9 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4974939 * @summary Boxing/unboxing negative unit and regression tests * @author gafter - * - * @compile/fail Boxing2.java + * @compile/fail/ref=Boxing2.out -XDrawDiagnostics Boxing2.java */ public class Boxing2 { diff --git a/langtools/test/tools/javac/boxing/Boxing2.out b/langtools/test/tools/javac/boxing/Boxing2.out new file mode 100644 index 0000000000000000000000000000000000000000..a10492c6604e80ac8239973e6dd6096e36cc5f8b --- /dev/null +++ b/langtools/test/tools/javac/boxing/Boxing2.out @@ -0,0 +1,2 @@ +Boxing2.java:12:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.Long) +1 error diff --git a/langtools/test/tools/javac/boxing/T5082929.java b/langtools/test/tools/javac/boxing/T5082929.java index 69eada759cf72412929e966a03a676b699ffefdb..07ea7a37776cde8213d9ada40e7df9a9fe77cf22 100644 --- a/langtools/test/tools/javac/boxing/T5082929.java +++ b/langtools/test/tools/javac/boxing/T5082929.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5082929 * @summary Comparing Float and Integer * @author Peter von der Ah\u00e9 - * @compile/fail T5082929.java + * @compile/fail/ref=T5082929.out -XDrawDiagnostics T5082929.java */ public class T5082929 { diff --git a/langtools/test/tools/javac/boxing/T5082929.out b/langtools/test/tools/javac/boxing/T5082929.out new file mode 100644 index 0000000000000000000000000000000000000000..6708e545feb6b077d3e72395380930b19ae96dcd --- /dev/null +++ b/langtools/test/tools/javac/boxing/T5082929.out @@ -0,0 +1,2 @@ +T5082929.java:11:23: compiler.err.incomparable.types: java.lang.Float, java.lang.Integer +1 error diff --git a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTableTest.java b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTableTest.java index b2fdd48e6f714de1e2bab3b7d5b964996d490d4a..9093dea79e6b67c4a0f8a04d63a05dc5a4bc14df 100644 --- a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTableTest.java +++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTableTest.java @@ -153,7 +153,6 @@ public class LocalVariableTableTest extends LocalVariableTestBase { @ExpectedLocals(name = "inTry", type = "D") @ExpectedLocals(name = "inSync", type = "F") @ExpectedLocals(name = "inDo", type = "B") - @ExpectedLocals(name = "inSwitch", type = "S") @ExpectedLocals(name = "inFor", type = "J") @ExpectedLocals(name = "s", type = "Ljava/util/stream/Stream;") public void deepScope() { @@ -179,17 +178,6 @@ public class LocalVariableTableTest extends LocalVariableTestBase { } } - @ExpectedLocals(name = "i", type = "I", scope = 0) - @ExpectedLocals(name = "i", type = "J", scope = 1) - public void reuseByLong() { - { - int i = 0; - } - { - long i = 1; - } - } - class LocalVariableTable implements VariableTable { final LocalVariableTable_attribute att; diff --git a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTypeTableTest.java b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTypeTableTest.java index 324ed9a7c5f36a56b176204edb56a65da40619f2..4a783a518a16b993cbeb1754f56a96412f61d27b 100644 --- a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTypeTableTest.java +++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTypeTableTest.java @@ -104,7 +104,6 @@ public class LocalVariableTypeTableTest<THIS> extends LocalVariableTestBase { @ExpectedLocals(name = "inTry", type = "TTHIS;") @ExpectedLocals(name = "inSync", type = "TTHIS;") @ExpectedLocals(name = "inDo", type = "TTHIS;") - @ExpectedLocals(name = "inSwitch", type = "TTHIS;") @ExpectedLocals(name = "inFor", type = "LLocalVariableTypeTableTest<-TTHIS;>;") @ExpectedLocals(name = "s", type = "Ljava/util/stream/Stream<+Ljava/lang/Integer;>;") public void deepScope() { @@ -130,17 +129,6 @@ public class LocalVariableTypeTableTest<THIS> extends LocalVariableTestBase { } } - @ExpectedLocals(name = "i", type = "TTHIS;", scope = 0) - @ExpectedLocals(name = "i", type = "Ljava/util/List<TTHIS;>;", scope = 1) - public void reuseByLong() { - { - THIS i = null; - } - { - List<THIS> i = null; - } - } - class LocalVariableTypeTable implements VariableTable { final LocalVariableTypeTable_attribute att; diff --git a/langtools/test/tools/javac/completion/C.out b/langtools/test/tools/javac/completion/C.out deleted file mode 100644 index f4d681b5371df533f3e5267bc0f4595beaa794f0..0000000000000000000000000000000000000000 --- a/langtools/test/tools/javac/completion/C.out +++ /dev/null @@ -1,5 +0,0 @@ -C.java:11: cannot access example.a.A -file example/a/A.class not found - class CInner extends example.B { - ^ -1 error diff --git a/langtools/test/tools/javac/completion/example/B.class b/langtools/test/tools/javac/completion/example/B.class deleted file mode 100644 index 948e8508d3b577e528034fad4394dd01d3ad2724..0000000000000000000000000000000000000000 Binary files a/langtools/test/tools/javac/completion/example/B.class and /dev/null differ diff --git a/langtools/test/tools/javac/defaultMethods/static/StaticInvoke.java b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke.java new file mode 100644 index 0000000000000000000000000000000000000000..368e35d6f7321fae8cc3edfdc5444ed8bb6b1c9e --- /dev/null +++ b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke.java @@ -0,0 +1,15 @@ +/* @test /nodynamiccopyright/ + * @bug 8037385 + * @summary Must not allow static interface method invocation in legacy code + * @compile -source 8 -Xlint:-options StaticInvoke.java + * @compile/fail/ref=StaticInvoke7.out -source 7 -Xlint:-options -XDrawDiagnostics StaticInvoke.java + * @compile/fail/ref=StaticInvoke6.out -source 6 -Xlint:-options -XDrawDiagnostics StaticInvoke.java + */ +import java.util.stream.Stream; + +class StaticInvoke { + void test() { + Stream.empty(); + java.util.stream.Stream.empty(); + } +} diff --git a/langtools/test/tools/javac/defaultMethods/static/StaticInvoke6.out b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke6.out new file mode 100644 index 0000000000000000000000000000000000000000..947d3ab44708cecc0835805b4a5b1ee79b2b9684 --- /dev/null +++ b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke6.out @@ -0,0 +1,3 @@ +StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6 +StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6 +2 errors diff --git a/langtools/test/tools/javac/defaultMethods/static/StaticInvoke7.out b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke7.out new file mode 100644 index 0000000000000000000000000000000000000000..1a2f58db85691ab6c8b063750d373b8f189b7a11 --- /dev/null +++ b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke7.out @@ -0,0 +1,3 @@ +StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7 +StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7 +2 errors diff --git a/langtools/test/tools/javac/completion/C.java b/langtools/test/tools/javac/diags/examples/VarargsFinalOnly.java similarity index 74% rename from langtools/test/tools/javac/completion/C.java rename to langtools/test/tools/javac/diags/examples/VarargsFinalOnly.java index be709e85e8a225e46f4fc11ec31113c4af82ac62..167bf3efcc49c63f3eb0d0c8caaaefc08c6cc5e9 100644 --- a/langtools/test/tools/javac/completion/C.java +++ b/langtools/test/tools/javac/diags/examples/VarargsFinalOnly.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,21 +21,12 @@ * questions. */ -/* - * @test - * @bug 4433676 - * @summary javac dies with NullPointerException in com.sun.tools.javac.v8.comp.Resolve.find - * @author gafter - * - * @compile/fail C.java - */ -public class C { - - class CInner extends example.B { - - public CInner(Object o) { - } +// key: compiler.err.varargs.invalid.trustme.anno +// key: compiler.misc.varargs.trustme.on.virtual.varargs.final.only +// options: -source 1.8 -Xlint:varargs,-options,-unchecked - } +import java.util.List; +class VarargsFinalOnly { + @SafeVarargs void m(List<String>... args) { } } diff --git a/langtools/test/tools/javac/enum/DA1.java b/langtools/test/tools/javac/enum/DA1.java index 7756a2fe9f720073d5aea67efd64af5d93e85524..a40d0e9bb2ed33943ec0ed9f962f36835e8e2d24 100644 --- a/langtools/test/tools/javac/enum/DA1.java +++ b/langtools/test/tools/javac/enum/DA1.java @@ -1,37 +1,11 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5023177 * @summary One can refer static, const static variables from instance initializers of enum * @author gafter - * - * @compile/fail DA1.java + * @compile/fail/ref=DA1.out -XDrawDiagnostics DA1.java */ -package da1; - enum T1 { ; static int N = 12; diff --git a/langtools/test/tools/javac/enum/DA1.out b/langtools/test/tools/javac/enum/DA1.out new file mode 100644 index 0000000000000000000000000000000000000000..58642b628975e78b66279e7e3ec624e38213d4fb --- /dev/null +++ b/langtools/test/tools/javac/enum/DA1.out @@ -0,0 +1,2 @@ +DA1.java:12:13: compiler.err.illegal.enum.static.ref +1 error diff --git a/langtools/test/tools/javac/enum/DA2.java b/langtools/test/tools/javac/enum/DA2.java index 61940f2ee59bb10b822ac13982fc3479effcbc30..a7af811b7a3548b44bc7d2fedcc0a8569c298ec3 100644 --- a/langtools/test/tools/javac/enum/DA2.java +++ b/langtools/test/tools/javac/enum/DA2.java @@ -1,37 +1,11 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5023177 * @summary One can refer static, const static variables from instance initializers of enum * @author gafter - * - * @compile/fail DA2.java + * @compile/fail/ref=DA2.out -XDrawDiagnostics DA2.java */ -package da2; - enum T2 { ; static int N = 12; diff --git a/langtools/test/tools/javac/enum/DA2.out b/langtools/test/tools/javac/enum/DA2.out new file mode 100644 index 0000000000000000000000000000000000000000..576dc2d3bfd558499688a4b2b935a25ad449fe6b --- /dev/null +++ b/langtools/test/tools/javac/enum/DA2.out @@ -0,0 +1,2 @@ +DA2.java:13:17: compiler.err.illegal.enum.static.ref +1 error diff --git a/langtools/test/tools/javac/enum/DA3.java b/langtools/test/tools/javac/enum/DA3.java index b5eb9c13b8c9c9508fd4ca9f99835c1a38708762..df6be345677d7eb2be202bcd062e94c73f35ccae 100644 --- a/langtools/test/tools/javac/enum/DA3.java +++ b/langtools/test/tools/javac/enum/DA3.java @@ -1,37 +1,11 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5023177 * @summary One can refer static, const static variables from instance initializers of enum * @author gafter - * - * @compile/fail DA3.java + * @compile/fail/ref=DA3.out -XDrawDiagnostics DA3.java */ -package da3; - enum T3 { ; static int N = 12; diff --git a/langtools/test/tools/javac/enum/DA3.out b/langtools/test/tools/javac/enum/DA3.out new file mode 100644 index 0000000000000000000000000000000000000000..2df3567a27175f9a8082e04ab4d9deaedff93e2e --- /dev/null +++ b/langtools/test/tools/javac/enum/DA3.out @@ -0,0 +1,2 @@ +DA3.java:13:17: compiler.err.illegal.enum.static.ref +1 error diff --git a/langtools/test/tools/javac/enum/EnumProtectedConstructor.java b/langtools/test/tools/javac/enum/EnumProtectedConstructor.java index a33da1340a8ddeb2940d1f1cffab8293a4ee0f08..481de39319c6ad8e09eaf3a466973b35dabae396 100644 --- a/langtools/test/tools/javac/enum/EnumProtectedConstructor.java +++ b/langtools/test/tools/javac/enum/EnumProtectedConstructor.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5009601 * @summary enum constructors cannot be declared public or protected * @author Joseph D. Darcy * - * @compile/fail EnumProtectedConstructor.java + * @compile/fail/ref=EnumProtectedConstructor.out -XDrawDiagnostics EnumProtectedConstructor.java */ enum EnumProtectedConstructor { diff --git a/langtools/test/tools/javac/enum/EnumProtectedConstructor.out b/langtools/test/tools/javac/enum/EnumProtectedConstructor.out new file mode 100644 index 0000000000000000000000000000000000000000..71826a2d331d46a7c53b44ec840326640e6769c4 --- /dev/null +++ b/langtools/test/tools/javac/enum/EnumProtectedConstructor.out @@ -0,0 +1,2 @@ +EnumProtectedConstructor.java:16:15: compiler.err.mod.not.allowed.here: protected +1 error diff --git a/langtools/test/tools/javac/enum/EnumPublicConstructor.java b/langtools/test/tools/javac/enum/EnumPublicConstructor.java index 46363cf7449411db99593a9543cafef0551e6861..313605970358c8f278ef368f8b68888edc497792 100644 --- a/langtools/test/tools/javac/enum/EnumPublicConstructor.java +++ b/langtools/test/tools/javac/enum/EnumPublicConstructor.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5009601 * @summary enum constructors cannot be declared public or protected * @author Joseph D. Darcy * - * @compile/fail EnumPublicConstructor.java + * @compile/fail/ref=EnumPublicConstructor.out -XDrawDiagnostics EnumPublicConstructor.java */ enum EnumPublicConstructor { diff --git a/langtools/test/tools/javac/enum/EnumPublicConstructor.out b/langtools/test/tools/javac/enum/EnumPublicConstructor.out new file mode 100644 index 0000000000000000000000000000000000000000..56c099f4330c2070c50b234be631bbf34ca588c0 --- /dev/null +++ b/langtools/test/tools/javac/enum/EnumPublicConstructor.out @@ -0,0 +1,2 @@ +EnumPublicConstructor.java:16:12: compiler.err.mod.not.allowed.here: public +1 error diff --git a/langtools/test/tools/javac/enum/EnumSwitch2.java b/langtools/test/tools/javac/enum/EnumSwitch2.java index 5992131b160ce8bd17bbeeafa5f5020b81add24e..71d8d00c8749090dd3a44860bc44aa71ac5d3898 100644 --- a/langtools/test/tools/javac/enum/EnumSwitch2.java +++ b/langtools/test/tools/javac/enum/EnumSwitch2.java @@ -1,37 +1,11 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4936393 * @summary enum switch case labels required to be unqualified. * @author gafter - * - * @compile/fail EnumSwitch2.java + * @compile/fail/ref=EnumSwitch2.out -XDrawDiagnostics EnumSwitch2.java */ -package enumswitch2; - enum E1 { a, b, c, d, e } class EnumSwitch2 { diff --git a/langtools/test/tools/javac/enum/EnumSwitch2.out b/langtools/test/tools/javac/enum/EnumSwitch2.out new file mode 100644 index 0000000000000000000000000000000000000000..840f10c39debb8c02fae85bc2de815fc17feb81d --- /dev/null +++ b/langtools/test/tools/javac/enum/EnumSwitch2.out @@ -0,0 +1,4 @@ +EnumSwitch2.java:14:16: compiler.err.enum.label.must.be.unqualified.enum +EnumSwitch2.java:15:16: compiler.err.enum.label.must.be.unqualified.enum +EnumSwitch2.java:15:9: compiler.err.duplicate.case.label +3 errors diff --git a/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum1.java b/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum1.java index d3306837b062c0838b83a691671d949cb1bd0fab..5af537686846c7799cf289613373c0f8544675ce 100644 --- a/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum1.java +++ b/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum1.java @@ -1,33 +1,9 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5009601 * @summary enum's cannot be explicitly declared abstract * @author Joseph D. Darcy - * - * @compile/fail ExplicitlyAbstractEnum1.java + * @compile/fail/ref=ExplicitlyAbstractEnum1.out -XDrawDiagnostics ExplicitlyAbstractEnum1.java */ abstract enum ExplicitlyAbstractEnum1 { diff --git a/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum1.out b/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum1.out new file mode 100644 index 0000000000000000000000000000000000000000..827e331a4913f4752349530fac8dc60c3497ff0b --- /dev/null +++ b/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum1.out @@ -0,0 +1,2 @@ +ExplicitlyAbstractEnum1.java:9:10: compiler.err.mod.not.allowed.here: abstract +1 error diff --git a/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum2.java b/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum2.java index 49342e0e15a180402fd32df3fbc5bf6522de176c..cbd9bd512d68f6f4aa6e33ebf5feb1a4e6feaf80 100644 --- a/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum2.java +++ b/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum2.java @@ -1,33 +1,9 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5009601 * @summary enum's cannot be explicitly declared abstract even if they are abstract * @author Joseph D. Darcy - * - * @compile/fail ExplicitlyAbstractEnum2.java + * @compile/fail/ref=ExplicitlyAbstractEnum2.out -XDrawDiagnostics ExplicitlyAbstractEnum2.java */ abstract enum ExplicitlyAbstractEnum2 { diff --git a/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum2.out b/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum2.out new file mode 100644 index 0000000000000000000000000000000000000000..8a35cec318026ab67122fc544c03957f8e2f662b --- /dev/null +++ b/langtools/test/tools/javac/enum/ExplicitlyAbstractEnum2.out @@ -0,0 +1,2 @@ +ExplicitlyAbstractEnum2.java:9:10: compiler.err.mod.not.allowed.here: abstract +1 error diff --git a/langtools/test/tools/javac/enum/ExplicitlyFinalEnum1.java b/langtools/test/tools/javac/enum/ExplicitlyFinalEnum1.java index 645c4bd99ca270b27a0836a340e7a5556d2f7e37..1dba3d0dff5e7d2148778b8913c39d90f44951cf 100644 --- a/langtools/test/tools/javac/enum/ExplicitlyFinalEnum1.java +++ b/langtools/test/tools/javac/enum/ExplicitlyFinalEnum1.java @@ -1,33 +1,9 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5009601 * @summary enum's cannot be explicitly declared final even if they are * @author Joseph D. Darcy - * - * @compile/fail ExplicitlyFinalEnum1.java + * @compile/fail/ref=ExplicitlyFinalEnum1.out -XDrawDiagnostics ExplicitlyFinalEnum1.java */ final enum ExplicitlyFinalEnum1 { diff --git a/langtools/test/tools/javac/enum/ExplicitlyFinalEnum1.out b/langtools/test/tools/javac/enum/ExplicitlyFinalEnum1.out new file mode 100644 index 0000000000000000000000000000000000000000..023d00e265fb2c1fe45a26f2a025ffa8a82f930f --- /dev/null +++ b/langtools/test/tools/javac/enum/ExplicitlyFinalEnum1.out @@ -0,0 +1,2 @@ +ExplicitlyFinalEnum1.java:9:7: compiler.err.mod.not.allowed.here: final +1 error diff --git a/langtools/test/tools/javac/enum/ExplicitlyFinalEnum2.java b/langtools/test/tools/javac/enum/ExplicitlyFinalEnum2.java index 84559051480912911fa63b332a145de26a87058b..73d3b8acb7b413726597a62e00543c9a4ef45ebf 100644 --- a/langtools/test/tools/javac/enum/ExplicitlyFinalEnum2.java +++ b/langtools/test/tools/javac/enum/ExplicitlyFinalEnum2.java @@ -1,33 +1,9 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5009601 * @summary enum's cannot be explicitly declared final * @author Joseph D. Darcy - * - * @compile/fail ExplicitlyFinalEnum2.java + * @compile/fail/ref=ExplicitlyFinalEnum2.out -XDrawDiagnostics ExplicitlyFinalEnum2.java */ final enum ExplicitlyFinalEnum2 { diff --git a/langtools/test/tools/javac/enum/ExplicitlyFinalEnum2.out b/langtools/test/tools/javac/enum/ExplicitlyFinalEnum2.out new file mode 100644 index 0000000000000000000000000000000000000000..09cbf1461add36c1be504efa96e5f6b4dda24461 --- /dev/null +++ b/langtools/test/tools/javac/enum/ExplicitlyFinalEnum2.out @@ -0,0 +1,2 @@ +ExplicitlyFinalEnum2.java:9:7: compiler.err.mod.not.allowed.here: final +1 error diff --git a/langtools/test/tools/javac/expression/NullAppend.java b/langtools/test/tools/javac/expression/NullAppend.java index 1b2c95e57d9b0b400ae4c2551b37c6ce4936de0a..1ced2313ef753dba6aff6eac9f698a29378e26ae 100644 --- a/langtools/test/tools/javac/expression/NullAppend.java +++ b/langtools/test/tools/javac/expression/NullAppend.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4620794 * @summary compiler allows null + null * @author gafter * - * @compile/fail NullAppend.java + * @compile/fail/ref=NullAppend.out -XDrawDiagnostics NullAppend.java */ class NullAppend {{ diff --git a/langtools/test/tools/javac/expression/NullAppend.out b/langtools/test/tools/javac/expression/NullAppend.out new file mode 100644 index 0000000000000000000000000000000000000000..a1ea4a720dd83ad75818ebd3d6a9b1e0a96c1190 --- /dev/null +++ b/langtools/test/tools/javac/expression/NullAppend.out @@ -0,0 +1,2 @@ +NullAppend.java:11:16: compiler.err.operator.cant.be.applied.1: +, compiler.misc.type.null, compiler.misc.type.null +1 error diff --git a/langtools/test/tools/javac/expression/NullAppend2.java b/langtools/test/tools/javac/expression/NullAppend2.java index 4998684981ca7be4e24dd2820fa1c83bb14d6de7..857d12f1671924645873b2a80bb99836759cf39d 100644 --- a/langtools/test/tools/javac/expression/NullAppend2.java +++ b/langtools/test/tools/javac/expression/NullAppend2.java @@ -1,33 +1,9 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4717193 * @summary javac improperly allows null + 1 * @author gafter - * - * @compile/fail NullAppend2.java + * @compile/fail/ref=NullAppend2.out -XDrawDiagnostics NullAppend2.java */ class NullAppend2 {{ diff --git a/langtools/test/tools/javac/expression/NullAppend2.out b/langtools/test/tools/javac/expression/NullAppend2.out new file mode 100644 index 0000000000000000000000000000000000000000..ac8987781eb4f942e86547d6c6526a5bd764c8eb --- /dev/null +++ b/langtools/test/tools/javac/expression/NullAppend2.out @@ -0,0 +1,2 @@ +NullAppend2.java:10:16: compiler.err.operator.cant.be.applied.1: +, compiler.misc.type.null, int +1 error diff --git a/langtools/test/tools/javac/flow/LVTHarness.java b/langtools/test/tools/javac/flow/LVTHarness.java index 7039a626a57ee0b1eb94a3962d6855cae3979148..c176e5e8ae875a0b91368d31711fabc54bc0efa9 100644 --- a/langtools/test/tools/javac/flow/LVTHarness.java +++ b/langtools/test/tools/javac/flow/LVTHarness.java @@ -23,7 +23,7 @@ /* * @test - * @bug 7047734 8027660 8037937 + * @bug 7047734 8027660 8037937 8047719 * @summary The LVT is not generated correctly during some try/catch scenarios * javac crash while creating LVT entry for a local variable defined in * an inner block diff --git a/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java b/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java index d96850ffd21693c195dd9cf57a5ec9bf2f9a669d..e67e191122d1d2499ad142667b289f7eea2d916b 100644 --- a/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java +++ b/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java @@ -5,7 +5,7 @@ public class TestCaseSwitch { @AliveRange(varName="o", bytecodeStart=31, bytecodeLength=16) @AliveRange(varName="o", bytecodeStart=50, bytecodeLength=15) @AliveRange(varName="o", bytecodeStart=68, bytecodeLength=1) - @AliveRange(varName="oo", bytecodeStart=39, bytecodeLength=26) + @AliveRange(varName="oo", bytecodeStart=39, bytecodeLength=8) @AliveRange(varName="uu", bytecodeStart=59, bytecodeLength=6) void m1(String[] args) { Object o; @@ -29,7 +29,7 @@ public class TestCaseSwitch { @AliveRange(varName="o", bytecodeStart=95, bytecodeLength=18) @AliveRange(varName="o", bytecodeStart=116, bytecodeLength=15) @AliveRange(varName="o", bytecodeStart=134, bytecodeLength=1) - @AliveRange(varName="oo", bytecodeStart=104, bytecodeLength=27) + @AliveRange(varName="oo", bytecodeStart=104, bytecodeLength=9) @AliveRange(varName="uu", bytecodeStart=125, bytecodeLength=6) void m2(String[] args) { Object o; @@ -50,12 +50,14 @@ public class TestCaseSwitch { o = "return"; } - @AliveRange(varName="o", bytecodeStart=31, bytecodeLength=8) - @AliveRange(varName="o", bytecodeStart=42, bytecodeLength=8) - @AliveRange(varName="o", bytecodeStart=53, bytecodeLength=9) - void m3(String[] args) { + @AliveRange(varName="o", bytecodeStart=35, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=46, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=78, bytecodeLength=5) + @AliveRange(varName="o", bytecodeStart=86, bytecodeLength=1) + @AliveRange(varName="oo", bytecodeStart=56, bytecodeLength=16) + void m3(int i) { Object o; - switch (args.length) { + switch (i) { case 0: o = "0"; o.hashCode(); @@ -64,10 +66,19 @@ public class TestCaseSwitch { o = "1"; o.hashCode(); break; + case 2: + int oo = i; + if (oo > 1) { + System.out.println("greater"); + } + break; + case 3: + int uu = i; default: o = "default"; o.hashCode(); } o = "finish"; } + } diff --git a/langtools/test/tools/javac/generics/inference/T8044546/CrashImplicitLambdaTest.java b/langtools/test/tools/javac/generics/inference/T8044546/CrashImplicitLambdaTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a34b356339b12da86cb69c7fe86b0d58cbb933a3 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/T8044546/CrashImplicitLambdaTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8044546 + * @summary Crash on faulty reduce/lambda + * @compile CrashImplicitLambdaTest.java + */ + +abstract class CrashImplicitLambdaTest { + boolean foo() { + return bar(true, a -> {}); + } + + abstract <T1> T1 bar(T1 t1, S<T1> s); + + interface S<S1> { + void baz(S1 s1); + } +} diff --git a/langtools/test/tools/javac/generics/inference/T8044546/NestedInvocationsTest.java b/langtools/test/tools/javac/generics/inference/T8044546/NestedInvocationsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..40e5c3df34a09f5b2428f0b7daa91d2c4f6b757e --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/T8044546/NestedInvocationsTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8044546 + * @summary Crash on faulty reduce/lambda + * @compile NestedInvocationsTest.java + */ + +class NestedInvocationsTest<T> { + boolean foo(I<T> i) { + return baz(zas(i)); + } + + <U> J<U, Boolean> zas(I<U> i) { + return null; + } + + <R> R baz(J<T, R> j) { + return null; + } + + interface I<I1> {} + + interface J<J1, J2> {} +} diff --git a/langtools/test/tools/javac/generics/wildcards/T8034147.java b/langtools/test/tools/javac/generics/wildcards/T8034147.java new file mode 100644 index 0000000000000000000000000000000000000000..4baade1ef5c9d02a42936dc0c958a5e56d313c4c --- /dev/null +++ b/langtools/test/tools/javac/generics/wildcards/T8034147.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8034147 + * @summary javac crashes with a NullPointerException during bounds checking + * @compile T8034147.java + */ + +class T8034147 { + static class One<X extends Two<? super X>> {} + static class Two<Y extends Three<? extends Y>> implements Three<Y> {} + interface Three<Z> {} +} diff --git a/langtools/test/tools/javac/lambda/LambdaTestStrictFP.java b/langtools/test/tools/javac/lambda/LambdaTestStrictFP.java new file mode 100644 index 0000000000000000000000000000000000000000..67e247e4224dd60ab49c9c233c10d4dfcf868031 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaTestStrictFP.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8046060 + * @summary Different results of floating point multiplication for lambda code block + */ + +strictfp +public class LambdaTestStrictFP { + + static double fld = eval(() -> { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + return x * y; + }); + + public static void main(String args[]) { + double result = eval(() -> { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + return x * y; + }); + { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + double z = x * y; + check(z, result, "method"); + check(z, fld, "field"); + } + } + + private static void check(double expected, double got, String where) { + if (got != expected) { + throw new AssertionError(where + ": Non-strictfp " + got + " != " + expected); + } + } + + private static double eval(Face arg) { + return arg.m(); + } + + private interface Face { + double m(); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaTestStrictFPFlag.java b/langtools/test/tools/javac/lambda/LambdaTestStrictFPFlag.java new file mode 100644 index 0000000000000000000000000000000000000000..dc1cccd608cd710215e93bdf46d4a5ad6918a52f --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaTestStrictFPFlag.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8046060 + * @summary Different results of floating point multiplication for lambda code block + */ + +import java.io.*; +import java.net.URL; +import com.sun.tools.classfile.*; +import static com.sun.tools.classfile.AccessFlags.ACC_STRICT; + +public class LambdaTestStrictFPFlag { + public static void main(String[] args) throws Exception { + new LambdaTestStrictFPFlag().run(); + } + + void run() throws Exception { + ClassFile cf = getClassFile("LambdaTestStrictFPFlag$Test.class"); + ConstantPool cp = cf.constant_pool; + boolean found = false; + for (Method meth: cf.methods) { + if (meth.getName(cp).startsWith("lambda$")) { + if ((meth.access_flags.flags & ACC_STRICT) == 0) { + throw new Exception("strict flag missing from lambda"); + } + found = true; + } + } + if (!found) { + throw new Exception("did not find lambda method"); + } + } + + ClassFile getClassFile(String name) throws IOException, ConstantPoolException { + URL url = getClass().getResource(name); + InputStream in = url.openStream(); + try { + return ClassFile.read(in); + } finally { + in.close(); + } + } + + class Test { + strictfp void test() { + Face itf = () -> { }; + } + } + + interface Face { + void m(); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaTestStrictFPMethod.java b/langtools/test/tools/javac/lambda/LambdaTestStrictFPMethod.java new file mode 100644 index 0000000000000000000000000000000000000000..e8a03ebcbe498fdaebbcdd54b0ab55420bda323e --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaTestStrictFPMethod.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8046060 + * @summary Different results of floating point multiplication for lambda code block + */ + +public class LambdaTestStrictFPMethod { + + public static void main(String args[]) { + new LambdaTestStrictFPMethod().test(); + } + + strictfp void test() { + double result = eval(() -> { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + return x * y; + }); + { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + double z = x * y; + check(z, result, "method"); + } + } + + strictfp void check(double expected, double got, String where) { + if (got != expected) { + throw new AssertionError(where + ": Non-strictfp " + got + " != " + expected); + } + } + + static double eval(Face arg) { + return arg.m(); + } + + interface Face { + double m(); + } +} diff --git a/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java b/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..51895dc330704a4c9d7579369ad86199b846aa54 --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java @@ -0,0 +1,24 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8038182 + * @summary javac crash with FunctionDescriptorLookupError for invalid functional interface + * @compile/fail/ref=CrashFunctionDescriptorExceptionTest.out -XDrawDiagnostics CrashFunctionDescriptorExceptionTest.java + */ + +class CrashFunctionDescriptorExceptionTest { + + @SuppressWarnings("unchecked") + void m () { + bar((B b) -> {}); + } + + <E extends A<E>> void bar(I<E> i) {} + + class A<E> {} + + class B<E> extends A<E> {} + + interface I<E extends A<E>> { + void foo(E e); + } +} diff --git a/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out b/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out new file mode 100644 index 0000000000000000000000000000000000000000..19f5569aff168c098f65014b8b84d941056eb283 --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out @@ -0,0 +1,2 @@ +CrashFunctionDescriptorExceptionTest.java:12:13: compiler.err.prob.found.req: (compiler.misc.no.suitable.functional.intf.inst: CrashFunctionDescriptorExceptionTest.I<CrashFunctionDescriptorExceptionTest.B>) +1 error diff --git a/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java b/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java new file mode 100644 index 0000000000000000000000000000000000000000..07f14efce960a10555f7a6c9291e51100cd5429d --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java @@ -0,0 +1,33 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8042759 + * @summary Lambda returning implicitly-typed lambdas considered pertinent to applicability + * @compile/fail/ref=ImplicitLambdaConsideredForApplicabilityTest.out -XDrawDiagnostics ImplicitLambdaConsideredForApplicabilityTest.java + */ + +abstract class ImplicitLambdaConsideredForApplicabilityTest { + interface A { + B m(int a, int b); + } + + interface C { + String m(int a, int b); + } + + interface B { + int m(int c); + } + + abstract void foo(A a); + + abstract void foo(C c); + + void bar() { + foo((int a, int b) -> { + if(a < b) + return c -> 0; + else + return c -> 0; + }); + } +} diff --git a/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out b/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out new file mode 100644 index 0000000000000000000000000000000000000000..d62ac05b61e296e45361be63e827df0cb7240cc1 --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out @@ -0,0 +1,2 @@ +ImplicitLambdaConsideredForApplicabilityTest.java:26:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.A), ImplicitLambdaConsideredForApplicabilityTest, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.C), ImplicitLambdaConsideredForApplicabilityTest +1 error diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java new file mode 100644 index 0000000000000000000000000000000000000000..21789e1a820a83fecb5802ff51e567b97233d548 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8044748 + * @summary JVM cannot access constructor though ::new reference although can call it directly + */ + +public class MethodRefNewInnerBootstrap { + + interface Constructor { + public MyTest execute(int i); + } + + public class MyTest { + public MyTest(int i) { System.out.println("Constructor executed " + i); } + } + + public Constructor getConstructor() { + return MyTest::new; + } + + public static void main(String argv[]) { + new MethodRefNewInnerBootstrap().call(); + } + + public void call() { + MyTest mt = new MyTest(0); + + Constructor c1 = MyTest::new; + c1.execute(1); + + Constructor c2 = getConstructor(); + c2.execute(2); + + Constructor c3 = new Constructor() { + public MyTest execute(int i) { + return new MyTest(3); + } + }; + c3.execute(3); + + Constructor c4 = new Constructor() { + public MyTest execute(int i) { + Constructor c = MyTest::new; + return c.execute(i); + } + }; + c4.execute(4); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java new file mode 100644 index 0000000000000000000000000000000000000000..ffdff5564530ffee4510ef695cd4b2c3402d3b96 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8037404 + * @summary javac NPE or VerifyError for code with constructor reference of inner class + */ + +import java.util.function.Supplier; +import java.util.stream.Stream; + +public class MethodRefNewInnerInLambdaNPE1 { + public static void main(String[] args) { + if (new MethodRefNewInnerInLambdaNPE1().getList().get().getClass() != TT.class) + throw new AssertionError("sanity failed"); + } + + Supplier<TT> getList() { + return () -> Stream.of(1).map(TT::new).findFirst().get(); + } + + class TT { + public TT(int i) { + + } + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java new file mode 100644 index 0000000000000000000000000000000000000000..f43a8008d1ef0ab73c90f846025157d85ad6e0ca --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8044737 + * @summary Lambda: NPE while obtaining method reference through lambda expression + * @compile MethodRefNewInnerInLambdaNPE2.java + */ + +public class MethodRefNewInnerInLambdaNPE2 { + + interface Constructor { + MyTest execute(); + } + + class MyTest { + MyTest() { System.out.println("Constructor executed"); } + } + + public Constructor getConstructor() { + return getConstructor(() -> { return MyTest::new; }); + } + + public static void main(String argv[]) { + MethodRefNewInnerInLambdaNPE2 t = new MethodRefNewInnerInLambdaNPE2(); + MyTest mytest = t.getConstructor().execute(); + } + + Constructor getConstructor(Wrapper arg) { + return arg.unwrap(); + } + + interface Wrapper { + Constructor unwrap(); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java new file mode 100644 index 0000000000000000000000000000000000000000..c6d7cef715ca2be5851d1e0a531e212dfdae77e0 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8037404 + * @summary javac NPE or VerifyError for code with constructor reference of inner class + */ + +import java.util.function.Function; +import java.util.stream.Stream; + +public class MethodRefNewInnerInLambdaVerify1 { + public static void main(String[] args) { + if (new MethodRefNewInnerInLambdaVerify1().map().apply(1).getClass() != TT.class) + throw new AssertionError("sanity failed"); + } + + Function<Integer,TT> map() { + return (i) -> Stream.of(i).map(TT::new).findFirst().get(); + } + + class TT { + public TT(int i) { + + } + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java new file mode 100644 index 0000000000000000000000000000000000000000..28e4db7ab87e170f65c41f2d220354d687f4290d --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8038776 + * @summary VerifyError when running successfully compiled java class + */ + +import java.util.function.Function; + +/** + * Derived from code by: + * @author Yawkat + */ +public class MethodRefNewInnerInLambdaVerify2 { + public static void main(String[] args) { new MethodRefNewInnerInLambdaVerify2().runTest(); } + + private void runTest() { + Worker worker = new Worker(); + run(() -> worker.check(field -> new SomeClass(field))); + run(() -> worker.check(SomeClass::new)); + } + + private void run(Runnable runnable) { + runnable.run(); + } + + private class SomeClass { + final Object field; + + SomeClass(Object field) { + this.field = field; + } + } + + private static class Worker { + void check(Function<Object, SomeClass> i) { + if (!i.apply("frank").field.equals("frank")) throw new AssertionError("sanity failed"); + } + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java new file mode 100644 index 0000000000000000000000000000000000000000..be6d4b25799dba8ce13fcc38a7f3412b3e0d1a4b --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8038776 + * @summary VerifyError when running successfully compiled java class + */ + +import java.util.function.Function; + +/** + * Derived from code by: + * @author Yawkat + */ +public class MethodRefNewInnerInLambdaVerify2simple { + public static void main(String[] args) { new MethodRefNewInnerInLambdaVerify2simple().runTest(); } + + private void runTest() { + Runnable r = (() -> { Sup w = SomeClass::new; } ); + } + + private class SomeClass { + SomeClass() { } + } +} + +interface Sup { + Object get(); +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java new file mode 100644 index 0000000000000000000000000000000000000000..110d78aba99d96f45b817a59d3caf61ce9ad1c60 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8048121 + * @summary javac complex method references: revamp and simplify + */ + +public class MethodRefQualifier1 { + + interface SAM { + void m(); + } + + static int count = 0; + + static void assertTrue(boolean cond, String msg) { + if (!cond) + throw new AssertionError(msg); + } + + MethodRefQualifier1 check() { + count++; + return this; + } + + void ido(Object... args) { } + + public static void main(String[] args) { + new MethodRefQualifier1().test(); + } + + void test() { + count = 0; + SAM s = check()::ido; + assertTrue(count == 1, "creation: unexpected: " + count); + count = 0; + s.m(); + assertTrue(count == 0, "evaluation: unexpected: " + count); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java new file mode 100644 index 0000000000000000000000000000000000000000..6970f5e14a1f041d673d38c13be2b760fa1daec2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8048121 + * @summary javac complex method references: revamp and simplify + * + * Make sure that the method reference receiver is evaluated exactly once + * even in this bridging case. + */ + + public class MethodRefSingleRefEvalBridge { + + interface SAM { + int m(); + } + + class ZZ { + // private to force bridging + private int four() { return 4; } + } + + static int count = 0; + ZZ azz = new ZZ(); + + static void assertEqual(int expected, int got) { + if (got != expected) + throw new AssertionError("Expected " + expected + " got " + got); + } + + public static void main(String[] args) { + new MethodRefSingleRefEvalBridge().test(); + } + + ZZ check() { + count++; + return azz; + } + + void test() { + count = 0; + SAM s = check()::four; + assertEqual(1, count); + + count = 0; + assertEqual(4, s.m()); + assertEqual(0, count); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefToInner.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefToInner.java new file mode 100644 index 0000000000000000000000000000000000000000..c1a98e6439174047a88238384ff9633d41ad5065 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefToInner.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8047341 + * @summary lambda reference to inner class in base class causes LambdaConversionException + */ + +import java.util.List; +import java.util.ArrayList; + +class MethodRefToInnerBase { + class TestString { + String str; + TestString(String strin) { + str = strin; + } + } +} +public class MethodRefToInner extends MethodRefToInnerBase { + public static void main(String[] args) { + new MethodRefToInner().run(); + } + MethodRefToInner() { + super(); + } + void run() { + List<String> list = new ArrayList<>(); + list.stream().forEach(TestString::new); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java b/langtools/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java new file mode 100644 index 0000000000000000000000000000000000000000..44935abe9b42fdbd77c5853bbe388051cd82d2d2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8048121 + * @summary javac complex method references: revamp and simplify + * + * Make sure NPE check is done even in the convert to Lambda case + */ + +public class MethodReferenceComplexNullCheckTest { + public static void main(String[] args) { + F fr = null; + boolean npeFired = false; + try { + IForm frf = fr::doit; + } catch (NullPointerException npe) { + npeFired = true; + } finally { + if (!npeFired) throw new AssertionError( "NPE should have been thrown"); + } + } + + interface IForm { + void xyz(Object... args); + } + + class F { + private void doit(Object... args) { } + } +} diff --git a/langtools/test/tools/javac/lib/DPrinter.java b/langtools/test/tools/javac/lib/DPrinter.java index 544d21fcb0a25575c6b0be23044951e97026b4f7..c20b913babec38c747e519bb6e1595da7aad8740 100644 --- a/langtools/test/tools/javac/lib/DPrinter.java +++ b/langtools/test/tools/javac/lib/DPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @bug 8043484 + * @bug 8043484 8007307 * @summary Make sure DPrinter.java compiles * @compile DPrinter.java */ @@ -50,6 +50,7 @@ import javax.tools.StandardJavaFileManager; import javax.tools.StandardLocation; import javax.tools.ToolProvider; +import com.sun.source.doctree.*; import com.sun.source.util.JavacTask; import com.sun.source.util.TaskEvent; import com.sun.source.util.TaskListener; @@ -74,6 +75,7 @@ import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.tree.TreeScanner; import com.sun.tools.javac.util.Assert; import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.Convert; import com.sun.tools.javac.util.Log; @@ -248,6 +250,20 @@ public class DPrinter { } } + public void printDocTree(String label, DocTree tree) { + if (tree == null) { + printNull(label); + } else { + indent(); + out.print(label); + out.println(": " + tree.getClass().getSimpleName() + "," + tree.getKind()); + + indent(+1); + tree.accept(docTreeVisitor, null); + indent(-1); + } + } + public void printFileObject(String label, FileObject fo) { if (fo == null) { printNull(label); @@ -265,6 +281,17 @@ public class DPrinter { printString(label, String.valueOf(i)); } + public void printLimitedEscapedString(String label, String text) { + String s = Convert.quote(text); + if (s.length() > maxSrcLength) { + String trim = "[...]"; + int head = (maxSrcLength - trim.length()) * 2 / 3; + int tail = maxSrcLength - trim.length() - head; + s = s.substring(0, head) + trim + s.substring(s.length() - tail); + } + printString(label, s); + } + public void printList(String label, List<?> list) { if (list == null) { printNull(label); @@ -304,6 +331,8 @@ public class DPrinter { printType(label, (Type) item, details); } else if (item instanceof JCTree) { printTree(label, (JCTree) item); + } else if (item instanceof DocTree) { + printDocTree(label, (DocTree) item); } else if (item instanceof List) { printList(label, (List) item); } else if (item instanceof Name) { @@ -877,6 +906,191 @@ public class DPrinter { // </editor-fold> + // <editor-fold defaultstate="collapsed" desc="DocTree visitor"> + + protected DocTreeVisitor<Void,Void> docTreeVisitor = new DefaultDocTreeVisitor(); + + /** + * Default visitor class for DocTree objects. + * Note: each visitXYZ method ends by calling the corresponding + * visit method for its superclass. + */ + class DefaultDocTreeVisitor implements DocTreeVisitor<Void,Void> { + + public Void visitAttribute(AttributeTree node, Void p) { + printName("name", node.getName()); + printString("vkind", node.getValueKind().name()); + printList("value", node.getValue()); + return visitTree(node, null); + } + + public Void visitAuthor(AuthorTree node, Void p) { + printList("name", node.getName()); + return visitBlockTag(node, null); + } + + public Void visitComment(CommentTree node, Void p) { + printLimitedEscapedString("body", node.getBody()); + return visitTree(node, null); + } + + public Void visitDeprecated(DeprecatedTree node, Void p) { + printList("body", node.getBody()); + return visitBlockTag(node, null); + } + + public Void visitDocComment(DocCommentTree node, Void p) { + printList("firstSentence", node.getFirstSentence()); + printList("body", node.getBody()); + printList("tags", node.getBlockTags()); + return visitTree(node, null); + } + + public Void visitDocRoot(DocRootTree node, Void p) { + return visitInlineTag(node, null); + } + + public Void visitEndElement(EndElementTree node, Void p) { + printName("name", node.getName()); + return visitTree(node, null); + } + + public Void visitEntity(EntityTree node, Void p) { + printName("name", node.getName()); + return visitTree(node, null); + } + + public Void visitErroneous(ErroneousTree node, Void p) { + printLimitedEscapedString("body", node.getBody()); + printString("diag", node.getDiagnostic().getMessage(Locale.getDefault())); + return visitTree(node, null); + } + + public Void visitIdentifier(IdentifierTree node, Void p) { + printName("name", node.getName()); + return visitTree(node, null); + } + + public Void visitInheritDoc(InheritDocTree node, Void p) { + return visitInlineTag(node, null); + } + + public Void visitLink(LinkTree node, Void p) { + printString("kind", node.getKind().name()); + printDocTree("ref", node.getReference()); + printList("list", node.getLabel()); + return visitInlineTag(node, null); + } + + public Void visitLiteral(LiteralTree node, Void p) { + printString("kind", node.getKind().name()); + printDocTree("body", node.getBody()); + return visitInlineTag(node, null); + } + + public Void visitParam(ParamTree node, Void p) { + printString("isTypeParameter", String.valueOf(node.isTypeParameter())); + printString("kind", node.getKind().name()); + printList("desc", node.getDescription()); + return visitBlockTag(node, null); + } + + public Void visitReference(ReferenceTree node, Void p) { + printString("signature", node.getSignature()); + return visitTree(node, null); + } + + public Void visitReturn(ReturnTree node, Void p) { + printList("desc", node.getDescription()); + return visitBlockTag(node, null); + } + + public Void visitSee(SeeTree node, Void p) { + printList("ref", node.getReference()); + return visitBlockTag(node, null); + } + + public Void visitSerial(SerialTree node, Void p) { + printList("desc", node.getDescription()); + return visitBlockTag(node, null); + } + + public Void visitSerialData(SerialDataTree node, Void p) { + printList("desc", node.getDescription()); + return visitBlockTag(node, null); + } + + public Void visitSerialField(SerialFieldTree node, Void p) { + printDocTree("name", node.getName()); + printDocTree("type", node.getType()); + printList("desc", node.getDescription()); + return visitBlockTag(node, null); + } + + public Void visitSince(SinceTree node, Void p) { + printList("body", node.getBody()); + return visitBlockTag(node, null); + } + + public Void visitStartElement(StartElementTree node, Void p) { + printName("name", node.getName()); + printList("attrs", node.getAttributes()); + printString("selfClosing", String.valueOf(node.isSelfClosing())); + return visitBlockTag(node, null); + } + + public Void visitText(TextTree node, Void p) { + printLimitedEscapedString("body", node.getBody()); + return visitTree(node, null); + } + + public Void visitThrows(ThrowsTree node, Void p) { + printDocTree("name", node.getExceptionName()); + printList("desc", node.getDescription()); + return visitBlockTag(node, null); + } + + public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) { + printString("name", node.getTagName()); + printList("content", node.getContent()); + return visitBlockTag(node, null); + } + + public Void visitUnknownInlineTag(UnknownInlineTagTree node, Void p) { + printString("name", node.getTagName()); + printList("content", node.getContent()); + return visitInlineTag(node, null); + } + + public Void visitValue(ValueTree node, Void p) { + printDocTree("value", node.getReference()); + return visitInlineTag(node, null); + } + + public Void visitVersion(VersionTree node, Void p) { + printList("body", node.getBody()); + return visitBlockTag(node, null); + } + + public Void visitOther(DocTree node, Void p) { + return visitTree(node, null); + } + + public Void visitBlockTag(DocTree node, Void p) { + return visitTree(node, null); + } + + public Void visitInlineTag(DocTree node, Void p) { + return visitTree(node, null); + } + + public Void visitTree(DocTree node, Void p) { + return null; + } + } + + // </editor-fold> + // <editor-fold defaultstate="collapsed" desc="Symbol visitor"> protected Symbol.Visitor<Void,Void> symVisitor = new SymbolVisitor(); @@ -1228,18 +1442,19 @@ public class DPrinter { } private void handle(TaskEvent e) { + JCCompilationUnit unit = (JCCompilationUnit) e.getCompilationUnit(); switch (e.getKind()) { case PARSE: case ENTER: h.handle(e.getSourceFile().getName(), - (JCTree) e.getCompilationUnit(), + unit, unit, dprinter); break; default: TypeElement elem = e.getTypeElement(); h.handle(elem.toString(), - (JCTree) trees.getTree(elem), + unit, (JCTree) trees.getTree(elem), dprinter); break; } @@ -1258,7 +1473,9 @@ public class DPrinter { Handler(String name) { this.name = name; } - abstract void handle(String label, JCTree tree, DPrinter dprinter); + abstract void handle(String label, + JCCompilationUnit unit, JCTree tree, + DPrinter dprinter); } Map<String,Handler> getHandlers() { @@ -1272,36 +1489,36 @@ public class DPrinter { protected final Handler[] defaultHandlers = { new Handler("trees") { @Override - void handle(String name, JCTree tree, DPrinter dprinter) { + void handle(String name, JCCompilationUnit unit, JCTree tree, DPrinter dprinter) { dprinter.printTree(name, tree); dprinter.out.println(); } }, - new Handler("symbols") { + new Handler("doctrees") { @Override - void handle(String name, JCTree tree, final DPrinter dprinter) { - TreeScanner ds = new TreeScanner() { - @Override - public void visitClassDef(JCClassDecl tree) { - visitDecl(tree, tree.sym); - super.visitClassDef(tree); - } - - @Override - public void visitMethodDef(JCMethodDecl tree) { - visitDecl(tree, tree.sym); - super.visitMethodDef(tree); - } - - @Override - public void visitVarDef(JCVariableDecl tree) { - visitDecl(tree, tree.sym); - super.visitVarDef(tree); + void handle(final String name, final JCCompilationUnit unit, JCTree tree, final DPrinter dprinter) { + TreeScanner ds = new DeclScanner() { + public void visitDecl(JCTree tree, Symbol sym) { + DocTree dt = unit.docComments.getCommentTree(tree); + if (dt != null) { + String label = (sym == null) ? Pretty.toSimpleString(tree) : sym.name.toString(); + dprinter.printDocTree(label, dt); + dprinter.out.println(); + } } + }; + ds.scan(tree); + } + }, - void visitDecl(JCTree tree, Symbol sym) { - dprinter.printSymbol(sym.name.toString(), sym); + new Handler("symbols") { + @Override + void handle(String name, JCCompilationUnit unit, JCTree tree, final DPrinter dprinter) { + TreeScanner ds = new DeclScanner() { + public void visitDecl(JCTree tree, Symbol sym) { + String label = (sym == null) ? Pretty.toSimpleString(tree) : sym.name.toString(); + dprinter.printSymbol(label, sym); dprinter.out.println(); } }; @@ -1311,7 +1528,7 @@ public class DPrinter { new Handler("types") { @Override - void handle(String name, JCTree tree, final DPrinter dprinter) { + void handle(String name, JCCompilationUnit unit, JCTree tree, final DPrinter dprinter) { TreeScanner ts = new TreeScanner() { @Override public void scan(JCTree tree) { @@ -1332,6 +1549,28 @@ public class DPrinter { }; } + protected static abstract class DeclScanner extends TreeScanner { + @Override + public void visitClassDef(JCClassDecl tree) { + visitDecl(tree, tree.sym); + super.visitClassDef(tree); + } + + @Override + public void visitMethodDef(JCMethodDecl tree) { + visitDecl(tree, tree.sym); + super.visitMethodDef(tree); + } + + @Override + public void visitVarDef(JCVariableDecl tree) { + visitDecl(tree, tree.sym); + super.visitVarDef(tree); + } + + protected abstract void visitDecl(JCTree tree, Symbol sym); + } + // </editor-fold> } diff --git a/langtools/test/tools/javac/nested/5009484/X.java b/langtools/test/tools/javac/nested/5009484/X.java index 5829e40a889c3bbbe0ad2745cce13d106c647c8c..b35f5584824cef0a429621fc2043448391fc01e4 100644 --- a/langtools/test/tools/javac/nested/5009484/X.java +++ b/langtools/test/tools/javac/nested/5009484/X.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 5009484 * @summary Compiler fails to resolve appropriate type for outer member * @author Philippe P Mulet - * @compile/fail X.java + * @compile/fail/ref=X.out -XDrawDiagnostics X.java */ public class X<T> { diff --git a/langtools/test/tools/javac/nested/5009484/X.out b/langtools/test/tools/javac/nested/5009484/X.out new file mode 100644 index 0000000000000000000000000000000000000000..5f7f640f84ebc58794bdcbdb7cf873aca79daf03 --- /dev/null +++ b/langtools/test/tools/javac/nested/5009484/X.out @@ -0,0 +1,2 @@ +X.java:22:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T, X) +1 error diff --git a/langtools/test/tools/javac/nested/5009484/Y.java b/langtools/test/tools/javac/nested/5009484/Y.java index e0714eba2daf42f1bedf5539336a1740dcef8e60..d56309737ae6e1d5416a28ec643e5ce36f0cfc3b 100644 --- a/langtools/test/tools/javac/nested/5009484/Y.java +++ b/langtools/test/tools/javac/nested/5009484/Y.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 5009484 * @summary Compiler fails to resolve appropriate type for outer member * @author Peter von der Ah\u00e9 - * @compile/fail Y.java + * @compile/fail/ref=Y.out -XDrawDiagnostics Y.java */ public class Y<T> { diff --git a/langtools/test/tools/javac/nested/5009484/Y.out b/langtools/test/tools/javac/nested/5009484/Y.out new file mode 100644 index 0000000000000000000000000000000000000000..1860f93f234ca80b1761c6ab51f53c8dfd51fbe3 --- /dev/null +++ b/langtools/test/tools/javac/nested/5009484/Y.out @@ -0,0 +1,2 @@ +Y.java:12:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T, Y<T>) +1 error diff --git a/langtools/test/tools/javac/overload/T4743490.java b/langtools/test/tools/javac/overload/T4743490.java index 86c39b65e60f09928f6756eae5e19b63f0a00946..9723301dee7310f27e4ed90cc3a5d4c116220cc4 100644 --- a/langtools/test/tools/javac/overload/T4743490.java +++ b/langtools/test/tools/javac/overload/T4743490.java @@ -1,33 +1,9 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4743490 * @summary overloading versus super.f(args) versus interfaces * @author gafter - * - * @compile/fail T4743490.java + * @compile/fail/ref=T4743490.out -XDrawDiagnostics T4743490.java */ class T4743490 { diff --git a/langtools/test/tools/javac/overload/T4743490.out b/langtools/test/tools/javac/overload/T4743490.out new file mode 100644 index 0000000000000000000000000000000000000000..13f63522eec9872078cf626dbb1194ee88be0a05 --- /dev/null +++ b/langtools/test/tools/javac/overload/T4743490.out @@ -0,0 +1,2 @@ +T4743490.java:21:18: compiler.err.ref.ambiguous: m, kindname.method, m(java.lang.String,java.lang.Object), T4743490.B, kindname.method, m(java.lang.Object,java.lang.String), T4743490.A +1 error diff --git a/langtools/test/tools/javac/overload/T5090220.java b/langtools/test/tools/javac/overload/T5090220.java index 63f3d982ddb3294fe6197d45f2eb5fb2b75afa5d..96a897e2fae9192474eb25f8967cab057467d248 100644 --- a/langtools/test/tools/javac/overload/T5090220.java +++ b/langtools/test/tools/javac/overload/T5090220.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 5090220 * @summary Autoboxing applied when calculating most-specific method - * @compile/fail T5090220.java + * @compile/fail/ref=T5090220.out -XDrawDiagnostics T5090220.java */ class T5090220 { diff --git a/langtools/test/tools/javac/overload/T5090220.out b/langtools/test/tools/javac/overload/T5090220.out new file mode 100644 index 0000000000000000000000000000000000000000..e4390c88b21ea5b7ff75ba44b1fd2d1931edae36 --- /dev/null +++ b/langtools/test/tools/javac/overload/T5090220.out @@ -0,0 +1,2 @@ +T5090220.java:16:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(int,java.lang.Integer), T5090220, kindname.method, foo(java.lang.Integer,double), T5090220 +1 error diff --git a/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java new file mode 100644 index 0000000000000000000000000000000000000000..61b70d28c70fedd7f34423155aca0275fd1f0259 --- /dev/null +++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8042345 + * @summary getDocComment() fails for doc comments on PackageElement found in package-info.java + */ + +import com.sun.source.util.JavacTask; + +import java.io.*; +import java.util.*; +import javax.annotation.processing.*; +import javax.lang.model.*; +import javax.lang.model.element.*; +import javax.lang.model.util.*; +import javax.tools.*; + +@SupportedAnnotationTypes("*") +public class TestPackageInfoComments extends AbstractProcessor { + + public static void main(String... args) throws Exception { + String[] opts = { + "-implicit:none", + "-processor", TestPackageInfoComments.class.getName(), + "-processorpath", System.getProperty("test.classes") + }; + File[] files = { + new File(System.getProperty("test.src"), "p/package-info.java") + }; + run_test(opts, files); + } + + static void run_test(String[] opts, File[] files) throws IOException { + DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() { + public void report(Diagnostic diagnostic) { + throw new Error(diagnostic.toString()); + } + }; + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); + Iterable<? extends JavaFileObject> units = fm.getJavaFileObjects(files); + JavacTask t = (JavacTask) c.getTask(null, fm, dl, Arrays.asList(opts), null, units); + t.parse(); + t.analyze(); + } + + // -- Annotation processor: Check all PackageDecl's have a doc comment + + Messager messager; + Elements elements; + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public void init(ProcessingEnvironment pEnv) { + super.init(pEnv); + messager = pEnv.getMessager(); + elements = pEnv.getElementUtils(); + } + + @Override + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { + for (Element e: roundEnv.getRootElements()) + new TestElementScanner().scan(e); + return true; + } + + class TestElementScanner extends ElementScanner7<Void, Void> { + @Override + public Void visitPackage(PackageElement e, Void v) { + if (elements.getDocComment(e) == null) + messager.printMessage(Diagnostic.Kind.ERROR, "doc comment is null", e); + return v; + } + } +} diff --git a/langtools/test/tools/javac/processing/model/util/elements/doccomments/p/package-info.java b/langtools/test/tools/javac/processing/model/util/elements/doccomments/p/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..a69d89200d86fbb965551365358080555ef3c5a5 --- /dev/null +++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/p/package-info.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** A non-empty comment. */ +package foo; diff --git a/langtools/test/tools/javac/tree/MissingSemicolonTest.java b/langtools/test/tools/javac/tree/MissingSemicolonTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c6b257ed8e1b558e4abeec8386b5b9dc723fb14d --- /dev/null +++ b/langtools/test/tools/javac/tree/MissingSemicolonTest.java @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8041648 + * @summary Verify that end positions are sane if semicolons are missing. + * @run main MissingSemicolonTest MissingSemicolonTest.java + */ + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.nio.file.Files; +import java.util.*; + +import javax.tools.*; + +import com.sun.source.tree.*; +import com.sun.source.tree.Tree.Kind; +import com.sun.source.util.*; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.parser.Scanner; +import com.sun.tools.javac.parser.ScannerFactory; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; +import com.sun.tools.javac.util.Context; + +public class MissingSemicolonTest { + public static void main(String... args) { + String testSrc = System.getProperty("test.src"); + File baseDir = new File(testSrc); + boolean ok = new MissingSemicolonTest().run(baseDir, args); + if (!ok) { + throw new Error("failed"); + } + } + + boolean run(File baseDir, String... args) { + if (args.length == 0) { + throw new IllegalStateException("Needs input files."); + } + + for (String arg : args) { + File file = new File(baseDir, arg); + if (file.exists()) + test(file); + else + error("File not found: " + file); + } + + System.err.println(fileCount + " files read"); + if (errors > 0) + System.err.println(errors + " errors"); + + return errors == 0; + } + + void test(File file) { + if (file.isFile() && file.getName().endsWith(".java")) { + try { + fileCount++; + String content = new String(Files.readAllBytes(file.toPath())); + List<int[]> spans = gatherTreeSpans(file, content); + int nextSemicolon = -1; + + //remove semicolons, one at a time, and verify the positions are still meaningful: + while ((nextSemicolon = content.indexOf(';', nextSemicolon + 1)) != (-1)) { + String updatedContent = + content.substring(0, nextSemicolon) + + " " + + content.substring(nextSemicolon + 1); + verifyTreeSpans(file, spans, updatedContent, nextSemicolon); + } + } catch (IOException e) { + error("Error reading " + file + ": " + e); + } + } + } + + public List<int[]> gatherTreeSpans(File file, String content) throws IOException { + JCCompilationUnit unit = read(file.toURI(), content); + List<int[]> spans = new ArrayList<>(); + new TreePathScanner<Void, Void>() { + @Override + public Void scan(Tree tree, Void p) { + if (tree != null) { + int start = ((JCTree) tree).getStartPosition(); + int end = ((JCTree) tree).getEndPosition(unit.endPositions); + + spans.add(new int[] {start, end}); + } + return super.scan(tree, p); + } + }.scan(unit, null); + return spans; + } + + public void verifyTreeSpans(File file, List<int[]> spans, + String updatedContent, int semicolon) throws IOException { + JCCompilationUnit updated = read(file.toURI(), updatedContent); + Iterator<int[]> nextSpan = spans.iterator(); + new TreePathScanner<Void, Void>() { + @Override + public Void scan(Tree tree, Void p) { + if (tree != null) { + int start = ((JCTree) tree).getStartPosition(); + int end = ((JCTree) tree).getEndPosition(updated.endPositions); + + if (tree.getKind() != Kind.ERRONEOUS) { + int[] expected = nextSpan.next(); + int expectedEnd = expected[1]; + + if (expectedEnd == semicolon + 1) { + Scanner scanner = scannerFactory.newScanner(updatedContent, true); + scanner.nextToken(); + while (scanner.token().pos < expectedEnd) + scanner.nextToken(); + expectedEnd = scanner.token().pos; + } + + if (expected[0] != start || expectedEnd != end) { + error(updatedContent + "; semicolon: " + semicolon + "; expected: " + + expected[0] + "-" + expectedEnd + "; found=" + start + "-" + end + + ";" + tree); + } + } + } + return super.scan(tree, p); + } + }.scan(updated, null); + } + + DiagnosticListener<JavaFileObject> devNull = (d) -> {}; + JavacTool tool = JavacTool.create(); + StandardJavaFileManager fm = tool.getStandardFileManager(devNull, null, null); + ScannerFactory scannerFactory = ScannerFactory.instance(new Context()); + + /** + * Read a file. + * @param file the file to be read + * @return the tree for the content of the file + * @throws IOException if any IO errors occur + * @throws MissingSemicolonTest.ParseException if any errors occur while parsing the file + */ + JCCompilationUnit read(URI uri, String content) throws IOException { + JavacTool tool = JavacTool.create(); + JavacTask task = tool.getTask(null, fm, devNull, Collections.<String>emptyList(), null, + Arrays.<JavaFileObject>asList(new JavaSource(uri, content))); + Iterable<? extends CompilationUnitTree> trees = task.parse(); + Iterator<? extends CompilationUnitTree> iter = trees.iterator(); + if (!iter.hasNext()) + throw new Error("no trees found"); + JCCompilationUnit t = (JCCompilationUnit) iter.next(); + if (iter.hasNext()) + throw new Error("too many trees found"); + return t; + } + + class JavaSource extends SimpleJavaFileObject { + + private final String content; + public JavaSource(URI uri, String content) { + super(uri, JavaFileObject.Kind.SOURCE); + this.content = content; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return content; + } + } + + /** + * Report an error. When the program is complete, the program will either + * exit or throw an Error if any errors have been reported. + * @param msg the error message + */ + void error(String msg) { + System.err.println(msg); + errors++; + } + + /** Number of files that have been analyzed. */ + int fileCount; + /** Number of errors reported. */ + int errors; + +} + +class TestCase { + String str1; + String str2; + public TestCase() { + super(); + super.hashCode(); + } + public TestCase(String str1, String str2) { + super(); + this.str1 = str1; + this.str2 = str2; + assert true; + } + + void newClass() { + new String(); + new String(); + } + + void localVars() { + String str1 = ""; + String str2; + String str3; + final String str4; + } + + void throwsException() { + throw new IllegalStateException(); + } + + int returnWithExpression() { + return 1; + } + + void returnWithoutExpression() { + return ; + } + + void doWhileBreakContinue() { + do { + if (true) + break; + if (false) + continue; + } while(true); + } + + void labelled() { + LABEL: doWhileBreakContinue(); + } + +} diff --git a/langtools/test/tools/javac/varargs/warning/Warn4.java b/langtools/test/tools/javac/varargs/warning/Warn4.java index 1a068c7424455bbb2d78b06f5b7a72d677f4077c..4598c483fd4af8e8216f46e5f00602e442b4c23f 100644 --- a/langtools/test/tools/javac/varargs/warning/Warn4.java +++ b/langtools/test/tools/javac/varargs/warning/Warn4.java @@ -73,13 +73,15 @@ public class Warn4 ModifierKind modKind) { switch(this) { case VARARGS: - return source == SourceLevel.JDK_6 || + return source.compareTo(SourceLevel.JDK_7) < 0 || suppressLevelDecl == SuppressLevel.UNCHECKED || trustMe == TrustMe.TRUST; case UNCHECKED: return suppressLevelClient == SuppressLevel.UNCHECKED || - (trustMe == TrustMe.TRUST && modKind != - ModifierKind.NONE && source == SourceLevel.JDK_7); + (trustMe == TrustMe.TRUST && + (((modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC) && + source.compareTo( SourceLevel.JDK_7) >= 0 ) || + (modKind == ModifierKind.PRIVATE && source.compareTo( SourceLevel.JDK_9) >= 0 ))); } SuppressLevel supLev = this == VARARGS ? @@ -92,7 +94,8 @@ public class Warn4 enum SourceLevel { JDK_6("6"), - JDK_7("7"); + JDK_7("7"), + JDK_9("9"); String sourceKey; @@ -115,7 +118,8 @@ public class Warn4 enum ModifierKind { NONE(" "), FINAL("final "), - STATIC("static "); + STATIC("static "), + PRIVATE("private "); String mod; diff --git a/langtools/test/tools/javac/varargs/warning/Warn5.java b/langtools/test/tools/javac/varargs/warning/Warn5.java index e45cd3616376cd4bee79f4c3d08c8b8f692e88e6..b73d1af5fa8664dfd842b81ffddc673b054a2a48 100644 --- a/langtools/test/tools/javac/varargs/warning/Warn5.java +++ b/langtools/test/tools/javac/varargs/warning/Warn5.java @@ -89,7 +89,8 @@ public class Warn5 enum ModifierKind { NONE(""), FINAL("final"), - STATIC("static"); + STATIC("static"), + PRIVATE("private"); String mod; @@ -111,7 +112,8 @@ public class Warn5 enum SourceLevel { JDK_6("6"), - JDK_7("7"); + JDK_7("7"), + JDK_9("9"); String sourceKey; @@ -238,7 +240,7 @@ public class Warn5 EnumSet<WarningKind> expectedWarnings = EnumSet.noneOf(WarningKind.class); - if (sourceLevel == SourceLevel.JDK_7 && + if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 && trustMe == TrustMe.TRUST && suppressLevel != SuppressLevel.VARARGS && xlint != XlintOption.NONE && @@ -247,11 +249,12 @@ public class Warn5 body.hasAliasing && (methKind == MethodKind.CONSTRUCTOR || (methKind == MethodKind.METHOD && - modKind != ModifierKind.NONE))) { + modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC || + (modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0)))) { expectedWarnings.add(WarningKind.UNSAFE_BODY); } - if (sourceLevel == SourceLevel.JDK_7 && + if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 && trustMe == TrustMe.DONT_TRUST && sig.isVarargs && !sig.isReifiableArg && @@ -259,20 +262,22 @@ public class Warn5 expectedWarnings.add(WarningKind.UNSAFE_DECL); } - if (sourceLevel == SourceLevel.JDK_7 && + if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 && trustMe == TrustMe.TRUST && (!sig.isVarargs || - (modKind == ModifierKind.NONE && - methKind == MethodKind.METHOD))) { + ((modKind == ModifierKind.NONE || + modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) < 0 ) && + methKind == MethodKind.METHOD))) { expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS); } - if (sourceLevel == SourceLevel.JDK_7 && + if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 && trustMe == TrustMe.TRUST && xlint != XlintOption.NONE && suppressLevel != SuppressLevel.VARARGS && - (modKind != ModifierKind.NONE || - methKind == MethodKind.CONSTRUCTOR) && + (modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC || + (modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0) || + methKind == MethodKind.CONSTRUCTOR) && sig.isVarargs && sig.isReifiableArg) { expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS); @@ -283,6 +288,7 @@ public class Warn5 throw new Error("invalid diagnostics for source:\n" + source.getCharContent(true) + "\nOptions: " + xlint.getXlintOption() + + "\nSource Level: " + sourceLevel + "\nExpected warnings: " + expectedWarnings + "\nFound warnings: " + dc.warnings); } diff --git a/langtools/test/tools/javac/warnings/suppress/T6707032.java b/langtools/test/tools/javac/warnings/suppress/T6707032.java new file mode 100644 index 0000000000000000000000000000000000000000..5a13d7378637468afe3a65680ec7982db033b980 --- /dev/null +++ b/langtools/test/tools/javac/warnings/suppress/T6707032.java @@ -0,0 +1,18 @@ +/** + * @test /nodynamiccopyright/ + * @bug 6707032 + * @summary Verify that \\@SuppressWarnings("divzero") works for constant initializers + * @build VerifySuppressWarnings + * @compile/ref=T6707032.out -XDrawDiagnostics -Xlint:divzero T6707032.java + * @run main VerifySuppressWarnings T6707032.java + */ + +public class T6707032 { + public static final int D1 = T6707032b.D0; + public static final int D2 = 1/0; +} + +class T6707032b { + public static final int D0 = 1/0; + public static final int D3 = T6707032.D2; +} diff --git a/langtools/test/tools/javac/warnings/suppress/T6707032.out b/langtools/test/tools/javac/warnings/suppress/T6707032.out new file mode 100644 index 0000000000000000000000000000000000000000..83b38a1562f8e73f3d2fddcbb76724cc7cbc7346 --- /dev/null +++ b/langtools/test/tools/javac/warnings/suppress/T6707032.out @@ -0,0 +1,3 @@ +T6707032.java:12:36: compiler.warn.div.zero +T6707032.java:16:36: compiler.warn.div.zero +2 warnings diff --git a/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java b/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java index 037f2a1764ae66f7d125c1ea525a412d05975d74..dad2ebecd72b43c6e42b207069be712a61ef3129 100644 --- a/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java +++ b/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,11 +55,12 @@ import javax.tools.SimpleJavaFileObject; * the @SuppressWarnings annotation on the declaration and verifies than no * warnings are produced inside the declaration, but all are produced outside it. * - * Currently only works with <code>unchecked,deprecation,cast</code> warnings. + * Currently only works with <code>unchecked,deprecation,cast,divzero</code> warnings. */ public class VerifySuppressWarnings { - private static final List<String> STANDARD_PARAMS = Arrays.asList("-Xlint:unchecked,deprecation,cast", "-Xjcov"); + private static final List<String> STANDARD_PARAMS = + Arrays.asList("-Xlint:unchecked,deprecation,cast,divzero"); public static void main(String... args) throws IOException, URISyntaxException { if (args.length != 1) throw new IllegalStateException("Must provide class name!"); @@ -133,7 +134,8 @@ public class VerifySuppressWarnings { }.scan(cut, null); for (final int[] declarationSpan : declarationSpans) { - final String suppressWarnings = "@SuppressWarnings({\"deprecation\", \"unchecked\", \"serial\"})"; + final String suppressWarnings = + "@SuppressWarnings({\"deprecation\", \"unchecked\", \"serial\", \"divzero\"})"; final String updatedContent = testContent.substring(0, declarationSpan[0]) + suppressWarnings + testContent.substring(declarationSpan[0]); final List<Diagnostic<?>> foundErrors = new ArrayList<>(diagnostics); DiagnosticListener<JavaFileObject> verifyDiagnostics = new DiagnosticListener<JavaFileObject>() { diff --git a/langtools/test/tools/javadoc/6227454/Test.java b/langtools/test/tools/javadoc/6227454/Test.java index e42c301b6d7777bc918a43f4722470e2ee022fd3..62dad90c5496136a1194557a9b509db1733100f1 100644 --- a/langtools/test/tools/javadoc/6227454/Test.java +++ b/langtools/test/tools/javadoc/6227454/Test.java @@ -38,15 +38,18 @@ public class Test extends Doclet { } void run() throws Exception { - test("<html><body>ABC XYZ</body></html>"); - test("<html><body>ABC XYZ</BODY></html>"); - test("<html><BODY>ABC XYZ</body></html>"); - test("<html><BODY>ABC XYZ</BODY></html>"); - test("<html><BoDy>ABC XYZ</bOdY></html>"); - test("<html> ABC XYZ</bOdY></html>", "Body tag missing from HTML"); - test("<html><body>ABC XYZ </html>", "Close body tag missing from HTML"); - test("<html> ABC XYZ </html>", "Body tag missing from HTML"); - test("<html><body>ABC" + bigText(8192, 40) + "XYZ</body></html>"); + String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " + + "\"http://www.w3.org/TR/html4/loose.dtd\">"; + String headTag = "<head><title>Title </title></head>"; + test(docType+"<html><body>ABC XYZ</body></html>"); + test(docType+"<html><body>ABC XYZ</BODY></html>"); + test(docType+"<html><BODY>ABC XYZ</body></html>"); + test(docType+"<html><BODY>ABC XYZ</BODY></html>"); + test(docType+"<html><BoDy>ABC XYZ</bOdY></html>"); + test(docType+"<html>"+headTag+" ABC XYZ</bOdY></html>", "Body tag missing from HTML"); + test(docType+"<html><body>ABC XYZ </html>", "Close body tag missing from HTML"); + test(docType+"<html>"+headTag+" ABC XYZ </html>", "Body tag missing from HTML"); + test(docType+"<html><body>ABC" + bigText(8192, 40) + "XYZ</body></html>"); if (errors > 0) throw new Exception(errors + " errors occurred"); diff --git a/langtools/test/tools/sjavac/IgnoreSymbolFile.java b/langtools/test/tools/sjavac/IgnoreSymbolFile.java new file mode 100644 index 0000000000000000000000000000000000000000..b7898bbc23c8d8623645e2e3259a3d7e2f67df23 --- /dev/null +++ b/langtools/test/tools/sjavac/IgnoreSymbolFile.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8047183 + * @summary JDK build fails with sjavac enabled + */ + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintStream; +import java.lang.reflect.Method; +import java.util.Arrays; + +public class IgnoreSymbolFile { + public static void main(String... args) throws Exception { + if (sjavacAvailable()) { + IgnoreSymbolFile test = new IgnoreSymbolFile(); + test.run(); + } else { + System.err.println("sjavac not available; test skipped"); + } + } + + void run() throws Exception { + String body = + "package p;\n" + + "import sun.reflect.annotation.*;\n" + + "class X {\n" + + " ExceptionProxy proxy;" + + "}"; + writeFile("src/p/X.java", body); + + new File("classes").mkdirs(); + + String server = "--server:portfile=testserver,background=false"; + int rc1 = compile(server, "-d", "classes", "-Werror", "src"); + if (rc1 == 0) + error("compilation succeeded unexpectedly"); + + int rc2 = compile(server, "-d", "classes", "-Werror", "-XDignore.symbol.file=true", "src"); + if (rc2 != 0) + error("compilation failed unexpectedly: rc=" + rc2); + + if (errors > 0) + throw new Exception(errors + " errors occurred"); + } + + int compile(String... args) throws ReflectiveOperationException { + // Use reflection to avoid a compile-time dependency on sjavac Main + System.err.println("compile: " + Arrays.toString(args)); + Class<?> c = Class.forName("com.sun.tools.sjavac.Main"); + Method m = c.getDeclaredMethod("go", String[].class, PrintStream.class, PrintStream.class); + Object sjavac = c.newInstance(); + int rc = (Integer) m.invoke(sjavac, args, System.err, System.err); + System.err.println("rc=" + rc); + return rc; + } + + void writeFile(String path, String body) throws IOException { + File f = new File(path); + if (f.getParentFile() != null) + f.getParentFile().mkdirs(); + try (FileWriter w = new FileWriter(f)) { + w.write(body); + } + } + + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + int errors; + + static boolean sjavacAvailable() { + try { + Class.forName("com.sun.tools.sjavac.Main"); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } +} diff --git a/langtools/test/tools/sjavac/SJavac.java b/langtools/test/tools/sjavac/SJavac.java index 867643e7f98dc9f71b29460e969f54a70ce89a41..59fb758502404bcbb94b999af126915742393acb 100644 --- a/langtools/test/tools/sjavac/SJavac.java +++ b/langtools/test/tools/sjavac/SJavac.java @@ -23,7 +23,6 @@ import java.util.*; import java.io.*; -import java.net.*; import java.nio.file.*; import java.nio.file.attribute.*; import java.nio.charset.*; @@ -43,6 +42,9 @@ class SJavac { } FileSystem defaultfs = FileSystems.getDefault(); + String serverArg = "--server:" + + "portfile=testportfile," + + "background=false"; // Where to put generated sources that will // test aspects of sjavac, ie JTWork/scratch/gensrc @@ -136,7 +138,7 @@ class SJavac { "private int b() { return A.DEFINITION; } native void foo(); }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); previous_bin_state = collectState(bin); previous_headers_state = collectState(headers); } @@ -145,7 +147,7 @@ class SJavac { System.out.println("\nTesting that no change in sources implies no change in binaries."); System.out.println("------------------------------------------------------------------"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map<String,Long> new_bin_state = collectState(bin); verifyEqual(new_bin_state, previous_bin_state); Map<String,Long> new_headers_state = collectState(headers); @@ -158,7 +160,7 @@ class SJavac { System.out.println("-----------------------------------------"); removeFrom(gensrc, "alfa/omega/AA.java"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map<String,Long> new_bin_state = collectState(bin); verifyThatFilesHaveBeenRemoved(previous_bin_state, new_bin_state, "bin/alfa/omega/AA$1.class", @@ -185,7 +187,7 @@ class SJavac { "public final static int DEFINITION = 18; public void aint() { } private void foo() { } }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map<String,Long> new_bin_state = collectState(bin); verifyNewerFiles(previous_bin_state, new_bin_state, @@ -211,7 +213,7 @@ class SJavac { "private int b() { return A.DEFINITION; } }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map<String,Long> new_bin_state = collectState(bin); verifyNewerFiles(previous_bin_state, new_bin_state, "bin/beta/B.class", @@ -236,7 +238,7 @@ class SJavac { "@java.lang.annotation.Native final static int alfa = 42; }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map<String,Long> new_bin_state = collectState(bin); verifyNewerFiles(previous_bin_state, new_bin_state, "bin/beta/B.class", @@ -262,7 +264,7 @@ class SJavac { "@java.lang.annotation.Native final static int alfa = 43; }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map<String,Long> new_bin_state = collectState(bin); verifyNewerFiles(previous_bin_state, new_bin_state, "bin/beta/B.class", @@ -299,7 +301,7 @@ class SJavac { "package beta; public class B { }"); compile("-x", "beta", "gensrc", "gensrc2", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false"); + serverArg); Map<String,Long> new_bin_state = collectState(bin); verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state, "bin/alfa/omega/A.class", @@ -310,7 +312,7 @@ class SJavac { System.out.println("----- Compile with exluded beta went well!"); delete(bin); compileExpectFailure("gensrc", "gensrc2", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false"); + serverArg); System.out.println("----- Compile without exluded beta failed, as expected! Good!"); delete(bin); @@ -341,7 +343,7 @@ class SJavac { compile("gensrc", "-x", "beta", "-sourcepath", "gensrc2", "-sourcepath", "gensrc3", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false"); + serverArg); System.out.println("The first compile went well!"); Map<String,Long> new_bin_state = collectState(bin); @@ -353,7 +355,7 @@ class SJavac { delete(bin); compileExpectFailure("gensrc", "-sourcepath", "gensrc2", "-sourcepath", "gensrc3", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false"); + serverArg); System.out.println("----- Compile without exluded beta failed, as expected! Good!"); delete(bin); @@ -378,7 +380,7 @@ class SJavac { "package gamma; public class C { alfa.omega.A a; }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "3", - "--server:portfile=testserver,background=false","--log=debug"); + serverArg,"--log=debug"); Map<String,Long> new_bin_state = collectState(bin); verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state, "bin/alfa/omega/A.class", @@ -407,7 +409,7 @@ class SJavac { "package beta; public class B { }"); compile("-x", "beta", "-src", "gensrc", "-x", "alfa/omega", "-sourcepath", "gensrc", - "-d", "bin", "--server:portfile=testserver,background=false"); + "-d", "bin", serverArg); Map<String,Long> new_bin_state = collectState(bin); verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state, @@ -431,7 +433,7 @@ class SJavac { "}"); compile("gensrc", "-d", "bin", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map<String,Long> previous_bin_state = collectState(bin); // Change pubapi of A, this should trigger a recompile of B. @@ -443,7 +445,7 @@ class SJavac { "}"); compile("gensrc", "-d", "bin", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map<String,Long> new_bin_state = collectState(bin); verifyNewerFiles(previous_bin_state, new_bin_state,