2008. 8. 11. 17:15

Eclipse 3.4 - New features for Java developers

Reference : http://download.eclipse.org/eclipse/downloads/drops/R-3.4-200806172000/whatsnew3.4/eclipse-news-part2.html

Java development tools
Java 개발 도구

Java Editor Breadcrumb
Java 편집기 Breadcrumb

현재 Java 편집기는 커서 위치에 있는 요소(element)의 경로를 보여주는 breadcrumb을 제공한다. breadcrumb 는 Toggle Breadcrumb 툴바 버튼이나 Alt+Shift+B 를 눌러서 활성화 될 수 있다:

Picture showing the breadcrumb in the Java editor

breadcrumb의 각 요소(element)를 선택하는 것이 가능하고, 컨텍스트 메뉴나 키보드 단축키를 통해 액션이 호출될 수 있다.

Context menu on breadcrumb item

게다가 breadcrumb 는 드랍다운 방식으로 다른 요소(element)로 이동하는 것을 가능하게 한다.

Breadcrumb drop down

Rich Javadoc Hover

이제 Javadoc hover 를 사용하여 Javadoc 내에서 자유롭게 돌아다닐 수 있다.

  • Javadoc 의 링크 따라가기
  • navigation history 에서 앞으로, 뒤로 가기
  • Javadoc view 에서 현재 내용 보여주기
  • 현재 요소(element)의 선언 보기
  • 외부 브라우저에서 현재 내용 보기
  • hover 크기 조정하기
  • hover 이동하기 (start dragging in the toolbar area)

The enriched Javadoc hover

hover 는 현재 자바 요소(element)에 해당하는 아이콘도 보여준다

To enrich a hover either press F2 or move the mouse into the hover. You can configure how to enrich the hover on the General > Editors > Text Editors preference page.

Rich Java problem hover

이제 problem hover 는 problem에 대한 가능한 모든 quick fix 를 제공하고, 여기로 마우스를 가져오면 F2 에 의해 툴바를 보여준다.

Enriched Problem Hover

Quick fix 는 링크를 클릭해서 실행할 수 있다. 툴바의 액션을 통해 어노테이션과 problem의 심각도를 설정할 수 있다.

Content assist improvements자동 완성 기능 향상

자동 완성 (Ctrl+Space) 은 몇 가지 면에서 향상되었다.

  • 현재 자동완성은 instanceof 문에서 더 많은 변수와 함수에 대한 접근을 제공한다:

    Instanceof Completion Proposals

    추천(recommendation)을 선택하면 대입 구문이 삽입된다.

  • 클래스 타입이 임포트되지 않아도 스태틱 멤버를 위한 자동 완성이 동작한다:

    Static Members Completion

    추천(recommendation)이 선택될 때 필요한 임포트가 추가된다.

  • 이제 자동 완성은 알 수 없는 타입의 함수도 제안할 수 있다:

    Second example of missing types

  • 함수 호출시 자동 완성은 가능한 인수를 보여준다:

    Content assist with proposed guessed arguments

    이 기능은 Java > Editor > Content Assist 설정 페이지에서 구성할 수 있다.

Quick assists

이 배포판에서는 새로운 quick assists (Ctrl+1) 가 추가되었다:

  • getter 와 setter 생성: 필드에서 가능.
    Screenshot of the 'create getter and setter' quick assist

  • 함수로 추출: 표현식과 명령문에서 가능.
    Screenshot of the 'extract method' quick assist

  • 지역 변수로 추출 without replacing all occurrences: 표현식에서 가능.
  • 스트링 연결을 위한 StringBuilder 사용: 스트링 연결에서 사용.
    Picture showing the 'Convert to StringBuffer' quick assist
    StringBuilder 는 1.5 이상의 버전에서 컴파일되는 Java 프로젝트에서 사용되고, StringBuffer 는 그 이전 버전의 프로젝트에서 사용된다.
  • 스트링 연결을 위한 MessageFormat 사용: StringBuilder 로 변환하는 것과 유사하게, MessageFormat 은 스트링 연결을 교체하기 위해 사용된다.
    Picture showing the 'Convert to MessageFormat' quick assist

