Update Eclipse compiler to 3.7 and switch to using ecj.jar

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc5.5.x/trunk@1195649 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/LICENSE b/LICENSE
index 1250dba..b3bf821 100644
--- a/LICENSE
+++ b/LICENSE
@@ -263,7 +263,7 @@
  */
 
 
-For the jasper-jdt.jar component:
+For the Eclipse JDT Java compiler:
 
 Eclipse Public License - v 1.0
 
diff --git a/STATUS.txt b/STATUS.txt
index 0eb10e3..5bb94fe 100644
--- a/STATUS.txt
+++ b/STATUS.txt
@@ -27,23 +27,6 @@
 PATCHES PROPOSED TO BACKPORT:
   [ New proposals should be added at the end of the list ]
 
-* Update Eclipse compiler and switch to using ecj.jar
-  http://people.apache.org/~markt/patches/2011-08-25-lib-update-tc5-v2.patch
-  +1: markt
-  +1: kkolinko:
-        + update build/resources/License.rtf to match LICENSE file
-        + in class-loader-howto.xml sort the JARs list alphabetically
-        I've run jarcheck tool against the archive. Results are in
-         http://people.apache.org/~kkolinko/patches/jarcheck/
-        Most classes are JDK 1.2 compatible. Some are JDK 1.6 (esp. annotations processor),
-        but it is the same in ecj 3.3.1 that is currently used.
-        Those classes are absent in jasper-compiler-jdt.jar that we would
-        generate, so their presence does not matter.
-  +1: rjung:
-        I suggest we switch after releasing 5.5.34 so that the change isn't introduced
-        immediately before tagging.
-  -1:
-
 * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52059
   http://svn.apache.org/viewvc?rev=1186763&view=rev
   Fix a typo in Windows uninstaller:
diff --git a/build/RELEASE-NOTES b/build/RELEASE-NOTES
index f68164b..697af10 100644
--- a/build/RELEASE-NOTES
+++ b/build/RELEASE-NOTES
@@ -86,7 +86,7 @@
 * commons-el.jar (Commons Expression Language 1.0)
 * commons-logging-api.jar (Commons Logging API 1.0.x)
 * jasper-compiler.jar (Jasper 2 Compiler)
-* jasper-compiler-jdt.jar (Eclipse JDT Java compiler)
+* ecj-x.y.z.jar (Eclipse JDT Java compiler)
 * jasper-runtime.jar (Jasper 2 Runtime)
 * jsp-api.jar (JSP 2.0 API)
 * naming-common.jar (JNDI Context implementation)
diff --git a/build/build.properties.default b/build/build.properties.default
index f182110..37668c9 100644
--- a/build/build.properties.default
+++ b/build/build.properties.default
@@ -146,10 +146,14 @@
 
 
 # ----- Eclipse JDT, version 3.3.1 or later -----
-jdt.home=${base.path}/eclipse/plugins
-jdt.lib=${jdt.home}
-jdt.jar=${jdt.lib}/org.eclipse.jdt.core_3.3.1.v_780_R33x.jar
-jdt.loc=http://archive.eclipse.org/eclipse/downloads/drops/R-3.3.1-200709211145/eclipse-JDT-3.3.1.zip
+jdt.version=3.7
+jdt.release=R-3.7-201106131736
+jdt.home=${base.path}/ecj-${jdt.version}
+jdt.jar=${jdt.home}/ecj-${jdt.version}.jar
+# The download will be moved to the archive area eventually. We are taking care of that in advance.
+# Note older JARs were called ecj.jar. Newer JARs are called ecj-${jdt.version}.jar
+jdt.loc.1=http://archive.eclipse.org/eclipse/downloads/drops/${jdt.release}/ecj-${jdt.version}.jar
+jdt.loc.2=http://download.eclipse.org/eclipse/downloads/drops/${jdt.release}/ecj-${jdt.version}.jar
 
 # ----- Tomcat native library -----
 tomcat-native.version=1.1.22
diff --git a/build/build.xml b/build/build.xml
index 89e9b99..230972d 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -87,9 +87,6 @@
   <property name="tomcat-dbcp.home" value="${base.path}/tomcat-deps/dbcp" />
   <property name="tomcat-dbcp.jar"
        value="${tomcat-dbcp.home}/naming-factory-dbcp.jar"/>
-  <property name="jasper-compiler-jdt.home" value="${base.path}/tomcat-deps/jdt" />
-  <property name="jasper-compiler-jdt.jar"
-       value="${jasper-compiler-jdt.home}/jasper-compiler-jdt.jar"/>
 
   <!-- Some compilers will disable debugging if true. And it doesn't do anything
        in most cases -->
@@ -234,7 +231,7 @@
 
     <!-- <copy todir="${tomcat.build}/common/lib" file="${ant.jar}"/>
     <copy todir="${tomcat.build}/common/lib" file="${ant-launcher.jar}"/> -->
-    <copy todir="${tomcat.build}/common/lib" file="${jasper-compiler-jdt.jar}"/>
+    <copy todir="${tomcat.build}/common/lib" file="${jdt.jar}"/>
   </target>
 
   <!-- ====================== Build all components =================== -->
