Should I care my libraries in SFS2X/extensions/__lib__ are different version with jar SFS2x/lib?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

crimsonfantasy
Posts: 13
Joined: 21 Feb 2018, 03:02

Should I care my libraries in SFS2X/extensions/__lib__ are different version with jar SFS2x/lib?

Postby crimsonfantasy » 25 Oct 2018, 13:21

Hi:
Let me take a simple example.
If I use jackson-databind-2.9.7.jar in my project, but SmartFox 2X core current do use jackson-databind-2.8.2.jar.
I deployed jackson-databind-2.9.7.jar in the SFS2X/extensions/__lib__.
I known SmartFox run my App using ClassLoader A, and using ClassLoader B on SmartFox instance. doesn't it?
Is going to be some potential problem?
Thank you. Respect!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Should I care my libraries in SFS2X/extensions/__lib__ are different version with jar SFS2x/lib?

Postby Lapo » 25 Oct 2018, 14:55

Hi,
class loading in Java is "parent first", meaning that the current class loader will delegate the loading to its parent class loader (if exists) and, if all else fails, it will try to load from the current class loader.

Because of this, if you want to run different versions of libraries already existing in SFS2X/lib/ it is going to be tricky.

1) If you deploy them in the same jar with your Extension they won't be loaded because the SFS2X version already exist in top class loader, which will load them first.

2) If you deploy them under extensions/__lib__/ you're essentially deploying a different version of a lib in the top classloader which means that "luck" will dictate which one gets seen.
Typically this results in which of the two versions the class loader sees first.

So the actual solution in this scenario would be to replace the SFS2X/lib/ library directly.
You can try to do that and see if everything works the same. Usually it does if the new library doesn't break any previous compatibility.

Hope it's clear.
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 42 guests