Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 339827

Summary: Eliminate duplicate object instantiation code and its exception handling
Product: [RT] RAP Reporter: Rüdiger Herrmann <ruediger.herrmann>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
ClassUtil none

Description Rüdiger Herrmann CLA 2011-03-13 11:09:58 EDT
Throughout the RWT code base there are several places where objects are created reflectively. Partly from known classes and partly from strings that represent class names. Class#newInstance() throws several checked exceptions which makes the code bulky. The exception handling is mostly the same but implemented redundantly each time.
A common utility class should provide methods to handle object instantiation and its exception handling.
Comment 1 Rüdiger Herrmann CLA 2011-03-13 11:11:10 EDT
Created attachment 191077 [details]
ClassUtil
Comment 2 Rüdiger Herrmann CLA 2011-03-13 11:24:30 EDT
Committed patch to CVS HEAD.
It introduces a ClassUtil class with overloaded newInstance() methods to create an instance from 
* a given class
* a given class name and class loader
* a given class and using the constructor derived from the given argument types
An unchecked ClassInstantiationException is thrown in case of any error during instantiation.
All places where instances where created _manually_ were replaced by calls to ClassUtil#newInstance().