Skip to main content

Posts

Showing posts from September, 2018

JDK 11 have nasty surprise? It has fast, scalable and easy to tune new garbage collector i.e. ZGC?

Java 11 is ready with new exciting features and it have nasty surprises as well, It have a newly designed Garbage Collector which is fast, scalable and easy to tune. Let's find out what is it. It is one of the most exciting feature in JDK 11. This brand new Garbage Collector, ZGC, which is being developed by Oracle that promises very low pause times on multi-terabyte heaps. JVM tuning will not be a tedious job because it is easy to tune as well. It is an experimental feature in JDK 11 later on it will available as full feature. It is scalable low latency Garbage Collector which means  it will have pause time less than 10ms no matter how big your heap is.  it is scalable, it can handle multi-terabyte heaps without affecting the performance.  Key features of ZGC are : 1. Concurrent  Marking Relocation/compaction Relocation set selection reference processing  StringTable cleaning 2. Single Generation 3. Load barriers 4. Colored pointers 5. Region based : heap is divided into small reg

Why LinkedList (Java) sucks? Performance comparison with ArrayList? When to use ArrayList over LinkedList?

Collection is the most used concept in Java after String, in collection framework we are mostly rely on ArrayList and LinkedList for keeping the objects in sequential form. these two are most used implementations of List interface but LinkedList always sucks in performance although LinkedList have some advantages as well. ArrayList is what you want. LinkedList is almost always a (performance) bug. Why LinkedList sucks: It uses lots of small memory objects internally to keep connecting the objects, and therefore impacts performance across the process. Lots of small objects are bad for cache-locality. Any indexed operation requires a traversal, i.e. has O(n) performance. This is not obvious in the source code, leading to algorithms O(n) slower than if ArrayList was used. Getting good performance is tricky. Even when big-O performance is the same as ArrayList, it is probably going to be significantly slower anyway. It's jarring to see LinkedList in source because it is probably the wr

Why rt.jar is missing from Jdk9?

Why rt.jar is missing from Jdk9? This is one of the most common question comes to our mind when we see the JDK 9 structure. Previous to JDK 9, Java was having all classes and packages into one single jar I.e. rt.jar aka Java Runtime. Which have 1000+ classes and packages. Rt.jar helps to execute the source code. It provides native support to the application. Let’s get understand with the example if you have written a program just to add two values and print the result.   Class example { public static void main(String args){ int a= 10; int b=20; int c=a+b; System.out.print(“Result ”+c); } } For example, to execute the above program on a machine that can be a PC, mobile device, calculator powered by Java must have this rt.jar and it’s huge in size. Other than PC these devices have very limited space and memory as they are developed for some specific purpose. So Java 9 came up with a new approach that is modular Java, with this approach they break this rt.jar into nearly 100 modules and

Introduction to Project Jigsaw aka Java Platform Module System? How it is going to change the big project development?

Java 9 was a major update in the Java Platform as Java introduced Java Platform Module System, also sometimes referred to as Project Jigsaw.  Jigsaw was the internally used project name during development. Later Jigsaw changed name to Java Platform Module System ( JPMS ). Java platform is totally changed by this implementation. Now java supports module based implementation. It was a must require feature and high on demand for last couple of years as it will help the developers to manage big projects in smaller independent modules and it also going to help the developers to maintain encapsulation among the packages as well, till Java 8 java supports class level abstraction only. In JDK 9, java rt.jar is also divided into the modules java 9 have 93 modules and later on with the release of java 10 these modules are increased to 99. These modules can be found in jdk home under jmods directory as you can see in the below image. What is a Module? Modularity adds a higher level of aggregation

What is enhanced switch statement??? How Java 12 is going to change the way of writing Switch statement?

Oracle provided the Java 12 EA (Early Access) version before releasing Java 11.It shows that Oracle is committed to provide the best features to the developers asap. In order to make coding easy and more readable Java 12 is going to change the way we are writing switch statement. In the traditional way we write the code as I have written below. public static void oldSwitchStatementDemo() {      System.out.println("Old Switch Statement:");      final int inputNumber = 3;      String resultStr;    switch (inputNumber){         case 1 :            resultStr = "ONE";            break;         case 2 :            resultStr = "TWO";            break;         case 3:            resultStr = "THREE";            break;         default:            resultStr = "N/A";      }    System.out.println("Input Number : " + inputNumber + " ==> " + resultStr);   } But after the release of Java 11 we can write the in t

What is SpotBugs? How it works?

SpotBugs is the spiritual successor of FindBugs , carrying on from the point where it left off with support of its community. SpotBugs is a program which uses static analysis to look for bugs in Java code. It is free software, distributed under the terms of the GNU Lesser General Public License . SpotBugs checks for more than 400 bug patterns. If you want to check the description of these 400 bugs please go to Description of all the 400 bug Patterns of SpotBugs . SpotBugs Eclipse Plugin integrates SpotBugs seamlessly with the most popular Java IDE and allows to run SpotBugs analysis incrementally on changed files or on demand per project. A quick plugin introduction is available at http://andrei.gmxhome.de/findbugs/index.html , and a short video demo is available on Youtube as Five minutes FindBugs Eclipse Plugin Demo . SpotBugs is valuable for both beginner and experienced programmers. If you just start to write Java applications, the tool will help you to learn better programming pr

