【问题标题】:How to build xerces-j 2.11 with an up-to-date JVM?如何使用最新的 JVM 构建 xerces-j 2.11?
【发布时间】:2015-02-18 09:28:10
【问题描述】:

我已经从https://svn.apache.org/repos/asf/xerces/java/tags/Xerces-J_2_11_0 签出了 xerces-j 2.11。现在我想构建它,但是在编译过程中出现以下错误:

compile:
   [xjavac] Compiling 596 source files to C:\Users\abrieg\workingcopy\xerces-trunk\build\classes
   [xjavac] C:\Users\abrieg\workingcopy\xerces-trunk\build\src\org\apache\html\dom\HTMLFrameElementImpl.java:28: error: HTMLFrameElementImpl is not abstract and does not override abstract method getContentDocument() in HTMLFrameElement
   [xjavac] public class HTMLFrameElementImpl
   [xjavac]        ^
   [xjavac] C:\Users\abrieg\workingcopy\xerces-trunk\build\src\org\apache\html\dom\HTMLIFrameElementImpl.java:28: error: HTMLIFrameElementImpl is not abstract and does not override abstract method getContentDocument() in HTMLIFrameElement
   [xjavac] public class HTMLIFrameElementImpl
   [xjavac]        ^
   [xjavac] C:\Users\abrieg\workingcopy\xerces-trunk\build\src\org\apache\html\dom\HTMLObjectElementImpl.java:28: error: HTMLObjectElementImpl is not abstract and does not override abstract method getContentDocument() in HTMLObjectElement
   [xjavac] public class HTMLObjectElementImpl
   [xjavac]        ^
   [xjavac] Note: Some input files use or override a deprecated API.
   [xjavac] Note: Recompile with -Xlint:deprecation for details.
   [xjavac] Note: Some input files use unchecked or unsafe operations.
   [xjavac] Note: Recompile with -Xlint:unchecked for details.
   [xjavac] 3 errors

问题是xjavac任务没有使用来自/tools/xml-apis.jar的类,而是使用jdk的rt.jar。 编译正在以下虚拟机中运行:

java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

我已经使用认可的库覆盖机制将 xerces-j 2.11 的 xml-apis.jar 放入 VM 中,但这不起作用。

xjavac 调用定义为

<xjavac srcdir="${build.src}"
       destdir="${build.dest}"
       source="${javac.source}"
       target="${javac.target}"
       classpath="${build.dir}/classes:${tools.dir}/${jar.apis}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}"
       debug="${debug}"
       debuglevel="${debuglevel}"
       deprecation="${deprecation}"
       optimize="${optimize}"
       includeAntRuntime="false"
       includeJavaRuntime="false"
       excludes="org/xml/sax/** 
            javax/xml/**
            org/w3c/dom/*
            org/w3c/dom/bootstrap/**
            org/w3c/dom/events/**
            org/w3c/dom/ls/**
            org/w3c/dom/html/**
            org/w3c/dom/ranges/**
            org/w3c/dom/traversal/**
            org/w3c/dom/views/**
            org/w3c/dom/xpath/**"
       />

如何确保 xml-apis.jar 用于编译而不是我的 JVM 中的类?

【问题讨论】:

    标签: java ant build xerces


    【解决方案1】:

    您需要将xml-apis.jar添加到 Javac 的 bootstrap classes

    <xjavac srcdir="${build.src}"
           destdir="${build.dest}"
           source="${javac.source}"
           target="${javac.target}"
           classpath="${build.dir}/classes:${tools.dir}/${jar.apis}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}"
           debug="${debug}"
           debuglevel="${debuglevel}"
           deprecation="${deprecation}"
           optimize="${optimize}"
           includeAntRuntime="false"
           includeJavaRuntime="false"
           excludes="org/xml/sax/** 
                javax/xml/**
                org/w3c/dom/*
                org/w3c/dom/bootstrap/**
                org/w3c/dom/events/**
                org/w3c/dom/ls/**
                org/w3c/dom/html/**
                org/w3c/dom/ranges/**
                org/w3c/dom/traversal/**
                org/w3c/dom/views/**
                org/w3c/dom/xpath/**"
           >
           <compilerarg line="-Xbootclasspath/p:${tools.dir}/${jar.apis}"/>
    </xjavac>
    

    【讨论】:

    • javac 的文档说-Xbootclasspath/p 在引导类路径中添加后缀。。无论如何,这工作得很好。
    • @SpaceTrucker 这显然是文档中的错误。已提交错误报告。如果你运行javac -X,你会得到正确的解释。
    • 为了记录,该错误被归档为JDK-8073401
    猜你喜欢
    • 2011-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    相关资源
    最近更新 更多