2009. 7. 21. 14:56

Eclipse 3.5 - new features for Java developers

원문 : http://download.eclipse.org/eclipse/downloads/drops/R-3.5-200906111540/eclipse-news-part2.html

Java 개발 도구


Java 편집기

생성자 자동완성

allocation 문이 완성되면 이제 Content Assist 는 class 의 가능한 생성자를 제안합니다:

Constructor completion

(위의 예저처럼) class 가 import 되어 있지 않으면 자동으로 import 가 추가됩니다.

Open Implementation 링크

overriding 가능한 메쏘드에 추가되는 Open Implementation 링크는 overriding 된 메쏘드를 직접 열거나(overriding 된 메쏘드가 하나일 때), overriding 된 모든 메쏘드를 보여줍니다.(hyperlink has been added for overridable methods, which directly opens the implementation in case there's only one, or shows all the concrete implementations for that method in the hierarchy of its declaring type, using the quick type hierarchy.) 기본적으로, overriding 가능한 메쏘드 위에 마우스를 놓고 Ctrl 키를 누르면 링크가 보입니다.

Open Implementation hyperlink for methods

이 링크에 대한 modifier(링크를 볼 때 누르는 키) 는 General > Editors > Text Editors > Hyperlinking preference 페이지에서 설정할 수 있습니다.


더블 클릭으로 주석 선택

주석의 시작이나 끝에서 더블 클릭하면 주석 전체가 선택됩니다.

Rename 리팩토링을 시작하는 quick fix

이제 Rename 리팩토링은 Quick Fix (Ctrl+1)를 통해서도 시작할 수 있습니다:

Quick Fix 'Rename in workspace' in Java editor



Javadoc header 의 링크

Javadoc hover 와 Javadoc 뷰의 헤더에서 다른 타입의 레퍼런스와 멤버에 링크가 추가되었습니다. 메쏘드의 리턴 타입이나 파라미터 타입을 클릭하여 그 타입의 Javadoc 을 빠르게 볼 수 있습니다.

Javadoc hover with mouse over method return type

그리고 다른 타입의 Javadoc 을 다 본 후 툴바에서 Back 을 클릭하면 원래의 Javadoc 을 다시 볼 수 있습니다.

NLS Hover 에서 Open in Properties File 동작

NLS string hover 의 툴바에 Open in Properties File 동작이 추가되었습니다.(The NLS string hover now has an Open in Properties File action in the toolbar which locates the selected NLS string in the corresponding properties file where it is defined.) 이 동작은 focus 가 hover 에 있으면 활성화됩니다.

Open in Properties File action in NLS hover


사용자의 줄바꿈을 변경하지 않는 Formatter 옵션

이제 Java code formatter 는 코드나 주석에서 라인을 합치지 않음으로써 (선택적으로) 사용자의 줄바꿈을 보존합니다.

예를 들어, 아래의 테스트 케이스에서 여러 줄에 걸친 return 문은:

Example of Code to Format

Never join lines 가 사용될 때, formatter 에 의해 변경되지 않습니다. 그리고  아래와 같은 결과를 생성합니다:

Coded Formatted with Never Join Lines

이 것은 Java > Code Style > Formatter preference 페이지에서 설정할 수 있습니다. Line WrappingComments 탭에서 Never join lines 옵션을 살펴보세요.


Java 비교 편집기

일반적인 편집 기능 향상

이제 Java 비교 편집기는 라인의 이동/복사/삭제와 fomatting 과 같은 텍스트 편집 기능을 지원합니다.

링크(Ctrl+Click)

Hyperlinking

Content Assist (Ctrl+Space)

Content Assist

Javadoc on hover

Javadoc hovers

Quick Outline (Ctrl+O)

Quick outline

타이핑 중 Java 비교 구조 조정

Java 비교 편집기는 이제 비교 편집기 내에서 타이핑하는 동안에도 구조를 갱신합니다.

Dynamic structure comparison


Java Refactoring 과 Source 동작

toString() 생성

새로운 toString() 생성기는 사용자가 정의한 클래스를 위한 toString() 메쏘드를 빠르게 생성하도록 도와줍니다. Source > Generate toString()... 은 결과 String 과 toString() 메쏘드 바디 안에 생성된 코드의 스타일을 설정하기 위한 몇 가지 옵션을 제공합니다.

Generate toString() dialog


hashCode() 와 equals() 생성시 선택적으로 block 사용

이제 Generate hashCode() and equals() 마법사에서 if 문을 위한 block 을 사용할 것인지 선택할 수 있습니다:

Generate hashCode() and equals() wizard


Java 컴파일러

동일한 값 비교

이제 컴파일러에서 같은 값을 비교하는 것을 감지되고 (기본적으로) 경고를 발생합니다:

Comparing Identical Values Warning Example

Java > Compiler > Errors/Warnings preference 페이지의 Potential programming problems 섹션이나 problem hover toolbar의 Configure Problem Severity 를 클릭하여 설정할 수 있습니다.


synchronized modifier 누락

이제 synchronized 메쏘드를 overriding 한 메쏘드가 synchronize 되지 않으면, 컴파일러는 경고를 발생시킵니다.

Problem hover with quick fix for missing synchronized modifier

synchronized modifier를 추가하는 quick fix 를 사용할 수 있습니다. 그리고 Preferences > Java > Compiler > Errors/WarningsPotential programming problems 섹션에서 문제의 심각도를 설정할 수 있습니다.

'switch' case 문에서 fall-through 에 대한 컴파일러 문제 제거

이제 $FALL-THROUGH$로 시작하는 주석을 case 문 앞에 작성함으로써 switch case 문에서 예상된 fall-through 에 대한 컴파일러 문제를 제거할 수 있습니다. 이 기능은 J2SE-5.0-style @SuppressWarnings("fallthrough") 어노테이션을 사용할 수 없는 코드를 위한 것입니다.(This is especially interesting for code that can't use the J2SE-5.0-style @SuppressWarnings("fallthrough") annotation.)

Problem hover with quick fixes for switch case fall-through

기본적으로 이 문제는 보고되지 않습니다. Preferences > Java > Compiler > Errors/WarningsPotential programming problems 섹션에서 'switch' case fall-through 경고를 활성화할 수 있습니다.

hashCode() 메쏘드 누락

이제 컴파일러는 hashCode() 메쏘드를 overriding 하지 않은 채 equals() 메쏘드를 overriding 했는지 탐지할 수 있습니다:

Problem hover with quick fix for missing hashCode method

hashCode() 메쏘드를 overriding 하는 quick fix 나 두 메쏘드를 모두 다시 생성하는 quick fix 를 사용할 수 있습니다.

기본적으로 이 문제는 보고하지 않습니다. Preferences > Java > Compiler > Errors/WarningsPotential programming problems 섹션에서 활성화 가능 합니다.



Dead code

이제 컴파일러는 dead code 가 탐지되면 경고를 발생시킵니다.

예를 들어, if (false) foo(); 는 Java Language Specification 에 의해 실행 불가능한 코드로 보고됩니다. 이 진단 기능이 활성화되면, foo() 의 호출은 dead code 라는 신호를 받습니다:

Problem hover with quick fix for dead code

기본적으로 이 문제는 경고로 보고됩니다. Preferences > Java > Compiler > Errors/WarningsPotential programming problems 섹션에서 문제의 심각도를 설정할 수 있습니다.

예를 들어 if (DEBUG) 처럼 if (상수) 문 뒤에 오는 dead code 는 보고되지 않는다는 것에 주의하십시오.


Classpath resolution honors the 'Class-Path' header of JAR manifest file

The 'Class-Path' header of a JAR manifest is now honored in the Java model. JARs defined by 'Class-Path' are now automatically added to the build path.

For example, 'nested.jar' is a referenced library although it was not explicitly specified in the project build path but through the manifest of 'lib.jar':

Class-Path Clause Example



Build path supports ".."

The path of a library, variable or container entry can now be anywhere relative to the project, e.g. if the library is on a sibling directory, its path can be specified using the ".." as follows:

Parent Relative Path Example



Build path resolution tolerates duplicate entries

Duplicate entries in the build path are now tolerated if the redundant entry is found while resolving the build path and not at the raw level.

For example, two user libraries used in the project build path referring to the same JAR file are tolerated:

Classpath Duplicate Entries Example

However, an error is reported if the same JAR file is directly specified twice:

Classpath Invalid Duplicate Entries Example



Compiler compliance follows execution environment

When you change the JRE on the build path of a Java project to an execution environment, Eclipse now automatically updates the compiler compliance settings on the Java Compiler properties page to use the settings defined by the execution environment.

Java Compiler properties page

Note that as of 3.5, an execution environment is the first choice when creating a new Java project or a launch configuration.



Java Views and Dialogs

Open Type 다이얼로그에서 검색어 강조

이제 Open Type 다이얼로그에서 검색어 패턴에 해당하는 문자열이 강조됩니다:

Emphasized matching characters in Open Type dialog


Package Explorer 에서 working set 정렬

이제 Configure Working Sets... 다이얼로그에 working set 을 알파벳순으로 정렬하기 위한 Sort working sets 옵션이 추가되었습니다. 이 설정이 저장됩니다. 그래서 새로운 working set 이 추가되어도 working set 은 정렬 상태를 유지합니다.

Sort working sets in Package Explorer

Top Level Elements > Working Sets view 메뉴를 통해 Package Explorer 에서 working set 을 활성화 할 수 있습니다.

Package Explorer 에서 working set 삭제

Package Explorer 에서 최상위 요소가 Working Set일 때, 이제 working set에 대한 Delete 기능이 활성화 됩니다. working set 이 삭제될 때, Package Explorer 에서 working set 을 제거하거나 숨길 수 있습니다:

Delete working sets from a Package Explorer


Package Explorer 로의 붙여넣기 패치

Bugzilla 의 패치를 적용하는 가장 빠를 방법은 무었일까요? 첨부파일을 열어서 패치를 복사하고 Package Explorer에 붙여넣는 것입니다.

Call Hierarchy can expand with constructors

In Callers mode, the Call Hierarchy now has an Expand With Constructors action in the context menu for instance methods.

This action replaces the normal children of the method with

  • the constructors of the method's declaring class
  • a node that contains the direct callers of the method.
This is useful for methods in anonymous classes, for example to follow the callers that create a Runnable, instead of those which actually call its run() method.

Expand With Constructors

Some methods (e.g. java.lang.Runnable#run()) are expanded with constructors by default. The defaults can be configured in the view menu.



Improved Javadoc view and hover

The Javadoc view and hovers now support the {@inheritDoc} tag and add links to overridden methods (like the Javadoc tool):

Improved Javadoc hover

Moreover, the message for deprecated elements now shows up on top, and relative links are supported (for example, to embed images from the "doc-files" directory or to link to {@docRoot}).



Open *.jardesc files with JAR Export Wizard

Opening *.jardesc files now launches the JAR Export Wizard by default.

Open With > JAR Export Wizard

The Open JAR Packager... action in the context menu is gone.



Open test result files in JUnit view

JUnit test result files from Eclipse or the Ant JUnit tasks can now be opened in the JUnit view via double click or via Open With > JUnit View.

Open With > JUnit View

If the files are not inside your workspace, you can still open them from the JUnit view via the Test Run History... drop-down menu. And the Import... and Export... actions now always start at the most recently used location.

Test Run History... > Import



JUnit 4.5

Eclipse JUnit4의 버전이 4.5 로 갱신되었습니다. 4.5의 변화에 대해 궁금하시면 Release Notes 를 참고하세요.

Runnable Jar-in-Jar exporter can package libraries

The Runnable JAR File Export wizard can now also package the required libraries into the exported runnable JAR file or into a folder next to the JAR:

Runnable JAR File Export wizard

The advantage of the second and third options is that the required libraries will just be copied and don't need be repackaged.