Pro Tips to improve your coding skills

All the professional coder are involve in the learning new technology and new programming language as programming world is evolving and as a coder we are facing some of the common issues like how to learn new things quickly, how to improve the coding skill etc. etc.Well learning new programming or technology is a different thing than improving coding skills. Coding skill doesn't bound with a programming language. Coding skills means the way a programmer writes his code and how he can improve the comments, code format, business logic implementation, adopting the new features of the programming like java 8 and 9 introduced some new features which are one of its kind.  Now I am going to share some of the tips to improve the coding style. First I want to make it in two categories. 1. When you are working on your workstation/official project. Gather complete requirements : Try to gather the complete requirements from your lead, project manger or client. Discuss the things with them as

What is cooking at Oracle for Java 11? Java 11 will include more than just features LTS and more?

Oracle’s move towards a faster release cycle means that more features and abilities are coming our way, faster than ever before.The Java 11 launch date is scheduled for September 2018, and the repository is currently open for bug fixes, as well as propositions for more JDK Enhancement Proposals (JEP) to be added to the upcoming version.  Local-Variable Syntax for Lambda Parameters (JEP 323) Epsilon: An Arbitrarily Low-Overhead Garbage Collector (JEP 318) Dynamic Class-File Constants (JEP 309) Remove the Java EE and CORBA Modules (JEP 320) Java 11 will include more than just features While this feature list is still not final and we’re expecting more JEPs to be added in the following months, Java 11 will have a little something extra. One of the main highlights that will come with Java 11, is long-term support of the platform. To understand what it means, let’s take a trip back to September 2017, when According to Oracle Java SE Support Roadmap Oracle is moving to long-term support (LT

Java 10 Unique Features and What's new Java 10?

Java 10 was released in March 2018, It comes just six months after its predecessor i.e. Java 9 and brings an enhanced Local Variable Type Inference, garbage collection and compilation and other exciting features. It was an enhancement to the Java 9 and its a new polished version of Java 9 as It was not a major update but still it include the important features and modifications such as Native-Header Generation Tool (aka javah) is removed. Java 8 to Java 9 it took 3 years and after 6 months of Java 9 Oracle released the Java 10. Java community announced its shift to a new 6 month cadence for Java. It moved to a Long Term Support (LTS) model for Oracle Java SE products. What does LTS mean? LTS version of the products will offer premier and sustained support from Oracle and it will be targeted every 3 years. Java 10 features 1. Local-Variable Type Inference :  Local-Variable Type Inference is the biggest new feature in Java 10. It adds type inference to declarations of local variables wit

Java 9 Unique features

Java 9 was initially release in September 2017, but it got some improvements in the October update later on it was final release in January 2018. Release Release date Highlights Java SE 9 2017-09-21 Initial release Java SE 9.0.1 2017-10-17 October 2017 security fixes and critical bug fixes Java SE 9.0.4 2018-01-16 Final release for JDK 9; January 2018 security fixes and critical bug fixes Java 9 Introduced an entire new structure, it is the first update that have an efficient architecture for small size devices and it was made possible due to modular structure. Java 9 introduced a new system to deal with the small devices with java modules. I have the following bunch of unique features/emhacements: 1. Java 9 REPL (JShell) : Introduced a new system to test the program using JShell. The Java Shell tool (JShell) is an interactive tool for learning the Java programming language and prototyping Java code. JShell is a Read-Evaluate-Print Loop ( REPL ), which evaluates declarations, statemen

Java 8 Unique features

Java 8 was released in March 2014 and it was great a update. Release Release date Highlights Java SE 8 2014-03-18 Initial release Java SE 8 Update 5 [252] 2014-04-15 Using " * " in  Caller-Allowable-Codebase  attribute; 11 bug fixes Java SE 8 Update 11 [253] 2014-07-15 Java Dependency Analysis Tool (jdeps); Java Control Panel option to disable sponsors; JAR file attribute – Entry-Point; JAXP processing limit property – maxElementDepth; 18 security bug fixes, [254]  15 bug fixes Java SE 8 Update 20 [255] 2014-08-19 669 bug fixes, [256]  JMC 5.4, String deduplication (disabled by default) Latest Java 8 version is Java SE 8 Update 181. Oracle decided to overhauled the java with new exciting features and these are : 1. forEach() method in Iterable interface : It is a new way to iterate over the collections (list, set, map etc.) 2. default and static methods in Interfaces : To provide the backward compatibility Java Introduced the default methods and it also help the programmers t