@@ -706,7 +703,7 @@
 
 
   <target name="build-depends" depends="init"
-          description="Builds various dependent components - APIs, dbcp, jdt">
+          description="Builds various dependent components - APIs, dbcp">
     <antcall target="build-servletapi"/>
     <antcall target="build-jspapi"/>
 
@@ -726,12 +723,12 @@
 
     <antcall target="build-tomcat-dbcp" />
 
-    <antcall target="downloadzip">
-      <param name="sourcefile" value="${jdt.loc}"/>
+    <antcall target="downloadfile-2">
+      <param name="sourcefile.1" value="${jdt.loc.1}"/>
+      <param name="sourcefile.2" value="${jdt.loc.2}"/>
       <param name="destfile" value="${jdt.jar}"/>
-      <param name="destdir" value="${base.path}"/>
+      <param name="destdir" value="${jdt.home}"/>
     </antcall>
-    <antcall target="build-jasper-compiler-jdt" />
   </target>
 
   <target name="build-tomcat-dbcp">
@@ -795,24 +792,6 @@
     </jar>
   </target>
 
-  <target name="build-jasper-compiler-jdt">
-       <mkdir dir="${jasper-compiler-jdt.home}"/>
-       <antcall target="-build-jasper-compiler-jdt">
-          <param name="basedir" value="${jasper-compiler-jdt.home}" />
-       </antcall>
-      </target>
-
-      <target name="-build-jasper-compiler-jdt">
-        <unjar src="${jdt.jar}" dest="${jasper-compiler-jdt.home}" />
-        <jar destfile="${jasper-compiler-jdt.jar}">
-            <fileset dir="${jasper-compiler-jdt.home}">
-                <include name="org/eclipse/jdt/core/compiler/**"/>
-                <include name="org/eclipse/jdt/internal/compiler/**"/>
-                <include name="org/eclipse/jdt/internal/core/util/CommentRecorder*"/>
-            </fileset>
-        </jar>
-  </target>
-
   <target name="build-webapps" depends="init"
           description="build  webapps">
 
@@ -1009,7 +988,7 @@
     <copy todir="${tomcat.embed}/lib">
       <fileset dir="${tomcat.build}/common/lib">
         <include name="jasper-compiler.jar"/>
-        <include name="jasper-compiler-jdt.jar"/>
+        <include name="ecj-${jdt.version}.jar"/>
       </fileset>
     </copy>
 
@@ -1162,7 +1141,6 @@
   <target name="clean-depend"
    description="Clean depend src components">
     <delete dir="${tomcat-dbcp.home}"/>    
-    <delete dir="${jasper-compiler-jdt.home}"/>
   </target>
   
   <target name="clean"
@@ -2174,6 +2152,38 @@
     <get src="${sourcefile}" dest="${destfile}" />
   </target>
 
+  <target name="downloadfile-2" unless="exist" depends="testexist">
+    <!-- Download the file from the two alternative locations -->
+    <mkdir dir="${destdir}" />
+
+    <antcall target="trydownload">
+      <param name="sourcefile" value="${sourcefile.1}" />
+    </antcall>
+
+    <antcall target="trydownload">
+      <param name="sourcefile" value="${sourcefile.2}" />
+    </antcall>
+
+    <available file="${destfile}" property="exist"/>
+    <fail unless="exist" message="Failed to download [${destfile}]. All download sources are unavailable." />
+  </target>
+
+  <target name="trydownload.check" depends="setproxy">
+    <condition property="trydownload.run">
+      <and>
+        <not>
+          <available file="${destfile}" />
+        </not>
+        <http url="${sourcefile}" />
+      </and>
+    </condition>
+  </target>
+
+  <target name="trydownload" if="trydownload.run" depends="trydownload.check">
+    <!-- Downloads a file if not yet downloaded and the source URL is available -->
+    <get src="${sourcefile}" dest="${destfile}" />
+  </target>
+
 
   <!-- ==================== Modeler tricks ====================
   -->
diff --git a/build/resources/License.rtf b/build/resources/License.rtf
index a0fc985..9ae6707 100644
--- a/build/resources/License.rtf
+++ b/build/resources/License.rtf
Binary files differ
diff --git a/container/catalina/src/share/org/apache/catalina/startup/TldConfig.java b/container/catalina/src/share/org/apache/catalina/startup/TldConfig.java
index ebc9d39..47f7597 100644
--- a/container/catalina/src/share/org/apache/catalina/startup/TldConfig.java
+++ b/container/catalina/src/share/org/apache/catalina/startup/TldConfig.java
@@ -88,7 +88,7 @@
         noTldJars.add("commons-logging-api.jar");
         noTldJars.add("commons-modeler.jar");
         noTldJars.add("jasper-compiler.jar");
-        noTldJars.add("jasper-compiler-jdt.jar");
+        noTldJars.add("ecj-3.7.jar");
         noTldJars.add("jasper-runtime.jar");
         noTldJars.add("jsp-api.jar");
         noTldJars.add("naming-resources.jar");
