This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
NetBeans 6.0 RC2: The behavior of "Surround with try {..." is different from NetBeans 5.5.1. In NB5.5.1, "int a;" will be moved to outside try {}. Source : -- public class Main { public Main() { int a = Integer.parseInt("5"); System.out.println(a); } } -- Result NB6.0: -- public class Main { public Main() { try { int a = Integer.parseInt("5"); } catch (NumberFormatException numberFormatException) { } System.out.println(a); } } -- Result NB5.5.1: -- public class Main { public Main() { int a; try { a = Integer.parseInt("5"); } catch (NumberFormatException ex) { ex.printStackTrace(); } System.out.println(a); } } --
Try "Surround with" for the line " int a = Integer.parseInt("5");"
This relates to the Surround with try-catch hint (code template).
Fixed. Selection template processing mechanism improved to move used variable declaration outside of blocks. Checking in JavaCodeTemplateProcessor.java; /cvs/java/editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java,v <-- JavaCodeTemplateProcessor.java new revision: 1.20; previous revision: 1.19 done