tag:blogger.com,1999:blog-36185384843473699312024-01-15T15:53:52.435-08:00JAVA Software TechnologyAnonymoushttp://www.blogger.com/profile/06122108442458529949noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-3618538484347369931.post-81126853598362988662015-12-08T03:13:00.000-08:002015-12-08T03:59:56.391-08:00New features in Java 9<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="color: purple;">New features in Java 9</span></h2>
<div>
<span style="color: blue;">Java 8</span> described as the major release of lambdas, streams and API changes, then <span style="color: blue;">Java 9</span> is all about Jigsaw, extra utilities and changes under the hood.<br />
<br />
http://blog.takipi.com/java-9-the-ultimate-feature-list/<br />
<br />
<h2 style="background-color: white; color: #444444; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 24px; line-height: 33.6px; margin: 0px 0px 10px; text-rendering: optimizeLegibility; word-wrap: break-word;">
<span style="font-size: large;">
1. Java + REPL = jshell</span></h2>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
The next release of Java will feature a new command line tool called jshell. It will Java way to REPL (Read-Eval-Print-Loop). </div>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
REPL = If you’ll want to run a few lines of Java on their own you can run is as command prompt. you don’t have to wrap it all in a separate project or method. you don't required to use even semicolons.</div>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 32px; word-wrap: break-word;">
<div class="syntaxhighlighter java" id="highlighter_631443" style="font-size: 1em !important; margin: 1em 0px !important; overflow-x: auto !important; overflow-y: hidden !important; position: relative !important; width: 860px; word-wrap: break-word;">
<div class="toolbar" style="background: rgb(212, 208, 200) !important; border-radius: 0px !important; border: none !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(160, 160, 160) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 10px !important; height: 11px !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: absolute !important; right: 1px !important; top: 1px !important; vertical-align: baseline !important; width: 11px !important; word-wrap: break-word; z-index: 10 !important;">
<span style="word-wrap: break-word;"><a class="toolbar_item command_help help" href="http://blog.takipi.com/5-features-in-java-9-that-will-change-how-you-develop-software-and-2-that-wont/#" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(160, 160, 160) !important; display: block !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 1px 0px 0px !important; position: static !important; right: auto !important; text-align: center !important; text-decoration: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">?</a></span></div>
<table border="0" cellpadding="0" cellspacing="0" style="background: none !important; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-radius: 4px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-spacing: 0px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-width: 1px 1px 1px 0px; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 20px 0px; max-width: 100%; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 860px; word-wrap: break-word;"><tbody style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">
<tr style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;"><td class="gutter" style="background: none !important; border-bottom-width: 0px !important; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-radius: 0px 0px 0px 4px; border-right-width: 0px !important; border-top-width: 0px; bottom: auto !important; box-sizing: content-box !important; color: rgb(120, 120, 120) !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 18px; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 8px; position: static !important; right: auto !important; top: auto !important; vertical-align: top; width: auto !important; word-wrap: break-word;"><div class="line number1 index0 alt2" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border-right-color: rgb(212, 208, 200) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important; word-wrap: break-word;">
<span style="font-family: inherit; font-size: x-small;">1</span></div>
<div class="line number2 index1 alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border-right-color: rgb(212, 208, 200) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important; word-wrap: break-word;">
<span style="font-family: inherit; font-size: x-small;">2</span></div>
<div class="line number3 index2 alt2" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border-right-color: rgb(212, 208, 200) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important; word-wrap: break-word;">
<span style="font-family: inherit; font-size: x-small;">3</span></div>
</td><td class="code" style="background: none !important; border-bottom-width: 0px !important; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-radius: 0px 0px 4px; border-right-width: 0px !important; border-top-width: 0px; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 18px; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 8px; position: static !important; right: auto !important; top: auto !important; vertical-align: top; width: 824.8px; word-wrap: break-word;"><div class="container" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">
<div class="line number1 index0 alt2" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important; word-wrap: break-word;">
<span style="font-family: inherit; font-size: x-small;"><code class="java plain" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">-> </code><code class="java value" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 153, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">2</code> <code class="java plain" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">+ </code><code class="java value" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 153, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">2</code></span></div>
<div class="line number2 index1 alt1" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important; word-wrap: break-word;">
<span style="font-family: inherit; font-size: x-small;"><code class="java plain" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">| Expression value is: </code><code class="java value" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 153, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">4</code></span></div>
<div class="line number3 index2 alt2" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important; word-wrap: break-word;">
<span style="font-family: inherit; font-size: x-small;"><code class="java plain" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">| assigned to temporary variable $</code><code class="java value" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 153, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">1</code> <code class="java plain" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">of type </code><code class="java keyword" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(127, 0, 85) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">int</code></span></div>
</div>
</td></tr>
</tbody></table>
</div>
</div>
<h2 style="background-color: white; color: #444444; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 24px; line-height: 33.6px; margin: 0px 0px 10px; text-rendering: optimizeLegibility; word-wrap: break-word;">
<span style="font-size: large;">
2. Microbenchmarks</span></h2>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
The Java Microbenchmarking Harness (JMH) is a Java harness for building, running, and analyzing nano/micro/milli/macro benchmarks. When it comes to accurate benchmarking, there are forces in play like warm up times and optimizations that can have a big impact on results. Especially when you’re going down to micro and nano seconds.<br />
JMH is your best choice if you want to get the most accurate results to help you reach the right decision following your benchmarks – And now it’s becoming a synonym with Java 9.</div>
<h2 style="background-color: white; color: #444444; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 24px; line-height: 33.6px; margin: 0px 0px 10px; text-rendering: optimizeLegibility; word-wrap: break-word;">
<span style="font-size: large;">
3. G1 be the new default garbage collector</span></h2>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
With Java 9, There’s a running proposal that’s still in debate to replace the default garbage collector (The parallel / Throughput collector) with G1 which was introduced in Java 7.</div>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
Generally, G1 was designed to better support heaps larger than 4GB and has been known to cause less frequent GC pauses, but when a pause do comes, it tends to be longer.</div>
<h3 style="background-color: white; font-family: lato, 'helvetica neue', helvetica, arial, sans-serif; line-height: 33.6px; margin: 0px 0px 10px; text-align: left; word-wrap: break-word;">
<span style="font-size: large;">
4. HTTP 2.0 is the future</span></h3>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
The official HTTP 2.0 RFC was approved just a few months ago, building on top of Google’s SPDY algorithm. SPDY has already shown great speed improvements over HTTP 1.1 ranging between 11.81% to 47.7% and its implementation already exists in most modern browsers.<br />
Java 9 will have full support for HTTP 2.0 and feature a new HTTP client for Java that will replace HttpURLConnection, and also implement HTTP 2.0 and websockets.</div>
<h3 style="background-color: white; font-family: lato, 'helvetica neue', helvetica, arial, sans-serif; line-height: 33.6px; margin: 0px 0px 10px; text-align: left; word-wrap: break-word;">
<span style="font-size: large;">
5. The process API just got a huge boost</span></h3>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
<div style="color: #333333; font-family: lato, 'helvetica neue', helvetica, arial, sans-serif; font-size: 16px; line-height: 22px;">
So far there has been a limited ability for controlling and managing operating system processes with Java. For example, in order to do something as simple as get your process PID in earlier versions of Java, you would need to either access native code or use some sort of a magical workaround. Moreover, it would require a different implementation for each platform to guarantee you’re getting the right result.</div>
<div style="color: #333333; font-family: lato, 'helvetica neue', helvetica, arial, sans-serif; font-size: 16px; line-height: 22px;">
<br /></div>
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String[] args) throws Exception</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Process proc = Runtime.getRuntime().exec(new String[]{ "/bin/sh", "-c", "echo $PPID" });</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if (proc.waitFor() == 0)</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>InputStream in = proc.getInputStream();</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>int available = in.available();</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>byte[] outputBytes = new byte[available];</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>in.read(outputBytes);</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>String pid = new String(outputBytes);</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("Your pid is " + pid);</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span><br />
<span style="color: #333333; font-family: "lato" , "helvetica neue" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 16px; line-height: 22px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></div>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
In Java 9, expect the code for retrieving Linux PIDs, that now looks like this:<br />
<br />
<code class="java plain" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">System.out.println(</code><code class="java string" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">"Your pid is "</code><span style="color: black; font-family: "consolas" , "bitstream vera sans mono" , "courier new" , "courier" , monospace , "important"; line-height: 17.6px; white-space: pre;"> </span><code class="java plain" style="background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; word-wrap: break-word;">+ Process.getCurrentPid())</code><br />
<br />
The update will extend Java’s ability to to interact with the operating system: New direct methods to handle PIDs, process names and states, and ability to enumerate JVMs and processes and more.</div>
<h3 style="background-color: white; font-family: lato, 'helvetica neue', helvetica, arial, sans-serif; line-height: 33.6px; margin: 0px 0px 10px; text-align: left; word-wrap: break-word;">
<span style="font-size: large;">
6. Debugging in Production</span></h3>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
Solving errors in production has always been a messy practice, grepping for clues over huge log files, and trying to identify the state that caused each exception or logged error. But what if you could avoid logs altogether? Here’s how it’s done.</div>
<h3 style="background-color: white; font-family: lato, 'helvetica neue', helvetica, arial, sans-serif; margin: 0px 0px 10px; text-align: left; word-wrap: break-word;">
<span style="font-size: large;"><span style="line-height: 33.6px;">7</span><span style="line-height: 25.2px;">. A standardized lightweight JSON API</span></span></h3>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
On a survey we conducted with 350 developers, the JSON API was just as hyped as Jigsaw but looks like it didn’t make the cut due to funding issues. Mark Reinhold, chief architect of the Java platform, on the JDK 9 mailing list:</div>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
“This JEP would be a useful addition to the platform but, in the grand scheme of things, it’s not as important as the other features that Oracle is funding, or considering funding, for JDK 9. We may reconsider this JEP for JDK 10 or a later release. ”</div>
<h3 style="background-color: white; color: #444444; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 18px; line-height: 25.2px; margin: 0px 0px 10px; text-rendering: optimizeLegibility; word-wrap: break-word;">
<span style="font-size: large;">
8. Money and Currency API</span></h3>
<div style="background-color: white; color: #333333; font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22px; margin-bottom: 20px; word-wrap: break-word;">
In other news, it also looks like the expected Money and Currency API is also lacking Oracle support. This is the answer we got from Anatole Tresch, the APIs spec lead:<br />
<br />
<br />
<a href="http://javasoftwaretechnology.blogspot.in/2015/11/whats-new-in-java-8.html" style="font-family: 'Times New Roman'; font-size: medium; line-height: normal;" target="_blank">New features in Java 8</a></div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06122108442458529949noreply@blogger.com1tag:blogger.com,1999:blog-3618538484347369931.post-89885248967511613502015-12-08T03:08:00.000-08:002015-12-08T03:14:40.857-08:00JAVA 9 Schedule <div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="color: #660000; font-family: inherit; font-size: large;">proposed schedule for JAVA 9</span></h2>
<h3 style="text-align: left;">
<span style="color: blue; font-size: small;">JAVA 9 is scheduled for September 2016.</span></h3>
<span style="color: blue;">2015-12-10 – Feature Complete</span><span style="font-size: x-small;"> – All features implemented and integrated into the master forest</span><br />
<span style="color: blue;">2016-02-04 – All Tests Run</span><span style="font-size: x-small;"> – All planned tests have been run on all supported platforms</span><br />
<span style="color: blue;">2016-02-25 – Rampdown Start</span><span style="font-size: x-small;"> – Increased level of scrutiny is applied to incoming changes</span><br />
<span style="color: blue;">2016-04-21 – Zero Bug Bounce</span><span style="font-size: x-small;"> – The bug backlog is completely addressed</span><br />
<span style="color: blue;">2016-06-16 – Ramp down Phase 2</span><span style="font-size: x-small;"> – A second round of checks is applied to incoming changes</span><br />
<span style="color: blue;">2016-07-21 – Final Release Candidate</span><span style="font-size: x-small;"> – The final release candidate has been declared and submitted for testing</span><br />
<span style="color: blue;">2016-09-22 – General Availability</span><span style="font-size: x-small;"> – Final release, ready for production use</span><br />
<br />
<a href="http://openjdk.java.net/projects/jdk9/" target="_blank">More Info</a><br />
<a href="http://javasoftwaretechnology.blogspot.com/2015/12/new-features-in-java-9.html" target="_blank">New features in Java 9</a><br />
<a href="http://javasoftwaretechnology.blogspot.in/2015/11/whats-new-in-java-8.html" target="_blank">New features in Java 8</a><br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/06122108442458529949noreply@blogger.com0tag:blogger.com,1999:blog-3618538484347369931.post-52896654376217794572015-11-24T03:34:00.000-08:002015-11-24T03:37:04.000-08:00Java Annotations Tutorial and Example<div dir="ltr" style="text-align: left;" trbidi="on">
<h1>
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">What is Java Annotations & How to Create It?</span></h1>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><i><span class="Apple-tab-span" style="background-color: white; color: #333333; line-height: 18px;"></span><span class="Apple-tab-span" style="background-color: white; color: #333333; line-height: 18px;"></span><span class="Apple-tab-span" style="background-color: white; color: #333333; line-height: 18px;"></span><span class="Apple-tab-span" style="background-color: white; color: #333333; line-height: 18px;"></span><span class="Apple-tab-span" style="background-color: white; color: #333333; line-height: 18px;"></span>Java annotations are used to provide meta data for your Java code. Being meta data, Java annotations do not directly affect the execution of your code. These annotations can then be processed at compile time by pre-compiler tools, or at runtime via Java Reflection.</i></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><i><br /></i></span></div>
<div>
<span style="color: blue; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="background-color: white; font-size: x-small; line-height: 18px;"></span><span style="background-color: white; font-size: 17.5px; line-height: 22.4px;"><b>Classes, methods, variables, parameters and packages may be annotated. </b></span></span></div>
<div>
<div>
<h3 style="margin-top: 30px; text-align: left;">
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Some Built-in Java Annotations</span></h3>
</div>
<div>
<ul style="background-color: white; color: #252525; font-size: 17.5px; line-height: 22.4px; list-style-image: url(data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20width%3D%225%22%20height%3D%2213%22%3E%0A%3Ccircle%20cx%3D%222.5%22%20cy%3D%229.5%22%20r%3D%222.5%22%20fill%3D%22%2300528c%22%2F%3E%0A%3C%2Fsvg%3E%0A); margin: 0.3em 0px 0px 1.6em; padding: 0px;">
<li style="margin-bottom: 0.1em;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><tt><b>@Override</b></tt> - Checks that the method is an override. Causes a compile error if the method is not found in one of the parent classes or implemented interfaces.</span></li>
<li style="margin-bottom: 0.1em;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><tt><b>@Deprecated</b></tt> - Marks the method as obsolete. Causes a compile warning if the method is used.</span></li>
<li style="margin-bottom: 0.1em;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><tt><b>@SuppressWarnings</b></tt> - Instructs the compiler to suppress the <a href="https://en.wikipedia.org/wiki/Compile_time" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #0b0080; text-decoration: none;" title="Compile time">compile time</a> warnings specified in the annotation parameters.</span></li>
</ul>
</div>
</div>
<div>
<h3 style="margin-top: 30px; text-align: left;">
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Java Annotation Types</span></h3>
</div>
<div>
<ol style="text-align: left;">
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><b><b>Build-time </b>instruction (Development time)</b><span style="background-color: white; color: #252525; font-size: 17.5px; line-height: 22.4px;"> - </span>Retention is set to source only, such annotation are use full at source level only and removed by compiler while generating binary class file.<br /><span style="color: #660000;"><b>e.g.</b> <b>@Documented</b></span></span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><b><b>Compiler </b> instructions (Deployment time)</b><span style="background-color: white; color: #252525; font-size: 17.5px; line-height: 22.4px;"> - </span>Retention is set be to class only. Such annotation are used by compiler or deployment tools for taking some specific action e.g. producing compile time error in case of some rule or guideline violation.<br /><b><span style="color: #660000;">e.g. @Depricated, @Override</span></b></span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Runtime instructions (Execution time)</b><span style="background-color: white; color: #252525; font-size: 17.5px; line-height: 22.4px;"> - </span>Retention is set run-time, such annotation are retained in class file are used for deducing some meta information at run time and may effect run time processing. These annotations are not ignored by VM.<br /><b><span style="color: #660000;">e.g. @Entity, @Test</span></b></span></li>
</ol>
</div>
<div>
<h3 style="background-color: white; border: 0px none; line-height: 1em; list-style: none; margin: 25px 0px 10px; outline: none; padding: 0px; text-align: left;">
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Use cases</span></h3>
</div>
<div>
<div style="background-color: white; border: 0px none; color: #333333; font-size: 15px; line-height: 18px; list-style: none; outline: none; padding: 0px 0px 1em;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Annotations can be used for many different purposes, the most common ones are:</span></div>
<ul style="background-color: white; border: 0px none; color: #333333; font-size: 15px; line-height: 18px; list-style: none; margin: 0px 0px 25px 10px; outline: none; padding: 0px;">
<li style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px none; list-style: disc outside none; margin: 0px 0px 5px 10px; outline: none; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><strong style="border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;">Information for the compiler</strong><span style="color: #252525; font-size: 17.5px; line-height: 22.4px;"> - </span>Annotations can be used by the compiler to produce warnings or even errors based on different rules. One example of this kind of usage is the Java 8 <code style="background: url(http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/themes/jarida/images/code-bg.png); border-color: rgb(225, 225, 225) rgb(240, 240, 240) rgb(240, 240, 240) rgb(225, 225, 225); border-style: solid; border-width: 1px; color: #666666; direction: ltr; display: inline; font-size: 11px; font-stretch: normal; line-height: 19px; list-style: none; margin: 0px 0px 20px; outline: none; overflow-x: visible; overflow-y: hidden; padding: 3px;">@FunctionalInterface</code> annotation. This one makes the compiler to validate the annotated class and check if it is a correct functional interface or not.</span></li>
<li style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px none; list-style: disc outside none; margin: 0px 0px 5px 10px; outline: none; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><strong style="border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;">Documentation</strong><span style="color: #252525; font-size: 17.5px; line-height: 22.4px;"> - </span>Annotations can be used by software applications to measure the quality of the code like FindBugs or PMD do or generate reports automatically like Jenkins, Jira or Teamcity.</span></li>
<li style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px none; list-style: disc outside none; margin: 0px 0px 5px 10px; outline: none; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><strong style="border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;">Code generation</strong><span style="color: #252525; font-size: 17.5px; line-height: 22.4px;"> - </span>annotations can be used to generate code or XML files automatically using metadata information present in the code. A good example of this is the JAXB library.</span></li>
<li style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px none; list-style: disc outside none; margin: 0px 0px 5px 10px; outline: none; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><strong style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px none; list-style: none; margin: 0px; outline: none; padding: 0px;">Runtime processing</strong><span style="color: #252525; font-size: 17.5px; line-height: 22.4px;"> - </span>Annotations that are examined in runtime can be used for different objectives like unit testing (Junit), dependency injection (Spring), validation, logging (Log4J) ,data access (Hibernate) etc.</span></li>
</ul>
</div>
<h3 style="text-align: left;">
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><span style="line-height: 18px;"><b>Creating Custom Annotation</b></span></span></h3>
<div>
<h4 style="background-color: white; line-height: 1.5em; margin: 0px 0px 0.5em; padding: 0px;">
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Rules of Thumb for Defining Java Annotation Types</span></h4>
<div style="background-color: white; line-height: 18.2px; margin-bottom: 1.5em; padding: 0px;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Here are some rules-of-thumb when defining an annotation type:</span></div>
<ol style="background-color: white; line-height: 18.2px; margin: 1em 1em 1em 2em; padding: 0px;">
<li style="list-style: decimal outside; margin: 0px; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Annotation declaration should start with an 'at' sign like @, following with an interface keyword, following with the annotation name.</span></li>
<li style="list-style: decimal outside; margin: 0px; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Method declarations should not have any parameters.</span></li>
<li style="list-style: decimal outside; margin: 0px; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Method declarations should not have any throws clauses.</span></li>
<li style="list-style: decimal outside; margin: 0px; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Return types of the method should be one of the following:</span></li>
<ul style="margin: 1em 1em 1em 2em; padding: 0px;">
<li style="list-style: disc outside; margin: 0px; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">primitives</span></li>
<li style="list-style: disc outside; margin: 0px; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">String</span></li>
<li style="list-style: disc outside; margin: 0px; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Class</span></li>
<li style="list-style: disc outside; margin: 0px; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">enum</span></li>
<li style="list-style: disc outside; margin: 0px; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">array of the above types</span></li>
</ul>
</ol>
<div style="background-color: white;">
<h4 style="border: 0px none; line-height: 18px; list-style: none; outline: none; padding: 0px 0px 1em;">
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">The Java reflection API</span></h4>
<ul style="border: 0px none; color: #333333; line-height: 18px; list-style: none; margin: 0px 0px 25px 10px; outline: none; padding: 0px;">
<li style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px none; list-style: disc outside none; margin: 0px 0px 5px 10px; outline: none; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><code style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: url(http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/themes/jarida/images/code-bg.png); background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: rgb(225, 225, 225) rgb(240, 240, 240) rgb(240, 240, 240) rgb(225, 225, 225); border-style: solid; border-width: 1px; color: #666666; direction: ltr; display: inline; font-stretch: normal; line-height: 19px; list-style: none; margin: 0px 0px 20px; outline: none; overflow-x: visible; overflow-y: hidden; padding: 3px;">getAnnotations()</code>: Returns all annotations for the given element, also the ones that are not explicitly defined in the element definition.</span></li>
<li style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px none; list-style: disc outside none; margin: 0px 0px 5px 10px; outline: none; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><code style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: url(http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/themes/jarida/images/code-bg.png); background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: rgb(225, 225, 225) rgb(240, 240, 240) rgb(240, 240, 240) rgb(225, 225, 225); border-style: solid; border-width: 1px; color: #666666; direction: ltr; display: inline; font-stretch: normal; line-height: 19px; list-style: none; margin: 0px 0px 20px; outline: none; overflow-x: visible; overflow-y: hidden; padding: 3px;">isAnnotationPresent(annotation)</code>: Checks if the passed annotation in available or not in the current element.</span></li>
<li style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px none; list-style: disc outside none; margin: 0px 0px 5px 10px; outline: none; padding: 0px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><code style="background: url(http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/themes/jarida/images/code-bg.png); border-color: rgb(225, 225, 225) rgb(240, 240, 240) rgb(240, 240, 240) rgb(225, 225, 225); border-style: solid; border-width: 1px; color: #666666; direction: ltr; display: inline; font-stretch: normal; line-height: 19px; list-style: none; margin: 0px 0px 20px; outline: none; overflow-x: visible; overflow-y: hidden; padding: 3px;">getAnnotation(class)</code>: Retrieves an specific annotation passed as parameter. Returns null if this annotation is not present for the given element.</span></li>
</ul>
<div style="border: 0px none; color: #333333; line-height: 18px; list-style: none; outline: none; padding: 0px 0px 1em;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span"></span><span class="Apple-tab-span"></span>This class is implementing by <code style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: url(http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/themes/jarida/images/code-bg.png); background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: rgb(225, 225, 225) rgb(240, 240, 240) rgb(240, 240, 240) rgb(225, 225, 225); border-style: solid; border-width: 1px; color: #666666; direction: ltr; display: inline; font-stretch: normal; line-height: 19px; list-style: none; margin: 0px 0px 20px; outline: none; overflow-x: visible; overflow-y: hidden; padding: 3px;">java.lang.Class</code>, <code style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: url(http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/themes/jarida/images/code-bg.png); background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: rgb(225, 225, 225) rgb(240, 240, 240) rgb(240, 240, 240) rgb(225, 225, 225); border-style: solid; border-width: 1px; color: #666666; direction: ltr; display: inline; font-stretch: normal; line-height: 19px; list-style: none; margin: 0px 0px 20px; outline: none; overflow-x: visible; overflow-y: hidden; padding: 3px;">java.lang.reflect.Method</code> and <code style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: url(http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/themes/jarida/images/code-bg.png); background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-color: rgb(225, 225, 225) rgb(240, 240, 240) rgb(240, 240, 240) rgb(225, 225, 225); border-style: solid; border-width: 1px; color: #666666; direction: ltr; display: inline; font-stretch: normal; line-height: 19px; list-style: none; margin: 0px 0px 20px; outline: none; overflow-x: visible; overflow-y: hidden; padding: 3px;">java.lang.reflect.Field</code> among others, so can be used basically with any kind of Java element.</span></div>
<div style="border: 0px none; color: #333333; font-size: 15px; line-height: 18px; list-style: none; outline: none; padding: 0px 0px 1em;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<pre><span class="strong" style="font-weight: bold;"><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">RetentionPolicy:</span></span></pre>
<pre><span class="strong"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="color: #333333; font-size: x-small; line-height: 18px;"> </span><span style="color: #353833;"><span style="font-weight: bold;">CLASS:</span><span style="font-size: x-small;">Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time.</span><span style="font-size: 22.1px; font-weight: bold;">
</span></span><span class="Apple-tab-span" style="color: #333333; font-size: x-small; line-height: 18px;"> </span><span style="color: #353833;"><span style="font-weight: bold;">RUNTIME</span>:<span style="font-size: x-small;">Annotations are to be recorded in the class file by the compiler and retained by the VM at run time, so they may be read reflectively.</span><span style="font-size: 22.1px; font-weight: bold;">
</span></span><span class="Apple-tab-span" style="color: #333333; font-size: x-small; line-height: 18px;"> </span><span style="color: #353833;"><span style="font-weight: bold;">SOURCE</span><span style="font-size: x-small;">: Annotations are to be discarded by the compiler.</span></span></span></span></pre>
<pre><span class="strong"><span style="color: #353833;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">
</span></span></span></pre>
<h3 style="text-align: left;">
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b>Create Custom Annotation Example</b></span></h3>
</div>
</div>
<h4 style="text-align: left;">
<span style="background-color: white; line-height: 18px;"><b><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Define new custom annotation</span></b></span></h4>
<div>
<span style="background-color: white;"></span><br />
<div style="color: #333333; font-size: small; line-height: 18px;">
<div>
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>@Retention( RetentionPolicy.RUNTIME )</span></span></div>
<div>
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>@Target( ElementType.METHOD )</span></span></div>
<div>
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public @interface CustomAnnotationMethod {</span></span></div>
<div>
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public String author() default "danibuiza";</span></span></div>
<div>
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public String date();</span></span></div>
<div>
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public String description();</span></span></div>
<div>
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>} </span></span></div>
</div>
<span style="background-color: white;">
</span>
<br />
<h4 style="line-height: 18px; text-align: left;">
<span style="background-color: white;">
<b><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Use on Class or Method</span></b></span></h4>
<span style="background-color: white;">
</span>
<div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="font-weight: bold; white-space: pre;"> </span><span style="font-size: x-small;">@CustomAnnotationClass( date = "2014-05-05" )</span></span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public class AnnotatedClass {</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><br /></span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>@CustomAnnotationMethod( date = "2014-06-05", description = "annotated method" )</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public String annotatedMethod() {</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return "nothing niente";</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></div>
<div>
<h4 style="line-height: 18px; text-align: left;">
<span style="background-color: white;">
<b><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Write a program to Process Annotations</span></b></span></h4>
<div style="color: #333333; font-size: small; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="font-size: x-small; white-space: pre;"> </span><span style="font-size: x-small;">public static void main(String[] args) throws Exception {</span></span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Class < AnnotatedClass > object = AnnotatedClass.class;</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"> </span></span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// Retrieve all annotations from the class</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Annotation[] annotations = object.getAnnotations();</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for (Annotation annotation: annotations) {</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(annotation);</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><br /></span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// Checks if an annotation is present</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if (object.isAnnotationPresent(CustomAnnotationClass.class)) {</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// Gets the desired annotation</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Annotation annotation = object.getAnnotation(CustomAnnotationClass.class);</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(annotation);</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"> </span></span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// the same for all methods of the class</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for (Method method: object.getDeclaredMethods()) {</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if (method.isAnnotationPresent(CustomAnnotationMethod.class)) {</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Annotation annotation = method.getAnnotation(CustomAnnotationMethod.class);</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(annotation);</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></div>
<div style="color: #333333; line-height: 18px;">
<span style="background-color: white;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></div>
<div>
<h4 style="color: black; font-size: medium; line-height: 1.5em; margin: 0px 0px 0.5em; padding: 0px;">
<span style="background-color: white;">
</span></h4>
</div>
</div>
</div>
<span style="background-color: white;">
</span></div>
</div>
Anonymoushttp://www.blogger.com/profile/06122108442458529949noreply@blogger.com0tag:blogger.com,1999:blog-3618538484347369931.post-44363966889892760302015-11-19T21:23:00.000-08:002015-11-19T21:27:41.623-08:00Improve Software Quality<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-family: "open sans" , "arial" , "sans serif"; font-weight: bold;"><span style="color: blue; font-size: small;">Improve Software Quality= Development Improvement + Management Improvement</span></span></h2>
<br />
<div style="font-family: 'Open Sans', arial, 'sans serif'; padding: 0px;">
<span style="margin: 0px; padding: 0px;"><b><span style="color: blue;">Development Improvement</span></b></span></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<br /></div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="font-size: small; margin: 0px; padding: 0px;"><span style="color: #660000;">1. Get the Requirements Right</span></span></div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: #555555;"> </span><span style="color: #660000;"><b> <span style="margin: 0px; padding: 0px;">Impact on Quality:</span></b></span><span style="color: #555555;"><b> </b>Meet business requirements; achieve a satisfying user experience.</span></div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: #555555;"> </span><span style="margin: 0px; padding: 0px;"><span style="color: #660000;"><b>Benefit:</b></span></span><span style="color: #555555;"> Less rework means less retesting and fewer cycles, which greatly reduces the overall effort.</span></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
</div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="font-size: small; margin: 0px; padding: 0px;"><span style="color: #660000;">2. Design Applications to Lessen Bug Risk</span></span></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: #660000;"><b><span style="margin: 0px; padding: 0px;">Impact on Quality:</span></b></span> Reduce defects.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: black; margin: 0px; padding: 0px;"><span style="color: #660000;"><b>Benefit:</b></span></span><span style="color: #555555;"> </span>Simpler, cleaner designs result in code that is simpler, cleaner, and easier to test and rework.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
</div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="font-size: small; margin: 0px; padding: 0px;"><span style="color: #660000;">3. Implement Best Practices, Follow Design Patterns & Principles, Increase Reusability</span></span></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: #660000;"><b>Impact on Quality:</b></span><span style="color: #555555;"><b> </b></span>Improves Quality and Performance</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: black; margin: 0px; padding: 0px;"><span style="color: #660000;"><b>Benefit:</b></span></span><span style="color: #555555;"> </span>Decreases unexpected bugs. Best Practices and Design Principle improves skills, reduces waste and improves quality. Fast development & thus Developers/Managers could give more time about Quality and user experience.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
</div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="font-size: small; margin: 0px; padding: 0px;"><span style="color: #660000;">4. Test Smarter to Test Less & Optimize the Use of Testing Tools</span></span></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: #660000;"><b>Impact on Quality:</b></span><span style="color: #555555;"><b> </b></span>Reduce defects.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: black; margin: 0px; padding: 0px;"><span style="color: #660000;"><b>Benefit:</b></span></span><span style="color: #555555;"> </span>A focus at risk areas on testing the most crucial. Automation frees resources from mundane testing to focus on the highest-priority tests and increases test cycles' repeatability.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<br /></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<br /></div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; padding: 0px;">
<span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px;"><b><span style="color: blue;">Management Improvement</span></b></span></span></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<br /></div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="font-size: small; margin: 0px; padding: 0px;"><span style="color: #660000;">1. Fine-Tune Team/Individual Goals to Include Quality</span></span></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: #660000;"><b>Impact on Quality:</b></span><span style="color: #555555;"><b> </b></span>Meet business requirements; achieve a satisfying user experience; reduce defects.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: black; margin: 0px; padding: 0px;"><span style="color: #660000;"><b>Benefit:</b></span></span>Team members perform according to their incentives, making quality improvement part of their goals reinforces desirable behavior.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
</div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="font-size: small; margin: 0px; padding: 0px;"><span style="color: #660000;">2. Define Quality and Broadcast Simple Quality Metrics</span></span></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: #660000;"><b>Impact on Quality:</b></span><span style="color: #555555;"><b> </b></span>Achieve a satisfying user experience. Increases Quality</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: black; margin: 0px; padding: 0px;"><span style="color: #660000;"><b>Benefit:</b></span></span><span style="color: #555555;"> </span>Highly visible metrics keep quality top of mind for the entire team and expose when efforts fall short.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
</div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="font-size: small; margin: 0px; padding: 0px;"><span style="color: #660000;">3. Reuse Knowledge and Experience</span></span></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: #660000;"><b>Impact on Quality:</b></span><span style="color: #555555;"><b> </b></span>Reduce defects.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: black; margin: 0px; padding: 0px;"><span style="color: #660000;"><b>Benefit:</b></span></span><span style="color: #555555;"> </span>Reusing ideas, documents, and expertise avoids making the same mistakes again. Makes the organization's best problem-solving experiences reusable.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<br /></div>
<div style="font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="font-size: small; margin: 0px; padding: 0px;"><span style="color: #660000;">4. Continues Feedbacks</span></span></div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: #660000;"><b>Impact on Quality:</b></span><span style="color: #555555;"><b> </b></span>Improves Quality and User experience.</div>
<div style="color: #555555; font-family: 'Open Sans', arial, 'sans serif'; font-size: 12px; padding: 0px;">
<span style="color: black; margin: 0px; padding: 0px;"><span style="color: #660000;"><b>Benefit:</b></span></span><span style="color: #555555;"> </span>Whatever has been learned about the product, the processes that produced it, or any other feedback will improve improves Quality and User experience.</div>
</div>
Anonymoushttp://www.blogger.com/profile/06122108442458529949noreply@blogger.com0tag:blogger.com,1999:blog-3618538484347369931.post-6422196321747657192015-11-18T03:06:00.001-08:002015-12-09T23:06:00.389-08:00New features in Java 8<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="background-color: white; color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: x-large; line-height: 31.5px;">Java 8 included following new Features.</span></h2>
<ol style="text-align: left;">
<ol>
<li style="border: 0px; box-sizing: border-box; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.4em; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="color: purple; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b style="background-color: white;"><i>Lambda expressions</i></b></span></li>
<li style="border: 0px; box-sizing: border-box; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.4em; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="color: purple; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b style="background-color: white;"><i>Method references</i></b></span></li>
<li style="border: 0px; box-sizing: border-box; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.4em; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="color: purple; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b style="background-color: white;"><i>Default Methods (Defender methods)</i></b></span></li>
<li style="border: 0px; box-sizing: border-box; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.4em; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="color: purple; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b style="background-color: white;"><i><span style="font-weight: inherit;">A new Stream API (</span>Parallel operations<span style="font-weight: inherit;">)</span></i></b></span></li>
<li style="border: 0px; box-sizing: border-box; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.4em; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="color: purple; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b style="background-color: white;"><i>Optional Class</i></b></span></li>
<li style="border: 0px; box-sizing: border-box; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.4em; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="color: purple; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b style="background-color: white;"><i>A new Date/Time API</i></b></span></li>
<li style="border: 0px; box-sizing: border-box; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.4em; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="color: purple; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b style="background-color: white;"><i><span style="font-weight: inherit;">Nashorn, the new JavaScript engine (</span>Java + JavaScript<span style="font-weight: inherit;">)</span></i></b></span></li>
<li style="border: 0px; box-sizing: border-box; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.4em; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="color: purple; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b style="background-color: white;"><i>Removal of the Permanent Generation</i></b></span></li>
<li style="border: 0px; box-sizing: border-box; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.4em; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="color: purple; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b style="background-color: white;"><i>Other New Features</i></b></span></li>
</ol>
</ol>
<div>
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div>
<h3 style="background-color: white; border: 0px; box-sizing: border-box; color: #323232; line-height: 1.4em; margin: 0px 0px 1.1em; outline: 0px; padding: 0px; text-align: left; vertical-align: baseline;">
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">
1. Lambda Expressions</span></h3>
</div>
<div>
<span style="color: #323232;"><span style="background-color: white; font-family: "arial" , "helvetica" , sans-serif; line-height: 31.5px;"><span class="Apple-tab-span" style="background-color: transparent; font-size: x-small; line-height: 24px; white-space: pre;"> </span>The biggest new feature of Java 8 is language level support for lambda expressions (Project Lambda). Java lambda expressions are Java's first step into functional programming. A Java lambda expression is thus a function which can be created without belonging to any class. A lambda expression can be passed around as if it was an object and executed on demand.</span></span><br />
<span style="color: #323232;"><span style="background-color: white; font-family: "arial" , "helvetica" , sans-serif; line-height: 31.5px;"><br /></span></span></div>
<h3 style="box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 1em; padding: 0px; text-align: justify; word-wrap: break-word;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Following are the important characteristics of a lambda expression</span></h3>
<div>
<ul style="text-align: left;">
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><b style="box-sizing: border-box;">Optional type declaration</b><span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: xx-small; line-height: 24px; text-align: justify;"> − No need to declare the type of a parameter. The compiler can inference the same from the value of the parameter.</span></span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><b style="box-sizing: border-box;">Optional parenthesis around parameter</b><span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: xx-small; line-height: 24px; text-align: justify;"> − No need to declare a single parameter in parenthesis. For multiple parameters, parentheses are required.</span></span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><b style="box-sizing: border-box;">Optional curly braces</b><span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: xx-small; line-height: 24px; text-align: justify;"> − No need to use curly braces in expression body if the body contains a single statement.</span></span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><b style="box-sizing: border-box;">Optional return keyword</b><span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: xx-small; line-height: 24px; text-align: justify;"> − The compiler automatically returns the value if the body has a single expression to return the value. Curly braces are required to indicate that expression returns a value.</span></span></li>
</ul>
</ul>
<ul class="list" style="box-sizing: border-box; color: #313131; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px;">
</ul>
<h3 style="text-align: justify;">
<span style="background-color: white; font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: small;">syntax: </span></span></h3>
<h2 style="text-align: justify;">
<span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="font-size: x-small; white-space: pre;"> </span><span style="font-weight: normal;">parameter -> expression body</span></span></span></h2>
</div>
<div style="text-align: left;">
<div style="text-align: left;">
</div>
<h3 style="text-align: left;">
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Examples:</span></span></span></h3>
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"></span></span></span><br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>1. With type declaration</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">
</span></span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>MathOperation addition = (int a, int b) -> a + b; </span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">
</span></span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>2. With out type declaration</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">
</span></span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>MathOperation subtraction = (a, b) -> a - b; </span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">
</span></span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>3. With return statement along with curly braces</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">
</span></span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>MathOperation multiplication = (int a, int b) -> { return a * b; }; </span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">
</span></span></span>
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>4. Without return statement and without curly braces</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>MathOperation division = (int a, int b) -> a / b;</div>
</span></span></span></div>
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"></span></span></span><br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><br /></span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">
</span></span></span></div>
</div>
<div>
<div style="line-height: 24px;">
<span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html" target="_blank">More Info</a></span></span></span><br />
<h3 style="text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="color: #660000; font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;">
<span style="font-family: inherit; font-size: large;">2. <span style="font-style: inherit; line-height: normal;">Method references</span></span></span></span><b style="color: #660000; line-height: normal;"><span style="font-style: inherit; font-weight: inherit;">(</span>Parallel operations<span style="font-style: inherit; font-weight: inherit;">)</span></b></span></h3>
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;">
</span></span>
</span><br />
<div>
<span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>You use lambda expressions to create anonymous methods. Method references help to point to methods by their names. A method reference is described using :: (double colon) symbol.</span></span></span></div>
<span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">
</span></span></div>
<div>
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>You can use replace Lambda Expressions with Method References where Lamdba is invoking already defined methods.</span></span><br />
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">You can’t pass arguments to methods Reference</span></span><br />
<h4 style="text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large; line-height: 24px;">There are four kinds of method references:</span></h4>
<ol style="text-align: left;">
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;">Reference to a static method</span><span style="line-height: 24px; white-space: pre;">
</span><span style="line-height: 24px;"><span style="color: #660000;">ContainingClass::staticMethodName</span></span></span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;">Reference to an instance method of a particular object<span style="white-space: pre;"><br /></span></span><span style="color: #660000; line-height: 24px;">containingObject::instanceMethodName</span></span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;">Reference to an instance method of an arbitrary object of a particular type<span style="white-space: pre;"><br /></span></span><span style="color: #660000; line-height: 24px;">ContainingType::methodName</span></span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;">Reference to a constructor</span><span class="Apple-tab-span" style="line-height: 24px; white-space: pre;">
</span><span style="color: #660000; line-height: 24px;">ClassName::new</span></span></li>
</ol>
</div>
<div>
<h3>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">Example:</span></span></h3>
</div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #660000;">List names = new ArrayList();</span></span><br />
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>names.add("Mahesh");</span><br />
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>names.add("Suresh");</span><br />
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>names.add("Ramesh");</span><br />
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>names.add("Naresh");</span><br />
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>names.add("Kalpesh");</span><br />
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"></span><br />
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>names.forEach(System.out::println);</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">
</span>
<br />
<div style="font-family: verdana, geneva, tahoma, arial, helvetica, sans-serif;">
<span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">
</span></div>
<div>
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html" target="_blank">More Info</a></span></span><br />
<h3 style="text-align: left;">
<span style="background-color: white; font-style: inherit; font-weight: inherit;"><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">3. Default Methods (Defender methods)</span></span></h3>
</div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="line-height: 24px; white-space: pre;"> </span>Default methods can be provided to an interface without affecting implementing classes as it includes an implementation just <span style="background-color: white; line-height: 24px;">by adding the keyword </span><em style="background-color: white; box-sizing: border-box; line-height: 24px;"><span style="box-sizing: border-box;">default</span></em><span style="background-color: white; line-height: 24px;"> before the method’s access modifier</span>.</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Modify one interface in JDK framework breaks all classes that extends the interface. Default methods enable us to add new or default functionalities/behavior to existing interfaces without breaking the classes that implements that interface.</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">After introducing Default Method, it seems that interfaces and abstract classes are same. However, they are still different concept in Java 8.</span></div>
<div>
<h3>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">Example:</span></span></h3>
</div>
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"></span></span><br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><span class="Apple-tab-span" style="font-size: x-small; white-space: pre;"> </span><span style="font-size: x-small;">public interface vehicle {</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">
</span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span> default void print(){</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">
</span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span> System.out.println("I am a vehicle!");</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">
</span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span> }</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">
</span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">
</span></span></div>
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small; line-height: 24px;">
</span></span></div>
<div>
<span style="font-style: inherit; font-weight: inherit;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html" target="_blank">More Info</a></span></span></div>
<div>
<span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="font-family: "arial" , "helvetica" , sans-serif;"></span></span>
<span style="font-style: inherit; font-weight: inherit;"><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b>4. A new Stream API.</b></span></span></div>
<div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="line-height: 24px; white-space: pre;"> </span>Don't confuse with InputStream and OutputStream from Java I/O. This is Completely different thing. Streams adhere to a common Pipes and Filters software pattern.</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="line-height: 24px; white-space: pre;"> </span>A Stream is a free flowing sequence of elements. They do not hold any storage as that responsibility lies with collections such as arrays, lists and sets. Every stream starts with a source of data, sets up a pipeline, processes the elements through a pipeline and finishes with a terminal operation. They allow us to parallelize the load that comes with heavy operations without having to write any parallel code. A new package java.util.stream was introduced in Java 8 to deal with this feature.</span></div>
</div>
<div>
<h3>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">Example:</span></span></h3>
</div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> myList =</span> <span style="font-size: x-small;">Arrays.asList("a1", "a2", "b1", "c2", "c1");</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></span>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>myList</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.stream()</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.filter(s -> s.startsWith("c"))</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.map(String::toUpperCase)</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.sorted()</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.forEach(System.out::println);</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><br /></span></div>
<div>
<div>
<b><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;">Deeper Look at Streams</span></b></div>
<div style="font-size: small;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="font-size: small;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="line-height: 24px; white-space: pre;"> </span>The Stream interface is defined in java.util.stream package. Starting from Java 8, the java collections will start having methods that return Stream. This is possible because of another cool feature of Java 8, which is default methods. Streams can be defiled as a sequence of elements from a source that supports aggregate operations.</span></div>
<div style="font-size: small;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="line-height: 24px; white-space: pre;"> </span>The source here refers to a Collection, IO Operation or Arrays who provides data to a Stream. Stream keeps the order of the data as it is in the source. Just like functional programming languages, Streams support Aggregate Operations. The common aggregate operations are filter, map, reduce, find, match, sort. These operations can be executed in series or in parallel.</span></div>
<div style="font-size: small;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><br /></span></div>
<div style="font-size: small;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="line-height: 24px; white-space: pre;"> </span>The Streams also support Pipelining and Internal Iterations. The Java 8 Streams are designed in such a way that most of its stream operations returns Streams only. This help us creating chain of various stream operations. This is called as pipelining. The pipelined operations looks similar to a sql query.</span></div>
</div>
<div>
<span style="font-style: inherit; font-weight: inherit;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><br /></span></span></div>
<div>
<span style="font-style: inherit; font-weight: inherit;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="http://radar.oreilly.com/2015/02/java-8-streams-api-and-parallelism.html" target="_blank">More Info</a></span></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"><br /></span></span>
<span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="color: #660000; font-family: inherit; font-size: large;"><b>5. Optional Class</b></span></span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="font-family: inherit; font-size: large;"><br /></span></span><span class="Apple-tab-span" style="font-size: x-small; line-height: 24px; white-space: pre;"> </span><span style="line-height: 24px;"><span style="font-size: x-small;">Optional is a new container type that wraps a single value, if the value is available. So it's meant to convey the meaning that the value might be absent. </span></span></span><br />
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Optional is an attempt to reduce the number of null pointer exceptions in Java systems, by adding the possibility to build more expressive APIs that account for the possibility that sometimes return values are missing. By using Optional, and never working with null, you could avoid null checks altogether.</span></span><br />
<h3>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">Example:</span></span></h3>
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"></span></span><br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="font-size: x-small;">public Optional<String> getOptionalNullString(){</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">
</span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span> return(null);</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">
</span></span>
<br />
<div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></span></div>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">
</span></span></div>
<div>
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: x-small;"></span></span><br /></span>
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>java.util.Optional is a container object which may or may not contain a non-null value. If a value is present, isPresent() will return true and get() will return the value.</span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<a href="http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html" target="_blank"><span style="font-family: "arial" , "helvetica" , sans-serif;">More Info</span></a><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b><span style="line-height: 24px;">6. </span><span style="line-height: 24px;">A new Date/Time API</span></b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-family: inherit; font-size: large;"><span style="line-height: 24px;"><br /></span></span>
<span style="line-height: 24px;"><span style="font-family: inherit; font-size: x-small;">Working with New Date and Time <span style="color: blue;">objects</span>. </span></span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: inherit; font-size: x-small;"><br /></span></span><span class="Apple-tab-span" style="font-size: x-small; line-height: 24px; white-space: pre;"> </span><span style="font-size: x-small; line-height: 24px;">By default <span style="color: blue;">LocalDate/Time classes</span> will use the system clock in the default time zone. We can change this by providing a time zone or an alternative Clock implementation.</span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>They are also coming with better time zone support with <span style="color: blue;">ZoneOffSet, ZoneId, ZonedDateTime </span>or<span style="color: blue;"> OffsetDateTime. </span></span></span><br />
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Parsing and Formatting of Dates are also revamped with new <span style="color: blue;">DateTimeFormatter</span> class.</span></span><br />
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: blue;">Clock</span>, which can be used to get current instant, date and time using time zone.</span></span><br />
<h4 style="text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Deeper Look at </b><span style="line-height: 24px;">Date/Time API</span></span></h4>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small; line-height: 24px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>New date and time API is located inside java.time package and some of the key classes are following.</span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="background-color: white;"><span style="color: blue;">Instant - Represents a timestamp</span></span></span><br />
<span style="background-color: white;"><span style="color: blue; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>LocalDate - Represents a year-month-day date without time.</span></span><br />
<span style="background-color: white;"><span style="color: blue; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>LocalTime - Represents a time without dates.</span></span><br />
<span style="background-color: white;"><span style="color: blue; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>LocalDateTime - Combines date and time in one class.</span></span><br />
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>We can use the plus and minus methods to add or subtract specific amounts of time. Note that these methods always return a new instance (Java 8 date/time classes are immutable).</span></span><br />
<h3>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">Example:</span></span></h3>
<span style="line-height: 24px;"><span style="font-family: inherit; font-size: x-small;"><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span>LocalDate tomorrow = LocalDate.now().plusDays(1);</span></span></span><br />
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Some information can be obtained without providing a specific date. For example, we can use the Year class if we need information about a specific year:</span></span><br />
<h3>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">Example:</span></span></h3>
<span style="line-height: 24px;"><span style="font-family: inherit; font-size: x-small;"><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span>Year currentYear = Year.now();</span></span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small; line-height: 24px;">boolean isLeap = currentYear.isLeap();</span></span><br />
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: xx-small;"><b>Timestamps</b></span></span><br />
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span>Classes like <span style="color: blue;">LocalDate </span>and <span style="color: blue;">ZonedDateTime </span>provide a human view on time. However, often we need to work with time viewed from a machine perspective. For this we can use the Instant class which represents timestamps. </span></span><br />
<h3>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">Example:</span></span></h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small; line-height: 24px;">Instant now = Instant.now(); // current time</span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small; line-height: 24px;">Instant fromUnixTimestamp = Instant.ofEpochSecond(1262347200); // from unix timestamp, 2010-01-01 12:00:00</span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small; line-height: 24px;">Instant fromEpochMilli = Instant.ofEpochMilli(1262347200000l); // same time in millis </span></span><br />
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: xx-small;"><b>Periods and Durations</b></span></span><br />
<span style="line-height: 24px;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: blue;">Period </span>and <span style="color: blue;">Duration </span>are two other important classes. Like the names suggest they represent a quantity or amount of time. A <span style="color: blue;">Period </span>uses date based values (years, months, days) while a <span style="color: blue;">Duration </span>uses seconds or nanoseconds to define an amount of time.</span></span><br />
<h3>
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: small;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;">Example:</span></span></h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small; line-height: 24px;">LocalDate firstDate = LocalDate.of(2010, 5, 17); // 2010-05-17</span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small; line-height: 24px;">LocalDate secondDate = LocalDate.of(2015, 3, 7); // 2015-03-07</span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small; line-height: 24px;">Period period = Period.between(firstDate, secondDate);</span></span><br />
<span class="Apple-tab-span" style="line-height: 24px; white-space: pre;"><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"> </span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small; line-height: 24px;">Instant firstInstant= Instant.ofEpochSecond( 1294881180 ); // 2011-01-13 01:13</span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small; line-height: 24px;">Instant secondInstant = Instant.ofEpochSecond(1294708260);</span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="line-height: 24px;"><span style="color: #660000; font-family: inherit; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small; line-height: 24px;">Duration between = Duration.between(firstInstant, secondInstant);</span></span><br />
<span style="font-family: inherit;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><a href="http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html" target="_blank">More Info</a> </span></span><br />
<span style="font-family: inherit;"><span style="font-family: "arial" , "helvetica" , sans-serif; line-height: 24px;"><a href="http://javarevisited.blogspot.in/2015/03/20-examples-of-date-and-time-api-from-Java8.html" target="_blank">More Examples</a></span></span></div>
<h3 style="text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="color: #660000; font-family: inherit; font-size: large;"><span style="font-style: inherit;">7. Nashorn, the new JavaScript engine </span></span><b style="color: #660000;"><span style="font-style: inherit; font-weight: inherit;">(</span>Java + JavaScript<span style="font-style: inherit; font-weight: inherit;">)</span></b></span></h3>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;"></span></span><br />
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;"><span class="Apple-tab-span" style="line-height: 24px; white-space: pre;"> </span>Nashorn is a JavaScript engine for the JVM that is released with Java 8. It has replaced the existing Rhino engine.</span></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;">
</span></span>
<br />
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;"><br /></span></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;">
</span></span>
<br />
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;"><span class="Apple-tab-span" style="line-height: 24px; white-space: pre;"> </span>As JavaScript is getting popular on server-side programming (like Node.js).</span></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;">
</span></span>
<br />
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;">The Nashorn javascript engine can either be used pragmatically from java programs or by utilizing the command line tool jjs, which is located in $JAVA_HOME/bin. If you plan to work with jjs you might want to put a symbolic link for simple access:</span></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;">
</span></span>
<br />
<div style="color: #660000;">
<h3 style="color: black;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;">
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: small;"><span style="line-height: 24px;">Example 1:</span></span></span></span></h3>
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;">
</span></span>
<br />
<div style="color: #660000;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$ jjs -scripting heredocs.js</span></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;">
</span></span>
<div style="color: #660000;">
<h3 style="color: black;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;">
<span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif; font-size: small;"><span style="line-height: 24px;">Example 2:</span></span></span></span></h3>
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span style="font-style: inherit;">
<div style="color: #660000;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>ScriptEngineManager engineManager = new ScriptEngineManager();</div>
<div style="color: #660000;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>ScriptEngine engine = engineManager.getEngineByName("nashorn");</div>
<div style="color: #660000;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>engine.eval(new FileReader("src/sample2/mustache.js"));</div>
<div style="color: #660000;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>engine.eval("print('Hello World!');");</div>
</span></span></div>
<h3 style="text-align: left;">
<div style="text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: small;"><b style="font-style: inherit;"><a href="http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html" target="_blank">More Info</a> </b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: small;"><b style="font-style: inherit;"><a href="http://winterbe.com/posts/2014/04/05/java8-nashorn-tutorial/" target="_blank">More Examples</a></b></span></div>
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><span style="font-style: inherit;">8. Removal of the Permanent Generation</span></span></h3>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="font-size: x-small; line-height: 24px; white-space: pre;"> </span>Permanent Generation memory space is completely removed.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">The good news is that it means no more java.lang.OutOfMemoryError: PermGen space problems and no need for you to tune and monitor this memory space any more.</span><br />
<h4 style="text-align: left;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif;">Impact:</span></b></h4>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small;">The PermSize and MaxPermSize JVM arguments are ignored and a warning is issued if present at start-up.</span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span class="Apple-tab-span" style="background-color: white; color: blue; white-space: pre;"> </span><span style="color: #660000; font-size: x-small;">Metaspace: A new memory space is born.</span></span><br />
<b><a href="https://dzone.com/articles/java-8-permgen-metaspace"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span id="goog_1967574374"></span>More Info</span></a></b><br />
<h3 style="text-align: left;">
<span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">9. Other New Features</span></h3>
<div>
<h4 style="text-align: left;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Concurrent accumulators</span></b></h4>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="color: #660000; white-space: pre;"> </span><span style="color: #444444;">One of the most common scenarios in concurrent programming is updating of numeric counters accessed by multiple threads.</span></span></div>
<h4 style="text-align: left;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Parallel operations</span></b></h4>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="color: #660000; white-space: pre;"> </span><span style="color: #444444;">You can think of this as an extension of iterators where the actual operation of extracting the next item from a collection on which to operate is carried out by an iterator. An exciting possibility opened by this design pattern is to enable operations carried out on long arrays such as sorting, filtering and mapping to be carried out in parallel by the framework. </span></span></div>
<h4 style="text-align: left;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">String.join</span></b></h4>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="color: #660000; white-space: pre;"> </span><span style="color: #444444;">String abc= String.join(" ", "Java", "8");</span></span></div>
<h4 style="text-align: left;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Type Annotations</span></b></h4>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="color: #660000; white-space: pre;"> </span><span style="color: #444444;">List<@Nullable String></span></span></div>
<div>
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>@NotNull String[] arr;</span></div>
<div>
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>new @NonEmpty @Readonly List(myNonEmptyStringSet)</span></div>
<div>
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>new @Interned MyObject()</span></div>
<h4 style="text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b>Functional Interface</b>s</span></h4>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="color: #660000; white-space: pre;"> </span><span style="color: #444444;">java.util.function</span></span></div>
<h4 style="text-align: left;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Stamped Locks</span></b></h4>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="color: #660000; white-space: pre;"> </span><span style="color: #444444;">The problem is that the ReadWriteLock can be super slow (up to 10x), which kind of defeats its purpose. Java 8 introduces a new ReadWrite lock – called StampedLock.</span></span></div>
<h4 style="text-align: left;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Controlling OS Processes</span></b></h4>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="color: #660000; white-space: pre;"> </span><span style="color: #444444;">Launching an OS process from within your code is right there with JNI calls – it’s something you do half-knowing there’s a good chance you’re going to get some unexpected results and some really bad exceptions down the line.</span></span></div>
<h4 style="text-align: left;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Exact Numeric Operations</span></b></h4>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="color: #660000; white-space: pre;"> </span><span style="color: #444444;">Math class geared towards protecting sensitive code from implicit overflows, by throwing an unchecked ArithmeticException when the value of an operation overflows its precision.</span></span></div>
<div>
<span style="color: #444444; font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>int safeC = Math.multiplyExact(bigA, bigB); // will throw ArithmeticException if result exceeds +-2^31</span></div>
<h4 style="text-align: left;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Secure Random Generation</span></b></h4>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;"><span class="Apple-tab-span" style="color: #660000; white-space: pre;"> </span><span style="color: #444444;">Java 8 has added a new method called SecureRandom.getInstanceStrong() whose aim is to have the JVM choose a secure provider for you.</span></span></div>
</div>
<h3 style="text-align: left;">
<b><span style="color: #660000; font-family: "arial" , "helvetica" , sans-serif; font-size: x-large;">References</span></b></h3>
<b style="font-style: inherit;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></b>
<span style="font-style: inherit;"><a href="http://openjdk.java.net/projects/jdk8/milestones" target="_blank"><span style="font-family: "arial" , "helvetica" , sans-serif;">Other Milestones Completed</span></a></span><br />
<a href="http://www.slideshare.net/jpaumard/jfokus-50-new-things-with-java-8" target="_blank"><span style="font-family: "arial" , "helvetica" , sans-serif;">New Features in Java SE 8 PPT</span></a><br />
<a href="http://www.infoq.com/articles/Java-8-Quiet-Features" target="_blank"><span style="font-family: "arial" , "helvetica" , sans-serif;">8 Great Java 8 Features</span></a><br />
<a href="https://www.youtube.com/watch?v=DCBIegEqKuo" target="_blank"><span style="font-family: "arial" , "helvetica" , sans-serif;">Video: New Features in Java SE 8</span></a><br />
<a href="http://openjdk.java.net/projects/jdk8/features" target="_blank"><span style="font-family: "arial" , "helvetica" , sans-serif;">JDK 8 Features</span></a></div>
<div>
<span style="font-size: 15px; line-height: 24px; text-align: left;"><span style="font-family: "verdana" , "geneva" , "tahoma" , "arial" , "helvetica" , sans-serif;"></span></span><br />
<span style="color: purple; font-size: large;"><b>Useful Links</b></span><br />
<div style="margin: 0.75em 0px; padding: 0px; position: relative; text-align: left;">
<span style="color: white; font-family: inherit; font-size: small;"><a href="http://javasoftwaretechnology.blogspot.in/2015/12/new-features-in-java-9.html" style="background-color: white;" target="_blank"><b>New features in Java 9</b></a></span><a href="http://javasoftwaretechnology.blogspot.in/2015/12/java-9-schedule.html" target="_blank"><b><span style="font-family: inherit;">JAVA 9 Schedule</span></b></a></div>
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
</div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06122108442458529949noreply@blogger.com0