提交 8bbc2c00 编写于 作者: T tbell

Merge

...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
# This is the JDK used to build and run the bootstrap version of javac. # This is the JDK used to build and run the bootstrap version of javac.
# The bootstrap javac is used to compile both boostrap versions of the # The bootstrap javac is used to compile both boostrap versions of the
# other tools, and product versions of all the tools. # other tools, and product versions of all the tools.
# Override this path as needed, either on the command line or in # Override this path as needed, either on the command line or in
# one of the standard user build.properties files (see build.xml) # one of the standard user build.properties files (see build.xml)
# boot.java.home = /opt/jdk/1.6.0 # boot.java.home = /opt/jdk/1.6.0
boot.java = ${boot.java.home}/bin/java boot.java = ${boot.java.home}/bin/java
boot.javac = ${boot.java.home}/bin/javac boot.javac = ${boot.java.home}/bin/javac
boot.javac.source = 6 boot.javac.source = 6
...@@ -37,7 +37,7 @@ boot.javac.target = 6 ...@@ -37,7 +37,7 @@ boot.javac.target = 6
# This is the JDK used to run the product version of the tools, # This is the JDK used to run the product version of the tools,
# for example, for testing. If you're building a complete JDK, specify that. # for example, for testing. If you're building a complete JDK, specify that.
# Override this path as needed, either on the command line or in # Override this path as needed, either on the command line or in
# one of the standard user build.properties files (see build.xml) # one of the standard user build.properties files (see build.xml)
# target.java.home = /opt/jdk/1.7.0 # target.java.home = /opt/jdk/1.7.0
...@@ -66,23 +66,23 @@ javac.debug = true ...@@ -66,23 +66,23 @@ javac.debug = true
javac.debuglevel = source,lines javac.debuglevel = source,lines
javac.no.jdk.warnings = -XDignore.symbol.file=true javac.no.jdk.warnings = -XDignore.symbol.file=true
# set the following to -version to verify the versions of javac being used # set the following to -version to verify the versions of javac being used
javac.version.opt = javac.version.opt =
# in time, there should be no exceptions to -Xlint:all # in time, there should be no exceptions to -Xlint:all
javac.lint.opts = -Xlint:all,-deprecation -Werror javac.lint.opts = -Xlint:all,-deprecation -Werror
# options for the <javadoc> task for javac # options for the <javadoc> task for javac
javadoc.jls3.url=http://java.sun.com/docs/books/jls/ javadoc.jls3.url=http://java.sun.com/docs/books/jls/
javadoc.jls3.cite=&lt;a href=&quot;${javadoc.jls3.url}&quot;&gt;The Java Language Specification, Third Edition&lt;/a&gt; javadoc.jls3.cite=&lt;a href=&quot;${javadoc.jls3.url}&quot;&gt;The Java Language Specification, Third Edition&lt;/a&gt;
javadoc.jls3.option=-tag "jls3:a:See &lt;cite&gt;${javadoc.jls3.cite}&lt;/cite&gt;:" javadoc.jls3.option=-tag "jls3:a:See &lt;cite&gt;${javadoc.jls3.cite}&lt;/cite&gt;:"
# jtreg, used to run the JDK regression tests # jtreg, used to run the JDK regression tests
# Override this path as needed, either on the command line or in # Override this path as needed, either on the command line or in
# one of the standard user build.properties files (see build.xml) # one of the standard user build.properties files (see build.xml)
# jtreg.home = /opt/jtreg/3.2.2_02 # jtreg.home = /opt/jtreg/3.2.2_02
# findbugs # findbugs
# Override this path as needed, either on the command line or in # Override this path as needed, either on the command line or in
# one of the standard user build.properties files (see build.xml) # one of the standard user build.properties files (see build.xml)
# findbugs.home = /opt/findbugs/1.2.1 # findbugs.home = /opt/findbugs/1.2.1
...@@ -94,46 +94,61 @@ javadoc.jls3.option=-tag "jls3:a:See &lt;cite&gt;${javadoc.jls3.cite}&lt;/cite&g ...@@ -94,46 +94,61 @@ javadoc.jls3.option=-tag "jls3:a:See &lt;cite&gt;${javadoc.jls3.cite}&lt;/cite&g
# parameter of Ant filesets. In particular, note the trailing '/'. # parameter of Ant filesets. In particular, note the trailing '/'.
javac.includes = \ javac.includes = \
javax/annotation/processing/ \ javax/annotation/processing/ \
javax/lang/model/ \ javax/lang/model/ \
javax/tools/ \ javax/tools/ \
com/sun/source/ com/sun/tools/javac/ com/sun/source/ com/sun/tools/javac/
javac.tests = \ javac.tests = \
tools/javac tools/javac
#
javadoc.includes = \ javadoc.includes = \
com/sun/javadoc/ \ com/sun/javadoc/ \
com/sun/tools/javadoc/ com/sun/tools/javadoc/
javadoc.tests = \ javadoc.tests = \
tools/javadoc/ tools/javadoc/
#
doclets.includes = \ doclets.includes = \
com/sun/tools/doclets/ com/sun/tools/doclets/
doclets.tests = \ doclets.tests = \
com/sun/javadoc/ com/sun/javadoc/
#
javah.includes = \ javah.includes = \
com/sun/tools/javah/ com/sun/tools/javah/
javah.tests = \ javah.tests = \
tools/javah/ tools/javah/
#
javap.includes = \ javap.includes = \
com/sun/tools/classfile/ \ com/sun/tools/classfile/ \
com/sun/tools/javap/ \ com/sun/tools/javap/ \
sun/tools/javap/ sun/tools/javap/
javap.tests = \ javap.tests = \
tools/javap/ tools/javap/
#
apt.includes = \ apt.includes = \
com/sun/mirror/ \ com/sun/mirror/ \
com/sun/tools/apt/ com/sun/tools/apt/
apt.tests = \ apt.tests = \
tools/apt/ tools/apt/
#
# The following value is used by the main jtreg target.
# An empty value means all tests
# Override as desired to run a specific set of tests
jtreg.tests =
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
--> -->
<project name="langtools" default="build" basedir=".."> <project name="langtools" default="build" basedir="..">
<!-- Force full debuginfo for javac if the debug.classfiles <!-- Force full debuginfo for javac if the debug.classfiles
property is set. This must be BEFORE the include of property is set. This must be BEFORE the include of
build.properties because it sets javac.debuglevel. --> build.properties because it sets javac.debuglevel. -->
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
<!-- Use this location for customizations common to all OpenJDK workspaces --> <!-- Use this location for customizations common to all OpenJDK workspaces -->
<property file="${user.home}/.openjdk/build.properties"/> <property file="${user.home}/.openjdk/build.properties"/>
<!-- Convenient shorthands for standard locations within the workspace. --> <!-- Convenient shorthands for standard locations within the workspace. -->
<property name="build.dir" location="build"/> <property name="build.dir" location="build"/>
<property name="build.bootstrap.dir" location="${build.dir}/bootstrap"/> <property name="build.bootstrap.dir" location="${build.dir}/bootstrap"/>
<property name="build.coverage.dir" location="${build.dir}/coverage"/> <property name="build.coverage.dir" location="${build.dir}/coverage"/>
...@@ -75,15 +75,25 @@ ...@@ -75,15 +75,25 @@
The best file to check for across Solaris/Linux/Windows/MacOS is one of the The best file to check for across Solaris/Linux/Windows/MacOS is one of the
executables; regrettably, that is OS-specific. --> executables; regrettably, that is OS-specific. -->
<condition property="java.marker" value="bin/java"> <condition property="java.marker" value="bin/java">
<os family="unix"/> <os family="unix"/>
</condition> </condition>
<condition property="java.marker" value="bin/java.exe"> <condition property="java.marker" value="bin/java.exe">
<os family="windows"/> <os family="windows"/>
</condition> </condition>
<!-- Standard property values, if not overriden by earlier settings. --> <!-- Standard property values, if not overriden by earlier settings. -->
<property file="${make.dir}/build.properties"/> <property file="${make.dir}/build.properties"/>
<!-- launcher.java is used in the launcher scripts provided to run
the tools' jar files. If it has not already been set, then
default it to use ${target.java.home}, if available, otherwise
quietly default to simply use "java". -->
<condition property="launcher.java"
value="${target.java.home}/bin/java" else="java">
<isset property="target.java.home"/>
</condition>
<!-- Standard target to build deliverables for JDK build. --> <!-- Standard target to build deliverables for JDK build. -->
<target name="build" depends="build-bootstrap-tools,build-all-classes"> <target name="build" depends="build-bootstrap-tools,build-all-classes">
...@@ -97,13 +107,13 @@ ...@@ -97,13 +107,13 @@
<jar file="${dist.lib.dir}/classes.jar" basedir="${build.classes.dir}"/> <jar file="${dist.lib.dir}/classes.jar" basedir="${build.classes.dir}"/>
<zip file="${dist.lib.dir}/src.zip" basedir="${src.classes.dir}"/> <zip file="${dist.lib.dir}/src.zip" basedir="${src.classes.dir}"/>
</target> </target>
<target name="build-bootstrap-tools" depends="build-bootstrap-javac,build-bootstrap-javadoc,build-bootstrap-doclets,build-bootstrap-javah"/> <target name="build-bootstrap-tools" depends="build-bootstrap-javac,build-bootstrap-javadoc,build-bootstrap-doclets,build-bootstrap-javah"/>
<target name="build-all-tools" depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap,build-apt"/> <target name="build-all-tools" depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap,build-apt"/>
<target name="build-all-classes" depends="build-classes-javac,build-classes-javadoc,build-classes-doclets,build-classes-javah,build-classes-javap,build-classes-apt"/> <target name="build-all-classes" depends="build-classes-javac,build-classes-javadoc,build-classes-doclets,build-classes-javah,build-classes-javap,build-classes-apt"/>
<!-- clean --> <!-- clean -->
<target name="clean" description="Delete all generated files"> <target name="clean" description="Delete all generated files">
...@@ -112,13 +122,11 @@ ...@@ -112,13 +122,11 @@
</target> </target>
<!-- Additional targets for running tools on the build --> <!-- Additional targets for running tools on the build -->
<!-- An alternative for the following would be to do a single jtreg run for all tests.
However, that would currently be slower, since we would have to run all the tests
with samevm="false", since not all test directories currently support samevm="true". -->
<target name="jtreg" depends="jtreg-javac,jtreg-javadoc,jtreg-doclets,jtreg-javah,jtreg-javap,jtreg-apt"/> <target name="jtreg" depends="build-all-tools,-def-jtreg">
<jtreg-tool name="all" tests="${jtreg.tests}"/>
</target>
<target name="findbugs" depends="-def-findbugs,build-all-tools"> <target name="findbugs" depends="-def-findbugs,build-all-tools">
<property name="findbugs.reportLevel" value="medium"/> <property name="findbugs.reportLevel" value="medium"/>
<mkdir dir="${dist.findbugs.dir}"/> <mkdir dir="${dist.findbugs.dir}"/>
...@@ -160,52 +168,52 @@ ...@@ -160,52 +168,52 @@
<delete file="${build.coverage.dir}/cobertura.ser"/> <delete file="${build.coverage.dir}/cobertura.ser"/>
<cobertura-instrument todir="${build.coverage.dir}/classes" <cobertura-instrument todir="${build.coverage.dir}/classes"
datafile="${build.coverage.dir}/cobertura.ser"> datafile="${build.coverage.dir}/cobertura.ser">
<fileset dir="${build.classes.dir}" <fileset dir="${build.classes.dir}"
includes="**/*.class" excludes="**/resources/*.class"/> includes="**/*.class" excludes="**/resources/*.class"/>
</cobertura-instrument> </cobertura-instrument>
</target> </target>
<target name="coverage-report" depends="-def-cobertura"> <target name="coverage-report" depends="-def-cobertura">
<mkdir dir="${dist.coverage.dir}"/> <mkdir dir="${dist.coverage.dir}"/>
<cobertura-report <cobertura-report
srcdir="${src.classes.dir}" srcdir="${src.classes.dir}"
destdir="${dist.coverage.dir}" destdir="${dist.coverage.dir}"
datafile="${build.coverage.dir}/cobertura.ser"/> datafile="${build.coverage.dir}/cobertura.ser"/>
<cobertura-report <cobertura-report
format="xml" format="xml"
srcdir="${src.classes.dir}" srcdir="${src.classes.dir}"
destdir="${dist.coverage.dir}" destdir="${dist.coverage.dir}"
datafile="${build.coverage.dir}/cobertura.ser"/> datafile="${build.coverage.dir}/cobertura.ser"/>
</target> </target>
<!-- javac targets --> <!-- javac targets -->
<target name="build-bootstrap-javac" depends="-def-build-bootstrap-tool"> <target name="build-bootstrap-javac" depends="-def-build-bootstrap-tool">
<build-bootstrap-tool name="javac" includes="${javac.includes}"/> <build-bootstrap-tool name="javac" includes="${javac.includes}"/>
</target> </target>
<target name="build-classes-javac" depends="build-bootstrap-javac"> <target name="build-classes-javac" depends="build-bootstrap-javac">
<build-classes name="javac" includes="${javac.includes}"/> <build-classes name="javac" includes="${javac.includes}"/>
</target> </target>
<target name="build-javac" depends="build-bootstrap-javac"> <target name="build-javac" depends="build-bootstrap-javac">
<build-tool name="javac" includes="${javac.includes}"/> <build-tool name="javac" includes="${javac.includes}"/>
</target> </target>
<target name="javadoc-javac" depends="build-javac,-def-javadoc-tool"> <target name="javadoc-javac" depends="build-javac,-def-javadoc-tool">
<javadoc-tool name="javac" includes="${javac.includes}" options="${javadoc.jls3.option}"/> <javadoc-tool name="javac" includes="${javac.includes}" options="${javadoc.jls3.option}"/>
</target> </target>
<target name="jtreg-javac" depends="build-javac,-def-jtreg"> <target name="jtreg-javac" depends="build-javac,-def-jtreg">
<jtreg-tool name="javac" samevm="true" tests="${javac.tests}"/> <jtreg-tool name="javac" tests="${javac.tests}"/>
</target> </target>
<target name="findbugs-javac" depends="build-javac,-def-findbugs"> <target name="findbugs-javac" depends="build-javac,-def-findbugs">
<findbugs-tool name="javac"/> <findbugs-tool name="javac"/>
</target> </target>
<target name="javac" depends="build-javac,jtreg-javac,findbugs-javac"/> <target name="javac" depends="build-javac,jtreg-javac,findbugs-javac"/>
<!-- javadoc targets --> <!-- javadoc targets -->
<target name="build-bootstrap-javadoc" depends="build-bootstrap-javac"> <target name="build-bootstrap-javadoc" depends="build-bootstrap-javac">
...@@ -213,31 +221,31 @@ ...@@ -213,31 +221,31 @@
includes="${javadoc.includes}" includes="${javadoc.includes}"
jarclasspath="javac.jar doclets.jar"/> jarclasspath="javac.jar doclets.jar"/>
</target> </target>
<target name="build-classes-javadoc" depends="build-classes-javac"> <target name="build-classes-javadoc" depends="build-classes-javac">
<build-classes name="javadoc" includes="${javadoc.includes}"/> <build-classes name="javadoc" includes="${javadoc.includes}"/>
</target> </target>
<target name="build-javadoc" depends="build-javac"> <target name="build-javadoc" depends="build-javac">
<build-tool name="javadoc" <build-tool name="javadoc"
includes="${javadoc.includes}" includes="${javadoc.includes}"
jarclasspath="javac.jar doclets.jar"/> jarclasspath="javac.jar doclets.jar"/>
</target> </target>
<target name="javadoc-javadoc" depends="build-javadoc,-def-javadoc-tool"> <target name="javadoc-javadoc" depends="build-javadoc,-def-javadoc-tool">
<javadoc-tool name="javadoc" includes="${javadoc.includes}"/> <javadoc-tool name="javadoc" includes="${javadoc.includes}"/>
</target> </target>
<target name="jtreg-javadoc" depends="build-javadoc,-def-jtreg"> <target name="jtreg-javadoc" depends="build-javadoc,-def-jtreg">
<jtreg-tool name="javadoc" samevm="false" tests="${javadoc.tests}"/> <jtreg-tool name="javadoc" tests="${javadoc.tests}"/>
</target> </target>
<target name="findbugs-javadoc" depends="build-javadoc,-def-findbugs"> <target name="findbugs-javadoc" depends="build-javadoc,-def-findbugs">
<findbugs-tool name="javadoc"/> <findbugs-tool name="javadoc"/>
</target> </target>
<target name="javadoc" depends="build-javadoc,jtreg-javadoc,findbugs-javadoc"/> <target name="javadoc" depends="build-javadoc,jtreg-javadoc,findbugs-javadoc"/>
<!-- doclets targets --> <!-- doclets targets -->
<target name="build-bootstrap-doclets" depends="build-bootstrap-javadoc,-def-build-bootstrap-jar"> <target name="build-bootstrap-doclets" depends="build-bootstrap-javadoc,-def-build-bootstrap-jar">
...@@ -246,11 +254,11 @@ ...@@ -246,11 +254,11 @@
jarmainclass="com.sun.tools.javadoc.Main" jarmainclass="com.sun.tools.javadoc.Main"
jarclasspath="javadoc.jar"/> jarclasspath="javadoc.jar"/>
</target> </target>
<target name="build-classes-doclets" depends="build-classes-javadoc"> <target name="build-classes-doclets" depends="build-classes-javadoc">
<build-classes name="doclets" includes="${doclets.includes}"/> <build-classes name="doclets" includes="${doclets.includes}"/>
</target> </target>
<target name="build-doclets" depends="build-javadoc"> <target name="build-doclets" depends="build-javadoc">
<!-- just jar, no bin for doclets --> <!-- just jar, no bin for doclets -->
<build-jar name="doclets" <build-jar name="doclets"
...@@ -259,17 +267,17 @@ ...@@ -259,17 +267,17 @@
</target> </target>
<!-- (no javadoc for doclets) --> <!-- (no javadoc for doclets) -->
<target name="jtreg-doclets" depends="build-doclets,-def-jtreg"> <target name="jtreg-doclets" depends="build-doclets,-def-jtreg">
<jtreg-tool name="doclets" samevm="false" tests="${doclets.tests}"/> <jtreg-tool name="doclets" tests="${doclets.tests}"/>
</target> </target>
<target name="findbugs-doclets" depends="build-doclets,-def-findbugs"> <target name="findbugs-doclets" depends="build-doclets,-def-findbugs">
<findbugs-tool name="doclets"/> <findbugs-tool name="doclets"/>
</target> </target>
<target name="doclets" depends="build-doclets,jtreg-doclets,findbugs-doclets"/> <target name="doclets" depends="build-doclets,jtreg-doclets,findbugs-doclets"/>
<!-- javah targets --> <!-- javah targets -->
<target name="build-bootstrap-javah" depends="build-bootstrap-javadoc"> <target name="build-bootstrap-javah" depends="build-bootstrap-javadoc">
...@@ -277,29 +285,29 @@ ...@@ -277,29 +285,29 @@
includes="${javah.includes}" includes="${javah.includes}"
jarclasspath="javadoc.jar doclets.jar javac.jar"/> jarclasspath="javadoc.jar doclets.jar javac.jar"/>
</target> </target>
<target name="build-javah" depends="build-javadoc"> <target name="build-javah" depends="build-javadoc">
<build-tool name="javah" <build-tool name="javah"
includes="${javah.includes}" includes="${javah.includes}"
jarclasspath="javadoc.jar doclets.jar javac.jar"/> jarclasspath="javadoc.jar doclets.jar javac.jar"/>
</target> </target>
<target name="build-classes-javah" depends="build-classes-javadoc"> <target name="build-classes-javah" depends="build-classes-javadoc">
<build-classes name="javah" includes="${javah.includes}"/> <build-classes name="javah" includes="${javah.includes}"/>
</target> </target>
<!-- (no javadoc for javah) --> <!-- (no javadoc for javah) -->
<target name="jtreg-javah" depends="build-javah,-def-jtreg"> <target name="jtreg-javah" depends="build-javah,-def-jtreg">
<jtreg-tool name="javah" samevm="true" tests="${javah.tests}"/> <jtreg-tool name="javah" tests="${javah.tests}"/>
</target> </target>
<target name="findbugs-javah" depends="build-javah,-def-findbugs"> <target name="findbugs-javah" depends="build-javah,-def-findbugs">
<findbugs-tool name="javah"/> <findbugs-tool name="javah"/>
</target> </target>
<target name="javah" depends="build-javah,jtreg-javah,findbugs-javah"/> <target name="javah" depends="build-javah,jtreg-javah,findbugs-javah"/>
<!-- javap targets --> <!-- javap targets -->
<target name="build-bootstrap-javap" depends="-def-build-bootstrap-tool"> <target name="build-bootstrap-javap" depends="-def-build-bootstrap-tool">
...@@ -307,85 +315,85 @@ ...@@ -307,85 +315,85 @@
includes="${javap.includes}" includes="${javap.includes}"
jarmainclass="sun.tools.javap.Main"/> jarmainclass="sun.tools.javap.Main"/>
</target> </target>
<target name="build-classes-javap" depends="build-classes-javac"> <target name="build-classes-javap" depends="build-classes-javac">
<build-classes name="javap" includes="${javap.includes}"/> <build-classes name="javap" includes="${javap.includes}"/>
</target> </target>
<target name="build-javap" depends="build-javac"> <target name="build-javap" depends="build-javac">
<build-tool name="javap" <build-tool name="javap"
includes="${javap.includes}" includes="${javap.includes}"
jarmainclass="com.sun.tools.javap.Main" jarmainclass="com.sun.tools.javap.Main"
jarclasspath="javac.jar"/> jarclasspath="javac.jar"/>
</target> </target>
<!-- (no javadoc for javap) --> <!-- (no javadoc for javap) -->
<target name="jtreg-javap" depends="build-javap,-def-jtreg"> <target name="jtreg-javap" depends="build-javap,-def-jtreg">
<jtreg-tool name="javap" samevm="true" tests="${javap.tests}"/> <jtreg-tool name="javap" tests="${javap.tests}"/>
</target> </target>
<target name="findbugs-javap" depends="build-javap,-def-findbugs"> <target name="findbugs-javap" depends="build-javap,-def-findbugs">
<findbugs-tool name="javap"/> <findbugs-tool name="javap"/>
</target> </target>
<target name="javap" depends="build-javap,jtreg-javap,findbugs-javap"/> <target name="javap" depends="build-javap,jtreg-javap,findbugs-javap"/>
<!-- apt targets --> <!-- apt targets -->
<target name="build-bootstrap-apt" depends="build-bootstrap-javac"> <target name="build-bootstrap-apt" depends="build-bootstrap-javac">
<build-bootstrap-tool name="apt" <build-bootstrap-tool name="apt"
includes="${apt.includes}" includes="${apt.includes}"
jarclasspath="javac.jar"/> jarclasspath="javac.jar"/>
</target> </target>
<target name="build-apt" depends="build-javac"> <target name="build-apt" depends="build-javac">
<build-tool name="apt" <build-tool name="apt"
includes="${apt.includes}" includes="${apt.includes}"
jarclasspath="javac.jar"/> jarclasspath="javac.jar"/>
</target> </target>
<target name="build-classes-apt" depends="build-classes-javac"> <target name="build-classes-apt" depends="build-classes-javac">
<build-classes name="apt" includes="${apt.includes}"/> <build-classes name="apt" includes="${apt.includes}"/>
</target> </target>
<target name="javadoc-apt" depends="build-apt,-def-javadoc-tool"> <target name="javadoc-apt" depends="build-apt,-def-javadoc-tool">
<javadoc-tool name="apt" includes="${apt.includes}"/> <javadoc-tool name="apt" includes="${apt.includes}"/>
</target> </target>
<target name="jtreg-apt" depends="build-apt,-def-jtreg"> <target name="jtreg-apt" depends="build-apt,-def-jtreg">
<jtreg-tool name="apt" samevm="true" tests="${apt.tests}"/> <jtreg-tool name="apt" tests="${apt.tests}"/>
</target> </target>
<target name="findbugs-apt" depends="build-apt,-def-findbugs"> <target name="findbugs-apt" depends="build-apt,-def-findbugs">
<findbugs-tool name="apt"/> <findbugs-tool name="apt"/>
</target> </target>
<target name="apt" depends="build-apt,jtreg-apt,findbugs-apt"/> <target name="apt" depends="build-apt,jtreg-apt,findbugs-apt"/>
<!-- Check targets --> <!-- Check targets -->
<target name="-check-boot.java.home" depends="-def-check"> <target name="-check-boot.java.home" depends="-def-check">
<check name="bootstrap java" property="boot.java.home" marker="${java.marker}"/> <check name="bootstrap java" property="boot.java.home" marker="${java.marker}"/>
</target> </target>
<target name="-check-target.java.home" depends="-def-check"> <target name="-check-target.java.home" depends="-def-check">
<check name="target java" property="target.java.home" marker="${java.marker}"/> <check name="target java" property="target.java.home" marker="${java.marker}"/>
</target> </target>
<target name="-check-cobertura.home" depends="-def-check"> <target name="-check-cobertura.home" depends="-def-check">
<check name="cobertura" property="cobertura.home" marker="cobertura.jar"/> <check name="cobertura" property="cobertura.home" marker="cobertura.jar"/>
</target> </target>
<target name="-check-findbugs.home" depends="-def-check"> <target name="-check-findbugs.home" depends="-def-check">
<check name="findbugs" property="findbugs.home" marker="lib/findbugs.jar"/> <check name="findbugs" property="findbugs.home" marker="lib/findbugs.jar"/>
</target> </target>
<target name="-check-jtreg.home" depends="-def-check"> <target name="-check-jtreg.home" depends="-def-check">
<check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/> <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
</target> </target>
<!-- Ant macro and preset defs --> <!-- Ant macro and preset defs -->
<target name="-def-build-tool" depends="-def-build-jar"> <target name="-def-build-tool" depends="-def-build-jar">
...@@ -397,7 +405,7 @@ ...@@ -397,7 +405,7 @@
<attribute name="classes.dir" default="${build.classes.dir}"/> <attribute name="classes.dir" default="${build.classes.dir}"/>
<attribute name="gensrc.dir" default="${build.gensrc.dir}"/> <attribute name="gensrc.dir" default="${build.gensrc.dir}"/>
<attribute name="lib.dir" default="${dist.lib.dir}"/> <attribute name="lib.dir" default="${dist.lib.dir}"/>
<attribute name="java" default="java"/> <attribute name="java" default="${launcher.java}"/>
<attribute name="javac.bootclasspath" default="${build.bootstrap.dir}/classes"/> <attribute name="javac.bootclasspath" default="${build.bootstrap.dir}/classes"/>
<attribute name="javac.java.home" default="${boot.java.home}"/> <attribute name="javac.java.home" default="${boot.java.home}"/>
<attribute name="javac.source" default="${javac.source}"/> <attribute name="javac.source" default="${javac.source}"/>
...@@ -425,8 +433,8 @@ ...@@ -425,8 +433,8 @@
<mkdir dir="@{bin.dir}"/> <mkdir dir="@{bin.dir}"/>
<copy file="${src.bin.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}"> <copy file="${src.bin.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}">
<filterset begintoken="#" endtoken="#"> <filterset begintoken="#" endtoken="#">
<filter token="PROGRAM" value="@{name}"/> <filter token="PROGRAM" value="@{name}"/>
<filter token="TARGET_JAVA" value="@{java}"/> <filter token="TARGET_JAVA" value="@{java}"/>
</filterset> </filterset>
</copy> </copy>
<chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/> <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>
...@@ -467,7 +475,7 @@ ...@@ -467,7 +475,7 @@
<jar destfile="@{lib.dir}/@{name}.jar" <jar destfile="@{lib.dir}/@{name}.jar"
basedir="@{classes.dir}" basedir="@{classes.dir}"
includes="@{includes}"> includes="@{includes}">
<manifest> <manifest>
<attribute name="Main-Class" value="@{jarmainclass}"/> <attribute name="Main-Class" value="@{jarmainclass}"/>
<attribute name="Class-Path" value="@{jarclasspath}"/> <attribute name="Class-Path" value="@{jarclasspath}"/>
</manifest> </manifest>
...@@ -530,7 +538,7 @@ ...@@ -530,7 +538,7 @@
includeAntRuntime="no" includeAntRuntime="no"
source="@{javac.source}" source="@{javac.source}"
target="@{javac.target}" target="@{javac.target}"
debug="${javac.debug}" debug="${javac.debug}"
debuglevel="${javac.debuglevel}"> debuglevel="${javac.debuglevel}">
<compilerarg value="-J-Xbootclasspath/p:@{javac.bootclasspath}"/> <compilerarg value="-J-Xbootclasspath/p:@{javac.bootclasspath}"/>
<compilerarg value="-Xbootclasspath/p:@{classes.dir}"/> <compilerarg value="-Xbootclasspath/p:@{classes.dir}"/>
...@@ -539,7 +547,7 @@ ...@@ -539,7 +547,7 @@
<compilerarg line="${javac.lint.opts}"/> <compilerarg line="${javac.lint.opts}"/>
</javac> </javac>
<copy todir="@{classes.dir}"> <copy todir="@{classes.dir}">
<fileset dir="${src.classes.dir}"> <fileset dir="${src.classes.dir}">
<include name="@{includes}"/> <include name="@{includes}"/>
<exclude name="**/*.java"/> <exclude name="**/*.java"/>
<exclude name="**/*.properties"/> <exclude name="**/*.properties"/>
...@@ -550,7 +558,7 @@ ...@@ -550,7 +558,7 @@
</sequential> </sequential>
</macrodef> </macrodef>
</target> </target>
<target name="-def-build-bootstrap-tool" depends="-check-boot.java.home,-def-build-tool"> <target name="-def-build-bootstrap-tool" depends="-check-boot.java.home,-def-build-tool">
<presetdef name="build-bootstrap-tool"> <presetdef name="build-bootstrap-tool">
<build-tool <build-tool
...@@ -566,7 +574,7 @@ ...@@ -566,7 +574,7 @@
full.version="${bootstrap.full.version}"/> full.version="${bootstrap.full.version}"/>
</presetdef> </presetdef>
</target> </target>
<target name="-def-build-bootstrap-jar" depends="-def-build-jar"> <target name="-def-build-bootstrap-jar" depends="-def-build-jar">
<presetdef name="build-bootstrap-jar"> <presetdef name="build-bootstrap-jar">
<build-jar <build-jar
...@@ -580,7 +588,7 @@ ...@@ -580,7 +588,7 @@
full.version="${bootstrap.full.version}"/> full.version="${bootstrap.full.version}"/>
</presetdef> </presetdef>
</target> </target>
<target name="-def-pcompile"> <target name="-def-pcompile">
<mkdir dir="${build.toolclasses.dir}"/> <mkdir dir="${build.toolclasses.dir}"/>
<javac fork="true" <javac fork="true"
...@@ -589,10 +597,10 @@ ...@@ -589,10 +597,10 @@
destdir="${build.toolclasses.dir}/" destdir="${build.toolclasses.dir}/"
classpath="${ant.home}/lib/ant.jar"/> classpath="${ant.home}/lib/ant.jar"/>
<taskdef name="pcompile" <taskdef name="pcompile"
classname="CompilePropertiesTask" classname="CompilePropertiesTask"
classpath="${build.toolclasses.dir}/"/> classpath="${build.toolclasses.dir}/"/>
</target> </target>
<target name="-def-javadoc-tool" depends="-check-target.java.home"> <target name="-def-javadoc-tool" depends="-check-target.java.home">
<macrodef name="javadoc-tool"> <macrodef name="javadoc-tool">
<attribute name="name"/> <attribute name="name"/>
...@@ -604,14 +612,14 @@ ...@@ -604,14 +612,14 @@
<!-- Note: even with this default value, includes <!-- Note: even with this default value, includes
from src.classes.dir get javadoc'd; see packageset below --> from src.classes.dir get javadoc'd; see packageset below -->
<property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project --> <property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project -->
<javadoc <javadoc
executable="${target.java.home}/bin/javadoc" executable="${target.java.home}/bin/javadoc"
destdir="${build.javadoc.dir}/@{name}" destdir="${build.javadoc.dir}/@{name}"
source="@{source}" source="@{source}"
windowtitle="UNOFFICIAL" windowtitle="UNOFFICIAL"
failonerror="true" failonerror="true"
use="true" use="true"
author="false" author="false"
version="false" version="false"
packagenames="${javadoc.packagenames}" > packagenames="${javadoc.packagenames}" >
<header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header> <header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header>
...@@ -640,8 +648,8 @@ ...@@ -640,8 +648,8 @@
</sequential> </sequential>
</macrodef> </macrodef>
</target> </target>
<target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home"> <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-target.java.home">
<taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant"> <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
<classpath> <classpath>
<pathelement location="${jtreg.home}/lib/jtreg.jar"/> <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
...@@ -652,7 +660,7 @@ ...@@ -652,7 +660,7 @@
<attribute name="name"/> <attribute name="name"/>
<attribute name="tests"/> <attribute name="tests"/>
<attribute name="jdk" default="${target.java.home}"/> <attribute name="jdk" default="${target.java.home}"/>
<attribute name="samevm" default="false"/> <attribute name="samevm" default="true"/>
<attribute name="verbose" default="summary"/> <attribute name="verbose" default="summary"/>
<attribute name="options" default=""/> <attribute name="options" default=""/>
<attribute name="keywords" default="-keywords:!ignore"/> <attribute name="keywords" default="-keywords:!ignore"/>
...@@ -660,9 +668,9 @@ ...@@ -660,9 +668,9 @@
<sequential> <sequential>
<property name="coverage.options" value=""/> <!-- default --> <property name="coverage.options" value=""/> <!-- default -->
<property name="coverage.classpath" value=""/> <!-- default --> <property name="coverage.classpath" value=""/> <!-- default -->
<jtreg <jtreg
dir="${test.dir}" dir="${test.dir}"
workDir="${build.jtreg.dir}/@{name}/work" workDir="${build.jtreg.dir}/@{name}/work"
reportDir="${build.jtreg.dir}/@{name}/report" reportDir="${build.jtreg.dir}/@{name}/report"
jdk="@{jdk}" jdk="@{jdk}"
samevm="@{samevm}" verbose="@{verbose}" samevm="@{samevm}" verbose="@{verbose}"
...@@ -673,7 +681,7 @@ ...@@ -673,7 +681,7 @@
<arg line="@{options}"/> <arg line="@{options}"/>
<arg line="@{tests}"/> <arg line="@{tests}"/>
</jtreg> </jtreg>
<!-- the next two properties are for convenience, when only <!-- the next two properties are for convenience, when only
a single instance of jtreg will be invoked. --> a single instance of jtreg will be invoked. -->
<condition property="jtreg.passed"> <condition property="jtreg.passed">
<equals arg1="${jtreg.@{name}.result}" arg2="0"/> <equals arg1="${jtreg.@{name}.result}" arg2="0"/>
...@@ -691,9 +699,9 @@ ...@@ -691,9 +699,9 @@
<include name="lib/**/*.jar"/> <include name="lib/**/*.jar"/>
</fileset> </fileset>
</path> </path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties"/> <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
</target> </target>
<target name="-def-findbugs" unless="findbugs.defined" depends="-check-findbugs.home"> <target name="-def-findbugs" unless="findbugs.defined" depends="-check-findbugs.home">
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"> <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
<classpath> <classpath>
...@@ -706,7 +714,7 @@ ...@@ -706,7 +714,7 @@
<attribute name="outputFile" default=""/> <attribute name="outputFile" default=""/>
<attribute name="reportLevel" default="high"/> <attribute name="reportLevel" default="high"/>
<sequential> <sequential>
<findbugs <findbugs
home="${findbugs.home}" home="${findbugs.home}"
output="@{output}" output="@{output}"
outputFile="@{outputFile}" outputFile="@{outputFile}"
...@@ -727,7 +735,7 @@ ...@@ -727,7 +735,7 @@
</macrodef> </macrodef>
<property name="findbugs.defined" value="true"/> <property name="findbugs.defined" value="true"/>
</target> </target>
<target name="-def-check"> <target name="-def-check">
<macrodef name="check"> <macrodef name="check">
<attribute name="name"/> <attribute name="name"/>
...@@ -753,7 +761,7 @@ ...@@ -753,7 +761,7 @@
</target> </target>
<!-- standard JDK target --> <!-- standard JDK target -->
<target name="sanity" <target name="sanity"
description="display settings of congiguration values"> description="display settings of congiguration values">
<echo level="info">ant.home = ${ant.home}</echo> <echo level="info">ant.home = ${ant.home}</echo>
<echo level="info">boot.java.home = ${boot.java.home}</echo> <echo level="info">boot.java.home = ${boot.java.home}</echo>
...@@ -769,15 +777,15 @@ ...@@ -769,15 +777,15 @@
<target name="post-sanity" depends="-def-jtreg,sanity,build" <target name="post-sanity" depends="-def-jtreg,sanity,build"
description="perform basic validation after a standard build"> description="perform basic validation after a standard build">
<jtreg <jtreg
dir="make/test" dir="make/test"
workDir="${build.jtreg.dir}/post-sanity/work" workDir="${build.jtreg.dir}/post-sanity/work"
reportDir="${build.jtreg.dir}/post-sanity/report" reportDir="${build.jtreg.dir}/post-sanity/report"
jdk="${target.java.home}" jdk="${target.java.home}"
verbose="summary" verbose="summary"
failonerror="false" resultproperty="jtreg.post-sanity.result"> failonerror="false" resultproperty="jtreg.post-sanity.result">
</jtreg> </jtreg>
</target> </target>
</project> </project>
...@@ -45,7 +45,7 @@ if [ "$LANGTOOLS_USE_BOOTCLASSPATH" != "no" ]; then ...@@ -45,7 +45,7 @@ if [ "$LANGTOOLS_USE_BOOTCLASSPATH" != "no" ]; then
fi fi
# tools currently assumes that assertions are enabled in the launcher # tools currently assumes that assertions are enabled in the launcher
ea=-ea:com.sun.tools ea=-ea:com.sun.tools...
# Any parameters starting with -J are passed to the JVM. # Any parameters starting with -J are passed to the JVM.
# All other parameters become parameters of #PROGRAM#. # All other parameters become parameters of #PROGRAM#.
......
/*
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package com.sun.tools.javac.file;
import java.io.Closeable;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.jar.JarFile;
/**
* A URLClassLoader that also implements Closeable.
* Reflection is used to access internal data structures in the URLClassLoader,
* since no public API exists for this purpose. Therefore this code is somewhat
* fragile. Caveat emptor.
* @throws Error if the internal data structures are not as expected.
*
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
* you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
class CloseableURLClassLoader
extends URLClassLoader implements Closeable {
CloseableURLClassLoader(URL[] urls, ClassLoader parent) throws Error {
super(urls, parent);
try {
getLoaders(); //proactive check that URLClassLoader is as expected
} catch (Throwable t) {
throw new Error("cannot create CloseableURLClassLoader", t);
}
}
/**
* Close any jar files that may have been opened by the class loader.
* Reflection is used to access the jar files in the URLClassLoader's
* internal data structures.
* @throws java.io.IOException if the jar files cannot be found for any
* reson, or if closing the jar file itself causes an IOException.
*/
public void close() throws IOException {
try {
for (Object l: getLoaders()) {
if (l.getClass().getName().equals("sun.misc.URLClassPath$JarLoader")) {
Field jarField = l.getClass().getDeclaredField("jar");
JarFile jar = (JarFile) getField(l, jarField);
//System.err.println("CloseableURLClassLoader: closing " + jar);
jar.close();
}
}
} catch (Throwable t) {
IOException e = new IOException("cannot close class loader");
e.initCause(t);
throw e;
}
}
private ArrayList<?> getLoaders()
throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException
{
Field ucpField = URLClassLoader.class.getDeclaredField("ucp");
Object urlClassPath = getField(this, ucpField);
if (urlClassPath == null)
throw new AssertionError("urlClassPath not set in URLClassLoader");
Field loadersField = urlClassPath.getClass().getDeclaredField("loaders");
return (ArrayList<?>) getField(urlClassPath, loadersField);
}
private Object getField(Object o, Field f)
throws IllegalArgumentException, IllegalAccessException {
boolean prev = f.isAccessible();
try {
f.setAccessible(true);
return f.get(o);
} finally {
f.setAccessible(prev);
}
}
}
...@@ -33,6 +33,7 @@ import java.io.IOException; ...@@ -33,6 +33,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
import java.lang.reflect.Constructor;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
...@@ -76,6 +77,7 @@ import com.sun.tools.javac.util.ListBuffer; ...@@ -76,6 +77,7 @@ import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log; import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Options; import com.sun.tools.javac.util.Options;
import java.io.Closeable;
import static javax.tools.StandardLocation.*; import static javax.tools.StandardLocation.*;
import static com.sun.tools.javac.main.OptionName.*; import static com.sun.tools.javac.main.OptionName.*;
...@@ -131,6 +133,7 @@ public class JavacFileManager implements StandardJavaFileManager { ...@@ -131,6 +133,7 @@ public class JavacFileManager implements StandardJavaFileManager {
protected boolean mmappedIO; protected boolean mmappedIO;
protected boolean ignoreSymbolFile; protected boolean ignoreSymbolFile;
protected String classLoaderClass;
/** /**
* User provided charset (through javax.tools). * User provided charset (through javax.tools).
...@@ -180,6 +183,7 @@ public class JavacFileManager implements StandardJavaFileManager { ...@@ -180,6 +183,7 @@ public class JavacFileManager implements StandardJavaFileManager {
mmappedIO = options.get("mmappedIO") != null; mmappedIO = options.get("mmappedIO") != null;
ignoreSymbolFile = options.get("ignore.symbol.file") != null; ignoreSymbolFile = options.get("ignore.symbol.file") != null;
classLoaderClass = options.get("procloader");
} }
public JavaFileObject getFileForInput(String name) { public JavaFileObject getFileForInput(String name) {
...@@ -747,8 +751,40 @@ public class JavacFileManager implements StandardJavaFileManager { ...@@ -747,8 +751,40 @@ public class JavacFileManager implements StandardJavaFileManager {
throw new AssertionError(e); throw new AssertionError(e);
} }
} }
return new URLClassLoader(lb.toArray(new URL[lb.size()]),
getClass().getClassLoader()); URL[] urls = lb.toArray(new URL[lb.size()]);
ClassLoader thisClassLoader = getClass().getClassLoader();
// Bug: 6558476
// Ideally, ClassLoader should be Closeable, but before JDK7 it is not.
// On older versions, try the following, to get a closeable classloader.
// 1: Allow client to specify the class to use via hidden option
if (classLoaderClass != null) {
try {
Class<? extends ClassLoader> loader =
Class.forName(classLoaderClass).asSubclass(ClassLoader.class);
Class<?>[] constrArgTypes = { URL[].class, ClassLoader.class };
Constructor<? extends ClassLoader> constr = loader.getConstructor(constrArgTypes);
return constr.newInstance(new Object[] { urls, thisClassLoader });
} catch (Throwable t) {
// ignore errors loading user-provided class loader, fall through
}
}
// 2: If URLClassLoader implements Closeable, use that.
if (Closeable.class.isAssignableFrom(URLClassLoader.class))
return new URLClassLoader(urls, thisClassLoader);
// 3: Try using private reflection-based CloseableURLClassLoader
try {
return new CloseableURLClassLoader(urls, thisClassLoader);
} catch (Throwable t) {
// ignore errors loading workaround class loader, fall through
}
// 4: If all else fails, use plain old standard URLClassLoader
return new URLClassLoader(urls, thisClassLoader);
} }
public Iterable<JavaFileObject> list(Location location, public Iterable<JavaFileObject> list(Location location,
......
...@@ -813,6 +813,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter { ...@@ -813,6 +813,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
} catch (Abort ex) { } catch (Abort ex) {
if (devVerbose) if (devVerbose)
ex.printStackTrace(); ex.printStackTrace();
} finally {
if (procEnvImpl != null)
procEnvImpl.close();
} }
} }
...@@ -936,7 +939,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { ...@@ -936,7 +939,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
/** /**
* Object to handle annotation processing. * Object to handle annotation processing.
*/ */
JavacProcessingEnvironment procEnvImpl = null; private JavacProcessingEnvironment procEnvImpl = null;
/** /**
* Check if we should process annotations. * Check if we should process annotations.
...@@ -947,7 +950,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter { ...@@ -947,7 +950,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
* @param processors user provided annotation processors to bypass * @param processors user provided annotation processors to bypass
* discovery, {@code null} means that no processors were provided * discovery, {@code null} means that no processors were provided
*/ */
public void initProcessAnnotations(Iterable<? extends Processor> processors) { public void initProcessAnnotations(Iterable<? extends Processor> processors)
throws IOException {
// Process annotations if processing is not disabled and there // Process annotations if processing is not disabled and there
// is at least one Processor available. // is at least one Processor available.
Options options = Options.instance(context); Options options = Options.instance(context);
...@@ -974,7 +978,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter { ...@@ -974,7 +978,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
} }
// TODO: called by JavacTaskImpl // TODO: called by JavacTaskImpl
public JavaCompiler processAnnotations(List<JCCompilationUnit> roots) throws IOException { public JavaCompiler processAnnotations(List<JCCompilationUnit> roots)
throws IOException {
return processAnnotations(roots, List.<String>nil()); return processAnnotations(roots, List.<String>nil());
} }
...@@ -1061,10 +1066,14 @@ public class JavaCompiler implements ClassReader.SourceCompleter { ...@@ -1061,10 +1066,14 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
return this; return this;
} }
} }
JavaCompiler c = procEnvImpl.doProcessing(context, roots, classSymbols, pckSymbols); try {
if (c != this) JavaCompiler c = procEnvImpl.doProcessing(context, roots, classSymbols, pckSymbols);
annotationProcessingOccurred = c.annotationProcessingOccurred = true; if (c != this)
return c; annotationProcessingOccurred = c.annotationProcessingOccurred = true;
return c;
} finally {
procEnvImpl.close();
}
} catch (CompletionFailure ex) { } catch (CompletionFailure ex) {
log.error("cant.access", ex.sym, ex.getDetailValue()); log.error("cant.access", ex.sym, ex.getDetailValue());
return this; return this;
......
...@@ -136,6 +136,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea ...@@ -136,6 +136,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
*/ */
Source source; Source source;
private ClassLoader processorClassLoader;
/** /**
* JavacMessages object used for localization * JavacMessages object used for localization
*/ */
...@@ -203,7 +205,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea ...@@ -203,7 +205,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
JavaFileManager fileManager = context.get(JavaFileManager.class); JavaFileManager fileManager = context.get(JavaFileManager.class);
try { try {
// If processorpath is not explicitly set, use the classpath. // If processorpath is not explicitly set, use the classpath.
ClassLoader processorCL = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH) processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH)
? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH) ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH)
: fileManager.getClassLoader(CLASS_PATH); : fileManager.getClassLoader(CLASS_PATH);
...@@ -213,9 +215,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea ...@@ -213,9 +215,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
* provider mechanism to create the processor iterator. * provider mechanism to create the processor iterator.
*/ */
if (processorNames != null) { if (processorNames != null) {
processorIterator = new NameProcessIterator(processorNames, processorCL, log); processorIterator = new NameProcessIterator(processorNames, processorClassLoader, log);
} else { } else {
processorIterator = new ServiceIterator(processorCL, log); processorIterator = new ServiceIterator(processorClassLoader, log);
} }
} catch (SecurityException e) { } catch (SecurityException e) {
/* /*
...@@ -1019,9 +1021,11 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea ...@@ -1019,9 +1021,11 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
/** /**
* Free resources related to annotation processing. * Free resources related to annotation processing.
*/ */
public void close() { public void close() throws IOException {
filer.close(); filer.close();
discoveredProcs = null; discoveredProcs = null;
if (processorClassLoader != null && processorClassLoader instanceof Closeable)
((Closeable) processorClassLoader).close();
} }
private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) { private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) {
......
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @run main/othervm -Xmx512m -Xms512m T6558476
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;
import com.sun.tools.javac.Main;
public class T6558476 {
private static File copyFileTo(File file, File directory) throws IOException {
File newFile = new File(directory, file.getName());
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(file);
fos = new FileOutputStream(newFile);
byte buff[] = new byte[1024];
int val;
while ((val = fis.read(buff)) > 0)
fos.write(buff, 0, val);
} finally {
if (fis != null)
fis.close();
if (fos != null)
fos.close();
}
return newFile;
}
private static String generateJavaClass(String className) {
StringBuffer sb = new StringBuffer();
sb.append("import sun.net.spi.nameservice.dns.DNSNameService;\n");
sb.append("public class ");
sb.append(className);
sb.append(" {\n");
sb.append(" public void doStuff() {\n");
sb.append(" DNSNameService dns = null;\n");
sb.append(" }\n");
sb.append("}\n");
return sb.toString();
}
public static void main(String[] args) throws IOException {
File javaHomeDir = new File(System.getProperty("java.home"));
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File outputDir = new File(tmpDir, "outputDir" + new Random().nextInt(65536));
outputDir.mkdir();
outputDir.deleteOnExit();
File dnsjarfile = new File(javaHomeDir, "lib" + File.separator + "ext" + File.separator + "dnsns.jar");
File tmpJar = copyFileTo(dnsjarfile, outputDir);
String className = "TheJavaFile";
File javaFile = new File(outputDir, className + ".java");
javaFile.deleteOnExit();
FileOutputStream fos = new FileOutputStream(javaFile);
fos.write(generateJavaClass(className).getBytes());
fos.close();
int rc = Main.compile(new String[]{"-d", outputDir.getPath(),
"-classpath",
tmpJar.getPath(),
javaFile.getAbsolutePath()});
if (rc != 0) {
throw new Error("Couldn't compile the file (exit code=" + rc + ")");
}
if (tmpJar.delete()) {
System.out.println("jar file successfully deleted");
} else {
throw new Error("Error deleting file \"" + tmpJar.getPath() + "\"");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册