SWT Templates

SWT 위젯을 위한 코드 빌딩 블럭을 제공하기 위해 템플릿의 집합이 추가되었다.

예를 들어, SWT 버튼을 추가하려면, Button이라고 치고 Ctrl+Space 를 누른 후, Button SWT 템플릿을 선택하고, Enter 를 누르면 된다.

Create a button with the Button template

가능한 모든 템플릿이 보고 싶다면 Java > Editor > Templates 설정 페이지로 가거나, Window > Show View > Other....를 선택하여 템플릿 뷰를 열어라.

New Template Variables
새로운 템플릿 변수

새로운 템플릿 변수가 추가되었고, 현존하는 변수도 향상되었다. 자세한 내용은 Template Variables 도움말을 참조하라.

Specify location for templates

It is now possible to specify the location where Java editor templates are applicable.

  • Statement location: The template shows up only when completing a statement.
  • Type member location: The template shows up only when completing a type member.

As a result, Content Assist (Ctrl+Space) will only show templates applicable at the current location.

Format edited lines on save

A new save action allows to format the edited lines on save. With this option enabled, format on save generates a minimal amount of changes, even on unformatted code.

Save action preference page

To enable this feature go to the Java > Editor > Save Actions preference page and select Format edited lines.

'Fix Project Setup' quick fix

타입을 찾지 못하는 경우, 새로운 quick fix 는 클래스 패스를 수정할 수 있는 방법을 제공한다:

Missing type with quick fix and fix project setup dialog

자바 프로젝트에서 quick fix 는 다른 프로젝트에서 타입을 찾고, 그 타입을 갖고 있는 JAR를 찾아서 빌드 패스에 추가한다. For PDE projects, information from the plug-in manifest is used to offer a new plugin dependency. Other project types can add their fix proposal through a new extension point.

Highlighting numbers in Java code
Java 코드에서 숫자 강조

Java 편집기는 이제 숫자를 최적화된 색으로 보여줄 수 있다.

Picture showing custom color for numbers

Java > Editor > Syntax Coloring 설정 페이지에서 색을 변경할 수 있다.

Javadoc shows constant value
Javadoc이 상수를 보여줌

Javadoc hover 와 Javadoc view 는 이제 스태틱 변수의 상수를 보여준다.

Picture showing Javadoc hover with constant value

Mark read and write occurrences

Mark Occurrences (Alt+Shift+O) 는 이제 읽기, 쓰기 접근을 다른 색으로 표시한다.

Picture showing read and write accesses in the Java editor

Mark Occurrences 는 툴바에서 활성화 될 수 있다. General > Editors > Text Editors > Annotations 에서 어노테이션의 색을 설정할 수 있다.

Occurrences in File improvements

Search > Occurrences in File 에 몇 가지 향상된 기능이 추가되었다:

  • The quick menu (Ctrl+Shift+U) now only shows the searches applicable for the current selection. If only one search kind is possible, the shortcut will directly invoke the search.

    Picture showing the 'Occurrences in File' quick menu

  • The menu now offers all searches available by Mark Occurrences.
  • Matches are now highlighted with different colors for read and write accesses in the search view.
  • 검색 뷰는 뷰 인풋이 현재 선택된 편집기와 연동되는 Link with Editor 모드를 제공한다.

    Picture showing 'Link With Editor' toolbar button in the 'Occurrences result view'

Extract Class refactoring

Extract Class replaces a set of fields with a new container object. All references to the fields are updated to access the new container object. This refactoring helps to group fields which logically belong together.

The following example demonstrates how to extract the fields x,y,z to a new class Position:

Extract Class Position

The refactoring results in the creation of a new Position class which is used in the original class:

Extract Class Position result

To execute the Extract Class refactoring, select a type and invoke Refactor > Extract Class.

New Clean Ups

The following Clean Ups have been added:

  • Correct indentation: Corrects the indentation of your source code.
  • Add unimplemented methods: Adds code stubs for all unimplemented methods.

