Index: common-build.xml
===================================================================
--- common-build.xml	(revision 494159)
+++ common-build.xml	(working copy)
@@ -28,9 +28,17 @@
 
   <property name="javac.deprecation" value="off"/>
   <property name="javac.debug" value="on"/>
+
+  <!-- if the value of javac.source is modified, then the value
+       of ${java.sourcetest.class} must be modified to be the name
+       of a class which does not exist in the core library for
+       ${java.source} but does exist in newer versions of java.
+   -->
   <property name="javac.source" value="1.4"/>
   <property name="javac.target" value="1.4"/>
-
+  <property name="javac.bootclasspath" value=""/>
+  <property name="java.sourcetest.class" value="java.util.Queue" />
+  
   <property name="project.name" value="site"/> <!-- todo: is this used by anakia or something else? -->
   <property name="build.encoding" value="utf-8"/>
 
@@ -96,9 +104,53 @@
     </echo>
   </target>
 
-  <target name="init" depends="javacc-uptodate-check, javacc-notice">
+  <target name="init" depends="javac-check, javacc-uptodate-check, javacc-notice">
   </target>
 
+  <target name="javac-check" unless="javac.trustbootclasspath">
+
+    <condition property="javac.check.ignoresystem" value="true" else="false">
+      <and>
+        <isset property="javac.bootclasspath" />
+        <not><equals arg1="${javac.bootclasspath}" arg2="" trim="true"/></not>
+      </and>
+    </condition>
+    <available
+      classname="${java.sourcetest.class}"
+      property="bootclasspath.bad"
+      classpath="${javac.bootclasspath}"
+      ignoresystemclasses="${javac.check.ignoresystem}"
+    />
+    <fail if="bootclasspath.bad">
+      
+      ##################################################################
+      JavaC Bootclasspath is not restrictive enough
+      JavaC Bootclasspath:  ${javac.bootclasspath}
+      JavaC Source Version: ${javac.source}
+
+      The Lucene build system has detected that your current Java
+      Compiler recognizes classes which are "too new" for the Java
+      version the Lucene Project is currently targetting
+      (${javac.source}).  This means that any source modifications you
+      make *may* include features added since Java ${javac.source}
+      and would not be compitable.
+
+      You should either:
+        A) Compile Lucene with a Java ${javac.source} Compiler
+
+        B) Set the "javac.bootclasspath" property for ant (either
+           on the command line using -Djavac.bootclasspath=... or in a
+           build.properties file) to point at copy of the rt.jar
+           which corrisponds with Java ${javac.source}.
+
+        C) Set the "javac.trustbootclasspath" property to force the
+           Lucene build system to skip this check in the future.
+
+      ##################################################################
+    </fail>
+  </target>
+
+
   <target name="javacc-check">
     <fail unless="javacc.present">
       ##################################################################
@@ -277,6 +329,7 @@
   <macrodef name="compile">
     <attribute name="srcdir"/>
     <attribute name="destdir"/>
+    <attribute name="failonerror" default="true"/>
     <element name="nested" implicit="yes" optional="yes"/>
 
     <sequential>
@@ -285,8 +338,10 @@
         encoding="${build.encoding}"
         srcdir="@{srcdir}"
         destdir="@{destdir}"
+        bootclasspath="${javac.bootclasspath}"
         deprecation="${javac.deprecation}"
         debug="${javac.debug}"
+        failonerror="@{failonerror}"
         source="${javac.source}"
         target="${javac.target}">
         <nested/>
