Possible to have super sources in a common package in a library?

59 views
Skip to first unread message

Neil Aggarwal

unread,
Dec 15, 2024, 4:35:58 PM12/15/24
to google-we...@googlegroups.com
Hello all:

I am using references to some external libraries in my data classes.

For example, the base class for my puzzle objects is
com.propfinancing.puzzle.Puzzle

I created a module for it by creating a Puzzle.gwt.xml
file in the same directory as its source code.

The entire com.propfinancing hierarchy is packaged into
two jars, one with the compiled code and another with the
sources.

I am using those jars in a different project so I put an
<inherits name="com.propfinancing.puzzle.Puzzle"/>
in that project's gwt.xml file.

One of the classes in that library is com.propfinancing.puzzle.Point
which is referenced by a subclass of com.propfinancing.puzzle.Puzzle.
It uses a class com.jme3.math.Vector3f which is from an external library.
I don't control that library and they did not package it for GWT.

So, I want to create a super source version of Vector3f for GWT.
I can create it in
com.propfinancing.puzzle.superSource.com.jme3.math.Vector3f
and put <super-source path="superSource"/> in the Puzzle.gwt.xml file.

But that is specific to the Puzzle.gwt.xml module. I can imagine in the
future
that I might have another module which references Vector3f and then I will
have to create a separate Vector3f file for it.

I think it would be better to create one file as
com.propfinancing.gwt.superSource.com.jme3.math.Vector3f
which I can then use in multiple modules.

This looks like it currently falls outside the scope of GWT.
Is that correct?

Thank you,
Neil

--
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
We offer 30 year loans on single family houses!

Neil Aggarwal

unread,
Dec 16, 2024, 1:25:02 AM12/16/24
to google-we...@googlegroups.com
I think I might have figured it out.

I created a file com/propfinancing/gwt/GWT.gwt.xml and put this
content in it:

<module>
<source path=""/>
<super-source path="superSource"/>
</module>

And then I put <inherits name="com.propfinancing.gwt.GWT"/> in
my outer project.

I have a bunch of other errors to resolve before I can test it, but the
compiler
is no longer telling me it can't find the source code for that class.

Jens

unread,
Dec 16, 2024, 9:54:57 AM12/16/24
to GWT Users
You only have to super-source something in GWT if the Java code is not compatible with GWT. That means if the Java code uses for example reflection or a class that GWT itself does not emulate. Super-source means you override a given Java class with different source code that is compatible with GWT compiler. So basically super sourcing is what GWT itself does to let you use all the (super sourced / emulated) Java classes from the Java SDK. For example java.util.Date in Java SDK uses Java Calendar and TimeZone but the super sourced version of it in GWT delegates to the native JavaScript Date provided by browsers. So the implementation of the API is very different.

If you have a 3rd party library and you are using some classes of it then you should first check if the source code of these classes is actually GWT compatible. If it is compatible (no reflection, no usage of classes that GWT does not emulate) then you only need the 3rd party library and  3rd party library sources as "compile" dependency. In your own code you create a /com/jme3/math/Jme3Math.gwt.xml file and add <source path="."/>. This would make everything below com.jme3.math package visible to GWT compiler once you inherit that GWT module. If you only want to include certain classes of that library you can use include/exclude patterns as well. Alternatively you can create your own Jme3Math-gwt project/module (in a multi-module build setup) with just the *.gwt.xml file and the correct classes+sources dependencies and then you use that project as a dependency. 

If you really have to super source the Vector3f class then you pretty much do the same as above but instead of <super-source> and provide a GWT compiler compatible implementation of Vector3f.

--- J.

Neil Aggarwal

unread,
Dec 16, 2024, 10:52:18 AM12/16/24
to google-we...@googlegroups.com

> If you have a 3rd party library and you are using some classes of it then you should first check

> if the source code of these classes is actually GWT compatible

 

That is an interesting point.  I might be able to package classes from third party
libraries into their own separate modules.

 

Unfortunately, in this case, com.jme3.math.Vector3f uses java.util.Logging
which is not supported.

Neil Aggarwal

unread,
Dec 16, 2024, 12:05:45 PM12/16/24
to google-we...@googlegroups.com
Apparenty the solution I tried below did not work.

I am getting this error from the GWT compiler:

Tracing compile failure path for type 'com.jme3.math.Vector3f'
[INFO] [ERROR] Errors in
'jar:file:/C:/Users/neil/.m2/repository/com/propfinancing/pflib/6.0.0/pfli
b-6.0.0-sources.jar!/com/propfinancing/gwt/superSource/com/jme3/math/Vecto
r3f.java'
[INFO] [ERROR] Line 4: The declared package
"com.propfinancing.gwt.superSource.com.jme3.math" does not match the
expected package "com.jme3.math"

I thought since I declared superSource, it was supposed to remove the
prefix from the package.

Thank you,
Neil

--
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
We offer 30 year loans on single family houses!

> -----Original Message-----
> From: Neil Aggarwal <ne...@propfinancing.com>
> Sent: Monday, December 16, 2024 12:24 AM
> To: 'google-we...@googlegroups.com' <google-web-
> too...@googlegroups.com>
> Subject: RE: Possible to have super sources in a common package in a
library?
>
> I think I might have figured it out.
>
> I created a file com/propfinancing/gwt/GWT.gwt.xml and put this content
in it:
>
> <module>
> <source path=""/>
> <super-source path="superSource"/>
> </module>
>
> And then I put <inherits name="com.propfinancing.gwt.GWT"/> in
> my outer project.
>
> I have a bunch of other errors to resolve before I can test it, but the
compiler is no
> longer telling me it can't find the source code for that class.
>

Jens

unread,
Dec 16, 2024, 1:03:34 PM12/16/24
to GWT Users
> Unfortunately, in this case, com.jme3.math.Vector3f uses java.util.Logging
which is not supported.


> I thought since I declared superSource, it was supposed to remove the
prefix from the package.

No. In your thinking you should treat /com/propfinancing/gwt/superSource as an ordinary source folder, just like src/main/java for example. So the package declaration in any file in the super-source folder should not contain the path prefix. Your superSource folder is the root.

-- J.

Neil Aggarwal

unread,
Dec 16, 2024, 1:20:20 PM12/16/24
to google-we...@googlegroups.com

> the package declaration in any file in the super-source folder should not contain the path prefix.

> Your superSource folder is the root.

 

Got it.  I missed that.

 

I updated the package and added an exclusion to the maven compiler for the
superSource files and it seems to be working.

 

Thanks!

Reply all
Reply to author
Forward
0 new messages