Translate

Monday, July 25, 2011

What are new features in Java 7 or JDK7?

I was looking at all new features of Java 7. List of features include to simplify common, day-to-day programming tasks: Strings in switch statements, try-with-resources statements, improved type inference for generic instance creation ("diamond" or "<>"), simplified varargs method invocation, better integral literals, improved exception handling (multi-catch), and my favorite feature fork-join framework. I found many blog posts mentioning them. I developed following simple examples to demonstrate all new JDK7 features. Click on following links to see the example code and its detailed explanation:

JDK7 feature's list of examples:
  1. An example of new feature in JDK 7 which can do type inference for generic instance creation.
  2. Try-with-resources statement
  3. String object is allowed in switch-case statement
  4. Catch multiple exceptions in a single catch block & more precise exception re-throw example
  5. Express literal values in binary with prefix '0b' (or '0B') for integral types (byte, short, int and long)
  6. Fork-Join Framework for supporting Parallel Programming
  7. Performance comparison of Executor framework vs ForkJoin framework’s RecursiveTask feature in java or JDK7 
  8. More informative varargs warnings

Following are few links/posts I found informative and useful:
  1. 7 new cool features in Java 7: http://sellmic.com/blog/2011/07/08/7-new-cool-features-in-java-7/
  2. Hidden Java 7 Features – System and Process CPU Load Monitoring: http://sellmic.com/blog/2011/07/21/hidden-java-7-features-cpu-load-monitoring/
  3. JDK 7 Features: http://openjdk.java.net/projects/jdk7/features/ 
  4. Java Fork/Join for Parallel Programming: http://www.javacodegeeks.com/2011/02/java-forkjoin-parallel-programming.html
  5. New Java 7 Language Features: http://java.dzone.com/articles/new-java-7-language-features?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+zones%2Fnetbeans+%28NetBeans+Zone%29
There are lots of new goodies, I will add more details regarding Java 7 features once I am ready with running examples.

Recently, I read about Java 7 having some severe bugs. Quoting "Some loops are mis-compiled due to errors in the HotSpot compiler optimizations, which causes programs to fail. This bug affects several Apache projects directly — Apache Lucene Core and Apache Solr have already raised a warning, noting that the bug might be present in Java 6 as well." For more details visit following blogs:
  1. Java7 Hotspot Loop Bug Details: http://www.infoq.com/news/2011/08/java7-hotspot
  2. Java 7 Ships With Severe Bug: http://developers.slashdot.org/story/11/07/29/1639233/Java-7-Ships-With-Severe-Bug?utm_source=slashdot&utm_medium=twitter 
  3. Don’t Use Java 7, For Anything: http://www.lucidimagination.com/blog/2011/07/28/dont-use-java-7-for-anything/

    Thursday, July 21, 2011

    Getting started with Android application development

    Many Java developers have shown their interest in Android application development but they don't know where to start. Few are planning to join Android training in some training institute. I advice not to do that. Internet is your best teacher. That is the way, I started learning Android.

    Following are few links which I started reading to understand Android platform. These links will give you good idea about Android basics and help you setup Android development environment using Eclipse IDE:
    1. http://developer.android.com/guide/topics/fundamentals.html#proclife
    2. http://www.vogella.de/articles/Android/article.html#installation_eclipse
    3. http://developer.android.com/guide/index.html
    4. http://developer.android.com/resources/tutorials/hello-world.html

    Tuesday, July 12, 2011

    Why do I get missing "use strict" statement error when I run my java script code through Crockford's JSLint?

    Strict Mode is a new feature in ECMAScript 5 that allows you to place a program, or a function, in a "strict" operating context. This strict context prevents certain actions from being taken and throws more exceptions. Strict mode helps out in a couple ways:
    • It catches some common coding bloopers, throwing exceptions.
    • It prevents, or throws errors, when relatively "unsafe" actions are taken (such as gaining access to the global object).
    • It disables features that are confusing or poorly thought out.
    Also note you can apply "strict mode" to the whole file... Or you can use it only for a specific function. Conclusion is it helps you make fewer errors, by detecting more things that could lead to breakages.

    References:
    1. You can also look at article about that : John Resig - ECMAScript 5 Strict Mode, JSON, and More 
    2. You can try JSLint (The JavaScript Code Quality Tool) online by visiting: http://www.jslint.com/ 
    3. JSHint looks pretty interesting too: http://www.jshint.com/