diff --git a/container/webapps/docs/changelog.xml b/container/webapps/docs/changelog.xml
index 6f663c9..4756bdc 100644
--- a/container/webapps/docs/changelog.xml
+++ b/container/webapps/docs/changelog.xml
@@ -40,6 +40,13 @@
  General, Catalina, Coyote, Jasper, Cluster, Webapps
 -->
 <section name="Tomcat 5.5.35 (jim)" rtext="">
+  <subsection name="General">
+    <changelog>
+      <update>
+        Update Eclipse compiler to 3.7 and switch to using ecj.jar. (markt)        
+      </update>
+    </changelog>
+  </subsection>
   <subsection name="Webapps">
     <changelog>
       <fix>
diff --git a/container/webapps/docs/class-loader-howto.xml b/container/webapps/docs/class-loader-howto.xml
index d081a62..ca348cc 100644
--- a/container/webapps/docs/class-loader-howto.xml
+++ b/container/webapps/docs/class-loader-howto.xml
@@ -139,8 +139,8 @@
     <ul>
     <li><em>commons-el.jar</em> - Jakarta commons el, implementing the 
         expression language used by Jasper.</li>
+    <li><em>ecj-x.y.x.jar</em> - The Eclipse JDT Java compiler.</li>
     <li><em>jasper-compiler.jar</em> - The JSP 2.0 compiler.</li>
-    <li><em>jasper-compiler-jdt.jar</em> - The Eclipse JDT Java compiler.</li>
     <li><em>jasper-runtime.jar</em> - The JSP 2.0 runtime.</li>
     <li><em>jsp-api.jar</em> - The JSP 2.0 API.</li>
     <li><em>naming-common.jar</em> - The JNDI implementation used by Tomcat 5
diff --git a/container/webapps/docs/jasper-howto.xml b/container/webapps/docs/jasper-howto.xml
index 58fef71..c92508b 100644
--- a/container/webapps/docs/jasper-howto.xml
+++ b/container/webapps/docs/jasper-howto.xml
@@ -168,7 +168,7 @@
 possible.</p>
 
 <p>Apache Ant, which was used in previous Tomcat releases, can be used instead instead of 
-the new compiler by simply removing the <code>common/lib/jasper-compiler-jdt.jar</code> file, 
+the new compiler by simply removing the <code>common/lib/ecj-x.y.z.jar</code> file, 
 and placing the <code>ant.jar</code> file from the latest Ant distribution in the 
 <code>common/lib</code> folder.  If you do this, you also need to use the "javac"
 argument to catalina.sh.</p>
diff --git a/eclipse.classpath b/eclipse.classpath
index 0f7062c..287e125 100644
--- a/eclipse.classpath
+++ b/eclipse.classpath
@@ -56,7 +56,7 @@
 	<classpathentry kind="var" path="TOMCAT_LIBS_BASE/javamail-1.4.1/mail.jar"/>
 	<classpathentry kind="var" path="TOMCAT_LIBS_BASE/jaf-1.1.1/activation.jar"/>
 	<classpathentry kind="var" path="TOMCAT_LIBS_BASE/tomcat-deps/dbcp/naming-factory-dbcp.jar"/>
-	<classpathentry kind="var" path="TOMCAT_LIBS_BASE/tomcat-deps/jdt/jasper-compiler-jdt.jar"/>
+	<classpathentry kind="var" path="TOMCAT_LIBS_BASE/ecj-3.7/ecj-3.7.jar"/>
 	<classpathentry kind="var" path="TOMCAT_LIBS_BASE/commons-el-1.0/commons-el.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
 	<classpathentry kind="var" path="TOMCAT_LIBS_BASE/commons-launcher/bin/commons-launcher.jar"/>
diff --git a/jasper/build.xml b/jasper/build.xml
index 910c69b..eeb1855 100644
--- a/jasper/build.xml
+++ b/jasper/build.xml
@@ -46,7 +46,7 @@
     <pathelement location="${servlet-api.jar}"/>
     <pathelement location="${jsp-api.jar}"/>
     <pathelement location="${tools.jar}"/>
-    <pathelement location="${jasper-compiler-jdt.jar}"/>
+    <pathelement location="${jdt.jar}"/>
     <pathelement location="${xerces.jar}"/>
     <pathelement location="${xercesImpl.jar}"/>
     <pathelement location="${xml-apis.jar}"/>
@@ -284,7 +284,7 @@
           tofile="${jasper.deploy}/common/lib/jasper-runtime.jar" />
 
     <!-- Copy JARs -->
-    <copy todir="${jasper.deploy}/common/lib" file="${jasper-compiler-jdt.jar}"/>
+    <copy todir="${jasper.deploy}/common/lib" file="${jdt.jar}"/>
     <copy todir="${jasper.deploy}/common/lib" file="${jsp-api.jar}"/>
     <copy todir="${jasper.deploy}/common/lib" file="${commons-el.jar}"/>