xwt jar in gwt

时间:2013-01-29 09:27:41

标签: gwt

我下载了xstream jar和sourcecode,并使用 winrar 将源代码附加到jar文件中

我创建了2个gwt.xml文件。

xstream.gwt.xml存在于com.thoughtworks

<?xml version="1.0" encoding="UTF-8"?> 
<module> 
<source path="xstream"/> 
</module>

和operations.gwt.xml存在于com.thoughworks.xstream

<?xml version="1.0" encoding="UTF-8"?> 
<module> 
<source path="annotations"/> 
<source path="converters"/> 
<source path="core"/> 
<source path="io"/> 
<source path="mapper"/> 
<source path="persistence"/> 
</module>

编辑:我的gwt项目xml

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='test'>
  <inherits name='com.google.gwt.user.User'/>
  <inherits name='com.google.gwt.user.theme.standard.Standard'/>
  <inherits name='com.thoughtworks.xstream'/>
  <entry-point class='com.example.test.client.Index'/>
</module>

但我收到了错误

Compiling module com.example.test.Test
   Validating newly compiled units
      Ignored 142 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/XStream.java'
      [ERROR] Line 499:  The method forName(String, boolean, ClassLoader) is undefined for the type Class
      [ERROR] Line 500:  The method getConstructor(Class[]) is undefined for the type Class
      [ERROR] Line 764:  The method forName(String, boolean, ClassLoader) is undefined for the type Class
      [ERROR] Line 765:  The method getConstructor(Class[]) is undefined for the type Class
      [ERROR] Line 1062:  The method getPackage() is undefined for the type Class<capture#10-of ? extends XStream>
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/basic/NullConverter.java'
      [ERROR] Line 30:  The method isAssignableFrom(Class) is undefined for the type Class<Mapper.Null>
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/basic/StringConverter.java'
      [ERROR] Line 73:  The method synchronizedMap(WeakCache) is undefined for the type Collections
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/collections/AbstractCollectionConverter.java'
      [ERROR] Line 77:  The method newInstance() is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/collections/TreeMapConverter.java'
      [ERROR] Line 54:  The method getDeclaredFields() is undefined for the type Class<TreeMap>
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/collections/TreeSetConverter.java'
      [ERROR] Line 48:  The method getDeclaredFields() is undefined for the type Class<TreeSet>
      [ERROR] Line 50:  The method isAssignableFrom(Class<capture#1-of ?>) is undefined for the type Class<SortedMap>
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/extended/DynamicProxyConverter.java'
      [ERROR] Line 51:  The method getDeclaredField(String) is undefined for the type Class<Proxy>
      [ERROR] Line 60:  The method getClassLoader() is undefined for the type Class<DynamicProxyConverter>
      [ERROR] Line 85:  The method getInterfaces() is undefined for the type Class<capture#2-of ? extends Object>
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/extended/JavaClassConverter.java'
      [ERROR] Line 61:  The method getClassLoader() is undefined for the type Class<capture#1-of ?>
      [ERROR] Line 65:  The method forName(String, boolean, ClassLoader) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/extended/JavaFieldConverter.java'
      [ERROR] Line 69:  The method getDeclaredField(String) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/extended/JavaMethodConverter.java'
      [ERROR] Line 107:  The method getDeclaredMethod(String, Class[]) is undefined for the type Class
      [ERROR] Line 109:  The method getDeclaredConstructor(Class[]) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/extended/LookAndFeelConverter.java'
      [ERROR] Line 44:  The method isAssignableFrom(Class) is undefined for the type Class<LookAndFeel>
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/reflection/AbstractReflectionConverter.java'
      [ERROR] Line 271:  The method isAssignableFrom(Class<capture#27-of ? extends Object>) is undefined for the type Class
      [ERROR] Line 326:  The method isAssignableFrom(Class<capture#32-of ? extends Object>) is undefined for the type Class
      [ERROR] Line 378:  The method isAssignableFrom(Class) is undefined for the type Class<Collection>
      [ERROR] Line 378:  The method isAssignableFrom(Class) is undefined for the type Class<Map>
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/reflection/AbstractAttributedCharacterIteratorAttributeConverter.java'
      [ERROR] Line 38:  The method getDeclaredMethod(String, Class[]) is undefined for the type Class<AttributedCharacterIterator.Attribute>
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/reflection/ExternalizableConverter.java'
      [ERROR] Line 58:  The method isAssignableFrom(Class) is undefined for the type Class<Externalizable>
      [ERROR] Line 104:  The method getDeclaredConstructor(Class[]) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/reflection/SerializableConverter.java'
      [ERROR] Line 90:  The method isAssignableFrom(Class) is undefined for the type Class<Serializable>
      [ERROR] Line 214:  The method isAssignableFrom(Class) is undefined for the type Class<Serializable>
      [ERROR] Line 271:  The method getDeclaredField(String) is undefined for the type Class
      [ERROR] Line 462:  The method isAssignableFrom(Class) is undefined for the type Class<Serializable>
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/core/DefaultConverterLookup.java'
      [ERROR] Line 37:  The method synchronizedMap(WeakHashMap) is undefined for the type Collections
      [ERROR] Line 86:  The method synchronizedMap(HashMap) is undefined for the type Collections
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/core/JVM.java'
      [ERROR] Line 46:  The method getProperty(String) is undefined for the type System
      [ERROR] Line 94:  The method getProperty(String) is undefined for the type System
      [ERROR] Line 185:  The method getProperty(String) is undefined for the type System
      [ERROR] Line 199:  The method getProperty(String) is undefined for the type System
      [ERROR] Line 231:  The method getClassLoader() is undefined for the type Class<capture#1-of ? extends JVM>
      [ERROR] Line 251:  The method newInstance() is undefined for the type Class
      [ERROR] Line 342:  The method getDeclaredFields() is undefined for the type Class<AttributedString>
      [ERROR] Line 350:  The method getDeclaredFields() is undefined for the type Class<JVM>
      [ERROR] Line 361:  The method getProperty(String) is undefined for the type System
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/core/util/CompositeClassLoader.java'
      [ERROR] Line 57:  The method getClassLoader() is undefined for the type Class<Object>
      [ERROR] Line 58:  The method getClassLoader() is undefined for the type Class<capture#1-of ? extends CompositeClassLoader>
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/core/util/CustomObjectInputStream.java'
      [ERROR] Line 95:  The method forName(String, boolean, ClassLoader) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/io/xml/XppDriver.java'
      [ERROR] Line 18:  The import org.xmlpull cannot be resolved
      [ERROR] Line 19:  The import org.xmlpull cannot be resolved
      [ERROR] Line 20:  The import org.xmlpull cannot be resolved
      [ERROR] Line 31:  XmlPullParserFactory cannot be resolved to a type
      [ERROR] Line 55:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 55:  XmlPullParserException cannot be resolved to a type
      [ERROR] Line 56:  XmlPullParserFactory cannot be resolved to a type
      [ERROR] Line 57:  XmlPullParserFactory cannot be resolved to a type
      [ERROR] Line 57:  XmlPullParserFactory cannot be resolved
      [ERROR] Line 59:  XmlPullParserFactory cannot be resolved to a type
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/io/xml/AbstractXppDriver.java'
      [ERROR] Line 19:  The import org.xmlpull cannot be resolved
      [ERROR] Line 20:  The import org.xmlpull cannot be resolved
      [ERROR] Line 54:  The method createParser() from the type AbstractXppDriver refers to the missing type XmlPullParser
      [ERROR] Line 55:  XmlPullParserException cannot be resolved to a type
      [ERROR] Line 93:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 93:  XmlPullParserException cannot be resolved to a type
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/mapper/MapperWrapper.java'
      [ERROR] Line 103:  The method isAssignableFrom(Class<capture#1-of ? extends MapperWrapper>) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/mapper/CachingMapper.java'
      [ERROR] Line 55:  The method synchronizedMap(HashMap) is undefined for the type Collections
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/mapper/ClassAliasingMapper.java'
      [ERROR] Line 60:  The method isAssignableFrom(Class) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/mapper/DefaultMapper.java'
      [ERROR] Line 47:  The method getClassLoader() is undefined for the type Class<DefaultMapper>
      [ERROR] Line 51:  The method forName(String, boolean, ClassLoader) is undefined for the type Class
      [ERROR] Line 53:  The method forName(String) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/mapper/ImplicitCollectionMapper.java'
      [ERROR] Line 97:  The method getDeclaredField(String) is undefined for the type Class
      [ERROR] Line 110:  The method isAssignableFrom(Class<capture#1-of ?>) is undefined for the type Class<Map>
      [ERROR] Line 114:  The method isAssignableFrom(Class<capture#2-of ?>) is undefined for the type Class<Collection>
      [ERROR] Line 127:  The method isAssignableFrom(Class) is undefined for the type Class
      [ERROR] Line 162:  The method isAssignableFrom(Class) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/core/util/Fields.java'
      [ERROR] Line 27:  The method getDeclaredField(String) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/core/util/Primitives.java'
      [ERROR] Line 30:  Byte.TYPE cannot be resolved
      [ERROR] Line 32:  Short.TYPE cannot be resolved
      [ERROR] Line 33:  Integer.TYPE cannot be resolved
      [ERROR] Line 34:  Long.TYPE cannot be resolved
      [ERROR] Line 35:  Float.TYPE cannot be resolved
      [ERROR] Line 36:  Double.TYPE cannot be resolved
      [ERROR] Line 37:  Boolean.TYPE cannot be resolved
      [ERROR] Line 38:  Void.TYPE cannot be resolved
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/reflection/SerializationMethodInvoker.java'
      [ERROR] Line 40:  The method getDeclaredMethods() is undefined for the type Class<capture#1-of ? extends new Object(){}>
      [ERROR] Line 48:  The method synchronizedMap(HashMap) is undefined for the type Collections
      [ERROR] Line 161:  The method getDeclaredMethod(String, Class[]) is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/reflection/PureJavaReflectionProvider.java'
      [ERROR] Line 58:  The method getDeclaredConstructors() is undefined for the type Class
      [ERROR] Line 68:  The method isAssignableFrom(Class) is undefined for the type Class<Serializable>
      [ERROR] Line 113:  The method getClassLoader() is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/converters/reflection/FieldDictionary.java'
      [ERROR] Line 136:  The method getDeclaredFields() is undefined for the type Class
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/io/xml/XmlFriendlyNameCoder.java'
      [ERROR] Line 278:  The method clone() is undefined for the type Object
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/core/util/XmlHeaderAwareReader.java'
      [ERROR] Line 100:  The method isWhitespace(char) is undefined for the type Character
      [ERROR] Line 109:  The method isWhitespace(char) is undefined for the type Character
      [ERROR] Line 124:  The method isWhitespace(char) is undefined for the type Character
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/io/xml/XppReader.java'
      [ERROR] Line 17:  The import org.xmlpull cannot be resolved
      [ERROR] Line 18:  The import org.xmlpull cannot be resolved
      [ERROR] Line 32:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 42:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 54:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 56:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 60:  XmlPullParserException cannot be resolved to a type
      [ERROR] Line 80:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 80:  The method createParser() from the type XppReader refers to the missing type XmlPullParser
      [ERROR] Line 82:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 84:  XmlPullParserException cannot be resolved to a type
      [ERROR] Line 93:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 96:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 96:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 96:  Class<XmlPullParser> cannot be resolved to a type
      [ERROR] Line 109:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 110:  XmlPullParser cannot be resolved
      [ERROR] Line 111:  XmlPullParser cannot be resolved
      [ERROR] Line 113:  XmlPullParser cannot be resolved
      [ERROR] Line 114:  XmlPullParser cannot be resolved
      [ERROR] Line 116:  XmlPullParser cannot be resolved
      [ERROR] Line 118:  XmlPullParser cannot be resolved
      [ERROR] Line 123:  XmlPullParserException cannot be resolved to a type
      [ERROR] Line 131:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 135:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 139:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 143:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 147:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 151:  XmlPullParser cannot be resolved to a type
      [ERROR] Line 155:  XmlPullParser cannot be resolved to a type
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/io/xml/PrettyPrintWriter.java'
      [ERROR] Line 267:  The method isDefined(char) is undefined for the type Character
      [ERROR] Line 267:  The method isISOControl(char) is undefined for the type Character
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/core/util/Pool.java'
      [ERROR] Line 49:  The method wait() is undefined for the type Object
      [ERROR] Line 68:  The method notify() is undefined for the type Object
   [ERROR] Errors in 'jar:file:/C:/Users/YRC/Downloads/xstream-1.4.4.jar!/com/thoughtworks/xstream/core/util/Cloneables.java'
      [ERROR] Line 32:  Cannot invoke clone() on the array type Object[]
      [ERROR] Line 44:  The method getMethod(String, Class[]) is undefined for the type Class<capture#4-of ? extends Object>
   [ERROR] Cannot proceed due to previous errors

2 个答案:

答案 0 :(得分:3)

你不能在GWT中使用反射;

  • getDeclaredFields

  • getDeclaredMethod

  • 的forName

  • getConstructor

和喜欢......都是反思性呼叫;

答案 1 :(得分:0)

GWt不支持客户端的所有代码,因此我们可以在服务器中使用它。  GWT支持RPC。 http://www.vogella.com/articles/GWT/article.html或参考 https://developers.google.com/web-toolkit/doc/latest/DevGuideServerCommunication

你需要做的是在lib中包含所有jar并配置构建路径,并且只在服务器端使用此代码。