首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GWT编译器[错误]行:类型不匹配:无法将元素类型Object转换为Foo

GWT编译器[错误]行:类型不匹配:无法将元素类型Object转换为Foo
EN

Stack Overflow用户
提问于 2014-03-21 20:49:18
回答 1查看 463关注 0票数 1

当我编译我的GWT时,我开始得到一个奇怪的错误。这只会在某些时候发生。

代码语言:javascript
复制
 [java] [ERROR] Line 62: Type mismatch: cannot convert from element type Object to SomeClass

文件中的第62行如下所示

代码语言:javascript
复制
for (SomeClass ans : someAutobeanInterface.getSomeClasses()) {

和someAutobeanInterface.getSomeClasses()

代码语言:javascript
复制
List<SomeClass> getSomeClasses();

someAutobeanInterface是一个GWT AutoBean接口。

我使用的是gwt版本2.5.0

我使用ant编译gwt。

代码语言:javascript
复制
<target name="fetch-gwt-dev">
    <echo>Setting up GWT-dependencies</echo>

    <artifact:dependencies filesetId="gwt-dev.dependencies.classpath">
        <dependency groupId="com.google.gwt" artifactId="gwt-dev" version="2.5.0" />
        <dependency groupId="com.bradrydzewski" artifactId="gwt-cal" version="0.9.3.1" />
        <dependency groupId="com.google.gwt.google-apis" artifactId="gwt-visualization" version="1.0.2" />
    </artifact:dependencies>

    <artifact:dependencies filesetId="gwt-user.dependencies.classpath">
        <dependency groupId="com.google.gwt" artifactId="gwt-user" version="2.5.0" />
        <dependency groupId="javax.validation" artifactId="validation-api" version="1.0.0.GA" classifier="sources" />
    </artifact:dependencies>
</target>

<macrodef name="compilegwtappfast" >
    <!-- XXX This macro is kind of strange since it depends on the target fetch-gwt-dev to have been run -->

    <attribute name="package" />
    <attribute name="fakepackage" />
    <attribute name="outputdir" />
    <!-- The number of workers -->
    <attribute name="numberOfWorkers" />
    <!-- If the app needs some additional entry on the classpath (such as GWT-Widgets, that should be added here) -->
    <element name="additional-classpath" optional="true" />

    <sequential>
        <echo>Compiling GWT app @{package} and putting it in @{outputdir}</echo>
        <echo>Compiling package: @{fakePackage}</echo>

        <!-- This directory isn't in SVN so it's not a problem if it doesn't exist -->
        <delete description="Cleaning compiler output directory" failonerror="false">
            <fileset dir="@{outputdir}">
                <include name="**"/>
            </fileset>
        </delete>

        <java fork="true" classname="com.google.gwt.dev.Compiler" failonerror="true">
            <classpath>
                <fileset refid="gwt-user.dependencies.classpath" />
                <fileset refid="gwt-dev.dependencies.classpath" />
                <filelist dir="${basedir}">
                    <file name="src/main/java/" />
                </filelist>
            </classpath>
            <jvmarg value="-Xmx256M"/>
            <arg line="-localWorkers @{numberOfWorkers}" />
            <arg line="-war @{outputdir}"/>
            <arg value="@{fakepackage}" />
        </java>

        <copy todir="@{outputdir}" description="Move the compiler-output to it's right location" failonerror="true">
            <fileset dir="@{outputdir}/@{package}/">
                <include name="**" />
            </fileset>
        </copy>
        <delete dir="@{outputdir}/@{package}">
        </delete>
    <tstamp>
        <format property="DONE_COMPILING" pattern="yyyy-MM-dd HH:mm:ss"/>  
    </tstamp>  
    <echo>Done compiling GWT-app: ${DONE_COMPILING}</echo>
    </sequential>
</macrodef>

<target name="compile-gwt" depends="fetch-gwt-dev">
    <compilegwtapp package="my.gwt.package" outputdir="${basedir}/src/main/webapp/mygwt/" numberOfWorkers="4"/>
</target>

有谁对如何解决这个问题有什么想法?

EN

回答 1

Stack Overflow用户

发布于 2014-03-30 23:49:58

eclipse中Java编译器遵从性设置可能存在严重错误。它们可能设置为不允许使用1.5+语法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22559269

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档