4

我们正在尝试使用 GWT 2.4 开发移动应用程序,但现在看来我碰壁了,无法解决问题。

我们为从服务器接收到的JSON数据编写了 4 种覆盖类型和 1种具有静态实用功能的覆盖类型。

根据我们使用这些实用功能的位置,我们会收到此错误:

java.lang.ClassFormatError: Illegal method name "<init>$" in class com/our/company/DataUtil
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
    at com.google.gwt.dev.shell.CompilingClassLoader.findClass(CompilingClassLoader.java:1085)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ...
    ...
    ...

我测试过的东西:

  • 在通过延迟绑定加载的模块中从 DataUtil 调用各种方法

结果:无论调用哪个方法,在编译期间都会出现错误并显示附加消息:

[ERROR] [wwapp] Failed to create an instance of'com.our.company.mobileapp.client.model.data.GimmeData' via deferred binding
  • 在活动中从 DataUtil 调用方法:

结果:错误在运行时显示为警报弹出窗口。

请允许我快速说明所有相关的类:

DataUtil --> 覆盖类型


AData --> Overlay Type BData -->
Overlay Type CData --> Overlay Type
DData --> Overlay Type
A --
B --
C --
D --> 各自的数据类型作为“纯”Java类


这是 DataUtil 类的简化版本:

public final class DataUtil extends JavaScriptObject
{
  protected DataUtil()
  {

  }

  private final native static JsArray<AData> asArrayOfAData( String json ) /*-{
        return eval(json);
  }-*/;

  private final static native BData asBData( String json ) /*-{
        if (json.charAt(0) != "(")
            json = "(" + json + ")";

        return eval(json);
  }-*/;

  private final static native JsArray<CData> asArrayOfCData( String json ) /*-{
        return eval(json);
  }-*/;


  private final static native JsArray<DData> asArrayOfDData( String json ) /*-{
        return eval(json);
  }-*/;


  public final static List<A> getListOfAs( String json )
  {
    JsArray<AData> arr = asArrayOfAData( json );
    List<A> list = new ArrayList<A>();

    for ( int i = 0; i < arr.length(); ++i )
    {
      list.add( arr.get( i ).asA() );
    }

    return list;
  }


  public final static B getB( String json )
  {
    return asBData( json ).asB();
  }

  public final static List<C> getListOfC( String json )
  {
    JsArray<CData> arr = asArrayOfCData( json );
    List<C> list = new ArrayList<C>();

    for ( int i = 0; i < arr.length(); ++i )
    {
      list.add( arr.get( i ).asC() );
    }

    return list;
  }

  public final static List<D> getListOfD( String json)
  {
    JsArray<DData> arr = asArrayOfDData( json);
    List<D> list = new ArrayList<D>();

    for ( int i = 0; i < arr.length(); ++i )
    {
      list.add( arr.get( i ).asD() );
    }

    return list;
  }
}

如果需要,我也会发布其他覆盖类型。我真的希望有人以前遇到过并解决了这个问题,如果是这样的话,请提前非常感谢;)。


根据要求,我将发布完整的课程。我只是剥离了评论、导入和包。

JSData(以前DataUtil):

public final class JSData extends JavaScriptObject
{
  protected JSData()
  {
  }

  private final native static JsArray<POIData> asArrayOfPOIData( String json ) /*-{
        return eval(json);
  }-*/;


  private final static native UserData asUserData( String json ) /*-{
        if (json.charAt(0) != "(")
            json = "(" + json + ")";

        return eval(json);
  }-*/;


  private final static native JsArray<CategoryData> asArrayOfCategoryData( String json ) /*-{
        return eval(json);
  }-*/;


  private final static native JsArray<RouteData> asArrayOfRouteData( String json ) /*-{
    return eval(json);
  }-*/;


