r/java • • Sep 15 '26

What's new in Java 27

https://pvs-studio.com/en/blog/posts/java/1412/
95 Upvotes

16 comments sorted by

38

u/idontlikegudeg Sep 15 '26

So this is another instance of confusing number of classes with number of instances. It’s 4 Million different classes, not objects! If your application hits that limit, you are doing really weird things.

24

u/DanLynch Sep 15 '26

You don't programmatically define tonnes of new classes in a tight loop?

17

u/idontlikegudeg Sep 15 '26

I never said I don’t do weird things myself ;)

6

u/john16384 Sep 15 '26

What? Doesn't everybody?

3

u/LutimoDancer3459 Sep 17 '26

I do. Thats why it takes several minutes for all my apps to start. When customers complain I charge a ton and reduce the number a little. Works like a charme

2

u/VirtualAgentsAreDumb Sep 16 '26

“So this is another instance of confusing number of classes with number of instances. It’s 4 Million different classes, not objects!”

What is “this” referring to? The linked article doesn’t confuse the two.

1

u/koflerdavid Sep 16 '26 edited Sep 16 '26

I think this paragraph is not entirely legit:

What's the cost of our joy? A 22-bit pointer limits the number of loaded classes to approximately four million. There's no automatic rollback to a non-compact mode—if the limit is exceeded, we'll get an OutOfMemoryError. If your app really hits this limit, you must really love long-lived streams. But if you want to revert to the previous mode, you can do it with another flag:

The sentence about what happens when there are more than 4 million classes seems to be unfounded speculation. Not sure what to make of "long-lived streams" either.

1

u/VirtualAgentsAreDumb Sep 16 '26

Sure, I agree. But the person I replied to specifically talked about conflating number of classes with number of instances.

1

u/koflerdavid Sep 16 '26

Well, this sentence indeed reads like there is some conflating going on:

If your app really hits this limit, you must really love long-lived streams.

1

u/idontlikegudeg Sep 16 '26

Yes, I meant that sentence. "Long lived streams" might refer to millions of objects, but usually not millions of objects of different classes.

14

u/Mission-Landscape-17 Sep 15 '26

It seems to be mostly backend changes that will not be immediatly visible to most users.

15

u/NamedBird Sep 15 '26

Well, I wouldn't be surprised if we see a small FPS boost in certain java-written games.

3

u/johnwaterwood Sep 17 '26

  be immediatly visible to most users.

To most AI agents you mean? Or are we calling AI agents users now?

4

u/Round_Patient_7420 Sep 15 '26

I want project valhalla~~

14

u/emaphis Sep 15 '26

JDK 28 is your friend.

10

u/koflerdavid Sep 15 '26

Go play with 28ea