Page 1 of 1

where is com.smartfoxserver.grid package?

Posted: 20 Nov 2017, 17:37
by Boorik
Hi,

I compile server side code with haxe. I'm facing an issue where compiler doesn't find any of the com.smartfoxserver.grid package files. In most of the cases I just have to add the matching jar file as dependency. But I can't find in what jar file is this package.
Can you help me on this?

Best regards

Re: where is com.smartfoxserver.grid package?

Posted: 20 Nov 2017, 17:58
by Lapo
Hi,
does Haxe compile into Java? Cool, I didn't know :)

Can you tell me exactly what SFS2X version are you using? Also what is exactly the class(es) that are not found?

Thanks

Re: where is com.smartfoxserver.grid package?

Posted: 22 Nov 2017, 08:20
by Boorik
Hi!

I use sfs2x 2.13

In haxe compilation we can add command like :
-java-lib whatever.jar
It creates extern definitions of classes and look recursively for dependencies.

The class it doesn't find :
Type not found : com.smartfoxserver.grid.events.IGridEvent
and everything in the grid package. I don't know why. Maybe the classes are protected or are located in another jar file.
When I look at the javadoc I don't find a definition for these classes.

Is there a definition somewhere?

Thanks

Re: where is com.smartfoxserver.grid package?

Posted: 22 Nov 2017, 09:11
by Lapo
Sorry, those classes are not included in SFS2X because they are not used by the server.

You may "fool" the compiler by creating a jar with that package an interface inside it.
The interface could be defined like this:

Code: Select all

public interface IGridEvent
{
   String getName();
   ISFSObject getParams();
}


Hope it helps

Re: where is com.smartfoxserver.grid package?

Posted: 22 Nov 2017, 11:42
by Boorik
Ok thank you,

I solved it by stopping the compiler earlier :
getGridManager return a com.smartfoxserver.v2.grid.IGridManager
so the compiler go to this direction and stuck on missing definitions.
I made a handmade extern that solve the issue, changing the IGridManager to Dynamic prevent the compiler to go further.
https://github.com/boorik/smartfox-haxe-server/blob/master/com/smartfoxserver/v2/SmartFoxServer.hx#L9

I wonder how the java compiler handle this lack of definition.

Best regards.

Re: where is com.smartfoxserver.grid package?

Posted: 22 Nov 2017, 14:32
by Boorik
I mean how are you able to compile an extension the "normal" way just using sfs2x and sfs2x-core jars without the same exception?

Haxe compiler generate .java files and then do :
javac "-sourcepath" "src" "-d" "obj" "-g" "-classpath" "./lib/sfs2x.jar:./lib/sfs2x-core.jar:./lib/slf4j-api-1.7.5.jar:./lib/geoip2-2.8.0.jar:./lib/mailapi.jar" "@cmd"

That seems to be like "normal" way but generate errors without using my extern fix.

Re: where is com.smartfoxserver.grid package?

Posted: 22 Nov 2017, 16:31
by Lapo
Boorik wrote:I mean how are you able to compile an extension the "normal" way just using sfs2x and sfs2x-core jars without the same exception?

Haxe compiler generate .java files and then do :
javac "-sourcepath" "src" "-d" "obj" "-g" "-classpath" "./lib/sfs2x.jar:./lib/sfs2x-core.jar:./lib/slf4j-api-1.7.5.jar:./lib/geoip2-2.8.0.jar:./lib/mailapi.jar" "@cmd"

That seems to be like "normal" way but generate errors without using my extern fix.

Hi,
the java compiler looks for classes that are referenced in your code. Other than that it won't complain.

For instance, I am not sure why you need to reference the "geopip" jar ... unless you're importing some of those classes directly in code?
For extensions you typically just need to tartget "sfs2x" and "sfs2x-core"

Cheers

Re: where is com.smartfoxserver.grid package?

Posted: 23 Nov 2017, 11:49
by Boorik
Ok,

The issue comes when haxe generate java classes. It's a pure haxe issue. That will be fixed in the future version.
Here is the related thread : https://github.com/HaxeFoundation/haxe/issues/3397
I will say when problem will be fixed. Meanwhile I will publish some externs that fix this issue.

Re: where is com.smartfoxserver.grid package?

Posted: 23 Nov 2017, 12:52
by Lapo
Thanks for the feedback. Good to know.