  public final static List<WWCategory> getListOfCategories( String json )
  {
    JsArray<CategoryData> arr = asArrayOfCategoryData( json );
    List<WWCategory> list = new ArrayList<WWCategory>();

    for ( int i = 0; i < arr.length(); ++i )
    {
      list.add( arr.get( i ).asWWCategory() );
    }

    return list;
  }

  public final static List<WWPOI> getListOfPOIs( String json )
  {
    JsArray<POIData> arr = asArrayOfPOIData( json );
    List<WWPOI> list = new ArrayList<WWPOI>();

    for ( int i = 0; i < arr.length(); ++i )
    {
      list.add( arr.get( i ).asWWPOI() );
    }

    return list;
  }


  public final static WWUser getUser( String json )
  {
    return asUserData( json ).asWWUser();
  }


  public final static List<WWRoute> getListOfRoutes( String routesJSON )
  {
    JsArray<RouteData> arr = asArrayOfRouteData( routesJSON );
    List<WWRoute> list = new ArrayList<WWRoute>();

    for ( int i = 0; i < arr.length(); ++i )
    {
      list.add( arr.get( i ).asWWRoute() );
    }

    return list;
  }
}

UserData

public final class UserData extends JavaScriptObject
{
  protected UserData()
  {

  }

  private static final Logger log = Logger.getLogger( "com.isp.wwapp.core.client.model.jsdata.UserData" );


  public final String getUserName()
  {
    String benutzername_js = getUserName_JS();
    String benutzername = Utils.unescape( benutzername_js );

    return benutzername;
  }
  private final native String getUserName_JS() /*-{
        return this.benutzername;
  }-*/;


  public final String getName()
  {
    String vorname_js = getName_JS();
    String vorname = Utils.unescape( vorname_js );
    log.info( vorname );
    return vorname;
  }
  private final native String getName_JS() /*-{
        return this.vorname;
  }-*/;



  public final String getSurname()
  {
    String nachname_js = getSurname_JS();
    String nachname = Utils.unescape( nachname_js );
    log.info( nachname );
    return nachname;
  }
  private final native String getSurname_JS()
  /*-{
        return this.nachname;
  }-*/;



  public final Boolean getGender()
  {
    String geschlecht_js = getGender_JS();
    Boolean geschlecht = null;

    geschlecht = geschlecht_js.equals( "w" );

    return geschlecht;
  }
  private final native String getGender_JS()
  /*-{
        return this.geschlecht;
  }-*/;



  public final String getNickname()
  {
    String nickname_js = getNickname_JS();
    String nickname = Utils.unescape( nickname_js );

    return nickname;
  }
  private final native String getNickname_JS()
  /*-{
        return this.nickname;
  }-*/;



  public final Date getBirthday()
  {
    String geburtstag_js = getBirthday_JS();
    Date geburtstag = null;

    try
    {
      geburtstag = DateTimeFormat.getFormat( "yyyy-MM-dd" ).parse( geburtstag_js );
    }
    catch ( IllegalArgumentException e )
    {
      log.log( Level.SEVERE, "Das Geburtsdatum konnte nicht richtig geparst werden.", e );
    }
    return geburtstag;
  }
  private final native String getBirthday_JS()
  /*-{
        return this.geburtstag;
  }-*/;


  public final String getPassword()
  {
    String passwort_crypt_js = getPassword_JS();
    String passwort_crypt = Utils.unescape( passwort_crypt_js );
    log.info( passwort_crypt );
    return passwort_crypt;
  }
  private final native String getPassword_JS()
  /*-{
        return this.passwort_crypt;
  }-*/;


  public final String getStreet()
  {
    String strasse_js = getStreet_JS();
    String strasse = Utils.unescape( strasse_js );

    return strasse;
  }
  private final native String getStreet_JS()
  /*-{
        return this.strasse;
  }-*/;


  public final String getStreetNumber()
  {
    String hausnr_js = getStreetNumber_JS();
    String hausnr = Utils.unescape( hausnr_js );

    return hausnr;
  }
  private final native String getStreetNumber_JS()
  /*-{
        return this.hausnr;
  }-*/;



