Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/main/java/org/javademos/init/Java14DemoLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.javademos.commons.IDemo;
import org.javademos.commons.IDemoLoader;
import org.javademos.java14.jep305.InstanceofPatternMatchingPreview;
import org.javademos.java14.jep358.NullPointerDemo;
import org.javademos.java14.jep359.RecordsPreviewDemo;
import org.javademos.java14.jep361.SwitchExpressionsDemo;
import org.javademos.java14.jep370.ForeignMemoryAccessDemo;
Expand All @@ -16,9 +17,10 @@ public class Java14DemoLoader implements IDemoLoader {

@Override
public void loadDemos(Map<Integer, IDemo> demos) {
demos.put(305, new InstanceofPatternMatchingPreview());
demos.put(359, new RecordsPreviewDemo());
demos.put(361, new SwitchExpressionsDemo());
demos.put(370, new ForeignMemoryAccessDemo());
demos.put(305, new InstanceofPatternMatchingPreview()); // JEP 305
demos.put(358, new NullPointerDemo()); // JEP 358
demos.put(359, new RecordsPreviewDemo()); // JEP 359
demos.put(361, new SwitchExpressionsDemo()); // JEP 361
demos.put(370, new ForeignMemoryAccessDemo()); // JEP 370
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.javademos.java17.nullpointer;
package org.javademos.java14.jep358;

import org.javademos.commons.IDemo;

Expand All @@ -10,13 +10,13 @@
/// Further reading:
/// - [Java 14 NullPointerException](https://www.baeldung.com/java-14-nullpointerexception)
///
/// @author alois.seckar@gmail.com
/// @author Abhineshhh
@SuppressWarnings("null") // we are deliberately invoking `NullPointerException` in this demo
public class NullPointerDemo implements IDemo {

@Override
public void demo() {
info("NULL POINTER DEMO", "Examples of 'helpful NullPointer' errors\nintroduced in Java 14");
info(358);

try {
// this will raise NullPointerException, but with helpful hint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.javademos.java17.nullpointer;
package org.javademos.java14.jep358;

import lombok.Getter;

Expand All @@ -7,7 +7,7 @@
* Here we have 4-level nested class structure and somewhere on the way
* one element is 'null', so invoking method on it will raise 'NullPointer'.
*
* @author alois.seckar@gmail.com
* @author Abhineshhh
*/
public class NullPointerLevel1 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.javademos.java17.nullpointer;
package org.javademos.java14.jep358;

import lombok.Getter;

Expand All @@ -7,7 +7,7 @@
* Here we have 4-level nested class structure and somewhere on the way
* one element is 'null', so invoking method on it will raise 'NullPointer'.
*
* @author alois.seckar@gmail.com
* @author Abhineshhh
*/
public class NullPointerLevel2 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.javademos.java17.nullpointer;
package org.javademos.java14.jep358;

import lombok.Getter;

Expand All @@ -7,7 +7,7 @@
* Here we have 4-level nested class structure and somewhere on the way
* one element is 'null', so invoking method on it will raise 'NullPointer'.
*
* @author alois.seckar@gmail.com
* @author Abhineshhh
*/
public class NullPointerLevel3 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.javademos.java17.nullpointer;
package org.javademos.java14.jep358;

/**
* Simple class to show 'helpful' NullPointerExceptions from Java 14.
* Here we have 4-level nested class structure and somewhere on the way
* one element is 'null', so invoking method on it will raise 'NullPointer'.
*
* @author alois.seckar@gmail.com
* @author Abhineshhh
*/
public class NullPointerLevel4 {

Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/JDK14Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
"link": true,
"code": false
},
{
"jep": 358,
"jdk": 14,
"name": "JEP 358 - Helpful NullPointerExceptions",
"dscr": "Enhances NullPointerExceptions to describe precisely which variable was null",
"link": false,
"code": true
},
{
"jep": 359,
"jdk": 14,
Expand Down