我们正试图利用GWT 2.4 开发一个“超强”移动应用程序,但现在看来我撞上了一堵墙,无法解决问题。
我们已经为我们从服务器上收到的数据撰写了4个 < em> 重叠类型 ,该服务器是 JSON 和1个有静态通用功能的 < em > 重叠类型 。
取决于我们在哪里使用这些通用函数,我们就会得到这个错误 :
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)
...
...
...
Things I have tested:
- Calling various methods from DataUtil in a module which is loaded via deferred binding
结果:无论使用哪种方法,错误在编辑时随附加消息显示:
[ERROR] [wwapp] Failed to create an instance of com.our.company.mobileapp.client.model.data.GimmeData via deferred binding
- Calling methods from DataUtil in Activities:
结果:错误在运行时显示为提醒弹出。
请允许我快速地说明所有相关类别:
DataUtil -- -- & gt; 重叠类型
AData --> Overlay Type
BData --> Overlay Type
CData --> Overlay Type
DData --> Overlay Type
A --
B --
C --
D --> respective data types as "pure" Java classes
这是 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
(以前的 Datatatil
):
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;
}
}