  public final String getZIP()
  {
    String plz_js = getZIP_JS();
    String plz = Utils.unescape( plz_js );

    return plz;
  }
  private final native String getZIP_JS()
  /*-{
        return this.plz;
  }-*/;


  public final String getDistrict()
  {
    String ortsteil_js = getDistrict_JS();
    String ortsteil = Utils.unescape( ortsteil_js );

    return ortsteil;
  }
  private final native String getDistrict_JS()
  /*-{
        return this.ortsteil;
  }-*/;


  public final String getLocation()
  {
    String ort_js = getLocation_JS();
    String ort = Utils.unescape( ort_js );

    return ort;
  }
  private final native String getLocation_JS()
  /*-{
        return this.ort;
  }-*/;


  public final String getState()
  {
    String landesteil_js = getState_JS();
    String landesteil = Utils.unescape( landesteil_js );

    return landesteil;
  }
  private final native String getState_JS()
  /*-{
        return this.landesteil;
  }-*/;




  public final String getRegion()
  {
    String region_js = getRegion_JS();
    String region = Utils.unescape( region_js );

    return region;
  }
  private final native String getRegion_JS()
  /*-{
        return this.region;
  }-*/;




  public final String getCountry()
  {
    String landname_js = getCountry_JS();
    String landname = Utils.unescape( landname_js );

    return landname;
  }
  private final native String getCountry_JS()
  /*-{
        return this.landname;
  }-*/;


  public final String getImageURL()
  {
    String foto_js = getImageURL_JS();
    String foto = Utils.unescape( foto_js );

    return foto;
  }
  private final native String getImageURL_JS()
  /*-{
        return this.foto;
  }-*/;



  public final String getWebsite()
  {
    String webseite_js = getWebsite_JS();
    String webseite = Utils.unescape( webseite_js );

    return webseite;
  }
  private final native String getWebsite_JS()
  /*-{
        return this.webseite;
  }-*/;



  public final Integer getDbId()
  {
    String idBenutzer_js = getDbId_JS();
    Integer idBenutzer = null;

    idBenutzer = Integer.parseInt( idBenutzer_js );

    return idBenutzer;
  }
  private final native String getDbId_JS()
  /*-{
        return this.idBenutzer;
  }-*/;



  public final String getEmail()
  {
    String email_js = getEmail_JS();
    String email = Utils.unescape( email_js );

    return email;
  }
  private final native String getEmail_JS()
  /*-{
        return this.email;
  }-*/;



  public final String getTel()
  {
    String festnetz_js = getTel_JS();
    String festnetz = Utils.unescape( festnetz_js );

    return festnetz;
  }
  private final native String getTel_JS()
  /*-{
        return this.festnetz;
  }-*/;



  public final String getMobile()
  {
    String mobil_js = getMobile_JS();
    String mobil = Utils.unescape( mobil_js );

    return mobil;
  }
  private final native String getMobile_JS()
  /*-{
        return this.mobil;
  }-*/;




  public final String getIMEI()
  {
    String imei_js = getIMEI_JS();
    String imei = imei_js;
    log.info( imei );
    return imei;
  }
  private final native String getIMEI_JS()
  /*-{
        return this.imei;
  }-*/;



  public final String getFax()
  {
    String fax_js = getFax_JS();
    String fax = Utils.unescape( fax_js );

    return fax;
  }
  private final native String getFax_JS()
  /*-{
        return this.fax;
  }-*/;



  public final String getSkype()
  {
    String skype_js = getSkype_JS();
    String skype = Utils.unescape( skype_js );

    return skype;
  }
  private final native String getSkype_JS()
  /*-{
        return this.skype;
  }-*/;



  public final String getICQ()
  {
    String icq_js = getICQ_JS();
    String icq = Utils.unescape( icq_js );

    return icq;
  }
  private final native String getICQ_JS()
  /*-{
        return this.icq;
  }-*/;



