Wednesday, August 01, 2012

Lombok - cool stuff, worth trying!


A friend of mine just shared with me Project Lombok (weird name but I guessed correctly that it's something Thai ;) As I understand the goal of this project is to minimize boilerplate Java code (like getters, setters, constructors, etc.) Very good idea!

The only question that bothers me is if it's easily possible to override any behavior (e.g. setters) without the need of resigning from Lombok auto-generatin for the rest of class' elements...

Anyway - it's really worth trying!

Wednesday, March 07, 2012

Byteman - use it when Mockito can't help


Byteman is a really cool stuff with which you could simulate JVM or OS behavior hardly possible to mock using mocking library (like Mockito). Read the full exaple (really short with no fluff) here: http://theholyjava.wordpress.com/2012/02/25/cool-tools-fault-injection-into-unit-tests-with-jboss-byteman-easier-testing-of-error-handling/

Thursday, January 05, 2012

Errata to Maven2 → Maven3 migration


In the section Cobertura plugin and Maven3 of "Maven2 → Maven3 migration - real life example" article I made a mistake that resulted in reporting a bug that does not exist.


  
    package
    
      clean
      check
    
  

should be changed to:

  
    clean
    clean
    
      clean
    
  
  
    package
    package
    
      check
    
  


Both goals instrument and check must never be in the same execution because check depends on instrument and calls it itself. So, in my example goal instrument was executed twice every time and it cause a lot of problems - many of them are still magic for me e.g. compilation error saying that ...HasBeenInstrumented class cannot be identified blah, blah, blah, even though "buggy" source code was untouched and did not use this Cobertura class. Anyway MCOBERTURA-155 is a non-issue.

Thursday, December 15, 2011

Maven2 → Maven3 migration - real life example


Couple of months after JDK 7 release I decided to update my projects to build on both new JDK and Maven3 (Maven2 previously). From JDK 7 I was expecting nothing new as the codebase of our projects should be migrated step by step as soon as the Ops start supporting new application servers that could run on Java 7. More important things were expected from Maven3, namely we wanted to shorten build time, that we already optimized by 20% using Maven2 by smart initialization of our unit tests (but that's another story). In this post I will explain what I had to change to make this happen.

Monday, December 05, 2011

FW: Garbage collection in HotSpot JVM


There is an excellent new post from Alexey Ragozin on JVM Garbage Collector:
http://www.dzone.com/links/r/garbage_collection_in_hotspot_jvm.html.
He posted almost all basics you should know about different types of GCs, how to enable them in HotSpot JVM and most importantly when to enable them.

Just go there and read it!

Friday, November 25, 2011

HotSpot (64bit server) hangs on socket read (JVM 1.7 bug?) - updated



Picture (c) Clker.com
Few days ago I started working on some maven-based project (Java 1.7.0) on my new laptop (with Windows 7 64bit installed) and I noticed that very often Maven 3 was stuck downloading JARs from the internet even though my internet connection was fine. I started investigating this issue and after checking thread dump and binary dump (DMP) I think I found a bug in HotSpot for 64bit Windows.

Wednesday, November 23, 2011

GC and preformance tuning for Tomcat (from VMware)


Coming back to my previous post "Beware of your GC": just yesterday Daniel Mikusa from VMware published his post "Performance Tuning the JVM for Running Apache Tomcat" which adds some more interesting information complementing my post. You could find "Selecting a Collector" section specifically interesting e.g.:

When you specify the option to run the concurrent collector, it is important to realize that garbage collection will happen concurrently with the application. This means that garbage collection will consume some of the processor resources that would have otherwise been available to the application. On systems with a large number of processors, this is typically not a problem. However, if your system has only one or two processors then you will likely want to enable the -XX:+CMSIncrementalMode option. This option enables incremental mode for the collector, which instructs the collector to periodically yield the processor back to the application and essentially prevents the collector from running for too long.

Enjoy!

Friday, November 18, 2011

Be aware of your GC


When you're learning Java and later developing your applications you usually tend to not to worry about the memory management - we have garbage collector after all, so what's to worry about. Surprisingly you should worry about memory in your Java applications as it's not that difficult to introduce memory leak after all.

Friday, July 29, 2011

Java 7 - it's here


Friday, July 22, 2011

JDK 7 is finally out...


...well, not yet but it will be in few days (Oracle Announces Release Date for Java 7). After Wikipedia "Java 7 (codename Dolphin) is an upcoming major update to Java, it has been launched on July 7 of 2011 and will be made available on July 28, 2011."

Here's the list of new features Java 7 will bring (consult JDK 7 project page for more details):

Features are listed in order, more or less, from lowest to highest in the overall JDK software stack.

vm JSR 292: Support for dynamically-typed languages (InvokeDynamic)
Strict class-file checking
lang JSR 334: Small language enhancements (Project Coin)
core Upgrade class-loader architecture
Method to close a URLClassLoader
Concurrency and collections updates
(jsr166y)
i18n Unicode 6.0
Locale enhancement
Separate user locale and user-interface
locale
ionet JSR 203: More new I/O APIs for the Java platform (NIO.2)
NIO.2 filesystem provider for zip/jar
archives
SCTP (Stream Control Transmission Protocol)
SDP (Sockets Direct Protocol)
Use the Windows Vista IPv6 stack
TLS 1.2
sec Elliptic-curve cryptography (ECC)
jdbc JDBC 4.1
client XRender pipeline for Java 2D
Create new platform APIs for 6u10 graphics features
Nimbus look-and-feel for Swing
Swing JLayer component
Gervill sound synthesizer [NEW]
web Update the XML stack
mgmt Enhanced MBeans

For me one of the most interesting changes are "Small language enhancements" that come from project Coin.
The goal of Project Coin is to determine what set of small
language changes should be added to JDK 7. That list is:
  • Strings in switch
  • Binary integral literals and underscores in numeric literals
  • Multi-catch and more precise rethrow
  • Improved type inference for generic instance creation
    (diamond)
  • try-with-resources statement
  • Simplified varargs method invocation

All Java developers have waited for this moment since December 2006 when JDK 6 was released. It was the longest and the most painful release in Java history. It took almost five years to do it while for previous versions the period between releases was more or less two years. Of course, five years waiting for new Java was the effect of many factors like problems of Sun (eventually bought by Oracle), making JDK an open source project and thus opening a pandora's box of non-open source licenses, etc.

But it's finally here.

Now we'll wait for JDK 8 with lambda expressions that were supposed to be delivered in version 7 but actually it's good that JDK guys decided to postpone some features to finally release it.

Enjoy and celebrate the new JDK 7.