Java 9 and Beyond
summary
Covers concrete Java 9–13 changes: module system replaces bloated rt.jar (~68MB) with modules vs classpath and enforces requires/exports so apps fail fast; try‑with‑resources accepts effectively‑final locals; interfaces gain private methods; finalize is deprecated; Streams add takeWhile/dropWhile and an overload of iterate; Optional adds ifPresentOrElse/orElseThrow; List.of/Set.of/Map.of and copyOf produce immutable collections; JShell REPL demos, CompletableFuture timeouts, var local type inference, Predicate.not, text blocks, and hints toward Project Loom.
AI-written summary · about
chapters (29)
- 0:00Start
- 3:12And So Oracle Was Struggling with this and Saying What Can We Do To Really Remove this Kind of a in a Burden and So They Decided To Come Up with a Six Months Release Cycle so What Does It Really Mean by a Six Months Release Cycle and I'Ve Had People Come Up to Me and Say Oh My Gosh that's Really Not Good if It's Going To Be Released every Six Months What about Quality What about You Know the Features and and Various Other Things and I Think It's Important To Really Understand that Java Is Being Released every Six Months but Java Is Not Being Developed every Six Months and that Is Something We Need To Really Understand because the Development of Java Is Not Taking Place every Six Months the Features They'Re Putting in each of the Release He's Taken the Time It Needs To Be Taken some of the Features Are Taking Five Years and Six Years and Seven Years and They'Re Not Going To Make It any any Faster
- 3:22So What Does It Really Mean by a Six Months Release Cycle and I'Ve Had People Come Up to Me and Say Oh My Gosh that's Really Not Good if It's Going To Be Released every Six Months What about Quality What about You Know the Features and and Various Other Things and I Think It's Important To Really Understand that Java Is Being Released every Six Months but Java Is Not Being Developed every Six Months and that Is Something We Need To Really Understand because the Development of Java Is Not Taking Place every Six Months the Features They'Re Putting in each of the Release He's Taken the Time It Needs To Be Taken some of the Features Are Taking Five Years and Six Years and Seven Years and They'Re Not Going To Make It any Any Faster and Contrast That Somehow into Six Six Months It's Not like Our Scrum that We Run every Month That's Not What They Are Doing
- 4:38Problem You Can Get on the Train in Six Months from Now so as a Result the Development Is Really Taking the Time It Needs To Take but the Release Is Not Forcing Itself To Slow Down so They Are Able To Release Much Faster As Soon as Certain Features Are Ready and Available and They Are Comfortable To Release It Now at the Same Token though One of the Things I'M Really Appreciate with What They Do Is They'Re Not Forcing Themselves to Predefined Certain Things That Go into a Release as They Get Closer to a Release if Things Are Really Shaping Up Really Well Then They Commit at that Point to a Particular Release but if They Find that that's Probably Not Ready They'Re Also Willing To Put that Away and Then Still Make a Release of Whatever They Have So Overall I Would Say that's Truly Agility in My Mind
- 5:37I'M GonNa Talk a Lot More about Java 9 Today because Obviously Java 9 Is the Biggest Release of Java in the Past but Then I Will Talk About 10 11 12 13 As Well but those Will Be Much Quicker because those Are Very Small You Know Bite-Sized Features Being Introduced Rather than Huge Features Being Released in the Past so with that Said Let's Talk about Java 9 and Then of Course We'Ll Go beyond that after that Well the Very First Thing Is What about Interfaces
- 5:59And Then of Course We'Ll Go beyond that after that Well the Very First Thing Is What about Interfaces Well Let's Talk about Interfaces Just for a Minute Let's Go Ahead and Start with a Little Okay Here To Say the Compiler Is Happy with What I'M Doing and What I Want To Do Here Is To Define an Interface To Begin with So Let's Say We Have an Interface Called Util and the Interface You Tell Let's Say Contains a Get a Let's Say Number of Cores over Here and I'M GonNa Write this Function as Number of Course and of Course the Compiler Is Quite Happy with Me as You Can See because We Just Define an Interface with a Method in It but of Course if I Were To Define a Body a Function Right Here Something like Return to Java Will Stare at Me and Ask Me if I Even Know Java because You CanNot Really Implement Methods with an Interfaces like that So What Does an Interface Do Well in the Past an Interface Was a Bunch of Collection of Methods
- 6:25Over Here and I'M GonNa Write this Function as Number of Course and of Course the Compiler Is Quite Happy with Me as You Can See because We Just Define an Interface with a Method in It but of Course if I Were To Define a Body a Function Right Here Something like Return to Java Will Stare at Me and Ask Me if I Even Know Java because You CanNot Really Implement Methods with an Interfaces like that So What Does an Interface Do Well in the Past an Interface Was a Bunch of Collection of Methods with no Implementation Here's How I Used To Define Interfaces I Would Say Interfaces Are Something That Says a Lot about What It'Ll Do but It Never Does Anything Kind Of like My Boss That's Basically What Interfaces Wear but that Changed Very Quickly in Java Eight because You Can Have Implementations within Interfaces so as a Result as You Can See Here You Can Provide Certain Method Implementations within Interfaces Similarly in Java Eight of Course We Had Static Methods As Well so for Example if I Were To Define a Method Static Right Here and Then I'M Going To Simply Say Return Four Also Here that One Works Too but Then that Brings the Question if Interfaces Can Have Methods
- 7:35Well Clearly Classes Have Methods and What if We Have Common Code between Multiple Methods in a Class We Typically Use an Extract Method Refactoring and Move that Code into a Common Method but Oftentimes if We Mark those Methods as Private Methods We Call Them as Helper Methods so the Obvious Question Is if Classes Can Have Private Methods Why Can't Interfaces Have Private Methods Well It Turns Out We Actually Can Do that We Can Say Private for Example Let's Say Get Count over Here and I'M GonNa Return a Four
- 11:14The Bad News about Garbage Collection in Java Is It Is Automatic and as a Result You Don't Know When It's GonNa Get Called so It's Very Unpredictable so Garbage Character in Java Is Kind Of like Garbage Collector in My Neighborhood Just because I Leave the Trash Out Doesn't Mean They Come and Get It So in Other Words in the Case of Java the Garbage Kit Could Remain for Quite a Long Time if There Is a Lot of Memory Datas and When the Runtime Determines that It Needs To Clean Up It Kicks In and Cleans It Up that's When It Releases the Memory for Most Part You Could Say if all You Have To Worry about Is Memory
- 11:40And When the Runtime Determines that It Needs To Clean Up It Kicks In and Cleans It Up that's When It Releases the Memory for Most Part You Could Say if all You Have To Worry about Is Memory You Don't Have To Really Deal with Garbage Collection That's Taken Care for You Well Unfortunately Though When It Comes to Programs There Are Two Kinds of Garbage You Need To Really Worry about One Garbage Is of Course the Memory That You Use during Runtime but the Other Garbage Is External Resources this Could Be a File That You Have Open a Database Connection That You Have Open a Socket That You Have Open or Whatever That Could Be that You Are Connecting to Externally
- 15:05The Garbage Cutter Doesn't Have a Reason To Run if the Garbage Cutter Doesn't Run There Is Nothing To Tell that It's Card To Call the Finalize Method Now this Is Actually a Problem Which Is Common in Programming a Lot of Us Do this Everyday and It's Somewhat Surprising To See that They Have Fall into this Trap As Well Which Is Taking Two Independent Ideas and Bringing Them Together this Is One of the Things We Do By Mistake a Lot of Times and Enrich a Key Called Such as Completing
- 16:07This Is Awesome Let's Do this but Unfortunately like You Saw Here the Finalize Method Is Not Being Called At All if They Ever Want To Rename the Finalize Method I Have an Idea a Better Name Would Be Bad Idea because that's What It Really Was It Was a Terrible Idea To Have Written the Finalize Method but I Can Bet You One of the Jquery Code Developers Is Is the Funniest Person in the World because I Think He Is Sitting There and Laughing His Head Off because He Provided a Method Which I Consider the Funniest Method in the Jdk It Is Called System Dot Gc because this this Function Is So Cool that When You Compile Your Code and When You Run It It Does Absolutely Nothing
- 18:52And I'M Really a Big Fan of the Fact that They Treated Finalized as Warning Deprecated Warning so What Am I Going To Do Then Well I Can Apply the Java 7 Technique Right Now and all I'M GonNa Do Is Simply Quietly Rename the Finalize Method as a Closed Method So Rename the Finalize As Close and Then Implements over Here the the Interface Implements Auto Closeable and by Implementing Auto Plausible You Are Saying that My Class Will Now Have a Closed Method Now What Do We Do We Go Over to this Code and Say Try and Then We Provide this Try Block Right Here and Then We Move this Code to Inside of the Reader So When We Execute the Code this Time You Will Notice that Constructor Is Going To Be Called the Op One Is Going To Be Called
- 19:31And Then We Move this Code to Inside of the Reader So When We Execute the Code this Time You Will Notice that Constructor Is Going To Be Called the Op One Is Going To Be Called but When We Leave Line Number 21 the Close Method Will Be Called Automatically As Well so as a Result We Are Able to this Is No Longer a Bad Idea to that Extent and of Course in this Case When We Run the Code You Can See that It Automatically Calls a Closed Method for Us So this Gives Us an Ability for Us To Use the Try with Resources Now Obvious Question Is Try with Resources To Be Really a Good Idea
- 27:40So What that Means Is after You Leave 22 on Line 22 the File the Close Method Was Actually Called Which Means You Are Cleaning Up Your External Resources and after Cleaning Up the External Resources You Can Still Come Back and Access the Object so You Can Call Potentially Methods on the Object at this Point if You Really Wanted to What that Means Is Its Potential that You May Be Able To Call Methods on the Object after the External Resource Have Been Removed Well if External Resource Have Been Removed How Valid Is this Object Moving Forward Which Means We Have To Do a Little Bit More Error Checking
- 32:24And It Will Refactor this Entire Code with that and All Your Unit Tests Will Still Pass and Check in the Code and Walk Away as the Building Burns Down and if You Ever Do this Don't Ever Tell Them I Gave You this Idea No I'M Just Kidding Don't Do this because It's GonNa Make It Really Hard To Read so the Goal Is Not To Really Make the Code Hard To Read Even though this Will Compile Your Goal Is Not To Really Write a Code like that So Quit Using Underscores
- 38:55I'M GonNa Keep Giving You no Gifts and the Last Person I'M GonNa Give a Gift To Is a Person with the Hat and I'M GonNa Stop Well that's a Logical Limit Rather than a Limit Based on Account So How Do We Really Make that Work Well the Good News Is that Was Added in Java 9 but before We Talk about What Java 9 Added Let's Step Back for a Second I Love Languages like Haskell and Language like Haskell I Would Say or in My Mind Gold Standard for Functional Programming They'Ve Been Around for a Long Time and They Provide some Really Really Nice Methods and of Course We Have Java and Java
- 44:38Functional Style of Looping
- 53:39What Is Optional
- 54:56Why Is Null Such a Bad Idea
- 1:14:21What Is a Live Lock
- 1:19:58Type of the Key versus the Type of the Value
- 1:23:03Java Code without Semicolon
- 1:25:26Modules
- 1:26:35Make Java More Secure
- 1:35:11Unnamed Module
- 1:37:15Automatic Native Modules
- 1:40:08Explicitly Named Module
- 1:46:28Java 10