Add unimplemented methods is most useful after adding a new method to an interface. Correct indentation is also available as save action.

To clean up your code select a set of Java elements and invoke Source > Clean Up.

Refactoring flags references in binaries

Refactorings now flag references to the refactored element inside compiled class files. Such references cannot be updated and would lead to problems at run time.

Refactoring error dialog showing references in binaries

Undo format

Formatting a set of Java elements, e.g. via Package Explorer, can now be undone using Edit > Undo Format (Ctrl+Z).

Annotation formatting improvements

The Java source code formatter now provides fine-grained options for line breaks after annotations. It is possible to specify for each type of annotation if it should be followed by a line break:

  • Annotations on members:

    A member annotation

  • Annotations on parameters:

    A parameter annotation

  • Annotations on local variables:

    A local variable annotation

This can be configured on the Java > Code Style > Formatter preference page.

Formatter preference dialog showing the new line tab page

Java compiler on multi-CPU machines
멀티 CPU 기계에서의 Java 컴파일러

Java 를 위한 Eclipse Compiler 는 멀티 CPU 기계에서의 멀티 쓰레딩 능력을 사용한다. 측정 결과 최대 30% 향상 되는 모습을 볼 수 있었다. 결과는 JRE 와 사용하는 플랫폼에 따라 다를 수 있다.

Support for external class folders

Class folders located outside the workspace (external) can now be added to the build path.

To add an external class folder use the Java Build Path page of the project properties, select the Libraries tab and push the Add External Class Folder button.

How set up an External Class Folder

New and improved compiler diagnostics

Several improvements have been made to the problem detection in the compiler:

  • Unnecessary declaration of thrown exception can now be ignored if it is documented with an @throws or an @exception tag.

    Screenshot of the Error/Warning preference page

    A Quick Fix (Ctrl+1) helps adding the Javadoc tag.

  • Unnecessary declaration of thrown exception can now report warnings for unused declarations of 'Exception' and 'Throwable'.

    A warning is issued if no such exception has been explicitly thrown in the code.

  • Null pointer accesses are now reported as a warning by default.
  • Unnecessary @SuppressWarnings annotations are now detected by the compiler.

    Unused Suppress Warning Example

    Note that @SuppressWarnings("all") is still silencing the warning for unnecessary @SuppressWarnings, as it is the master switch to silence all warnings.

  • Redundant superinterfaces can now be detected by the compiler.

    Example of diagnosed redundant super interface

    The unnecessary code can be removed by using Quick Fix (Ctrl+1).

You can configure this settings on the Java > Compiler > Errors/Warnings preference page.

CLDC 1.1 class file compatibility

The Java compiler can now create CLDC 1.1 compatible class files.

You can set this on the Java > Compiler preference page:

Screenshot of the Compiler preference page

Flexible ZIP archive extensions

It is now possible to add ZIP archives to the build path with file extensions other than .zip or .jar.

It is now, for example, possible to add a .rar file on the build path.

JUnit view shows execution time
JUnit 화며에서 실행 시간 표시

이제 JUnit 화면은 테스트 케이스와 테스트 수트에서의 경과 시간을 보여준다.

JUnit view with elapsed time

Improved Javadoc view
향상된 Javadoc 화면

Javadoc 화면이 향상되었다:

  • 현재 인풋과 관련된 아이콘
  • 히스토리에서 뒤로 앞으로 가는 액션
  • 링크의 활성화/비활성화 액션 (Action to enable and disable link with selection.)
  • 외부의 브라우저에서 현재 인풋을 보여주는 액션

Javadoc View

Rearrange content of files per drag and drop
드래그앤 드랍마다 파일의 컨텐트 재배열

Java 브라우징 퍼스펙티브에서 아웃라인 뷰, 멤버 뷰와 같은 정렬되지 않은 뷰에서 드래그앤 드랍을 통해 멤버를 다시 배열할 수 있게 되었다.

Outline view showing a drag and drop interaction.

Call Hierarchy view works with fields and types
호출 히스토리 뷰에서의 필드와 타입