  public final String getTwitter()
  {
    String twitter_js = getTwitter_JS();
    String twitter = Utils.unescape( twitter_js );

    return twitter;
  }
  private final native String getTwitter_JS()
  /*-{
        return this.twitter;
  }-*/;




  public final Integer getMyPoiDbID()
  {
    String persPoi_js = getMyPoi_JS();
    Integer persPoiId = null;

    try
    {
      persPoiId = Integer.parseInt( persPoi_js );

    }
    catch ( NumberFormatException e )
    {
      log.log( Level.SEVERE, "Fehler beim Parsen der POI Datenbank-Id.", e );
    }



    return persPoiId;
  }
  private final native String getMyPoi_JS()
  /*-{
        return this.persPoi;
  }-*/;




  public final WWUser asWWUser()
  {

    Contact con = new Contact( this.getEmail(), this.getTel(), this.getMobile() );

    //TODO restliche Kontaktattribute füllen .

    Address adr =
        new Address( this.getStreet(), this.getStreetNumber(), this.getLocation(), this.getZIP(),
            this.getCountry() );

    WWUser wwuser =
        new WWUser( this.getDbId(), this.getName(), this.getSurname(), con, adr, this.getUserName(),
            Utils.hexStringToByteArray( this.getPassword() ), this.getIMEI() );

    log.info( wwuser.toString() );

    return wwuser;

  }

}

POIData

public class POIData extends JavaScriptObject
{

  private final Logger log = Logger.getLogger( "com.isp.wwapp.core.client.model.jsdata.POIData" );

  protected POIData()
  {
  }



  public final Integer getDbId()
  {
    Integer dbid = null;
    String dbid_js = getDbId_JS();
    try
    {
      dbid = Integer.parseInt( dbid_js );
    }
    catch ( NumberFormatException nfe )
    {
      log.log( Level.INFO, "Die Datenbank-ID " + dbid_js + " konnte nicht in ein Integer geparst werden.",
          nfe );
    }


    return dbid;
  }
  private final native String getDbId_JS() /*-{
        return this.idPoi;
  }-*/;



  public final String getLabel()
  {
    return Utils.unescape( getLabel_JS() );
  }
  private final native String getLabel_JS() /*-{
        return this.poiBez;
  }-*/;


  public final String getDescription()
  {
    return Utils.unescape( getDescription_JS() );
  }
  private final native String getDescription_JS() /*-{
        return this.kurztext;
  }-*/;

  public final Double getLongitude()
  {
    Double lon = null;
    String lon_js = getLongitude_JS();
    try
    {
      lon = Double.parseDouble( lon_js );
    }
    catch ( NumberFormatException nfe )
    {
      log.log( Level.SEVERE, "Die Longitude " + lon_js + " konnte nicht in ein Double geparst werden.", nfe );
    }
    return lon;
  }
  private final native String getLongitude_JS() /*-{
        return this.laenge;
  }-*/;

  public final Double getLatitude()
  {
    Double lat = null;
    String lat_js = getLatitude_JS();
    try
    {
      lat = Double.parseDouble( lat_js );
    }
    catch ( NumberFormatException nfe )
    {
      log.log( Level.SEVERE, "Die Latitude " + lat_js + " konnte nicht in ein Double geparst werden.", nfe );
    }
    return lat;
  }
  private final native String getLatitude_JS() /*-{
        return this.breite;
  }-*/;


  public final String getStreet()
  {
    return Utils.unescape( getStreet_JS() );
  }
  private final native String getStreet_JS() /*-{
        return this.strasse;
  }-*/;


  public final String getStreetNumber()
  {
    return Utils.unescape( getStreetNumber_JS() );
  }
  private final native String getStreetNumber_JS() /*-{
        return this.hausnr;
  }-*/;


  public final String getZIP()
  {
    return Utils.unescape( getZIP_JS() );
  }
  private final native String getZIP_JS() /*-{
        return this.plz;
  }-*/;


