Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339827 - Eliminate duplicate object instantiation code and its exception handling
Summary: Eliminate duplicate object instantiation code and its exception handling
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-13 11:09 EDT by Rüdiger Herrmann CLA
Modified: 2011-03-13 11:24 EDT (History)
0 users

See Also:


Attachments
ClassUtil (46.68 KB, patch)
2011-03-13 11:11 EDT, Rüdiger Herrmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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().