new to GWT, trying to determine the cause of compilation errors for existing software project

198 views
Skip to first unread message

otakuj462

unread,
Apr 25, 2009, 10:54:37 AM4/25/09
to Google Web Toolkit
Hi,

I'm quite new to GWT, and I'm trying to diagnose the source of some
compilation errors for an existing open source project that leverages
GWT (incidentally, for my Google Summer of Code project). Without
going into the details of the purpose of the application, I was hoping
someone could offer some general guidance as to why these particular
errors might be occuring.

The errors occur when attempting to compile certain method calls on
instances of class OutputStream. So, for example:

[java] [ERROR] Errors in 'file:/C:/workspace-gsoc/
org.eclipse.swt.e4.jcl/src/gwt/extended/javascript/java/io/
OutputStreamWriter.java'
[java] [ERROR] Line 31: The method close() is undefined
for the type OutputStream
[java] [ERROR] Line 42: The method flush() is undefined
for the type OutputStream
[java] [ERROR] Line 56: The method write(byte[], int,
int) is undefined for the type OutputStream

This is on GWT 1.5. I also tried it on GWT 1.6, and I believe it threw
the same error. I know that on GWT 1.6, OutputStream is emulated
[http://code.google.com/webtoolkit/doc/1.6/RefJreEmulation.html], but
I'm not sure about 1.5.

I'd appreciate any guidance anyone can offer. Thanks,

Jake

Vitali Lovich

unread,
Apr 25, 2009, 2:46:09 PM4/25/09
to Google-We...@googlegroups.com
OutputStream is in GWT 1.5.  OutputStream is an abstract class - are you overriding the methods it throws errors on?  eclipse is good about telling you & auto-fixing stuff like that.  can you post your implementation of OutputStreamWriter if this isn't the problem?

Thomas Broyer

unread,
Apr 25, 2009, 6:07:16 PM4/25/09
to Google Web Toolkit
As the doc says, no method is emulated on OutputStream, only the
(default) constructor:
http://code.google.com/p/google-web-toolkit/source/browse/releases/1.6/user/super/com/google/gwt/emul/java/io/OutputStream.java

Actually OutputStream is only there to support System.out.print()/
println(), so that you could use it in your code and get it compiled
to a no-op in JavaScript, without compile error.

> I'd appreciate any guidance anyone can offer.

Provide your own OutputStream emulation (and make sure it is picked in
place of the one packaged within GWT)

For instance, this is the emulated OutputStream for an Adobe AIR
environment:
http://code.google.com/p/gwt-in-the-air/source/browse/trunk/super/net/ltgt/gwt/air/emul/java/io/OutputStream.java

Jake

unread,
Apr 26, 2009, 2:34:24 AM4/26/09
to Google Web Toolkit
Thomas and Vitali, thank you for the expert advice. I believe I'm
beginning to put this problem into perspective. Here is the
OutputStream implementation bundled with this project:

http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/bundles/org.eclipse.swt.e4.jcl/src/gwt/extended/common/java/io/OutputStream.java?view=markup

Here's the top-level module file I'm attempting to compile:

http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/examples/org.eclipse.swt.e4.examples/dojo/controlexample/controlexample.gwt.xml?view=markup

Finally, here's the module file which should pull in
OutputStream.java:

http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/examples/org.eclipse.swt.e4.examples/dojo/controlexample/controlexample.gwt.xml?view=markup

My theory right now is that for some reason, our project's custom
OutputStream.java is not being found or used, and is therefore being
replace by GWT's built-in OutputStream class. But I'm not sure how
that could occur, as I know that GWT errors out if I specify a module
that it cannot find. So it seems that it must have found the module,
but is for some reason not using it in favor of its built-in
OutputStream class. Very strange.

If you have any idea as to why this might be occurring, or how to
correct it, I would greatly appreciate it if you would let me know.
Thanks,

Jake
> (default) constructor:http://code.google.com/p/google-web-toolkit/source/browse/releases/1....
>
> Actually OutputStream is only there to support System.out.print()/
> println(), so that you could use it in your code and get it compiled
> to a no-op in JavaScript, without compile error.
>
> > I'd appreciate any guidance anyone can offer.
>
> Provide your own OutputStream emulation (and make sure it is picked in
> place of the one packaged within GWT)
>
> For instance, this is the emulated OutputStream for an Adobe AIR
> environment:http://code.google.com/p/gwt-in-the-air/source/browse/trunk/super/net...

Vitali Lovich

unread,
Apr 26, 2009, 5:21:09 PM4/26/09
to Google-We...@googlegroups.com
I thought you were trying to use the built-in OutputStream.  Are you sure the package name on your class is right?  Shouldn't it be gwt.extended.common.java.io?

Thomas Broyer

unread,
Apr 26, 2009, 5:56:19 PM4/26/09
to Google Web Toolkit


On 26 avr, 08:34, Jake <otakuj...@gmail.com> wrote:
> Thomas and Vitali, thank you for the expert advice. I believe I'm
> beginning to put this problem into perspective. Here is the
> OutputStream implementation bundled with this project:
>
> http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/bundle...
>
> Here's the top-level module file I'm attempting to compile:
>
> http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/exampl...
>
> Finally, here's the module file which should pull in
> OutputStream.java:
>
> http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/exampl...
>
> My theory right now is that for some reason, our project's custom
> OutputStream.java is not being found or used, and is therefore being
> replace by GWT's built-in OutputStream class. But I'm not sure how
> that could occur, as I know that GWT errors out if I specify a module
> that it cannot find. So it seems that it must have found the module,
> but is for some reason not using it in favor of its built-in
> OutputStream class. Very strange.

If you re-define/emulate Java Runtime classes, you have to put them in
a <super-source/>

http://code.google.com/webtoolkit/doc/1.6/DevGuideOrganizingProjects.html#DevGuideModuleXml

Jake

unread,
Apr 26, 2009, 5:56:53 PM4/26/09
to Google Web Toolkit
I originally thought that I was trying to use the built-in
OutputStream, because I believed that it implemented
OutputStream.write and the other methods that GWT was having trouble
with, but now I understand that the built-in OutputStream does not
implement those methods, and thus a custom OutputStream must be
written. This is coherent with what I have found already existing in
the project, e.g. a custom OutputStream. So I believe that the problem
lies in that GWT is for some reason not using the custom
OutputStream.

I'm fairly certain the package name is correct, as src/gwt/extended/
common is a source folder, and not a package (also, Eclipse complains
when I change the package name).

Do you have any ideas as to why GWT might not be using the custom
OutputStream?

Please let me know. Thanks,

Jake

On Apr 26, 5:21 pm, Vitali Lovich <vlov...@gmail.com> wrote:
> I thought you were trying to use the built-in OutputStream.  Are you sure
> the package name on your class is right?  Shouldn't it be
> gwt.extended.common.java.io?
>
> On Sun, Apr 26, 2009 at 2:34 AM, Jake <otakuj...@gmail.com> wrote:
>
> > Thomas and Vitali, thank you for the expert advice. I believe I'm
> > beginning to put this problem into perspective. Here is the
> > OutputStream implementation bundled with this project:
>
> >http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/bundle...
>
> > Here's the top-level module file I'm attempting to compile:
>
> >http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/exampl...
>
> > Finally, here's the module file which should pull in
> > OutputStream.java:
>
> >http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/exampl...

Jake

unread,
Apr 26, 2009, 5:58:24 PM4/26/09
to Google Web Toolkit
@Thomas: That's probably exactly it. I'll review the documentation and
report back on whether I succeeded.

Thank you for your help,

Jake
> http://code.google.com/webtoolkit/doc/1.6/DevGuideOrganizingProjects....

Jake

unread,
Apr 26, 2009, 7:17:31 PM4/26/09
to Google Web Toolkit
OK, so I read through the docs you linked to, and also took a look at
the way you were using super-source in Emulation.gwt.xml in gwt-in-the-
air:

http://code.google.com/p/gwt-in-the-air/source/browse/trunk/super/net/ltgt/gwt/air/emul/Emulation.gwt.xml

I attempted to do the same thing with extended_JCL.gwt.xml, which
pulls in the custom OutputStream class, as well as other resources:

http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/bundles/org.eclipse.swt.e4.jcl/src/gwt/extended/common/extended_JCL.gwt.xml?view=markup

I changed it to:

<module>
<source path="com/ibm/icu/text"/>
<super-source/>
</module>

I'm now getting error messages like this:

[java] [ERROR] Errors in 'jar:file:/C:/workspace-gsoc/
DojoResources/gwt/gwt-user.jar!/com/google/gwt/emul/java/util/
Iterator.java'
[java] [ERROR] Line 16: The declared package "java.util"
does not match the expected package "com.google.gwt.emul.java.util"
[java] [ERROR] Errors in 'jar:file:/C:/workspace-gsoc/
DojoResources/gwt/gwt-user.jar!/com/google/gwt/benchmarks/translatable/
com/google/gwt/benchmarks/client/Benchmark.java'
[java] [ERROR] Line 16: The declared package
"com.google.gwt.benchmarks.client" does not match the expected package
"com.google.gwt.benchmarks.translatable.com.google.gwt.benchmarks.client"

As this is getting a bit complex, I feel like the thing to do is try
to use super-source in a reduced case. But, I just have one question
right now, which is, does super-source knock out *all* of the built-in
emulation provided by GWT by "re-rooting" a source path? This is how I
would interpret the above error output. If this is the case, is it not
safe to use super-source more than once in a project?

I'd greatly appreciate it if you would let me know what you think.
Thanks,

Jake

Thomas Broyer

unread,
Apr 27, 2009, 5:20:57 AM4/27/09
to Google Web Toolkit


On 27 avr, 01:17, Jake <otakuj...@gmail.com> wrote:
> OK, so I read through the docs you linked to, and also took a look at
> the way you were using super-source in Emulation.gwt.xml in gwt-in-the-
> air:
>
> http://code.google.com/p/gwt-in-the-air/source/browse/trunk/super/net...
>
> I attempted to do the same thing with extended_JCL.gwt.xml, which
> pulls in the custom OutputStream class, as well as other resources:
>
> http://dev.eclipse.org/viewcvs/index.cgi/e4/org.eclipse.e4.swt/bundle...
>
> I changed it to:
>
> <module>
>         <source path="com/ibm/icu/text"/>

If those classes are emulated versions of "pure Java" APIs, you should
also put them in <super-source> (and given that you declare the
current package/path as a <super-source>, they actually are already;
so: just remove this line)

>         <super-source/>
> </module>
>
> I'm now getting error messages like this:
>
>         [java]    [ERROR] Errors in 'jar:file:/C:/workspace-gsoc/
> DojoResources/gwt/gwt-user.jar!/com/google/gwt/emul/java/util/
> Iterator.java'
>         [java]       [ERROR] Line 16: The declared package "java.util"
> does not match the expected package "com.google.gwt.emul.java.util"

You must not compile the emulation classes using javac, only when
processed by the GWTCompiler (1.5) or Compiler (1.6) tools or the
hosted mode.
(GWT uses two "source trees" to make it clearer and easier to manage:
src and super; super is added to the classpath only when using
GWTCompiler/Compiler or GWTShell/HostedMode)


Reply all
Reply to author
Forward
0 new messages