  public final String getLocation()
  {
    return Utils.unescape( getLocation_JS() );
  }
  private final native String getLocation_JS() /*-{
        return this.ort;
  }-*/;


  public final String getCountry()
  {
    return Utils.unescape( getCountry_JS() );
  }
  private final native String getCountry_JS() /*-{
        return this.landName;
  }-*/;


  public final String getDistrict()
  {
    return Utils.unescape( getDistrict_JS() );
  }
  private final native String getDistrict_JS() /*-{
        return this.ortsteil;
  }-*/;


  public final String getState()
  {
    return Utils.unescape( getState_JS() );
  }
  private final native String getState_JS() /*-{
        return this.landesteil;
  }-*/;


  public final String getRegion()
  {
    return Utils.unescape( getRegion_JS() );
  }
  private final native String getRegion_JS() /*-{
        return this.region;
  }-*/;


  public final String getURL()
  {
    return Utils.unescape( getURL_JS() );
  }
  private final native String getURL_JS() /*-{
        return this.url;
  }-*/;


  public final String getContactEmail()
  {
    return Utils.unescape( getContactEmail_JS() );
  }
  private final native String getContactEmail_JS() /*-{
        return this.kontaktEmail;
  }-*/;


  public final String getContactTel()
  {
    return Utils.unescape( getContactTel_JS() );
  }
  private final native String getContactTel_JS() /*-{
        return this.kontaktTel;
  }-*/;


  public final String getContactMobile()
  {
    return Utils.unescape( getContactMobile_JS() );
  }
  private final native String getContactMobile_JS() /*-{
        return this.kontaktTel2;
  }-*/;


  public final String getContactFax()
  {
    return Utils.unescape( getContactFax_JS() );
  }
  private final native String getContactFax_JS() /*-{
        return this.kontaktFax;
  }-*/;


  @Deprecated
  public final List<String> getCategoryLabels()
  {
    JsArrayString labelsArray = getCategoryLabels_JS();
    List<String> labelsList = new ArrayList<String>();

    for ( Integer i = 0; i < labelsArray.length(); ++i )
    {
      labelsList.add( Utils.unescape( labelsArray.get( i ) ) );
    }
    return labelsList;
  }
  private final native JsArrayString getCategoryLabels_JS() /*-{
        var katLabels = new Array();
        for ( var i = 0; i < this.myKat.length; ++i) {
            katLabels.push(this.myKat[i].katBez);
        }
        return katLabels;
  }-*/;


  public final List<WWCategory> getCategories()
  {
    List<WWCategory> cats = new ArrayList<WWCategory>();
    JsArray<CategoryData> cats_js = getCategories_JS();

    for ( Integer i = 0; i < cats_js.length(); ++i )
    {
      cats.add( cats_js.get( i ).asWWCategory() );
    }
    return cats;
  }
  private final native JsArray<CategoryData> getCategories_JS() /*-{
        return eval(this.myKat);
  }-*/;

  public final Date getLastModified()
  {
    String geaendertAm_js = getLastModified_JS();
    Date geaendertAm = null;


    DateTimeFormat wwDTFormat = DateTimeFormat.getFormat( "yyyy-MM-dd HH:mm:ss" );
    try
    {
      geaendertAm = wwDTFormat.parse( geaendertAm_js );

    }
    catch ( IllegalArgumentException e )
    {
      log.log( Level.SEVERE, "Parsen des Datums " + geaendertAm_js + "ist fehlgeschlagen.", e );
    }



    return geaendertAm;
  }
  private final native String getLastModified_JS() /*-{
        return this.geaendertAm;
  }-*/;


  public final int getPosition()
  {
    String position_js = getPosition_JS();
    int position = 0;
    try
    {
      position = Integer.parseInt( position_js );
    }
    catch ( NumberFormatException e )
    {
      log.log( Level.SEVERE, "Fehler beim Parsen der Position des POIs.", e );
    }

    return position;
  }
  private final native String getPosition_JS()
  /*-{
        return this.position;
  }-*/;


