0

I'm maintaining an old Java project that was originally written in 1.4 and is now being migrated to a Java 7 environment. The project uses Ant.

When building I receive the following warning

warning: [options] bootstrap class path not set in conjunction with -source 1.4

and I think I've now done enough reading to understand that this is because I'm using the Java 7 compiler to compile code to run in 1.4. However I don't want this - I want to use the 7 compiler to build 7 code.

Using ant -v I see that the argument -source 1.4 is passed to the javac command but I can't find where it's coming from. None of the build.properties files used by build.xml provide this argument. The project uses some xmlbean functionality and the warning is issued when building the xmlbean target in build.xml.

I have some other projects that are going through a similar process and these do not issue the warning during the build. In these projects Ant does not pass -source 1.4. to javac They are not using xmlbeans so I thought maybe the issue could be related to this.

After a lot of searching I decided I would just put the 1.4 rt.jar on the classpath and forget about it. However this didn't help. I first included it in the xmlbeans target's classpath and then as the 'bootclashpath' property for the whole build.xml file, but no joy.

The relevant section of build.xml looks like this

<target name="xmlbeans" depends="setup">
    <xmlbean classgendir="${schema.compile.dir}" destfile="${dist.dir}/${schema.jar.file}" failonerror="true">
        <fileset dir="${config.dir}">
            <include name="**/*.xsd"/>
        </fileset>
        <classpath>
            <pathelement location="${lib.dir}/xbean.jar"/>
            <pathelement location="${lib.dir}/jsr173_1.0_api.jar"/>
        </classpath>
    </xmlbean>
</target>

<taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean">
    <classpath>
        <pathelement location="${lib.dir}/xbean.jar"/>
        <pathelement location="${lib.dir}/jsr173_1.0_api.jar"/>
    </classpath>
</taskdef>
tomfumb
  • 3,669
  • 3
  • 34
  • 50

1 Answers1

1

Seems as XmlBeans is the cause for that.
From their installation instructions :
"Requirements

Before installing XMLBeans, you will need to have JDK 1.4 installed and Ant. Once you have those, continue with the steps below."

Probably some xmlbeans internal !? Check their sources.
See another stackoverflow posting for alternatives if that is an option :
Java Xml Binding

Community
  • 1
  • 1
Rebse
  • 10,307
  • 2
  • 38
  • 66
  • Interesting, but can you tell me how XmlBeans would be influencing the compiler arguments passed by Ant? I don't even know how the included jars would be communicating that to the build manager – tomfumb Oct 17 '13 at 20:37
  • see => http://grepcode.com/file/repo1.maven.org/maven2/org.apache.xmlbeans/xmlbeans/2.4.0/org/apache/xmlbeans/impl/tool/XMLBean.java - line 264 also comment above line 782 = "Generate java source compatible with the given version. Currently, only "1.4" or "1.5" are supported and "1.4" is the default." – Rebse Oct 17 '13 at 20:46
  • well I still don't understand quite how the two communicate but it looks like that could very well be the problem! Thanks. Now I need to figure out if it's possible to use rt.jar to remove the warning – tomfumb Oct 17 '13 at 20:50
  • seems source=1.4 is the default when using the task and only 1.4 or 1.5 are possible values. i'll bet when using you'll get -source 1.5 From http://xmlbeans.apache.org/news.html => "Starting with XmlBeans 2.6.0, binary files are compatible with JDK1.6. Sources are still compatible with JDK 1.4" seems like JAXB is a better solution – Rebse Oct 17 '13 at 21:13
  • P.S.: putting the 1.4 rt.jar on classpath or similar is a hack but NO solution ;-) and in that case it won't fix your problems – Rebse Oct 17 '13 at 21:34