Using both java and scala libraries needed?

trickydee
Posts: 33
Joined: Fri Jul 17, 2015 8:58 am

Using both java and scala libraries needed?

Postby trickydee » Mon Aug 10, 2015 8:12 am

Is shipping of the Java library really needed when bundling the Scala library?
I'm asking this as I see many shared packages and class names so it's not clear is the Scala library just a wrapper or complete replacement.
If it's a wrapper, why not extend the java library and have only specific Scala code in that lib?

Regards

luca.passani
Posts: 65
Joined: Thu May 19, 2011 2:49 pm

Re: Using both java and scala libraries needed?

Postby luca.passani » Mon Aug 10, 2015 9:56 am

Hello, thank you for your question. The Scala Library is a wrapper around the Java library and the lib only contains Scala specific parts.

I hope this answers your question. If not, can you elaborate a bit more about what you are trying to achieve and how you envision things to be made differently?

Thanks

trickydee
Posts: 33
Joined: Fri Jul 17, 2015 8:58 am

Re: Using both java and scala libraries needed?

Postby trickydee » Mon Aug 10, 2015 12:14 pm

luca.passani wrote:Hello, thank you for your question. The Scala Library is a wrapper around the Java library and the lib only contains Scala specific parts.

I hope this answers your question. If not, can you elaborate a bit more about what you are trying to achieve and how you envision things to be made differently?

Thanks
Hi Luca,
I think that depends on your definition of a wrapper or at least how one is supposed to use the libraries. For example, If one looks at the internals of both jars, they both contain the Device interface (both of them defining the same thing), AbstractCapabilityHolder, ... almost everything. So, if we put both jars on the classpath, how do you know which of the classes will be used by the JRE? This typically leads to class cast exceptions. Essentially same classes loaded by different classloaders which even though share package and name are essentially different classes. You should either make a self-contained scala library (which I think is the case, but that's difficult to say as only scientia knows its implementation) and you should document that it is the only dependency which is needed, or you should put in the scala library only the scala code referencing the original classes from the java jar.
One side-effect from sharing the same package and class names is that if one wants to create one-jar or shaded libraries with both libs we will inevitably get conflicts.

Cheers


Who is online

Users browsing this forum: No registered users and 3 guests