 My name is Mark Reinhold and I'm the chief architect Java platform group so a Couple of years ago. I don't know how many of you attended my talk at the eclipse day. I was Stefan Herman at the time. I Have decided to promote myself promote myself as the Java chief architect anyway, the to Restart my name is Shri Khan and I work in Oracle as a part of the Langtools group Working on the Java language compiler. So if you run Java C, you have run my code including all the bugs there So I used to earlier work in the eclipse JDT compiler team and I Let the Java 8 efforts and eclipse and once that shipped decided it's time to Quickly bolt without having to address all the problems and bugs and defect reports whatever so I'm here at Oracle today and I will give a high-level overview of some of the features that we are working on Beyond Java 9 Java 9 from a feature set point of view is closed and you are probably Aware of what is coming in Java 9? So I'll not spend time on that most important thing coming up There is module system So beyond Java 9, what are the things that are cooking is what we are going to cover at a high level So one of the interesting things that happens in the Oracle Java products group is that at any point in time There is investigation prototyping research development implementation work going on for Two three releases. There are some of us working on what is likely to be Java 10 work Some of us working on Java 11, you know, some of us are working on things that are not even tagged to any particular release so a lot of Work is happening people You know working in a dedicated fashion on things that have nothing to do with Java 9 at all a lot of this is available for you In the information as well as source code is available for Valhalla Valhalla is the Code name for the project some of the feature set that are being investigated and explored So documents design documents rationals JEP documents plus source code repositories lot of it is available already for people to take a look at participate comment and Get involved in so you're welcome to do that. So moving on So this slide is a mandatory slide. I need to show it's Basically says that whatever we discuss here is information purposes only not a commitment to deliver From Oracle it's not an obligation for Oracle to deliver You should not rely upon and making purchasing or product implementation decisions So highly speculative you can just take it that all of this is alive. So moving on So two key features that I'm going to give a introduction to That are being considered as part of this project Valhalla Valhalla is a code name So I don't know what it stands for. I think it's a lake or a mountain or something I've forgotten what it is. So is a umbrella term for a collection of features that are being investigated two of the core features that come in Valhalla are what are called value types and Generic specialization. So those are the two that I'm going to give an introduction on so beginning with value types Consider this class a very simple class implementing another abstraction for a complex number, right? I'm sorry implementing the abstraction for a point So X and Y represented inside a reference object. This is how we would code it today and What are the some of the problems you have in the present Java 8 implementation or Java 9 implementation? in terms of layout performance and all that you can take a look at by considering how this gets represented in memory to Kind of amplify the problem. I'll actually show How this gets represented an array of points get represented in today's implementation in the JVM and the compiler So basically an array is a reference type So it's an object and as an object it has an object header every object in Java implementation as object header which stores Certain information that's required by the runtime Such as object identity virtual tables so on and so forth. So you have an object header followed by A bunch of references pointing into individual objects that are allocated on the heap Right. So each of the point objects that stores the X and Y for a certain point has its own box It's own object. It's a reference has its own header and Eat the array actually holds just references pointers into the objects that are actually sitting on the heap What is wrong with such an arrangement if you have just a handful of points that you're representing in the array Things are fine. The overhead is not much But if you have a huge number of points that you need to process or a huge number of tiny objects that you need to process Hold in an array and process then the overhead quickly gets very high the overhead in this case of a point Which holds two integers is actually much more than the metadata that the object needs to hold is much more than the actual Payload itself right X and Y to integers 32 bits whatever but the you know typically you have object header is typically 8 bytes That's 15 bytes based on the implementation So the metadata overwhelms the actual data that the object has to capture and then you have a huge number of such Tiny objects millions of them that you need to represent in your collection when the overhead quickly gets very high Overhead is not just in terms of the bytes. That's one part of it It has other ramifications also such as you know if you take a typical garbage collector one implementation of a garbage collector could be Implementing a generational collection which requires, you know, basically the regions to be scanned and earlier You know different generation objects to be migrated to different regions of the heap, right? So objects actually copying collectors objects have actually get copied and moved to a different region as the program runs and That overhead you can imagine as you have a large number of tiny objects The overhead of copying those objects over and over to different generations different regions gets overwhelming, right? so that is one part of it a more Pernicious problem comes with respect to the fact that reaching into the actual data Requires chasing a pointer, right? So you need to so if you are actually reaching into any of the Points x or y you need to follow a pointer into the objects location in the heap What is wrong with that? Basically the pointer in direction pointer chasing now, right? The objects are all scattered all over the heap There is no predictable allocation pattern that you can expect They are all over the heap and the access order could be random which basically means that there could be a lot of Cash misses as the objects get accessed and cash misses carry a huge amount of penalty There's no locality of reference as opposed to if this array was where to be an array of integers And you are scanning through the array entire array looking for a certain something, right? The integers are all packed one after the other after the other after the other in memory and As a result when you access them there is locality of reference You are accessing successive memory locations and the cash fills that result from an earlier cash miss Immediately benefit you when you access a subsequent element and so your program, you know is not thrashing, you know not evicting and not Running into lots of cash issues there here the allocation is all random they could be all over the map and One object could be evicting the other from the cash and they could all be you know overlaid in the cash line as far as the Memory layout is concerned and that could cause a severe performance penalty and a cash miss is encountered You know you really have to you take a big hit in terms of 200 instructions or 300 instructions worth of cycles lost in filling The cash and the pipeline is tall for that to happen so a number of such factors like that come into play into are being considered for Addressing in Valhalla by coming up with an alternate Layout by coming up with an alternate value class scheme value type scheme So one alternative that you can resort to today is to simply use this so here There is locality of reference that's you know, you were able to exploit the X and Y of the point or Whatever the complex number real and imaginary so you can hold them as two separate array of integers or array of whatever primitive types and the locality problem is addressed, but what is the problem in this approach you have basically breaking down the abstraction Right instead of representing a point as a point You are now chosen to represent, you know, you're basically giving up on abstraction Right, so a lot of real-world code performance sensitive performance intensive code probably does that and we don't want people to do this We want Java as a language to recognize that you know, there are certain problems around this space and Have linguistic support runtime support for that and that is where the entire idea of the feature of value types comes in if Point could somehow Be represented this way. This is the ideal representation. No headers all inlined It's one way of looking at value types is to say, you know, just if you're all familiar with inline functions in line methods This is inlining of data, right? So just as you're able to have a contiguous array of integers or, you know, your primitives What if I'm able to avail the same thing with my user-defined types So values in a way of looking at it or use the defined primitives the support for programming defined primitives in the language So what could it look like? So let's move on to here to let's go back here to ask the question can without changing the language can the JVM do some magic and Somehow inline things instead of providing the headers and you know scattering the object all over the place In some extremely limited cases the VM can do that But those limitations are so high that in practical cases You're not going to be able to the VM is not going to be able to offer real advantage of real benefit to you What are the some of the problems there? So the problems come from the point of view of some basic features that have been there in the language from day one right Java allows you to synchronize on any object right, you don't need a special kind of Up, you know Lock object or something that you need to create to synchronize as code section You can just any object that you have you can synchronize on it This requires some metadata to be available the header goes to support the speech You need some metadata space to hold the information to hold the lock to hold the information that it's locked and whatever So it's not possible for the VM to predict if it decides to buy magic without you know There being any language constructs if the VM today takes your code and lays out an array of points like that like this Then if somewhere down the line you were to synchronize on a certain element of the array you have a problem How do you hold that information and where do you hold that information becomes problem? So this is something that you cannot do anything about because you know programs can pass around References all over the place and you don't know the VM care has really limited View of the world and has no means of knowing that does somewhere down the line an array gets passed to somewhere Some method and that passes it to some other method and you know Somebody could synchronize and there's no way for the VM to know not know so it has to assume defensively that Any object could be synchronized upon a Second problem comes in the fact that I'm you can do a reference comparison like this equals equals for reference types basically compares the identity Right object identity gets compared as opposed to the object value, right? So the object identity comparison can happen anywhere down the line if the VM where to inline points You know all the elements of the point array inside How would it materialize the reference all of a sudden when such a comparison is called for right? So Java doesn't allow you to materialize addresses There's no language support for materializing addresses within an array I'm like see where you can do pointer arithmetic and something like that so here There's no such possibility so constructs like this which are extremely common would break if the VM where to do some Auto magic thing there yet another problem with that is you know There is a method identity hash code that basically assumes that objects are in the heap and Computes an identity hash code your program can down the line all of a sudden at some point Call this method and it should be possible for it to have an identity and headers and all that stuff And so this goes to show that What a VM can do without linguistic support is limited Because the VM has no means of really ascertaining at runtime Without extremely expensive computation. What is possible in a context? What could the linguistic support look like well hypothetically assume that there is a keyword value The syntax is provisional assume that there is a keyword value which exists and by using which a programmer Expresses the intent that you know I really want this to be a value class a user defined primitive the moment you stick this in this certain Semantics gets applied to this class first of all. It's a value Which means that it's like a primitive in certain respects. It does not Extend object even though it looks like a class. It's declared to be a class. It does not extend object The class is final you can't Point does not extend anything nor can something extend point. It's final But other than that it can have fields it can have methods Because it's a final class really it doesn't take part in the virtual inheritance and you know polymorphic dispatch and all that stuff Whatever methods you declare are the ones that when you call them. That's where it's going to bind to there's no subtype Possible for that So you can declare fields you can declare methods for all practical purposes that look like a class except it doesn't extend object It can it's a final class and the fields are immutable once the value is constructed It's why it's it cannot be further changed very similar to user defined primitives, right? If I have a integer x which which holds the value hundred at this point It's possible that you can change x to hold some other value It's possible for you to change the integer variable x to hold some other value But it's not possible for you to change the value hundred hundred will always stay hundred in a similar fashion once this is These are the value value instances. We should not say value objects because it could be confusing these objects value instances once they are constructed are immutable the class is final and So from the motto or the goal for the project is that the user defined primitive value type should for all practical purposes from a coding standpoint Look like a class, but it should work like an int which also means when you pass a value to a method When you pass a value instance to a method Pretty much it gets it can get past like integers get passed integers get passed on registers They are not sitting in the heap integers get passed on registers and you know the method can manipulate the value The value any changes that are made don't reflect back So it's passed by value semantics right in a similar fashion Values can be passed so if they are suitable if the compiler and if the runtime determines that it's suitable For passing and registers values can be passed on registers So the suitability criteria will very lightly involve the size of the object, right? So we are looking at you know tiny objects and What not so if it's going to hold that doesn't feel it doesn't It's not viable to pass it on registers unless you know that you can imagine an implementation that does Extremely sophisticated analysis and passes some hot fields in registers and some cold fields somewhere else But that's that's a stretch of the imagination So values can be passed on registers. That's going to be a key performance feature there and So for all the if we succeed the success criteria for the project is that you know for all practical purposes Most of the implementation of value classes should look like a class and but work like an so what today looks like this and If values don't extend Object or any any type and They cannot be extended also that really you know the the entire virtual dispatch and all the machinery that's required to implement virtual dispatch goes away and one of the implied semantics of Sticking in the way the keyword value there is that you will not be able to the compiler will now be able to Stop you from doing certain things that require Metadata in the object in the instance layout Such as if you attempt to synchronize on a value instance the compiler will tell you you can't do that If you call system identity code you the compiler will tell you it can't do that You can still you call the use equals equals, but the semantics of that is being worked out the semantics We know it will not implement identity comparison because there is no notion of identity for Values So the you don't need a virtual table. You don't need the metadata to represent the run time type information Locking and all the everything goes away So what we used to look like this can now look like this, which is the goal that we started out like Right. So what does this buy you? We discussed three things in the beginning Locality of reference as you're iterating through the Zaday you are not running into cache misses, right? The cache lines get filled not with just the data that you're accessing But in terms of cache line size, which could be 64 bytes 128 bytes So when you touch the first X a whole block of cache line worth of data gets pulled in and they are immediately available to you As you iterate further so performance gets improved From a garbage collection standpoint The object is now looked like one Contiguous monolithic object as opposed to several, you know Thousands of tiny objects and the garbage collector if it's smart can make a decision not to move this object around as a dust generational Copying collection right it can devise some strategy for dealing with you know huge objects and not take the hit there So codes like a class works you can end an implementation exists So you are you know Valhalla there are repositories that are available I don't believe there they provide early access builds pre-built binaries may not be available But it's fairly easy to set up a repository and build it in experiment with it. So there is already a fairly evolved implementation that You can take a look at and play with So what are some of the use cases so? any number of Representations from different domains are possible some common ones that we expect are from the numerics in 128 could be a representation could have a value class abstraction complex numbers decimals tuples Tuples can also represent implement can be used to implement multiple return values from a method Optional which got introduced in JD JDK 8 Was commented in the in the java doc as a potential Migrant right so the java doc actually if you read through the optional java doc from JDK 8 It actually says please don't do these operations on this because the future version might migrate this to a value type and your code will break a Bunch of such options. I will give you one detailed example cursor Which is a faster form of iteration that can be implemented using value types. So optional Is a good candidate to migrate to values it got introduced in java 8 So basically the streams API right so in the streams API you set up a pipeline with various method calls chained one after the other after the other and the data flows through the stream and If one stage of the pipeline could end up returning null The next stage of the pipeline will have to first check for null before Doing its thing right so your code is going to look terrible So which is where optional got introduced there for you to take advantage of so you basically wrap the value Inside optional so optional can hold the value or hold null But optional the optional instance itself is not null right so that can be that can flow through the pipeline So is a good candidate for? Converting into value so it just holds one reference inside it and you can ask whether the reference is null Or you can get the reference or if it's null you can pass a default value and things like that So getting back to the cursor example right so the iterator today looks like this the interface for iterator looks like this Has a has next method you can query the next element in the iterated Collection you can remove So your current day implementation could look like this right if you have a array iterator it holds an array of elements array of some generic element and It knows the size of the array it knows that it maintains the current element in the in the variable offset And you can ask does it have a next it implements iterator so you can ask does it have a next one more element and Get the next element right so fairly straightforward implementation, but if you look at this right first of all this is Mutable right it's modifying itself by it's modifying its state offset is being incremented internally right so not a candidate for converting to values as such and How would the cursor? Implementation look like right so you could iterate it alternatively by using a value class at a cursor that that could look like this it implements a cursor of T and like earlier holds an array and a Notion of where in the array you are cursor position in the ad you can query it Is there more you can ask for the current one and when you call next right? It actually returns the next cursor this code has a problem there It says T it should actually say returns the last method public T next should actually read public cursor of T next so when you ask for the next element and a next cursor It doesn't mutate itself because values are immutable like pretty much like user-defined primitive values are immutable So it instead returns a new cursor which would Carry along with it the notion of there there in the iteration process you are so it returns a new cursor of ad a and offset plus one All right, how would the code look like this? so so you materialize a cursor cursor of string and While the cursor is not empty Do something with the current one? So if you look at this the Cursor C, right, which is a value Very small value Just two elements can be held Most likely can be held in registers The cursor instance can be held in registers do something if it's not a horrendously complicated method can be in line C dot current the call on the cursor is not a virtual call because Values don't participate in inheritance. They don't extend. They cannot be extended So there is a new opcode that's being introduced invoke direct So you have a refer you have a instance and value instance and you can directly invoke a method on it without consulting virtual tables and whatever and So the call Yeah, see that is That's a good question. It's also a style of programming that You know the functional programming and you know with the mutable thing and it's not a new problem as such So to answer your question, I would deflect that question to say it's overall the same question that as You know functional programming with immutable objects, so it does create new ones Perhaps the compiler can inline them inline the calls and Do certain optimizations there and it's not a non-issue so So looking at this loop C can be held in registers To access the method to call the method. There is no virtual dispatch with indirection involved compiler knows Where the call is going the runtime VM knows where the call is going the call could probably be in line and Body of the loop similarly can be optimized in different ways So you can end up with a pretty tight implementation of so one of the complications that comes in evolving a language is When you add a new feature, how well does that feature work with everything else that has been Added to the language so far, right? So this problem is getting Complexer and complexer as time goes because you know when you implement Java 5 when you're when you are Laying out the vision for Java 5 you really have feature set from 1 2 3 4 releases that you a new features should interact with gel well with a Java 9 time at Java 10 or whenever JDK Valhalla is what we call it, right? So we don't put a number to it because we don't know when this will get integrated So at that point in time we have at least up from you know Java 1 to Java 9 the feature set that exists should Harmon work in a harmonious fashion with whatever new thing that we are adding there So if you look at this as a requirement, which is a very hard requirement You know you can't build very fantastic features that don't work at all with each other, right? So if you look at this then one of the interesting complications that comes here is this okay? I have values. That's wonderful. They are they provide me with a bunch of Interesting performance characteristics. That's wonderful. How well do they play with the other features in the language? So one of the interesting complications that comes here is one of the interesting questions that comes is can I have? Values in collections or can I in general so you know can I do new are a list of point? This is a huge huge huge question Because a point a value class Is not a reference as such it does not extend object and In Java 5 generics implementation and all the way through till date, right? Generics are implemented in Java by erasure What we mean by that is to say that if you Implement if you look at a list Class declaration in JDK. It's going to say at a class at a list of tea, right? Where tea is the type variable? If no bounds are given for the type variable, which is the case for are a list So it will simply say new are a list of tea, right? The compiler and the overall implementation assumes that tea is some Subtype of object if you just say tea Tea extends object is the assumption, right? So tea is some type it's a type variable the variable can assume values which are From the domain of types all of which must extend objects So tea extends object is what the compiler and the language specification treats plain tea as and So if you actually look at the class file this assemble the class file using Java p command, right? and look at the class file a Method like map you can you say get of tea and that returns a tea right at the source code level the hash map at the map method Get takes a tea for the key It takes a key K and returns a V value, right? But if you look at the class file the get method would have been compiled down by the compiler To a method that says returns object method name is get takes an object Right, so irrespective of whatever instantiation that your program makes on that particular map It's guaranteed that the map is in can be instantiated only for tea values the type values that are Subtypes of objects and so such a erasure based implementation scheme works fine. I can have a list of string I can have a list of Integer The capital I integer or I can have a list of add a list of something all that will work because by it by definition All of these are reference types all of these extend object either directly or indirectly through a chain and so can Be passed to a method that expects an object and encodes an object in its signature, right? So the Java implements unlike C++ C++ on the other hand Does template instantiation by if I have a you know the standards template library STL in C++ has the vector class, right? So your program may use vector or map or whatever from C++ STL instantiating it with various concrete types all over the place a large application That gets built that way. It's very likely or it's not at all unlikely that in the binary implementation of the you know, they get the edit out Or they know the equivalent of your class file if you look at it You may end up with vector of string vector of this type vector of that type, you know every particular instantiation basically the compiler takes the code for the template class and Sticks in in the type variable positions the actual instantiated type concrete types Generates a class like that compiles the class produces the object code for that so Vector of string and vector of integer don't share any code all the Type substitutions are done independently the the classes are compiled object code is produced that has its own lots of complex problems arise out of such an implementation from an implementation standpoint as well as from a runtime standpoint a lot of Complications come from that and you know in retrospect the erasure based implementation in Java Has a lot going for it though. It's a fairly Tendentious subject, you know people hold very Passionate views on this is broken that is broken and things like that so but anyway to returning to return to return to this problem here because Erasure is the key Strategy for input so in Java you can have at in a particular Java project you can have at a list of Thousands of different type in third concrete types In the binary level, you're going to have just one class file for a realist, right? So that has the erased object based implementation Right because object is at the root of the hierarchy any type any of the thousand different types that you have can be passed to it And you know things are fine On the other hand point now is not a subtype of object and so cannot play well with the ratio based generic implementation So I cannot Pass I cannot store points and collections unless I do something about it in the language and the implementation of the language So the problem boils down to really the same thing as saying, you know, can I say new are a list of hints? You know that you can't you have to say new are a list of integer and involve the boxing cast there And you can't just store primitives in this thing So this was okay in Java 5 time because there are only Eight primitives right outside of those eight primitives any of the innumerable types you can any of the innumerable abstractions you can cook up can be stored in collections Only those eight are banned and they incur this performance There is a work around for that in the form of the boxed types and though they incur some performance penalty there But now with values you're actually opening the door. It's not just eight Limited number of types anymore. You can have the the door is as wide open as reference types Right, you can have any number of abstractions that you want to call out as being value types Which means that the Java 5? Okay, we know that's a problem. We have provided a work around people can live with that that story is not going to work we need to somehow crack this problem and provide support for instantiating Collections or any generic type in general parameterizing any generic type with any types including primitives including values and References and so the implementation eventually is going to be a mix of what Java has always done and what C++ has done in terms of you know The for all reference types We will continue with the same story of producing one class file based on erasure For reference types, we will have to instantiate in the at the file system level We will have to produce different class files by actually doing the substitutions So at a list of string integer URL, they all boil down to the same thing in the news in the new world This is how it's going to look all reference types will continue to use the same it is the implementation while There will be specialized classes for integers and values and so on and so forth so from an implementation standpoint this raises lots of challenges Because how exactly do you do that? When is the time to do that they do the specialization and how do you do that and what type of meta data needs to be captured for you To do that you can't go back to the source code or not often possible You know, it could be just be a library class that you know, I realized is library You can't do what C++ does So how do you manage that you need to carry along a lot of metadata in the class file and make use of that and the JDM instruction set is also fairly irregular in terms of The references the bytecode for loading moving data around are a load and a store Which is what would have been generated for the class while if you see an area list of in you need to change it to I load and I store and there are additional complications You know integers operate on one slot in the stack while Longs and doubles take two slots and that requires you know layout issues and the number of other interesting problems come From a language point of view also a few problems come in and I'll outline some of the interesting solutions there So all of them will have the same class here the different value These are all int and point are very similar as you know, they're both values So int is not really a class and not called out. There's no source code representation for that So these would have their own separate implementation that somehow generated So we have an implementation that works fairly well, which is basically a class loading time So the compiler when it generates a class Generates a lot of metadata in the class file that's required to for the specialization and the specializer one implementation of that hooks into class loading and at the class load time it will See that a certain specialized classes required and take the Generic class and specialize that and load that That's one possible implementation I mentioned that Migrating this requires certain interesting complications. So I'll speak to some of them. First of all We want the programmer to express an intent that you know Is class that a genetic class that I write I would want that class to be I Would want the users of the class to be able to parameterize that with any type Including primitives and whatever because in the absence of you know, if that's not going to be required Then we don't want to generate all the metadata and carry that along So there is a programmer has to first express an intent and the current syntax for that Which is provisional is to add a modifier to the type variable so you basically say any T should be possible here, right and If you do that Then basically the compiler knows that T the domain of T now is the universe of types values existing primitives and Existing references all references all primitives whatever right so the domain of the type variable T is the universe now That we introduce some problems right some complications come in there So look at the statement data of I equals null null is necessarily a reference value reference instance a reference I don't want to say value it goes with references, right? So if I can't assign if T is instantiated with int I can't assign null to int I can't do that today, and I won't be able to do that tomorrow, right? So this is a complication. So what do you do and how do you handle that and there are different tricks and Things that are being considered conditional code blocks So if so this basically has a lowercase T. This is this should be capital T So bear ref capital T. It should read and so if T is a reference type then use this block Otherwise this block is not applicable. This is new syntax. That's coming up More interesting problem. This is a much more interesting problem. So the area list has methods today Let's say remove and you can provide an index It will remove the element at that index or you can say remove and give a T element And it'll remove it will scan the area list and remove the element if it's present What happens if you instantiate this class this container with int if I want to instantiate it with area list of int Then T gets substituted with int and now suddenly you end up with two remove methods with the same signature, right? They differ in return types, but return types are not considered in the language for You know the whether the method signature is the same or not So you end up with two instances of remove of int and that's a problem. So how do I tackle this problem? well the way that's Done a way it could be done is to change remove the int taking remove to remove at and introduce a where ref T conditional block and use the old remove method and call the new method So this basically would allow all the existing code to just work fine They can continue to use remove of int the existing code operating on You know reference references in the container can continue to work They will call this method which deflects to that method while The new implementation any new code Will have to call remove at to work properly with the universe of types that are possible here So having invented the syntax for conditional blocks conditional code blocks Yeah, there are other tricks that it can be put to use for for example, if I have an array list of Boolean So c++ actually allows you to partially specialized templates or specialized templates or partially specialized templates. So um, you know the compiler by default c++ compiler by default will stick in will substitute your actual concrete instantiated parameter type type two on top of the Variable and you know produce the template instantiation But if you wanted the ability to hand instantiate One specific version it's possible in c++ and the conditional Code block feature allows you to do that if you want to say for example say array list of Boolean The current implementation would you know at best if you want to take the most efficient implementation We'll have to have a Boolean array and you know that takes Space and you can now try to pack it into bits all you need is a bit to Represent that and that becomes possible with conditional code blocks okay So that's two features that are in evolution. There is a lot more and uh, Valhalla is also just one of the Uh projects that are going on at this time. There is also a project Panama which is looking into object layout arrays 2.0 basically faster better add is and Interaction between different languages In terms of object layout and foreign interfaces and foreign object layout handling all those things are lots of interesting work going on there And uh, but i'm not qualified to speak about that. So the two features that uh That i'm involved in so that's a high level overview of what's coming up there So as i mentioned a lot of the code is available out there a lot of documents are available out there. It's open JDK So You're welcome to take a look participate. You can sign up for mailing lists or other forums contribute code Send your resume We are hiring So That's all i had if you have questions. I'm happy to answer them and See that in itself doesn't do much right, you know, what What does that buy you by saying not extends object? What does that buy you over and above? Saying value on the other hand, I would say that saying sticking in a keyword value there Expresses intent serves a certain documentation purpose So I that in itself I don't see a benefit there Values can hold objects. Yeah values can hold references. So as their fields Yeah See hold on So a value Codes like a class So can you can declare fields? The fields that you declare can be primitives can be values Can be references if you have references there, right? So going back to the cursor example, right if you have references there The representation for references doesn't change So the the value now is going to hold a pointer into the heap object that the reference object is But if I have a value that Declars a field which is a value The inner value would get inlined Into the outer value because there is no heap representation with pointers there. It's inline data Which also means that a value class cannot declare a field of its own type Right unless your linked list implementation is a good example, right? So you have a node and that says Pointer next node node next, right? Or your tree representation, right left and right That becomes possible with references you can't do such a thing because the moment the values are inline So if a value class value instance value type declares a field that's its own type that Inlining would proceed indefinitely and you know the compiler will actually refuse to do that and throw an error So respecting that particular limitation a value class codes like a class So it can have fields fields can be references values or other values or Primitives then you store references you're storing The references in the pointer the actual payload the object itself is in the heap very much like it is today And they will you will have to chase that pointer into the heap to reach into the actual object data adding new keywords will add the overhead of Any feature that gets added to the language there is a learning curve, right? So this is Well any linguistic feature that gets added to the language has a learning curve So new constructs new keywords new syntax new semantics I don't think We are at a point where I cannot think of a scheme where the compiler and the runtime can divine Automatically what the programmer want it does in a number of ways and you know Gives you better optimized programs even when you write Sloppy code the compilers transform that into better code Some things are possible Some things are not going to be possible if the programmer has to express an intent to Tag something so that goes back to the early part of this talk where I asked the question can the vm Automatically change the layout so that locality of reference is guaranteed Vm cannot because Objects get passed around all over the place And you know I can pass it to method foo which passes to bar which passes to bars and bars can now synchronize And the vms limited scope at runtime you can incur only so much penalty To analyze programs because the return on the investment must be good for you to do invest So There's very limited options that are available for the thing to just automatically give better Thing which means that constructs are going to be added language is going to evolve Everything if you look at any Any of the releases right where linguistic constructs have been added So java 8 streams api requires a new way of thinking and that new way of thinking I look at streams based code in my own project and It took me a while to Make the mental model shift to understand that code and I don't write that code even today Right my colleagues write that code and I don't write that code today if I have to write code I write like java 7 code and which is fine accepted and all that but people write that code and Lambdas you need to learn this in tax semantics and all that It's not a problem that's going to go away Not really okay That's a that's a problem and the way the problem is being tackled is by saying that recognizing keywords only in limited contexts For example java 8 introduces java 9 introduces lots of keywords the module system thing right so exports Users provides All those things right Depends requires module system module info file requires a lot of new keywords to be added But those keywords are recognized as keywords only inside module info file your rest of the program can say exports And a little bit it can be a valid variable name Right likewise. I would imagine that whatever is the final choice of keyword that's decided upon one way to handle that is to say that in the Only if it occurs in the modifier position of a class right so this is actually the example that I showed It's featuring in the mod if like public final static Those are all modifiers for a class if it's annotations if it features there treat that as a new keyword Otherwise treat that as an identifier as one possible approach the same problem was handled in 1.5 then enumerations and Asserts were introduced right they introduced two new keywords enum and assert become a keyword and compilers have provided a way of saying you know um Throw an error if they are used as keyword or as identifier or accept them. So they've provided some Transition path See, I don't Have the particular example in mind. So there is uh, there is this Example that shows that even in java fi in the sdk jdk There are some gaps in Generifying right instead of the exact thing instead of encoding the type variable people have encoded object there So you will have a problem. So the compiler is not going to be able to specialize such methods. So The type variable for specialization to kick in the type variable must be must carry a specifier any And must be used in the signatures of the method and field declarations and so on Yes Yes So you can have a plain class not a generic class You can have a plain class that today declares a generic method You can modify the type variable with any and the compiler will Basically at this point in time what it does is it spits out a separate class to hold that method and does some magic there Um, I think that implementation is also changing. But yes, it is possible But Generic methods can be specialized just as methods can be generic independent of the holding class Being generic or not specialization So the term that's being pushed is any fine like generic fine So a method can be unified independently of its holding class So that that that that's a horrendously that introduce a lot of complications in the implementation of the compiler, but the whole story is Let's take the hit if it results in a simpler user model as opposed to banning things and you know Documenting you can't do this you can't do this you can't do this Somebody had a question say that again if that's so I'm going to completely punt on that No next to nothing about serialization but I can follow up on that and If you're interested I let me know I follow up on that and share what the story is all right, so basically the um At the moment this is still an evolving prototype at the moment. There is When you declare a value class um It internally extends java lang value Okay, a new base type for the value hierarchy is being created like you know enumerations all of them extend java lang enumeration and so in a in a similar fashion there is a java lang value that's being introduced as a base class and that holds two string hash code and equals Nothing else. So basically the rest of the object methods are not applicable And these are available see that's a That's a runtime check right instance of is a runtime check and it necessarily operates on Oh, okay, okay, okay It is possible. It would it would be the equivalent syntax. It doesn't I I I that's interesting. I can feed the back There of t and t instance of something is yeah t instance of object Yeah, so I can I can feed that I'm sorry No, no, no, I I can feed I can feed the back But I think there is going to be other complications as you know what I showed you is just one example where f t I think there are that that syntax has more to it Not just whether something is the reference of this I think it allows you to say where this is boolean or something right that I don't have the full syntax See this I don't know but in general the new language constructs are going to be there Where is not a loop? Where is where a loop? Where is where a loop? There's no where in java Anyway, if the any new constructs that are going to be introduced, it's they're going to make sure it doesn't clash with Such a thing If there's no loop in java by name there, but if it is there That there needs to be a story for how many but you need to Say it without being judgmental you need to get hold of the fact that you're going to have to learn new syntax We can happily code. I am very happy coding in java 1.4, but that's not possible anymore See hold on the array of values The array itself is not immutable the array is very much mutable array is a reference type right so if I say array of five Take one cell that at this point Is holding a certain value I can make that change To hold some other value that's possible because arrays are references correct See it's the same problem as if I have int x equals five Can I change x? You can change x to hold some other value, but you can't change five itself five will stay five till eternity So that's the same thing so the array itself is mutable like You can change the x and y. Yeah, that's not possible Correct at the construction time once it's constructed. It's immutable See the complications come from the point of view of codes like a class works like an int so if I pass A value to a method It's passed by value right as in it's passed on registers and whatever and if modifications where to be allowed Those modifications won't reflect at the call site And that for reference for what look codes like a class that would be a very confusing thing Right, so that's why they're not allowed. It's uh immutable on account of that If it codes like a class and the called method is allowed to modify it And the modification doesn't reflect at the call site. It's going to be very confusing So just declare them immutable being user defined primitives so All right Thank you very much. Yeah last question See I must confess I don't know the plans for that um That inquiry, I mean, I I don't know the plan as and I don't even know what goes into oracle jdk I work on open jdk so It's entirely speculative like the very first slide said it's entirely speculative It's very likely. We are very interested. We are strongly motivated to make it happen A lot of effort and investigation work. That's going into it if you rewind the clock back All the major features that have shipped in java over many different releases have come in the same fashion So lambdas were in cooking for quite a while So it's not like, you know People said, okay java 7 shipped and let's start with java 8 and what do we want to do? No And java 6 was going on lamb lambdas, you know The very first implementation of closures Which lambdas are in a way of looking at it happened in 1978 or something right it's a 40 roughly 40 year old feature in a way of looking at it so the um Investigation work has been going on module systems has been in the cooking for quite some time Like that so these are Being actively prototyped and researched They will very likely show up at some time and we are strongly motivated to have it happen But you know the dates we don't know jdk 10. It may not be 11. We don't know. We don't want to come into that It will hopefully show up soon But it's highly speculative that if you none of the officially published JDK bits will carry this And they will there is a process the java community process Which needs to this needs to be fed through that with expert groups formed and you know They will get to debate the feature at various points a lot of times the feature gets changed quite a bit during the JCP process Before itself a lot of community participation Experts commons and all that it's not something that Someone sitting in an island puts together and throws it at the world All right. Thank you very much. Lots of familiar faces. I enjoyed being here