Posts

Showing posts with the label java 15

CharSequence isEmpty Method

isEmpty() method added in CharSequence class as a default methid in jdk 15. isEmpty method: default boolean isEmpty() Returns true if this character sequence is empty. Implementation Requirements: The default implementation returns the result of calling length() == 0. Returns: true if length() is 0, otherwise false Example: CharSequence ch = ///Object if(ch.isEmpty()){ //return true if empty }

JDK 15 Has Been Released | What's new in JDK 15?

JDK 15 is live! Download it from the Java SE Downloads page. See the JDK 15 Release Notes for detailed information about this release.  The following are some of the important additions and updates in Java SE 15 and JDK 15: Java 15 Features: 339: Edwards-Curve Digital Signature Algorithm (EdDSA) 360: Sealed Classes (Preview) 371: Hidden Classes 372: Remove the Nashorn JavaScript Engine 373: Reimplement the Legacy DatagramSocket API 374: Disable and Deprecate Biased Locking 375: Pattern Matching for instanceof (Second Preview) 377: ZGC: A Scalable Low-Latency Garbage Collector 378: Text Blocks 379: Shenandoah: A Low-Pause-Time Garbage Collector 381: Remove the Solaris and SPARC Ports 383: Foreign-Memory Access API (Second Incubator) 384: Records (Second Preview) 385: Deprecate RMI Activation for Removal What's New in JDK 15 - New Features and Enhancements: This section describes some of the enhancements in Java SE 15 and JDK 15....

Java - JEP 347: Enable C++14 Language Features

This features added in JDK 16. This includes being able to build with recent versions of various compilers that support C++11/14 language features. Summary: Allow the use of C++14 language features in JDK C++ source code, and give specific guidance about which of those features may be used in HotSpot code. The purpose of this JEP is to formally allow C++ source code changes within the JDK to take advantage of C++14 language features. Lists of new features for C++11 and C++14, along with links to their descriptions, can be found in the online documentation for some of the compilers and libraries: C++ Standards Support in GCC C++ Support in Clang Visual C++ Language Conformance libstdc++ Status libc++ Status

Java - Foreign-Memory Access API

The Foreign-Memory Access API was proposed by JEP 370 and targeted to Java 14 in late 2019 as an incubating API. This JEP proposes to incorporate refinements based on feedback, and re-incubate the API in Java 15. The following changes will be considered for inclusion: A rich VarHandle combinator API, to customize memory access var handles; Targeted support for parallel processing of a memory segment via the Spliterator interface; Enhanced support for mapped memory segments (e.g., MappedMemorySegment::force); Safe API points to support serial confinement (e.g., to transfer thread ownership between two threads); and Unsafe API points to manipulate and dereference addresses coming from, e.g., native calls, or to wrap such addresses into synthetic memory segments. Goals Generality: A single API should be able to operate on various kinds of foreign memory (e.g., native memory, persistent memory, managed heap memory, etc.). Safety: It should not be possible for the API to underm...

Java - Pattern Matching for instanceof

Enhance the Java programming language with pattern matching for the instanceof operator. Pattern matching allows common logic in a program, namely the conditional extraction of components from objects, to be expressed more concisely and safely. For example, all Java programmers with the instanceof-and-cast idiom: if (obj instanceof String) {     String s = (String) obj;     // use s } There are three things going on here: a test (is obj a String?), a conversion (casting obj to String), and the declaration of a new local variable (s) so we can use the string value. The use of pattern matching in instanceof should dramatically reduce the overall number of explicit casts in Java programs. Moreover, type test patterns are particularly useful when writing equality methods. Consider the following equality method taken from Item 10 of the Effective Java book: @Override public boolean equals(Object o) {     return (o instanceof CaseInsensitiveString)...

Java Hidden Classes

Hidden Classes Hidden classes are classes that cannot be used directly by the bytecode of other classes. Hidden classes are intended for use by frameworks that generate classes at run time and use them indirectly, via reflection. A hidden class may be defined as a member of an access control nest, and may be unloaded independently of other classes. Creating a hidden class Whereas a normal class is created by invoking ClassLoader::defineClass, a hidden class is created by invoking Lookup::defineHiddenClass. This causes the JVM to derive a hidden class from the supplied bytes, link the hidden class, and return a lookup object that provides reflective access to the hidden class. The invoking program should store the lookup object carefully, for it is the only way to obtain the Class object of the hidden class. The major difference in how a hidden class is created lies in the name it is given. A hidden class is not anonymous. It has a name that is available via Class::getName and ...

Java - APIs for Creating Unmodifiable Collections

Several new APIs have been added that facilitate the creation of unmodifiable collections. The List.copyOf Set.copyOf Map.copyOf  methods create new collection instances from existing instances. New methods have been added to the Collectors class in the Stream package. toUnmodifiableList toUnmodifiableSet toUnmodifiableMap   These allow the elements of a Stream to be collected into an unmodifiable collection.

Lambda expressions - implicitly typed parameters

For formal parameters of implicitly typed lambda expressions, allow the reserved type name `var` to be used, so that:     (var x, var y) -> x.process(y) is equivalent to:     (x, y) -> x.process(y) An implicitly typed lambda expression must use `var` for all its formal parameters or for none of them. In addition, `var` is permitted only for the formal parameters of implicitly typed lambda expressions --- explicitly typed lambda expressions continue to specify manifest types for _all_ their formal parameters, so it is not permitted for some formal parameters to have manifest types while others use `var`. The following examples are illegal:     (var x, y) -> x.process(y)         // Cannot mix 'var' and 'no var' in implicitly typed lambda expression     (var x, int y) -> x.process(y)     // Cannot mix 'var' and manifest types in explicitly typed lambda expression In theory, it would be...

Java 15 features | What's new in Java 15?

Image
Java 15 Features JDK 15 is the open-source reference implementation of version 15 of the Java SE Platform as specified by by JSR 390 in the Java Community Process. Some of the important Java 15 features are: 371: Hidden Classes 372: Remove the Nashorn JavaScript Engine 377: ZGC: A Scalable Low-Latency Garbage Collector 378: Text Blocks 379: Shenandoah: A Low-Pause-Time Garbage Collector 373: Reimplement the Legacy DatagramSocket API 374: Disable and Deprecate Biased Locking 375: Pattern Matching for instanceof 339: Edwards-Curve Digital Signature Algorithm (EdDSA) 360: Sealed Classes (Preview) 381: Remove the Solaris and SPARC Ports 383: Foreign-Memory Access API (Second Incubator) 384: Records (Second Preview) Some More java 15 features are coming up. We will discuss once openjdk Java Community Process released some information. Java 15 Features : Hidden Classes Hidden classes are classes that cannot be used directly by the bytecode of o...