이제 콜러 모드에서 콜 히스토리 뷰에서더 만은 종류의 엘리먼트를 사용한다:

  • 필드의 자식은 필드에 접근(읽기, 쓰기)하는 모든 멤버다.
  • 타입의 자식이나 인스턴스 초기화 함수는 타입의 모든 생성자이다.

Caller Hierarchy on a field

Runnable JAR export wizard

Runnable JAR File Export wizard 가 런치 설정을 기반으로 JAR 파일을 생성한다. 생성된 JAR 파일은 필요한 JAR 파일과 프로젝트의 클래스 파일을 포함한 프로젝트의 모든 클래스 파일을 담고 있다.

생성된 JAR 는 아래의 명령으로 실행 가능하다:

java -jar generated_file.jar

또는 대부분의 운영 체제에서 파일을 더블클릭하여 실행할 수 있다.

Picture showing the runnable JAR export wizard

export wizard 는 JAR를 빌드할 때 사용되는 ANT 스크립트도 생성할 수 있다.

실행 가능한 JAR 파일을 생성하려면, File > Export... 로 가서 Java > Runnable JAR file wizard 를 선택하라.

More Java search options
Java 검색 옵션 증가

이제 타입 참조 검색은 코드에서 틀정 매치 로케이션으로 제한된다. 예를 들어, 대입 표현식에서, 필드와 지역 변수 타입에서 참조를 찾는 것이 가능하다.

아래의 예제는 코드에서 모든 catch 문을 검색하는 방법을 보여준다 (search for references to '*' and limit to catch clauses):

Picture showing the match location selection UI

Paste creates snippet for members and statements

Package Explorer 뷰에서 멤버와 명령문을 붙여넣는 (Ctrl+V) 것이 가능하다. Eclipse 는 필요한 모든 엘리먼트를 생성해준다.

예를 들어, 아래의 명령문을 _pasted_code_ 에 붙여넣으면:

		List<Number> numbers;
numbers= Arrays.asList(1, 2, 42);

 이 구문을 위한 Java 클래스와 메인 함수를 생성한다:

Pasted snippet into _pasted_code_

Enhanced debug hover

디버깅할 때의 변수 hover 가 object inspector를 표시하도록 향상되었다. 보이는 Variables 뷰나 Expressions 뷰에서의 토글 세팅에 따라 viewThe inspector 가 논리적인 구조를 보여준다.

Debug hover

Execution environment description files
실행 환경 설명 파일

An execution environment description file describes a JVM and the environment it represents (see Execution Environment Descriptions for detailed information on the file format). The file defines JVM properties such as boot path, endorsed directories, language level, executables, source attachments, and so on.

You can now add JREs to your workspace using execution environment description files from the Installed JREs preference page. Press Add and select the Execution Environment Description JRE type.

Choose the kind of JRE to add

On the following page specify an .ee file. This will create a JRE with attributes from the description file. This example shows J9 configured for Foundation 1.1.

Add JRE based on execution environmet description file

Search for installed JREs on Mac
맥에 설치된 JRE 검색

이제 맥에 설치된 모든 JRE를 검색할 수 있다. Java > Installed JREs 설정 페이지에서 Pressing the Search 버튼을 누르면 운영체제의 기본 위치에 설치된 모든 VM을 볼 수 있다 (/System/Library/Frameworks/JavaVM.framework/Versions).

Search for installed JREs

Search results include launch configurations

Launch configurations now appear when searching for references to a main type. Double-clicking on the search result opens the launch dialog on that configuration.

References to a main type include launch configurations

Wait for remote debug connection

A socket listening connector has been added to the Remote Java Application launch type. This allows you to start the Java debugger listening for connection on a specific socket. The program being debugged can then be started with command line options to connect back to the debugger. Select "Standard (Socket Listen)" in the connection type drop down.

Connect tab using a socket listening connector

Default watchpoint suspend settings

You can now control the suspend settings for newly created watchpoints. A watchpoint can suspend execution when a field is accessed, modified, or both. The new preference is available on the Java > Debug preference page.

Suspend policy for watchpoints