Java SE 11 New Features

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello my name is Harry Leo Garcia Romero I'm a director of product management with Oracle for the Java platform group and I'm going to tell you a little bit about Java 11 and some of the features that were introduced in this latest version so first I'll tell you about the release cadence we've recently changed the way in which we release versions of Java I'm going to talk about how this makes it more open and allows better communication with the community and the other contributors to Java then I'll tell you a little bit about what's new in Java I see 11 and I'll hand off to some of my colleagues to tell you the last part about what's happening after Java 11 and training in summary so for the release cadence overview we used to have a traditional model on which we produced a major version and the goal was to have a major version approximately every two years and then we would support it for a very long time so you ended up with this very common looking schema for a roadmap now if you paid close attention at the beginning of those two years when a release was the most current one we had what we called minor updates so if we had used the previous model after releasing JDK 9 we would have come up with a 9.1 9.2 9.3 and then six months after that 10 1001 1002 and so on and so forth so you'll notice we were supposed to have an opportunity for releasing something new every six months or so however when you're talking about projects that last that long that's not how it works out you run into issues and you end up having to sometimes delay the next major version so we had closer to three years rather than two between Java 8 and Java 9 now we go back to the original intent we thought we're already set up on paper to have a release every six months but under the previous model some of those releases had some constraints on what could go on so you had the major features needed a in the Java specification and they could only go on on the major releases and then during the minor updates you could improve here and there but you were constrained you couldn't change the spec so you couldn't add new api's we thought why don't we lift that constraint and in order to do that rather than having a major release we're gonna have feature releases so every six months we're gonna have a new feature release and this is not the same thing as a new major release every six months because there's no way we can deliver the number of features that we used to deliver in one of those majors you know every six months but the point is now we can deliver any change a change in the spec remove something deprecated something on any one of these releases now it wouldn't be possible for us to support all of these releases for a very long time like we did before so we're gonna borrow something that's been used by industry for operating systems and browsers and some of those releases we're going to call LTS or long-term support releases and for those releases will offer updates for a very long period whereas the others get superseded by the release of the next one the next question after that is of course well how often are you gonna have an LTS now even though we were aiming for two years between releases we've been averaging three years between major releases so we've decided to try at first with let's go with an LTS every three years we've recently released JDK 11 which is the first long-term release under this new model and we have another one scheduled three years after eleven with JDK 17 and so on and so forth these changes are not retroactive so all the commitments that we had for JDK six seven and eight remain as they were there's another important change that happened here which is we used to produce a binary called the Oracle JDK which was mostly based on open JDK but included some commercial features and some of the functionality that was not available in open JDK and we release that and there a license called by recall the binary code license the BCL which allowed you to use it on general-purpose computers without having to pay a license fee to Oracle as long as you complied with certain constraints of the license now that meant that the Oracle JDK didn't quite match the code in open JDK and that's pretty common by the way but now that we're gonna have these releases happen so frequently any differences between the binaries get very costly so starting with JDK 9 we decided you know what we're gonna try to match and not have any differences our goal is to have the binaries be exactly what you would get if you go on compile open JDK code we weren't ready for JDK 9 so there were still some functionality that was available only an Oracle JDK that wasn't yet in open JDK weren't quite there either for JDK 10 but for JDK on 11 and onwards they're virtually interchangeable there is no different capabilities or performance between open JDK and Oracle JDK so that's one in functionality wise there's also another important change which is licensing as I said we had this license called the binary code license which worked for public usage and also work for commercial usage but it had some constraints for that made it not ideal for either of those so we decided ok why don't we use a more commonly used license for the open source version and we've released the open JDK binaries under the GPL which is an open source license that most people are familiar with from their downloads of Linux now that we have an open JDK binary and the GPL we can say okay the Oracle JDK then doesn't have to have these dual purpose license starting with JDK 11 when they match we're gonna offer the Oracle JDK only on their commercial license so the Oracle JDK and the open JDK binaries they have the same generally the same performance the difference is Oracle JDK has support so if you run into a problem you can call Oracle and it therefore requires that you license it from Oracle and you'll pay a fee for it open JDK on the other hand you know it's the same quality tested by the same people but if you run into a problem you know you'll have to go online and look for a solution you can file a bug in open JDK and we'll address it you know at the same priority as we would any other open JDK bug also a big distinction is the availability of long term support as you can see from this graph or slightly better if we put it in this format the open JDK binaries you get only the latest version so there is no long term availability for the open JDK binaries as soon as JDK 12 comes out we stop providing binaries for updates for JDK 11 whereas if you stay on the Oracle JDK will offer your long-term support and will offer releases for at least eight years which is the standard Oracle terms for support so making java more open this means what I just said that we expect most people will go from grabbing the Oracle JDK to using instead the open JDK by Oracle which is available at that URL JDK the Java net what I said that there were some features that were not available before to the open version but we're available in Oracle this is pretty much the list right we had application class data sharing which we made open with the release of JDK 10 and allows you to share some classes you I'm sorry it allows you to reduce the amount of memory that you use when you're running to processes that use the same classes you have Project CGC which never quite made it as a commercial product but that's where it was going and it instead has been included in open JDK 11 and onwards flight recorder and its partner Mission Control allow you to monitor what the JVM is doing in production with very little overhead gonna touch up on those in a minute a Mission Control is if you will the player that allows you to play the recordings made by flight recorder so flight recorder is the capability in the JVM for creating these logs no let's call it that and Mission Control allows you to investigate them and see what was going on and usage logger which is the only thing that hasn't yet been made available to the community which allows reporting how Java is being used in your system so what's new in Java is c11 as I mentioned Java C 11 is no longer a major release so unlike the hundreds of changes that came say in JDK 8 or JDK 9 10 and 11 have a very small set when compared when we started the planning for JDK 11 we only had well it's s3 it's actually for jets targeted right that the ones in that least and as we approach the release date we increase that we ended up delivering 17 jabs and that's a Java and has been proposal and that's the unit of work that we use for delivery and functionality in the JDK so what I was saying before right we had a much larger number of jets on JDK 8 and 9 the major releases than we did with 10 11 and 12 and and that we expect in 12 and above so some of the features that came with 11 jep 330 allows you to launch a single source file program so when you're writing a complex application you're going to end up probably with thousands if not hundreds of classes but when you're learning most people just write a simple class and then the overhead of having to compile it first and then run it decreases on the you know it just breaks your rhythm when you're trying to learn this so starting with JDK 11 you can just run without compiling the hello world java class that you wrote you can see a sample here so you know takes an extra step makes it more fluent so jab 321 introduced HTTP client to the JDK and if you were paying attention you may wonder didn't we have HTTP 2 with JDK 9 in JDK 9 this was a incubator module which meant we weren't sure it was ready to be used in a standard format so we taught people only use it if you're willing to have a change underneath you now with JDK 11 we feel that we've reached the point where we can just put this in the standard and have everybody use them in production without worrying that it might change in the next version so it supports HTTP 2 and WebSockets it's a standard thing line we also introduced jab 332 TLS 1.3 which is an overhaul of the protocol used for creating secure connections now this is a poster child of what you can gain by using this new model on which we assign new features to our release much closer to when they're done TLS 1.3 the standard was approved only a month or so before the release of JDK 11 now under the old model there was no way that a standard approve a month before a major release was going to make it into that release it would have had to be delayed until the next one so you would have seen it about three and a half years after it was approved in this case it worked out perfectly and JDK 11 offered support for a new set of security algorithms pretty much immediately another important enhancement is jet 328 Java flight recorder so this one is actually one of the more exciting ones Oracle's JDK for over a decade now has had the capability of creating a very detailed profile of what the java virtual machine was doing when running a program so this was very useful for two cases when you were developing an application if you wanted to understand what was going on and you wanted to get some insight of how your code is being interpreted during runtime these would have given you that inside and perhaps more interestingly when you're using this in production it allows you to catch errors that are very hard to catch in development time so say you have a problem that happens when some memory has been leaking for I don't know 10 days you're not gonna find that while running in your IDE because you know when I have this thing running ten days so normally you would find this because something blows up in production and the team that's running these would just restart a machine and then tell the developer hey something went wrong can you fix it and you've lost all of the information that you would have needed to debug this if you have flight recorder on on the other hand when something like this happens flight recorder is continuously riding in a circular memory buffer and when something goes bad I'll just save that and allows that to be handed over to the developers so that they can at a separate time and different machine debug it and figure out what went wrong so this has been used for support within Oracle products very successfully for a long time but before JDK 11 it was a commercial feature starting with JDK 11 it is now available to any member of the community and we expect that it'll grow with more contributors as well we also introduced CGC this is by the way an experimental feature in JDK 11 so there might be some further changes to it but we've already received some fantastic feedback on this it allows you to handle multi terabyte heaps and have very small and I won't say deterministic but probablistic lis very unlikely that you'll have GC pulses that are larger than say 10 milliseconds and as you can see here there's a minor whenever you start to trade off I don't one more post times usually get hit with a reduction in throughput but this is a pretty manageable 15% for that 10 millisecond pulse times so this is pretty exciting and what's more this is the foundation so this will get better over time this is an example of that if you want to go and take a look at these numbers the first one the one on the top left that gives you the the throughput right and you can see that CGC is comparable to parallel and g1 however the pulse times are much smaller with CGC notice the last one the scale is logarithmic so it's even more impressive than it looks like at first sight so you should take this for a spin and at this point I'm gonna hand off the presentation to two of my colleagues Nick Rustica is going to continue with a couple more of the jabs that are available in JDK 11 Thank You Aurelio this is Nick I'm a curriculum developer and game designer with Oracle University in part 2 we'll take a look at two more jobs but in more detail these topics are tested on Oracle's professional certification exams the idea being that if you become Oracle certified you can go to a company and confidently say hey I know what I'm doing I'm an Oracle certified professional I'm believe I'm qualified for this job this promotion or whatever the case may be a Java 11 certified professional the expectation is that you should be able to create variables using local variable type inference and create lambda expressions with type inferred local variables as lambda parameters Jeb to 86 local variable type inference was introduced as their JDK 10 previously all local variable declarations required an explicit type on the left hand side in this example byte array output stream you can see it on both the left and the right side that's quite a bit of typing though now the explicit type can be replaced by the reserved type named var the compiler infers the variable type from the initializer on the right hand side why is this helpful take a look at this example this code reads a line of text from a socket using try with resources the networking and i/o API is use an object wrapper idiom each intermediate object is declared as a resource variable so that it will be closed properly if narrower occur while opening a subsequent wrapper the confessional code for this requires the name of the class to be repeated on both the left and right hand size of the variable declaration so in this case input stream inputstreamreader bufferedreader but the result is a bit clattery with local variable type inference that noise is reduced considerably and as a result variable names align making your code more readable and class names aren't repeated making your code more concise what do we mean by reserved type name I want to explain this by comparing it to keywords we know that keywords can't be used for variable names but var is not a keyword so if your old code happen to use var as a variable name it won't break under Java leaven it's just not a recommended name because it's not all that descriptive instead by reserved type name we mean that far for type inference is only used when we know we're looking for type information where can it be used with local variables where the type can be inferred from the initial value as enhanced for loop indices traditional for loop index variables and with some nonde notable types nandi notable meaning types that can exist in your program where there is no explicit way to write the name of that type such as intersection types for example if you needed to infer a non explicit type that if it existed would sit at the intersection of two other types or anonymous class types for example to declare a singleton instance of a local class to let the compiler infer the proper reference type to access the unique fields and methods within an anonymous inner class where can it not be used it can't be used in declarations without an initial value or in initializations with a null value compound declarations array initializers fields parameters or as a method return type well why not consider this bad example method public var gets something it has a var something parameter and then it returns something so what kind of argument can be passed into this method what exactly is the return type how should this compile because something could be anything type inference is an algorithm not magic a goal of this feature is to let developers more quickly read and understand code but to achieve the understanding both humans and the compiler require context now could you argue that you could infer what something is based on code elsewhere let's say that this method is being called and an object of type a is used as an argument can we safely infer the type of something not quite because what's the stop code from elsewhere from passing in an object of type B another goal of this feature is to prevent action added distance issues don't allow code elsewhere to conflict on what type to infer this prevents binary incompatibilities type must be inferred where the variable is declared now there's a bit of debate around this feature people against it will argue this feature is bad because useful information is being hidden readability is being impaired and bad developers will misuse and overuse the future to write terrible code arguments in favor this feature say I think this is great because redundant information is removed code is more concise and more readable and don't worry about catering to the bad developers bad developers will write terrible code no matter what so who's right well this feature like many others must be used with good judgment and there are guidelines you can use to more effectively realize the benefits of this feature guideline 1 choose a variable name that provides useful information this was always a best practice but it's even more important now consider names that express the variables role or nature result isn't all that informative of a variable name we can tell from the context that result is going to be a stream of customer objects but that contest goes away when we use var so a more informative name for the variable would be customers for example also consider names that convey the variables meaning or type X for the list of customers again isn't all that áfourá of change that to custom lists that's a better name guideline to minimize the scope of local variables in this example we have an ArrayList and we're adding an item to it that's intended to be processed last now this works but what if we later realize we need to change the list to a set a bug is going to occur because set has no defined iteration order now the issue is easy to assess when all the pertinent code is very close but let's say we have a hundred lines of code between where our hash set is created and where we add an item because they're so far away it becomes harder to read and harder to assess the situation guideline 3 consider var when the initializer provides sufficient information here both sides of these statements offer type information byte array output stream bufferedreader lists we can see those written on both the left and right hand side the constructor or factory method calls should provide enough context so change the left-hand side to var or echo becomes much more concise much more readable guideline for consider var to split chained or nested expressions the examples we'll look at will take a collection of strings and finds which occurs most as a single expression it's hard to decipher the stream and optional mix it looks like a single stream pipeline but in fact it's a short stream followed by a second stream over the results of the first followed by a mapping of the optional and result of the second stream if you split it splitting may yield a good balance of readability concision guideline 5 don't worry too much about programming to the interface with local variables a common java idiom is to construct an instance with a concrete initializer type but assign it to a variable of an interface type binding the code to the abstraction in this case the list instead of the implementation in this example of the ArrayList offers flexibility to change the initializer type with minimal complications but this isn't possible when working with local variable type inference var list equals new ArrayList string this is going to be inferred as an ArrayList not a list but potential issues can be easily avoided or mitigated because list is a local variable whose scope should be extremely limited that's what guideline 2 was all about guideline 6 take care using var with diamond or generic methods consider this statement priority queue of item objects item Q equals new priority queue of items the diamond feature lets you emit explicit type information as you can see on the right hand side var also lets you omit explicit type information as you can see on the left hand side but if you combine both it strips the statement of context as a result item Q is inferred as priority Q of objects which may not be that helpful what you can do though is how some arguments which can provide context so type is inferred properly here we have a comparator of string objects comp then we can pass that into the priority queue constructor and as a result item Q is inferred as priority Q of string objects finally guideline 7 take care using var with literals there's no issue with boolean character long or string literals the issue occurs when you're working with whole numbers if you're not careful your whole number may be inadvertently inferred as an integer type take a look at the first Apple white flags equals zero how do we know that we intend zero to be a byte because we're declaring that variable flags to be a byte whereas if you use VAR flies equals zero there's no information here to say we intend to save this as a byte the situation is similar with shorts and Long's at least in the case of the long but we at least have the option of writing 17 L that'll provide enough context for the compiler to know that base is meant to be alone not an int floating point numbers require similar care just be sure that if you mean to save your variable as a float use the little F for context otherwise it'll be saved off as a double you could also cast on all these situations but that's contrary to the goal of being concise the last chap we'll cover is Jeb 3:23 local variable syntax for lambda parameters previously lambda expressions could be explicitly typed they could also be implicitly typed but now landing expressions can also be implicitly typed using the VAR syntax what are the benefits of this well the obvious benefit is that it gives you uniform syntax for local variable type inference everywhere you look it can be done using VAR a more interesting benefit in the context of lambda expressions are the use of annotations and modifiers previously these required explicitly typed lambdas there was no shorthand version for this now Evora provides a more readable implicitly typed alternative just a few words of caution though these examples will won't compile previously you could never mix implicitly and explicitly typed land up parameters and the same is true now with far you can't mix far and non var implicitly typed London expressions and you can't mix far and non var in explicitly typed lambda expressions and just like lambda expressions that have a single explicitly type parameter that requires parentheses the same is true about fara parameter neither can omit parentheses and that's it study hard get some good Java 11 experience under your belt and you should be ready for the certification exam thanks Nick so let's have a look at what's going to happen after job 11 so some of the big challenges or opportunities that we have thrown in front of us include things like making sure that your var runs really well in containers containers are becoming very prevalent in deployments today we are constantly looking at how we can improve on predictability and make sure that Java runs really well and in the predictable way performance has always been very very important for us and that's something that we'd like to stay on top of and we will continue to invest in that and make sure that new features as they come in through processors and that we start leveraging them and making sure that Java runs really fast one of the things that we've started looking into more recently and that it's becoming more important in our industry is data optimizations so code we've been looking at for quite a while and now we're looking at new areas and those include things like data so I'll go into in a few minutes some of the specific things we're looking into there hardware we are looking into new types of hardware not new devices new instructions in the CPUs and making sure that we leverage those and make sure that Java really leverages the acceleration that we get out of those features scalability which is a variant of performance is obviously important as well we want to make sure that Java can leverage many CPUs a lot of memory and wrongly really well without you having to tune things manually and of course we're always looking into how we can improve the java language by introducing new features and new constructs to make it easier to run the right code and perhaps more importantly read code which is obviously what you do more of so looking at some of the specific projects we have around this so with the new release model we now have a Java that is moving forward in a faster and more predictable way than ever before so this release model has us now delivering a feature release every six months and it's part of introducing this new model we've also had to make some changes to the development process in the background we obviously want to
Info
Channel: Oracle University
Views: 11,766
Rating: 4.6410255 out of 5
Keywords: oracle, training, certification, java, education, developer
Id: 81lj7EugAnE
Channel Id: undefined
Length: 31min 2sec (1862 seconds)
Published: Thu Apr 18 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.