News for hackers. Stuff that matters.
Re:Guava: Google core libraries for Java by bradleyjg on Wednesday November 08, 2023 @03:43PM (#38196673)
This used to be much more valuable in older versions of java. But some of the most useful parts now have analogues in the standard library.
Re:Guava: Google core libraries for Java by shrdlu2 on Wednesday November 08, 2023 @04:36PM (#38197447)
That, and also when caffeine came out it replaced one of the major uses (caching) of guava.

https://github.com/ben-manes/caffeine

Re:Guava: Google core libraries for Java by plandis on Wednesday November 08, 2023 @07:41PM (#38199367)
Yeah this was about the last piece I’d really go to Guava for and Caffeine has been better for years at this point.
Re:Guava: Google core libraries for Java by happymellon on Wednesday November 08, 2023 @03:45PM (#38196687)
Indeed, and now it's just a hassle dealing with Guava CVEs that get flagged up for functionality that doesn't actually require Guava.
Re:Guava: Google core libraries for Java by cosmotic on Wednesday November 08, 2023 @03:51PM (#38196777)
And dealing with mismatching guava versions brought in as transitive dependencies.
Re:Guava: Google core libraries for Java by mey on Wednesday November 08, 2023 @03:58PM (#38196889)
Even better is getting Gradle/Maven to correctly pull "plain" vs "Android" versions of the package instead of them just publishing the diverging code base as two repository packages.

https://github.com/google/guava/issues/2914

Re:Guava: Google core libraries for Java by erik_seaberg on Wednesday November 08, 2023 @04:03PM (#38196974)
I wish Guava weren’t just one library that breaks backward compatibility casually. They follow semver, but the major version changes so often that it’s not that helpful (they’re up to 32.x!)
Re:Guava: Google core libraries for Java by falserum on Wednesday November 08, 2023 @04:30PM (#38197376)
What about just staying with older version, if you don’t have capacity to upgrade?
Re:Guava: Google core libraries for Java by dtech on Wednesday November 08, 2023 @04:45PM (#38197556)
The problem is conflicting transitives, lib A depends on 29, B on 31.
Re:Guava: Google core libraries for Java by ygra on Wednesday November 08, 2023 @05:07PM (#38197808)
Does Java have a solution for such things where both libs can use their own version without them conflicting (unless they hand out Guava types to others, of course)? Custom class loaders?
Re:Guava: Google core libraries for Java by mrudolph22 on Wednesday November 08, 2023 @05:27PM (#38198075)
Java doesn’t have a universal practical solution for this. Principled solutions based on custom class loaders (such as OSGi) added tremendous complexity and created more problems than they solved. Other solutions such as shading (renaming classes and their usages to prevent name conflicts between different versions) work in some cases but have their own limitations and drawbacks.
Re:Guava: Google core libraries for Java by aramattamara on Wednesday November 08, 2023 @05:48PM (#38198345)
What about Java modules (aka JEP-200, aka Project Jigsaw, completed in 2017)?

Used it for JavaFX apps with no problems.

Re:Guava: Google core libraries for Java by mrudolph22 on Thursday November 09, 2023 @12:48AM (#38201623)
Java modules are fine but don’t offer a solution for version conflicts.
Re:Guava: Google core libraries for Java by ianlevesque on Wednesday November 08, 2023 @05:28PM (#38198096)
Yes custom class loaders can solve this. Eclipse had an entire OSGI module system that did this among other things. In general though Java (and Kotlin) have been trending toward simpler and lighter though for years and I’d recommend just sorting out your dependencies, even drop some, to avoid that kind of thing.
Re:Guava: Google core libraries for Java by aramattamara on Wednesday November 08, 2023 @05:46PM (#38198323)
Yes, it's called Java modules (aka JEP-200).

Although people often skip it and put everything in one module. It was released in Java 9 (started in 2014 and completed fully in 2017).

Re:Guava: Google core libraries for Java by vips7L on Wednesday November 08, 2023 @06:12PM (#38198599)
AFAIK Jigsaw solves a different problem. The transitive dep will still be found on the module path.
Re:Guava: Google core libraries for Java by Someone on Wednesday November 08, 2023 @06:47PM (#38198918)
In some cases, shading can also help. That, basically, renames a classes used in a jar. It has to be done by the creator of the jar, though.

https://stackoverflow.com/a/49811665:

“If your uber JAR is likely to be used as a dependency in another application then there's a risk that the versions of the dependent classes in the uber JAR might clash with versions of those same dependencies in this other application. Shading helps to avoid any such issue by renaming the packages within the uber JAR”

> unless they hand out Guava types to others, of course

You still can hand out guava objects to others, as long as you hand them out as being of a standard Java interface.

That will work as long as the receiver of the type uses instanceof with a class type or reflection, so it is a bit brittle. Technically, any breakage would indicate a bug in the receiving code, but fixing it cleanly may be impossible.

Re:Guava: Google core libraries for Java by paulddraper on Wednesday November 08, 2023 @06:47PM (#38198926)
AKA "diamond dependencies"

Java 9 modules address this.

Re:Guava: Google core libraries for Java by macksd on Wednesday November 08, 2023 @04:46PM (#38197559)
That gets tough with transitive dependencies and the frequent CVEs.
Re:Guava: Google core libraries for Java by paulddraper on Wednesday November 08, 2023 @06:46PM (#38198915)
> What about just staying with older version

See grandparent: "dealing with mismatching guava versions brought in as transitive dependencies"

Re:Guava: Google core libraries for Java by vips7L on Wednesday November 08, 2023 @03:51PM (#38196786)
or dealing with the 100 conflicting versions of Guava being pulled in as transitive dependencies.
Re:Guava: Google core libraries for Java by esafak on Wednesday November 08, 2023 @03:57PM (#38196876)
I dealt with a repo that admitted only one version of each library, so we were stuck with an old version of Guava because it was used all over the place, and upgrading it would have required a lot of refactoring which was not worth anyone's time. One reason to prefer smaller libraries. https://en.wikipedia.org/wiki/Public_goods_game
Re:Guava: Google core libraries for Java by nikanj on Wednesday November 08, 2023 @04:00PM (#38196926)
CVEs are terrible nowadays. Any enterprising ”security researcher” can file one against your project, and the CVE aggregators will flat refuse to take it down. See for example CVE-2023-29827 or CVE-2023-35116
Re:Guava: Google core libraries for Java by happymellon on Thursday November 09, 2023 @12:25AM (#38201497)
Unfortunately that doesn't prevent "security" from putting checks in the build pipelines.
Re:Guava: Google core libraries for Java by p1mrx on Wednesday November 08, 2023 @05:07PM (#38197811)
Does the standard library have a function to parse IP addresses without querying DNS? InetAddresses.forString() was the main reason I used Guava in the past.
Re:Guava: Google core libraries for Java by vips7L on Wednesday November 08, 2023 @06:23PM (#38198712)
InetAddress::getByName
Re:Guava: Google core libraries for Java by latestthing on Wednesday November 08, 2023 @06:26PM (#38198743)
This queries dns in some cases
Re:Guava: Google core libraries for Java by vips7L on Wednesday November 08, 2023 @09:42PM (#38200435)
Not when it’s an IP literal.
Re:Guava: Google core libraries for Java by p1mrx on Thursday November 09, 2023 @03:03AM (#38202314)
What if you don't know if it's an IP literal?
Re:Guava: Google core libraries for Java by johnasmith on Wednesday November 08, 2023 @06:45PM (#38198900)
One of the newer things I've appreciated from guava is ListenableFuture to Kotlin suspend functions interop.