Questions tagged [project-valhalla]

A proposed enhancement to the JVM (and therefore JDK) to improve runtime performance. The most visible axes of this proposal are value types and generics specialization; in particular, the latter would allow to declare a List in Java which is not possible as of 2015.

The URL of the project is here.

This project is still a work in progress. Numerous resources on the Internet already exist to highlight the potential benefits this project would bring to the JVM.

Value types, in particular, would allow for "simple" object instances to do away with what is called their "object identity"; indeed, even a bare-bones Object in Java brings along with it some metadata (its identity) which, in most case, will not be used (consider that each instance is usable as a monitor; see synchronized); this project would allow to leave this identity behind where it is not needed. As of yet, it is unclear how this should be done technically, but candidate implementations already exist (see link above).

Generics specialization would mean that a List<int> would be a possible type declaration in the future. Historically though, Java has had type erasure, but this feature means that the compiler, in the future, will not be able to content itself with only verifying bounds checking of generics: it will have to be able to correctly generate code for specialized versions of classes whose type arguments are primitives, if such versions exist at all -- all the while maintaining backwards compatibility.

10 questions
33
votes
4 answers

What are Value Types from Project Valhalla?

I've started reading about Project Valhalla and there is something I really don't understand and it's the Value Types. This is what I understand: 1) Are objects that can't be compare it as reference? final ValueType a = new ValueType(); final…
chiperortiz
  • 4,751
  • 9
  • 45
  • 79
15
votes
1 answer

Projected generic specialization in Java 9 or later, vs List: how will .remove() work?

Generic specialization along with value types are a projected feature of future JVMs; link to the Valhalla project page here. Now, from what I understand, it would then become possible to declare a: final List myList = new ArrayList<>(); // for…
fge
  • 119,121
  • 33
  • 254
  • 329
5
votes
1 answer

Is it ok to Serialize Value based objects if the application never relies on its object identity?

Sonar shows Make this value-based field transient so it is not included in the serialization of this class. This is a future-proof bug when value-based class will be released. So, if the application never relies on its object identity can I…
sagar
  • 53
  • 5
4
votes
1 answer

How to generically initialize a value type with its default value?

In the context of Java's Project Valhalla, how can I generically initialize a value type with its default value? Initially, I thought that assigning null to any value type would perform this initialization. However, the answers and comments to this…
fps
  • 33,623
  • 8
  • 55
  • 110
3
votes
2 answers

Can null be assigned to or be compared to a value type variable?

In Java, there have always existed primitive types and references, but not value types. One of the goals of Project Valhalla is to explore and incubate feature candidates such as value types. I would like to know if null can be assigned to a value…
fps
  • 33,623
  • 8
  • 55
  • 110
1
vote
0 answers

Declaration of a value-type Class

I want to specify my Class as a value-type one, so it can be stacked in method calls. I tried the @jdk.internal.ValueBased annotation but it is not exposed from its module. The doco gives a list of required properties, but does not say how to…
Perdi Estaquel
  • 819
  • 1
  • 6
  • 21
1
vote
0 answers

Why doesn't Project Valhalla introduce mutable structs?

Looks to me like primitive classes could behave more efficiently (at reasonable sizes) if they weren't immutable as currently proposed, but worked more like C structs. Given this primitive class primitive class Point implements Shape { public…
0
votes
0 answers

Map matching not working, When coordinates are inside home or office, Where missing road in OSM data

My aim is to create a map-making algorithm. So I have GPS data of user travel, Valhalla map matching is perfect solution for my use case, But where GPS track route inside home, office or parking slot, Then Valhalla map matching provide the nearest…
0
votes
0 answers

Are L-world value types (from project valhalla) useless in practice?

I wrote two versions of a program to test the performance impact of object allocations in a java program. One uses simple java objects: class Point { public final double x; public final double y; public Point(double a, double b) { …
saga
  • 1,933
  • 2
  • 17
  • 44
0
votes
1 answer

Can Valhalla's Value Objects hold generic types and flatten them in case they are primitive types?

Will JEP 169: Value Objects and JEP 218: Generics over Primitive Types specifications work together? Or better, is the following scenario possible? @jvm.internal.value.ValueCapableClass final class Tuple { private final T1 t1; …
payloc91
  • 3,724
  • 1
  • 17
  • 45