-1

What are safe refactorings when migrating an application from Java 6 to Java 7?

For example one can consider using the new diamond operator, the new automatic resource management a.k.a. try with resources, multi-catch functionality but are there any more?

Adrian
  • 6,013
  • 10
  • 47
  • 68

1 Answers1

1

Diamond operator / type inference is safe.

try-with-resources is mostly safe. If you didn't close some of your files, streams properly before, it will also correct a few bugs for free. But this may have side effects.

Multi-catch has the same caveats, if you replace catch (Exception) or worse: catch (Throwable) by proper multi-catching, you could have some throwables bubbling up the stack that got caught before (NullPointerExceptions and the like mostly).

Arthur Noseda
  • 2,534
  • 19
  • 28