  public final WWPOI asWWPOI()
  {
    WWPOI poi = new WWPOI( this.getDbId(), this.getLatitude(), this.getLongitude(), this.getLabel() );


    poi.setDescription( this.getDescription() );
    poi.setUrl( this.getURL() );
    poi.setPosition( this.getPosition() );

    Address adr = new Address();
    adr.setCountry( this.getCountry() );
    adr.setDistrict( this.getDistrict() );
    adr.setLocation( this.getLocation() );
    adr.setZip( this.getZIP() );
    adr.setState( this.getState() );
    adr.setStreet( this.getStreet() );
    adr.setStreetNumber( this.getStreetNumber() );

    poi.setAddress( adr );

    Contact con = new Contact();
    con.setEmail( this.getContactEmail() );
    con.setFax( this.getContactFax() );
    con.setTel( this.getContactTel() );
    con.setMobile( this.getContactMobile() );

    poi.setContactData( con );

    List<WWCategory> categories = GimmeThatSingleton.getInstance().getCategories();

    List<WWCategory> poiCats = this.getCategories();

    for ( WWCategory poiCat : poiCats )
    {

      for ( WWCategory cat : categories )
      {
        // wenn katergorie vorhanden, vorhandene hinzufügen zu poi

        if ( poiCat.equals( cat ) )
        {

          poi.addToCategory( cat );

        }
      }
    }

    if ( poi.getCategories() == null )
      return null; //TODO throw exception?

    return poi;
  }
}

RouteData

public final class RouteData extends JavaScriptObject
{
  protected RouteData()
  {
  }

  private final Logger log = Logger.getLogger( "com.isp.wwapp.core.client.model.jsdata.RouteData" );

  public final String getLabel()
  {
    return Utils.unescape( getLabel_JS() );
  }
  private final native String getLabel_JS() /*-{
        return this.routenBez;
  }-*/;


  public final Integer getDbId()
  {
    Integer dbid = null;
    String dbid_js = getDbId_JS();
    try
    {
      dbid = Integer.parseInt( dbid_js );
    }
    catch ( NumberFormatException nfe )
    {
      log.log( Level.SEVERE, "Die Datenbank-ID " + dbid_js + " konnte nicht in ein Integer geparst werden.",
          nfe );
    }


    return dbid;
  }
  private final native String getDbId_JS() /*-{
        return this.idRoute;
  }-*/;
  /**
   * @return
   */
  public final WWRoute asWWRoute()
  {
    WWRoute route = new WWRoute( getDbId(), null, getLabel(), null );
    return route;
  }
}

CategoryData

public final class CategoryData extends JavaScriptObject
{

  protected CategoryData()
  {
  }

  private final Logger log = Logger.getLogger( "com.isp.wwapp.core.client.model.jsdata.CategoryData" );


  public final String getLabel()
  {
    return Utils.unescape( getLabel_JS() );
  }
  private final native String getLabel_JS() /*-{
        return this.katBez;
  }-*/;

  public final String getDescription()
  {
    return Utils.unescape( getDescription_JS() );
  }
  private final native String getDescription_JS() /*-{
        return this.katBeschreibung;
  }-*/;

  public final Integer getDbId()
  {
    Integer dbid = null;
    String dbid_js = getDbId_JS();
    try
    {
      dbid = Integer.parseInt( dbid_js );
    }
    catch ( NumberFormatException nfe )
    {
      log.log( Level.SEVERE, "Die Datenbank-ID " + dbid_js + " konnte nicht in ein Integer geparst werden.",
          nfe );
    }


    return dbid;
  }
  private final native String getDbId_JS() /*-{
        return this.idKat;
  }-*/;


  public final native Boolean isSubcategory() /*-{
        return (this.unterKatVon != null);
  }-*/;
  public final native Boolean hasSubcategory() /*-{
        return (this.hatUnterKat == 'j');
  }-*/;

