6
Eclipse Realizing Exception Handling Strategies by Extending Quick Fix in Eclipse Email: { s3598021, s1669021, hseih}@ntut.edu.tw (robustness) (Eclipse plug-in) Eclipse Java checked unchecked exceptions checked unchecked exceptions [1][2][4][5] Java checked exception checked exception (rethrow) (handle) (Integrated Development Environment IDE) Eclipse (handler) (exception handler) rethrow( ) refine( ) Eclipse (plug-ins) Eclipse Java IDE Java Eclipse Java Eclipse 2.1 Java 1 Java exception Exception RuntimeException Error[9] Exception exception checked exception unchecked exception 1 Java exception Java checked unchecked exceptions checked exception signature Proceedings of the Second Taiwan Conference on Software Engineering, Taipei, Taiwan, 2006 89

o f À [ < c Realizing Exception Handling Strategies by ...ctchen/pdf/TCSE2006-Exception.pdf · Realizing Exception Handling Strategies by Extending Quick Fix in Eclipse f §(g

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: o f À [ < c Realizing Exception Handling Strategies by ...ctchen/pdf/TCSE2006-Exception.pdf · Realizing Exception Handling Strategies by Extending Quick Fix in Eclipse f §(g

Eclipse

Realizing Exception Handling Strategies by Extending Quick Fix in Eclipse

Email: { s3598021, s1669021, hseih}@ntut.edu.tw

(robustness)

(Eclipse plug-in)

Eclipse

Java checked

unchecked exceptions

checked unchecked

exceptions

[1][2][4][5] Java

checked exception —

checked exception

— (rethrow)

(handle)

(Integrated Development Environment IDE)

Eclipse

(handler)

(exception

handler)

rethrow( )

refine( )

Eclipse

(plug-ins) Eclipse

Java IDE

Java Eclipse

Java

Eclipse

2.1 Java

1 Java exception

Exception RuntimeException

Error[9] Exception exception

checked exception

unchecked exception

1 Java exception

Java checked unchecked

exceptions

checked exception

signature

Proceedings of the Second Taiwan Conference on Software Engineering, Taipei, Taiwan, 2006 89

Page 2: o f À [ < c Realizing Exception Handling Strategies by ...ctchen/pdf/TCSE2006-Exception.pdf · Realizing Exception Handling Strategies by Extending Quick Fix in Eclipse f §(g

2 copy method

checked exception IOException

copy 2

copy try-catch

2 copy

IOException throws

(backup() throws IOException)

handle-or-declare rule[11] Java

Java unchecked exception

3

2 Java checked exception

3 Java unchecked exception

Java

(homogeneous exception) [10] Homogeneous

exception package

signature checked exception

checked exception

[3]

java.net package (Application

Programming Interface API) socket

Socket (constructor)

IOException

BindException SocketException

homogeneous exception java.net

package API BindException

SocketException java.io package

IOException

2.2 Eclipse

Eclipse

API Eclipse

— (checked

exception) 4 23

acceptor.createSocket(1234) IOException

checked exception

handle-or-declare

Java

(maker)

Eclipse

5

“Add throws declaration” “Surround with

try/catch” handle-or-declare

declare handle

4 Eclipse

5 Eclipse

“Surround with try/catch”

6 try/catch

IOException

Eclipse

(task) “// TODO”

“ (task view)”

6

Proceedings of the Second Taiwan Conference on Software Engineering, Taipei, Taiwan, 2006 90

Page 3: o f À [ < c Realizing Exception Handling Strategies by ...ctchen/pdf/TCSE2006-Exception.pdf · Realizing Exception Handling Strategies by Extending Quick Fix in Eclipse f §(g

Eclipse

checked exception

signature

propagate

handle declare

separation of concern

[7]

exception handler

(functional logic)

exception

handler

exception handler exception

handler

7

Retry/Take an alternative Propagate

Ignore 1

( )

2 (

)

3 (false alarm[6])

7

Retry Take an Alternative

Retry

Take an Alternative

Propagate

rethrow refine/wrap

recover

cleanup

[12] Java

IRepeatExecutor IRepeatExecutor time

redundancy Eiffel retry

model IRepeatExecutor 3

time redundancy (1) retry

(2)

default

(3)

Retry Take an alternative

retry model

IExceptionChecker catch generic

exception type [11] catch

clause

IOException(homogeneous exception

) runtime BindException

(IOException subclass)

IExceptionChecker

IExceptionChecker

IUncaughtExceptionHandler

handler

Eclipse

4.1 Eclipse

Eclipse

(extension points)

org.eclipse.jdt.ui.quickFixProcessors

IQuickFixProcessor

(problem)

(completion proposal)

(resolution)

“ ”

“Add throws declaration”

“Surround with try/catch” Eclipse

Proceedings of the Second Taiwan Conference on Software Engineering, Taipei, Taiwan, 2006 91

Page 4: o f À [ < c Realizing Exception Handling Strategies by ...ctchen/pdf/TCSE2006-Exception.pdf · Realizing Exception Handling Strategies by Extending Quick Fix in Eclipse f §(g

4.2 “Surround with try/catch”

Eclipse

Eclipse

“Surround with try/catch”

8

QuickFixProcessor IQuickFixProcessor

Eclipse

QuickFixProcessor

LocalCorrectionsSubProcessor

LocalCorrectionsSubProcessor

“Surround with try/catch”

SurroundWithTryCatchRefactoring

CUCorrectionProposal

CUCorrectionProposal

8 Eclipse “Surround with try/catch”

4.3

Eclipse

“Surround with try/catch” Eclipse

(Refactoring) API

[8] Eclipse

Refactoring Rename

Move Extract Method Encapsulate Field

Eclipse 3.0 Refactoring

API LTK(Eclipse Language Toolkit

)[8] Refactoring

8 Refactoring LTK

Refactoring

(precondition)

(Change) (postcondition)

Change

Eclipse

AST(Abstract Syntax Tree) [8] Eclipse

Java AST AST

AST

visitor AST Node visit

visitor

AST Node

accessor (getter setter)

4.4

CUCorrectionProposal

CUCorrectionProposal

(text change)

9 EHRefactoringProposal

Eclipse CUCorrectionProposal

9 EHRefactoringProposal

Add ExceptionChecker

IExceptionChecker

IExceptionChecker

generic exception

generic exception

Add top-level catcher

IUncaughtExceptionHandler

( checked unchecked

exceptions)

Retry with alternatives

Take an Alternative

IRepeatExecutor

Retry with default values

Take an Alternative

IRepeatExecutor default

Retry with original values

Retry

Proceedings of the Second Taiwan Conference on Software Engineering, Taipei, Taiwan, 2006 92

Page 5: o f À [ < c Realizing Exception Handling Strategies by ...ctchen/pdf/TCSE2006-Exception.pdf · Realizing Exception Handling Strategies by Extending Quick Fix in Eclipse f §(g

IRepeatExecutor retry

10

10 IRefactoing

IRefactoring CUCorrectionProposal

AbstractRefactoring IRefactoring

Refactoring

ExceptionChecker TopLevelCatcher

TimeRedundancyWithAlternative

TimeRedundancyWithDefaultValue

TimeRedundancyWithRetry

AbstractRefactoring

AbstractTimeRedundancy

Eclipse

8 11

EHQuickFixProcessor

IRefactoring

EHQuickFixSubProcessor

EHQuickFixSubProcessor

EHRefactoringProposal

EHRefactoringProposal

EHQuickFixProcessor

EHQuickFixSubProcessor

11

“Add ExceptionChecker” ( 12) “Add

top-level catcher”( 13) “Retry with alternatives”

( 14) “Retry with default values” ( 15)

“Retry with original values” ( 16)

( )

(“Add throws

declaration” “Surround with try/catch”)

12 “Add ExceptionChecker”

homogeneous exception

13 “Add top-level catcher”

14 “Retry with alternatives”

15“Retry with default values”

16 “Retry with original values”

17 “Retry with alternatives”

Proceedings of the Second Taiwan Conference on Software Engineering, Taipei, Taiwan, 2006 93

Page 6: o f À [ < c Realizing Exception Handling Strategies by ...ctchen/pdf/TCSE2006-Exception.pdf · Realizing Exception Handling Strategies by Extending Quick Fix in Eclipse f §(g

acceptor.createSocket(1234)

IRepeatExecutor

try/catch

import

Take an Alternative

createAcceptor

createSocket

alternative1

IRepeatExecutor

RepeatExecutionException

17 1

2 3 RepeatExecutionException

Java

Eclipse

Eclipse

Eclipse

[1] Anonymous, Java Exceptions Are Particularly

Evil,

http://www.c2.com/cgi/wiki?JavaExceptionsAre

ParticularlyEvil, accessed 2005.

[2] Anonymous, Checked Exceptions Are Of

Dubious Value,

http://www.c2.com/cgi/wiki?CheckedExceptions

AreOfDubiousValue, accessed 2005.

[3] Arno Haase, “Java Idioms: Exception

Handling,” EuroPLoP, 2002.

[4] B. Venners, Failure and Exceptions: A

Conversation with James Gosling, Part

II,http://www.artima.com/intv/solidP.html, 2003.

[5] B. Venners and B. Eckel, The Trouble with

Checked Exceptions: A Conversation with

Anders Hejlsberg, Part II,

http://www.artima.com/intv/handcuffsP.html,

2003.

[6] B. Meyer, “Disciplined Exceptions,” Technical

Report, Interactive Software Engineering,

1998.

[7] B. Meyer, Object-Oriented Software Construction, 2nd Edition, Prentice-Hall, 1997.

[8] J. Arthorne and C. Laffra, Official Eclipse 3.0 Faqs, Addison-Wesley, 2004.

[9] J. Gosling, B. Joy, G. Steele, and G. Bracha,

The Java Language Specification, 3rd Edition,

Addison-Wesley, 2005.

[10] K. Arnold, J. Gosling, and D. Holmes, The

Java Programming Language, 4th Edition,

Addison-Wesley, 2005.

[11] S. Stelting, Robust Java: Exception Handling, Testing and Debugging, Prentice hall PTR,

2005.

[12] Y. C. Cheng, C.-T Chen, and J. S. Jwo,

"Exception handling: An Architecture Model and

Utility Support," Proceedings of the 12th

Asia-Pacific Software Engineering Conference,

2005.

17 “Retry with alternatives”

Proceedings of the Second Taiwan Conference on Software Engineering, Taipei, Taiwan, 2006 94