Interconnecting non-String objects (non int / long) in Java 8


I was going through this documentation from Oracle :

And came across this piece of code regarding type annotation

Class instance creation expression:

new @Interned MyObject();

Does it mean Java8 or future versions is-allowing/will-allow interning of non String/long/int objects ?

As far as I know there are no such plans. It's just an example how annotations can be used. I guess it can be implemented by third-party annotation processors like project Lombok, but unlikely we will see such feature in JDK (at least in the near future). Other examples like @Readonly are also just examples, they are not supposed to be added to JDK.

Please note that using String.intern() in the user code is extremely bad. Now it's not so big disaster like it was in JDK6, but it's still bad. You can easily implement your own Object pool using ConcurrentHashMap.putIfAbsent(obj, obj).