Can I re-use the same API for code that runs via GWT in the browser?
Experiment:
- Check out source code from http://github.com/ceki/slf4j from trunk on 2010-06-17
- Add GWT dependencies in Maven, add get-maven plugin in POM
- Create a dummy entry point and a get.xml file
- Run mvn gwt:compile
[INFO] Compiling module org.slf4j.GWTTest
[INFO] Validating newly compiled units
[INFO] [ERROR] Errors in 'file:/O:/2010/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java'
[INFO] [ERROR] Line 28: The import java.net cannot be resolved
[INFO] [ERROR] Line 207: The method getClassLoader() is undefined for the type Class
[INFO] [ERROR] Line 217: URL cannot be resolved to a type
[INFO] [ERROR] Line 217: URL cannot be resolved to a type
[INFO] [ERROR] Errors in 'file:/O:/2010/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java'
[INFO] [ERROR] Line 27: The import java.text cannot be resolved
[INFO] [ERROR] Errors in 'file:/O:/2010/slf4j-api/src/main/java/org/slf4j/MDC.java'
[INFO] [ERROR] Line 74: No source code is available for type java.lang.NoClassDefFoundError; did you forget to inherit a required module?
[INFO] [ERROR] Errors in 'file:/O:/2010/slf4j-api/src/main/java/org/slf4j/MarkerFactory.java'
[INFO] [ERROR] Line 53: No source code is available for type java.lang.NoClassDefFoundError; did you forget to inherit a required module?
[INFO] [ERROR] Errors in 'file:/O:/2010/slf4j-api/src/main/java/org/slf4j/helpers/BasicMDCAdapter.java'
[INFO] [ERROR] Line 47: No source code is available for type java.lang.InheritableThreadLocal
[INFO] [ERROR] Errors in 'file:/O:/2010/slf4j-api/src/main/java/org/slf4j/helpers/NamedLoggerBase.java'
[INFO] [ERROR] Line 40: No source code is available for type java.io.ObjectStreamException; did you forget to inherit a required module?
These errors show that SLF4j is not GWT-ready by itself. Now there are two options:
- Create a drop-in replacement that implements some parts differently
- Create a new SLF4j-like API which IS GWT-ready
No comments:
Post a Comment