--- a/langtools/.hgignore Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/.hgignore Tue Jul 01 14:28:22 2014 -0700
@@ -1,5 +1,6 @@
^build/
^dist/
+^.idea
/nbproject/private/
^.hgtip
.DS_Store
--- a/langtools/make/build.xml Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/make/build.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/ant.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/build.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/codeStyleSettings.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/compiler.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/inspectionProfiles/langtools.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/inspectionProfiles/profiles_settings.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/langtools.iml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/misc.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/modules.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/vcs.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/make/intellij/workspace.xml Tue Jul 01 14:28:22 2014 -0700
@@ -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>
+
--- a/langtools/src/share/classes/com/sun/javadoc/AnnotatedType.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/javadoc/AnnotatedType.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface AuthorTree extends BlockTagTree {
+ /**
+ * Returns the name of the author.
+ * @return the name
+ */
List<? extends DocTree> getName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface BlockTagTree extends DocTree {
+ /**
+ * Returns the name of the tag.
+ * @return the name of the tag
+ */
String getTagName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface CommentTree extends DocTree {
+ /**
+ * Returns the text of the comment.
+ * @return the comment text
+ */
String getBody();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface DeprecatedTree extends BlockTagTree {
+ /**
+ * Returns the description explaining why an item is deprecated.
+ * @return the description
+ */
List<? extends DocTree> getBody();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/DocTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface DocTree {
+ /**
+ * Enumerates all kinds of trees.
+ */
@jdk.Exported
enum Kind {
/**
@@ -227,6 +230,9 @@
*/
OTHER;
+ /**
+ * The name of the tag, if any, associated with this kind of node.
+ */
public final String tagName;
Kind() {
@@ -239,7 +245,7 @@
}
/**
- * Gets the kind of this tree.
+ * Returns the kind of this tree.
*
* @return the kind of this tree.
*/
@@ -251,6 +257,9 @@
*
* @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);
}
--- a/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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);
}
--- a/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface EndElementTree extends DocTree {
+ /**
+ * Returns the name of this element.
+ * @return the name
+ */
Name getName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
* 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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
@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
--- a/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface IdentifierTree extends DocTree {
+ /**
+ * Returns the name of the identifier.
+ * @return the name
+ */
Name getName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface InlineTagTree extends DocTree {
+ /**
+ * Returns the name of the tag.
+ * @return the name of the tag
+ */
String getTagName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface ReturnTree extends BlockTagTree {
+ /**
+ * Returns the description of the return value of a method.
+ * @return the description
+ */
List<? extends DocTree> getDescription();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface SeeTree extends BlockTagTree {
+ /**
+ * Returns the reference.
+ * @return the reference
+ */
List<? extends DocTree> getReference();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface SerialDataTree extends BlockTagTree {
+ /**
+ * Returns the description of the serial data.
+ * @return the description
+ */
List<? extends DocTree> getDescription();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/TextTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface TextTree extends DocTree {
+ /**
+ * Returns the text.
+ * @return the text
+ */
String getBody();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface UnknownBlockTagTree extends BlockTagTree {
+ /**
+ * Returns the content of an unrecognized block tag.
+ * @return the content
+ */
List<? extends DocTree> getContent();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface UnknownInlineTagTree extends InlineTagTree {
+ /**
+ * Returns the content of an unrecognized inline tag.
+ * @return the content
+ */
List<? extends DocTree> getContent();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface ValueTree extends InlineTagTree {
+ /**
+ * Returns the reference to the value.
+ * @return the reference
+ */
ReferenceTree getReference();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface VersionTree extends BlockTagTree {
+ /**
+ * Returns the body of the tag.
+ * @return the body
+ */
List<? extends DocTree> getBody();
}
--- a/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface ArrayTypeTree extends Tree {
+ /**
+ * Returns the element type of this array type.
+ * @return the element type
+ */
Tree getType();
}
--- a/langtools/src/share/classes/com/sun/source/tree/AssertTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/AssertTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/BlockTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/BlockTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/BreakTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/BreakTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
*/
@jdk.Exported
public interface BreakTree extends StatementTree {
+ /**
+ * Returns the label for this {@code break} statement.
+ * @return the label
+ */
Name getLabel();
}
--- a/langtools/src/share/classes/com/sun/source/tree/CaseTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/CaseTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/CatchTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/CatchTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ClassTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ClassTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
--- a/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
*/
@jdk.Exported
public interface ContinueTree extends StatementTree {
+ /**
+ * Returns the label for this {@code continue} statement.
+ * @return the label
+ */
Name getLabel();
}
--- a/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface ErroneousTree extends ExpressionTree {
+ /**
+ * Returns any trees that were saved in this node.
+ * @return the trees
+ */
List<? extends Tree> getErrorTrees();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface ExpressionStatementTree extends StatementTree {
+ /**
+ * Returns the expression constituting this statement.
+ * @return the expression
+ */
ExpressionTree getExpression();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface IdentifierTree extends ExpressionTree {
+ /**
+ * Returns the name of the identifier.
+ * @return the name
+ */
Name getName();
}
--- a/langtools/src/share/classes/com/sun/source/tree/IfTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/IfTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ImportTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ImportTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface IntersectionTypeTree extends Tree {
+ /**
+ * Returns the bounds of the type.
+ * @return the bounds
+ */
List<? extends Tree> getBounds();
}
--- a/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/LineMap.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/LineMap.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
@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 @@
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 @@
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 @@
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.
*
--- a/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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
}
--- a/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/PackageTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/PackageTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -37,6 +37,15 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface ParenthesizedTree extends ExpressionTree {
+ /**
+ * Returns the expression within the parentheses.
+ * @return the expression
+ */
ExpressionTree getExpression();
}
--- a/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface PrimitiveTypeTree extends Tree {
+ /**
+ * Returns the kind of this primitive type.
+ * @return the kind of the type
+ */
TypeKind getPrimitiveTypeKind();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface ReturnTree extends StatementTree {
+ /**
+ * Returns the expression to be returned.
+ * @return the expression
+ */
ExpressionTree getExpression();
}
--- a/langtools/src/share/classes/com/sun/source/tree/Scope.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/Scope.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface ThrowTree extends StatementTree {
+ /**
+ * Returns the expression to be thrown.
+ * @return the expression
+ */
ExpressionTree getExpression();
}
--- a/langtools/src/share/classes/com/sun/source/tree/Tree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public enum Kind {
-
+ /**
+ * Used for instances of {@link AnnotatedTypeTree}
+ * representing annotated types.
+ */
ANNOTATED_TYPE(AnnotatedTypeTree.class),
/**
@@ -613,6 +616,10 @@
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 @@
}
/**
- * Gets the kind of this tree.
+ * Returns the kind of this tree.
*
* @return the kind of this tree.
*/
@@ -633,6 +640,9 @@
*
* @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);
}
--- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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);
}
--- a/langtools/src/share/classes/com/sun/source/tree/TryTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/TryTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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
--- a/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface UnaryTree extends ExpressionTree {
+ /**
+ * Returns the expression that is the operand of the unary operator.
+ * @return the expression
+ */
ExpressionTree getExpression();
}
--- a/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
*/
@jdk.Exported
public interface UnionTypeTree extends Tree {
+ /**
+ * Returns the alternative type expressions.
+ * @return the alternative type expressions
+ */
List<? extends Tree> getTypeAlternatives();
}
--- a/langtools/src/share/classes/com/sun/source/tree/VariableTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/VariableTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@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();
}
--- a/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
@jdk.Exported
public interface WildcardTree extends Tree {
+ /**
+ * Returns the bound of the wildcard.
+ * @return the bound
+ */
Tree getBound();
}
--- a/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
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
--- a/langtools/src/share/classes/com/sun/source/util/DocTreePath.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreePath.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
@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 @@
/**
* 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 @@
}
/**
- * 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() {
--- a/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
@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 @@
}
/**
- * 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 @@
}
/**
- * 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;
--- a/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
* <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 @@
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 @@
}
/**
- * 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 @@
* 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 @@
* 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 @@
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 @@
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 @@
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 @@
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 @@
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;
--- a/langtools/src/share/classes/com/sun/source/util/DocTrees.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/DocTrees.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
@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 @@
}
/**
- * 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 @@
}
/**
- * 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 @@
* @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,
--- a/langtools/src/share/classes/com/sun/source/util/JavacTask.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/JavacTask.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
}
/**
- * 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 @@
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 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 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 @@
* 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();
}
--- a/langtools/src/share/classes/com/sun/source/util/Plugin.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/Plugin.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
@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
*/
--- a/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
/**
* 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 @@
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);
}
--- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
/**
* 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 @@
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);
}
--- a/langtools/src/share/classes/com/sun/source/util/SourcePositions.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/SourcePositions.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
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,
--- a/langtools/src/share/classes/com/sun/source/util/TaskEvent.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/TaskEvent.java Tue Jul 01 14:28:22 2014 -0700
@@ -79,18 +79,45 @@
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 @@
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 + ","
--- a/langtools/src/share/classes/com/sun/source/util/TaskListener.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/TaskListener.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
@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);
}
--- a/langtools/src/share/classes/com/sun/source/util/TreePath.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/TreePath.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
@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 @@
/**
* 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;
--- a/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
}
/**
- * 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 @@
}
/**
- * 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;
--- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
* <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 @@
* }
* </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 @@
@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 @@
* 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 @@
* 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;
}
--- a/langtools/src/share/classes/com/sun/source/util/Trees.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/Trees.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
@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 @@
}
/**
- * 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 @@
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 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 @@
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
*/
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java Tue Jul 01 14:28:22 2014 -0700
@@ -99,7 +99,7 @@
}
/**
- * 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
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
}
/**
- * 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
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java Tue Jul 01 14:28:22 2014 -0700
@@ -104,7 +104,7 @@
}
/**
- * 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
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Tue Jul 01 14:28:22 2014 -0700
@@ -812,21 +812,24 @@
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 @@
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 @@
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 @@
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 @@
}
};
}
-
-
/**
* 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,
+ INTERFACE,
ANNOTATION,
- INTERFACE,
- CLASS,
+ 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,
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Tue Jul 01 14:28:22 2014 -0700
@@ -126,6 +126,9 @@
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;
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Tue Jul 01 14:28:22 2014 -0700
@@ -854,7 +854,7 @@
}
/**
- * 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.
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Tue Jul 01 14:28:22 2014 -0700
@@ -240,6 +240,9 @@
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:
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Tue Jul 01 14:28:22 2014 -0700
@@ -626,7 +626,7 @@
* (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 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 @@
return false;
return
t.isRaw() ||
- supertype(t) != null && isDerivedRaw(supertype(t)) ||
+ supertype(t) != Type.noType && isDerivedRaw(supertype(t)) ||
isDerivedRaw(interfaces(t));
}
@@ -2968,6 +2968,12 @@
}
@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()) {
List<Type> typarams = t.getTypeArguments();
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Jul 01 14:28:22 2014 -0700
@@ -249,36 +249,30 @@
*/
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 @@
currentTarget = infer.instantiateFunctionalInterface(that,
currentTarget, explicitParamTypes, resultInfo.checkContext);
}
+ currentTarget = types.removeWildcards(currentTarget);
lambdaType = types.findDescriptorType(currentTarget);
} else {
currentTarget = Type.recoveryType;
@@ -2894,7 +2889,7 @@
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 @@
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);
}
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Jul 01 14:28:22 2014 -0700
@@ -127,6 +127,7 @@
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 @@
*/
boolean allowStrictMethodClashCheck;
+ /** Switch: can the @SafeVarargs annotation be applied to private methods?
+ */
+ boolean allowPrivateSafeVarargs;
+
/** Switch: -complexinference option set?
*/
boolean complexInference;
@@ -266,6 +271,14 @@
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 @@
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 @@
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 @@
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 @@
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 @@
* @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);
+ }
+ });
}
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Tue Jul 01 14:28:22 2014 -0700
@@ -953,7 +953,7 @@
LambdaReturnScanner() {
super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP,
- FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
+ FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Jul 01 14:28:22 2014 -0700
@@ -354,6 +354,7 @@
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 @@
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 @@
//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;
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Jul 01 14:28:22 2014 -0700
@@ -320,7 +320,9 @@
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 @@
//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 @@
// </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 @@
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()));
+ //body generation - this can be either a method call or a
+ //new instance creation expression, depending on the member reference kind
+ JCExpression expr = (tree.getMode() == ReferenceMode.INVOKE)
+ ? expressionInvoke(rcvr)
+ : expressionNew();
- //bridge method 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();
-
- //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 @@
}
/**
- * 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 @@
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 @@
}
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 @@
}
}
- /**
- * 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 @@
@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 @@
contextMap.put(tree, context);
super.visitLambda(tree);
context.complete();
+ return context;
}
finally {
frameStack = prevStack;
@@ -1351,47 +1332,24 @@
* 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 @@
}
}
- 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 @@
*/
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 @@
// 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 @@
// 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 @@
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,40 +1999,27 @@
* 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() {
@@ -2075,62 +2027,6 @@
}
/**
- * 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()
*/
boolean isArrayOp() {
@@ -2165,13 +2061,16 @@
}
/**
- * 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() {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Jul 01 14:28:22 2014 -0700
@@ -958,9 +958,10 @@
}
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) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Jul 01 14:28:22 2014 -0700
@@ -866,90 +866,6 @@
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 @@
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);
}
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Jul 01 14:28:22 2014 -0700
@@ -1953,12 +1953,12 @@
}
}
- 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 @@
}
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 @@
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);
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Jul 01 14:28:22 2014 -0700
@@ -2766,7 +2766,7 @@
boolean trackVar(VarSymbol var) {
return (var.owner.kind == MTH &&
- (var.flags() & (PARAMETER | HASINIT)) == 0 &&
+ (var.flags() & PARAMETER) == 0 &&
analyzer.trackable(var));
}
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Tue Jul 01 14:28:22 2014 -0700
@@ -693,7 +693,6 @@
int p = bp;
nextChar();
Name name = null;
- boolean checkSemi = false;
if (ch == '#') {
int namep = bp;
nextChar();
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Jul 01 14:28:22 2014 -0700
@@ -412,9 +412,16 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Jul 01 14:28:22 2014 -0700
@@ -1101,6 +1101,10 @@
# 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
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties Tue Jul 01 14:28:22 2014 -0700
@@ -102,8 +102,6 @@
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
--- a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Tue Jul 01 14:28:22 2014 -0700
@@ -490,7 +490,6 @@
"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",
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue Jul 01 14:28:22 2014 -0700
@@ -656,6 +656,10 @@
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);
--- a/langtools/src/share/classes/com/sun/tools/javac/util/JavacMessages.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/JavacMessages.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
/**
- * 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) {
--- a/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
* 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.
--- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
}
/**
- * 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() {
--- a/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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.
--- a/langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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.
--- a/langtools/src/share/classes/com/sun/tools/sjavac/CleanProperties.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/CleanProperties.java Tue Jul 01 14:28:22 2014 -0700
@@ -36,6 +36,7 @@
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 @@
// 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,
--- a/langtools/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
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 @@
}
// 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 @@
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 @@
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 @@
// 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;
}
}
--- a/langtools/src/share/classes/com/sun/tools/sjavac/CompileProperties.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/CompileProperties.java Tue Jul 01 14:28:22 2014 -0700
@@ -38,6 +38,7 @@
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 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,
--- a/langtools/src/share/classes/com/sun/tools/sjavac/CopyFile.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/CopyFile.java Tue Jul 01 14:28:22 2014 -0700
@@ -32,6 +32,7 @@
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 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,
--- a/langtools/src/share/classes/com/sun/tools/sjavac/JavacState.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/JavacState.java Tue Jul 01 14:28:22 2014 -0700
@@ -40,6 +40,7 @@
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 @@
sr.put(e.getKey(), e.getValue());
}
}
- perform(binDir, sr);
+ perform(null, binDir, sr);
}
/**
@@ -641,20 +642,21 @@
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 @@
* 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 @@
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(),
--- a/langtools/src/share/classes/com/sun/tools/sjavac/Main.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/Main.java Tue Jul 01 14:28:22 2014 -0700
@@ -33,7 +33,9 @@
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 @@
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.
--- a/langtools/src/share/classes/com/sun/tools/sjavac/Transformer.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/Transformer.java Tue Jul 01 14:28:22 2014 -0700
@@ -31,6 +31,7 @@
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 @@
* 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,
--- a/langtools/src/share/classes/com/sun/tools/sjavac/Util.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/Util.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 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();
--- a/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 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 @@
/** 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 @@
// 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());
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavacServiceImpl.java Tue Jul 01 14:28:22 2014 -0700
@@ -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;
+ }
+}
--- a/langtools/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilationResult.java Tue Jul 01 14:28:22 2014 -0700
@@ -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;
+ }
+}
--- a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java Tue Jul 01 14:28:22 2014 -0700
@@ -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.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 CompilerThread grabCompilerThread() throws InterruptedException {
available.acquire();
if (compilers.empty()) {
- return new CompilerThread(this);
+ return new CompilerThread(this, new JavacServiceImpl(javacServer));
}
return compilers.pop();
}
--- a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Tue Jul 01 14:28:22 2014 -0700
@@ -44,19 +44,18 @@
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 @@
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 @@
// 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 @@
context = new Context();
ResolveWithDeps.preRegister(context);
AttrWithDeps.preRegister(context);
- JavaCompilerWithDeps.preRegister(context, this);
+ JavaCompilerWithDeps.preRegister(context, javacServiceImpl);
subTasks = new ArrayList<>();
}
@@ -320,6 +321,7 @@
// 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) {
--- a/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
// 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 @@
/**
* 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 @@
// 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;
@@ -220,134 +205,6 @@
}
/**
- * 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 @@
/**
* 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", ",");
@@ -421,243 +278,6 @@
}
/**
- * 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.
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacService.java Tue Jul 01 14:28:22 2014 -0700
@@ -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);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java Tue Jul 01 14:28:22 2014 -0700
@@ -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;
+ }
+}
--- a/langtools/src/share/classes/javax/tools/Diagnostic.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/Diagnostic.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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.
*
--- a/langtools/src/share/classes/javax/tools/DiagnosticCollector.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/DiagnosticCollector.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
}
/**
- * 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
*/
--- a/langtools/src/share/classes/javax/tools/DocumentationTool.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/DocumentationTool.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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.
--- a/langtools/src/share/classes/javax/tools/FileObject.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/FileObject.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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).
*
--- a/langtools/src/share/classes/javax/tools/JavaCompiler.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/JavaCompiler.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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.
--- a/langtools/src/share/classes/javax/tools/JavaFileManager.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/JavaFileManager.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
*/
interface Location {
/**
- * Gets the name of this location.
+ * Returns the name of this location.
*
* @return a name
*/
@@ -127,7 +127,7 @@
}
/**
- * 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 @@
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 @@
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 @@
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 @@
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.
*
--- a/langtools/src/share/classes/javax/tools/JavaFileObject.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/JavaFileObject.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
}
/**
- * Gets the kind of this file object.
+ * Returns the kind of this file object.
*
* @return the kind
*/
--- a/langtools/src/share/classes/javax/tools/StandardJavaFileManager.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/StandardJavaFileManager.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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
--- a/langtools/src/share/classes/javax/tools/StandardLocation.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/StandardLocation.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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
--- a/langtools/src/share/classes/javax/tools/Tool.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/Tool.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
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
*/
--- a/langtools/src/share/classes/javax/tools/ToolProvider.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/ToolProvider.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
= "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 @@
= "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
--- a/langtools/test/com/sun/javadoc/DocRootSlash/overview.html Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/DocRootSlash/overview.html Tue Jul 01 14:28:22 2014 -0700
@@ -38,7 +38,7 @@
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 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>
--- a/langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java Tue Jul 01 14:28:22 2014 -0700
@@ -59,7 +59,7 @@
* 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:
--- a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html Tue Jul 01 14:28:22 2014 -0700
@@ -39,7 +39,7 @@
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 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>
--- a/langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html Tue Jul 01 14:28:22 2014 -0700
@@ -9,7 +9,6 @@
subclasses, subinterfaces, nested classes, nested interfaces,
inheriting from other packages, constructors, fields,
methods, and so forth.
-<p>
</body>
</html>
--- a/langtools/test/com/sun/javadoc/ValidHtml/overview.html Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/ValidHtml/overview.html Tue Jul 01 14:28:22 2014 -0700
@@ -9,7 +9,6 @@
subclasses, subinterfaces, nested classes, nested interfaces,
inheriting from other packages, constructors, fields,
methods, and so forth.
-<p>
</body>
</html>
--- a/langtools/test/com/sun/javadoc/testHref/pkg/C3.java Wed Jul 05 19:47:10 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2005, 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 pkg;
-
-/**
- * <action>
- */
-public class C3 {}
--- a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java Tue Jul 01 14:28:22 2014 -0700
@@ -250,8 +250,6 @@
+ "<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 @@
+ "<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>"
--- a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java Tue Jul 01 14:28:22 2014 -0700
@@ -76,7 +76,7 @@
* 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)}.
*/
--- a/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java Tue Jul 01 14:28:22 2014 -0700
@@ -47,7 +47,7 @@
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\">",
--- a/langtools/test/com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java Tue Jul 01 14:28:22 2014 -0700
@@ -28,7 +28,7 @@
* 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>
--- a/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java Tue Jul 01 14:28:22 2014 -0700
@@ -36,21 +36,20 @@
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();
-
checkOutput("pkg1/C1.html", true,
"<html lang=\"" + defaultLanguage + "\">");
--- a/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java Tue Jul 01 14:28:22 2014 -0700
@@ -51,9 +51,9 @@
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");
--- a/langtools/test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java Tue Jul 01 14:28:22 2014 -0700
@@ -33,7 +33,7 @@
* <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 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 @@
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 += ", ";
--- a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java Tue Jul 01 14:28:22 2014 -0700
@@ -117,6 +117,31 @@
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<>();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/a/A.java Tue Jul 01 14:28:22 2014 -0700
@@ -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() {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/a/something.java Tue Jul 01 14:28:22 2014 -0700
@@ -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() {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/b/B.java Tue Jul 01 14:28:22 2014 -0700
@@ -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;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/b/something.java Tue Jul 01 14:28:22 2014 -0700
@@ -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{}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/e/something.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/J.java Tue Jul 01 14:28:22 2014 -0700
@@ -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(){}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/package-info.java Tue Jul 01 14:28:22 2014 -0700
@@ -0,0 +1,26 @@
+/*
+ * 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 package
+ */
+package something;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/something.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 {}
--- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java Tue Jul 01 14:28:22 2014 -0700
@@ -122,8 +122,6 @@
+ "<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>"
--- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java Tue Jul 01 14:28:22 2014 -0700
@@ -76,7 +76,7 @@
* 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)}.
*/
--- a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java Tue Jul 01 14:28:22 2014 -0700
@@ -79,6 +79,23 @@
"<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
--- a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C1.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C1.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 UsedClass methodInC1(UsedClass p) {
return p;
}
+
+ public List<UsedClass> methodInC1ReturningType() {
+ return null;
+ }
+
+ /*
+ * this must not appear anywhere.
+ */
+ UsedClass methodInC1Protected(List<UsedClass> p){
+ return p;
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java Tue Jul 01 14:28:22 2014 -0700
@@ -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() {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C9.java Tue Jul 01 14:28:22 2014 -0700
@@ -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(){}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java Tue Jul 01 14:28:22 2014 -0700
@@ -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();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java Tue Jul 01 14:28:22 2014 -0700
@@ -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();
+}
--- a/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java Tue Jul 01 14:28:22 2014 -0700
@@ -138,7 +138,7 @@
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"),
--- a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTableTest.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTableTest.java Tue Jul 01 14:28:22 2014 -0700
@@ -153,7 +153,6 @@
@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 @@
}
}
- @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;
--- a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTypeTableTest.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTypeTableTest.java Tue Jul 01 14:28:22 2014 -0700
@@ -104,7 +104,6 @@
@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 @@
}
}
- @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;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke.java Tue Jul 01 14:28:22 2014 -0700
@@ -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();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke6.out Tue Jul 01 14:28:22 2014 -0700
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke7.out Tue Jul 01 14:28:22 2014 -0700
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/VarargsFinalOnly.java Tue Jul 01 14:28:22 2014 -0700
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+// 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) { }
+}
--- a/langtools/test/tools/javac/flow/LVTHarness.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/javac/flow/LVTHarness.java Tue Jul 01 14:28:22 2014 -0700
@@ -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
--- a/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java Tue Jul 01 14:28:22 2014 -0700
@@ -5,7 +5,7 @@
@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 @@
@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 @@
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 @@
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";
}
+
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/T8044546/CrashImplicitLambdaTest.java Tue Jul 01 14:28:22 2014 -0700
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/T8044546/NestedInvocationsTest.java Tue Jul 01 14:28:22 2014 -0700
@@ -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> {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/wildcards/T8034147.java Tue Jul 01 14:28:22 2014 -0700
@@ -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> {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaTestStrictFP.java Tue Jul 01 14:28:22 2014 -0700
@@ -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();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaTestStrictFPFlag.java Tue Jul 01 14:28:22 2014 -0700
@@ -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();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaTestStrictFPMethod.java Tue Jul 01 14:28:22 2014 -0700
@@ -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();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java Tue Jul 01 14:28:22 2014 -0700
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out Tue Jul 01 14:28:22 2014 -0700
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java Tue Jul 01 14:28:22 2014 -0700
@@ -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;
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out Tue Jul 01 14:28:22 2014 -0700
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java Tue Jul 01 14:28:22 2014 -0700
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java Tue Jul 01 14:28:22 2014 -0700
@@ -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) {
+
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java Tue Jul 01 14:28:22 2014 -0700
@@ -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();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java Tue Jul 01 14:28:22 2014 -0700
@@ -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) {
+
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java Tue Jul 01 14:28:22 2014 -0700
@@ -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");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java Tue Jul 01 14:28:22 2014 -0700
@@ -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();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java Tue Jul 01 14:28:22 2014 -0700
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java Tue Jul 01 14:28:22 2014 -0700
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefToInner.java Tue Jul 01 14:28:22 2014 -0700
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java Tue Jul 01 14:28:22 2014 -0700
@@ -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) { }
+ }
+}
--- a/langtools/test/tools/javac/lib/DPrinter.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/javac/lib/DPrinter.java Tue Jul 01 14:28:22 2014 -0700
@@ -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.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.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 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 @@
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 @@
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 @@
// </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 @@
}
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 @@
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 @@
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("doctrees") {
+ @Override
+ 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);
+ }
+ },
+
new Handler("symbols") {
@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 visitDecl(JCTree tree, Symbol sym) {
- dprinter.printSymbol(sym.name.toString(), sym);
+ 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 @@
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 @@
};
}
+ 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>
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java Tue Jul 01 14:28:22 2014 -0700
@@ -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;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/p/package-info.java Tue Jul 01 14:28:22 2014 -0700
@@ -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;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/tree/MissingSemicolonTest.java Tue Jul 01 14:28:22 2014 -0700
@@ -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();
+ }
+
+}
--- a/langtools/test/tools/javac/varargs/warning/Warn4.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/javac/varargs/warning/Warn4.java Tue Jul 01 14:28:22 2014 -0700
@@ -73,13 +73,15 @@
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 @@
enum SourceLevel {
JDK_6("6"),
- JDK_7("7");
+ JDK_7("7"),
+ JDK_9("9");
String sourceKey;
@@ -115,7 +118,8 @@
enum ModifierKind {
NONE(" "),
FINAL("final "),
- STATIC("static ");
+ STATIC("static "),
+ PRIVATE("private ");
String mod;
--- a/langtools/test/tools/javac/varargs/warning/Warn5.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/javac/varargs/warning/Warn5.java Tue Jul 01 14:28:22 2014 -0700
@@ -89,7 +89,8 @@
enum ModifierKind {
NONE(""),
FINAL("final"),
- STATIC("static");
+ STATIC("static"),
+ PRIVATE("private");
String mod;
@@ -111,7 +112,8 @@
enum SourceLevel {
JDK_6("6"),
- JDK_7("7");
+ JDK_7("7"),
+ JDK_9("9");
String sourceKey;
@@ -238,7 +240,7 @@
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 @@
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 @@
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 @@
throw new Error("invalid diagnostics for source:\n" +
source.getCharContent(true) +
"\nOptions: " + xlint.getXlintOption() +
+ "\nSource Level: " + sourceLevel +
"\nExpected warnings: " + expectedWarnings +
"\nFound warnings: " + dc.warnings);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/suppress/T6707032.java Tue Jul 01 14:28:22 2014 -0700
@@ -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;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/suppress/T6707032.out Tue Jul 01 14:28:22 2014 -0700
@@ -0,0 +1,3 @@
+T6707032.java:12:36: compiler.warn.div.zero
+T6707032.java:16:36: compiler.warn.div.zero
+2 warnings
--- a/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
* 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 @@
}.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>() {
--- a/langtools/test/tools/javadoc/6227454/Test.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/javadoc/6227454/Test.java Tue Jul 01 14:28:22 2014 -0700
@@ -38,15 +38,18 @@
}
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");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/sjavac/IgnoreSymbolFile.java Tue Jul 01 14:28:22 2014 -0700
@@ -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;
+ }
+ }
+}
--- a/langtools/test/tools/sjavac/SJavac.java Wed Jul 05 19:47:10 2017 +0200
+++ b/langtools/test/tools/sjavac/SJavac.java Tue Jul 01 14:28:22 2014 -0700
@@ -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 @@
}
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 @@
"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 @@
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 @@
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 @@
"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 @@
"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 @@
"@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 @@
"@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 @@
"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 @@
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 @@
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 @@
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 @@
"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 @@
"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 @@
"}");
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 @@
"}");
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,