#java
Sealed Classes
Java 15 introduces Sealed Classes, a preview language feature, that allows classes/interfaces to restrict which other classes/interfaces may extend or implement them. Here is an example:
In the example above, Vehicle is a sealed class, which specifies three permitted subclasses; Car, Truck and Motorcycle.
Sealing serves two main purposes:
It restricts which classes or interfaces can be a subtype of a class or interface and thus preserves the integrity of your API.
It allows the compiler to list all the permitted subtypes of a sealed type (exhaustiveness analysis), which will (in a future Java release) enable switching over type patterns in a sealed type (and other features). For example, given the following switch statement, the compiler will detect that there is a case statement for every permitted subclass of Vehicle (so no default clause is needed) and it will also give an error if any of them are missing
Sealed Classes
Java 15 introduces Sealed Classes, a preview language feature, that allows classes/interfaces to restrict which other classes/interfaces may extend or implement them. Here is an example:
In the example above, Vehicle is a sealed class, which specifies three permitted subclasses; Car, Truck and Motorcycle.
Sealing serves two main purposes:
It restricts which classes or interfaces can be a subtype of a class or interface and thus preserves the integrity of your API.
It allows the compiler to list all the permitted subtypes of a sealed type (exhaustiveness analysis), which will (in a future Java release) enable switching over type patterns in a sealed type (and other features). For example, given the following switch statement, the compiler will detect that there is a case statement for every permitted subclass of Vehicle (so no default clause is needed) and it will also give an error if any of them are missing
#java
What is the structure of Java Heap?
The JVM has a heap of runtime data. Memory for all class instances and arrays is allocated to this heap, which is created at the JVM start-up. Heap memory for objects is reclaimed by the garbage collector, which is an automatic memory management system.
Both living objects, which are accessible by the application and won’t be part of garbage collection, and dead objects, which will never be accessible by the application but haven’t yet been collected by the garbage collector, make up the heap memory space until the dead objects eventually end up in the garbage collector.
What is the structure of Java Heap?
The JVM has a heap of runtime data. Memory for all class instances and arrays is allocated to this heap, which is created at the JVM start-up. Heap memory for objects is reclaimed by the garbage collector, which is an automatic memory management system.
Both living objects, which are accessible by the application and won’t be part of garbage collection, and dead objects, which will never be accessible by the application but haven’t yet been collected by the garbage collector, make up the heap memory space until the dead objects eventually end up in the garbage collector.
#java StreamAPI
We have a source - our collection. We don't copy all the elements at once, but stretch it, loading the elements in stages, doing some operations.
It's like a file stream, only instead of reading byte by byte, we get references to objects
Therefore, when the stream is open (we are working with the address space of our data structure), we cannot change it.
That is, if we had a collection with objects of the Person type, we could do something like this:
We have a source - our collection. We don't copy all the elements at once, but stretch it, loading the elements in stages, doing some operations.
It's like a file stream, only instead of reading byte by byte, we get references to objects
[1]
(if we don't have a primitive stream - IntStream, etc.)Therefore, when the stream is open (we are working with the address space of our data structure), we cannot change it.
[1]
By the way, this is a stream of object references, not a stream of bytes. It means we can modify objects of the collection by reference(setters, getters, and so on).That is, if we had a collection with objects of the Person type, we could do something like this:
personList.stream().forEach(x->x.setName("New name"));
#news #java
Oracle doesn't want Java EE any more
Oracle wants someone else to lead enterprise Java, though it says it will stay involved. Apache and Eclipse are likely candidates to take over Java EE.
Oracle wants to end its leadership in the development of enterprise Java and is looking for an open source foundation to take on the role.
The company said today that the upcoming Java EE (Enterprise Edition) 8 presents an opportunity to rethink how the platform is developed. Although development is done via open source with community participation, the current Oracle-led process is not seen agile, flexible, or open enough. ”We believe that moving Java EE technologies to an open source foundation may be the right next step, to adopt more agile processes, implement more flexible licensing and change the governance process,” Oracle said in a statement.
Oracle doesn't want Java EE any more
Oracle wants someone else to lead enterprise Java, though it says it will stay involved. Apache and Eclipse are likely candidates to take over Java EE.
Oracle wants to end its leadership in the development of enterprise Java and is looking for an open source foundation to take on the role.
The company said today that the upcoming Java EE (Enterprise Edition) 8 presents an opportunity to rethink how the platform is developed. Although development is done via open source with community participation, the current Oracle-led process is not seen agile, flexible, or open enough. ”We believe that moving Java EE technologies to an open source foundation may be the right next step, to adopt more agile processes, implement more flexible licensing and change the governance process,” Oracle said in a statement.