  public final Integer getParentDbId()
  {
    Integer parentdbid = null;
    String parentdbid_js = getParentDbId_JS();
    if ( parentdbid_js == null )
      return null;
    try
    {
      parentdbid = Integer.parseInt( parentdbid_js );
    }
    catch ( NumberFormatException nfe )
    {
      log.log( Level.SEVERE, "Die Datenbank-ID " + parentdbid_js
          + " konnte nicht in ein Integer geparst werden.", nfe );
      parentdbid = null;
    }
    return parentdbid;
  }
  private final native String getParentDbId_JS() /*-{
        return this.unterKatVon;
  }-*/;



  public final Date getlastModified()
  {
    String geaendertAm_js = getlastModified_JS();
    Date geaendertAm = null;


    /*
     * Serverformat eines Datum : "yyyy-mm-dd hh:mm:ss"
     */

    DateTimeFormat wwDTFormat = DateTimeFormat.getFormat( "yyyy-MM-dd HH:mm:ss" );
    try
    {
      geaendertAm = wwDTFormat.parse( geaendertAm_js );

    }
    catch ( IllegalArgumentException e )
    {
      log.log( Level.SEVERE, "Parsen des Datums " + geaendertAm_js + "ist fehlgeschlagen.", e );
    }



    return geaendertAm;
  }
  private final native String getlastModified_JS() /*-{
        return this.geaendertAm;
  }-*/;


  public final WWCategory asWWCategory()
  {

    WWCategory cat = new WWCategory( this.getParentDbId(), this.getDbId(), this.getLabel() );
    cat.setDescrition( this.getDescription() );

    return cat;
  }
}
4

3 回答 3

3

我认为问题出在您的*Data覆盖类型中,因为您声明了实例字段:

private final Logger log = Logger.getLogger( "com.isp.wwapp.core.client.model.jsdata.CategoryData" );

文档指出覆盖类型不能有任何实例字段。

将其移除或使其成为静态的。

于 2012-07-24T11:01:33.550 回答
1

试试这些步骤

  1. 确保所有覆盖类型都有一个受保护的无参数构造函数。
  2. 公开本机方法
  3. 保持你的覆盖类型简单并将非本地方法移动到不同的类中
于 2012-07-22T06:45:38.470 回答
1

我可能已经复制了您的错误:

它归结为两个覆盖类型相互交叉引用的覆盖类,其中错误实际上在第二个覆盖类中。

主要的:

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsonUtils;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;

public class _37_OverLayStackOverfflowQuestion implements EntryPoint {

    String jsonS = "{\"hello\":\"world\"}";

    public void onModuleLoad() {
        JavaScriptObject jso = JsonUtils.safeEval(jsonS);
        DataUtil overlayEr = jso.cast();
        OtherOverlay wellwell = jso.cast();

        overlayEr.test(wellwell);
        Window.alert("works");
    }
}

第一次叠加:

import java.util.List;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayString;

public final class DataUtil extends JavaScriptObject {
    protected DataUtil() {

    }

    public final native void test(OtherOverlay json) /*-{
        return;
    }-*/;
}

第二个叠加:

import com.google.gwt.core.client.JavaScriptObject;

public class OtherOverlay extends JavaScriptObject {
    protected OtherOverlay() {
    }

    public final native void someFkt()/*-{
        alert('hello');
    }-*/;

    int i = 0;
}

错误出现在第二个 Overlay 类的最后一页中:int i = 0;

但是,错误消息出现在 DataUtil 中。

java.lang.ClassFormatError: Illegal method name "<init>$" in class stefan/client/DataUtil
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at com.google.gwt.dev.shell.CompilingClassLoader.findClass(CompilingClassLoader.java:1085)

我猜您的错误出现在您的覆盖类之一中。检查每个是否单独工作!

于 2012-07-23T15:42:06.823 回答