Bug 182327 - [source generation] Integrate "generate clone()" plugin into main build stream
Summary: [source generation] Integrate "generate clone()" plugin into main build stream
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 enhancement with 9 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL: http://www.sable.mcgill.ca/~ebodde/ge...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-13 10:23 EDT by Eric Bodden CLA
Modified: 2008-09-04 10:25 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Bodden CLA 2007-04-13 10:23:22 EDT
Hi all.

Four a course project I have developed a plugin that helps manage the concern of object cloning in Java, using Eclipse. The plugin consists of two parts:

1.  An Eclipse builder that detects four different code smells w.r.t. cloning:
         1. Returning null from clone()
         2. Never calling super.clone().
         3. Implementing clone() but not Clooneable or vice versa.
         4. In a Java 5 project, not using the covariant return type for
            clone().
2. A code generator very similar in style to "generate hashCode()/equals()" that allows to generate correct clone methods with selective deep copy of fields that have as declared type a reference type that also implements Cloneable.

You can download the plugin and a report plus slides about it at the attached URL. My question is whether you would consider integrating this functionality into the main Eclipse build stream. I deliberately tried to make the implementation as consistent as possible with the current implementation of "generate hashCode() and equals()" in order to provide a similar look and feel and to allow for easy integration.

The flip-side for me is that because of that I use a lot of internal APIs. Hence, integration into Eclipse would be very desirable from my point of view.

Thanks in advance!
Comment 1 Olivier Thomann CLA 2007-04-13 10:31:46 EDT
Moving to JDT/UI.
Comment 2 Philipe Mulet CLA 2007-04-13 10:57:10 EDT
1. feels like new compiler warnings
Comment 3 Neale Upstone CLA 2007-04-25 11:49:04 EDT
Gets my vote.
Anything that makes deep vs shallow clone as easy as selecting "generate clone()" would be a welcome addition.
Comment 4 Martin Aeschlimann CLA 2007-05-08 12:33:17 EDT
Maybe file separate bugs for this. Checking would be in the compiler, code generation in jdt.ui.
We will have a look at this in 3.4.
Comment 5 Eric Bodden CLA 2007-05-08 13:02:33 EDT
> Maybe file separate bugs for this. Checking would be in the compiler, code
> generation in jdt.ui.

Yes, I agree that this should be split. Checking and code generation are really separate. The only thing that combines them are the warning markers. Should I split this up or are you going to take care of this?
Comment 6 Martin Aeschlimann CLA 2007-05-09 03:18:41 EDT
Best is if you do it, so it is clear who's suggestion it is.
I expect that if JDT core likes the suggestion they would add it to the compiler directly, using the normal Java problem markers.
Comment 7 Eric Bodden CLA 2007-05-09 08:26:38 EDT
Ok, from now on, this bug is restricted to the code generation part of the plugin (bullet 2. from the original report). Bug 186135 will handle the related compiler checks.
Comment 8 Eric Bodden CLA 2007-11-02 23:01:54 EDT
Hey again. I was just wondering if this is going to make it into the 3.4 release. Can you tell? Thanks!
Comment 9 Martin Aeschlimann CLA 2007-11-05 12:00:32 EST
Yes, it is tagged as 3.4, so we still plan to do this.
Comment 10 Martin Aeschlimann CLA 2008-04-24 12:59:58 EDT
Not for 3.4, sorry, this got lost. I'm also not sure that we really want to add the new wizard. Please understand that we are very careful when adding new features, as maintenance is costly.

Comment 11 Eric Bodden CLA 2008-04-24 13:27:39 EDT
Sure, no pressure. I (and others) can use it in form of a plugin in the meantime.
Comment 12 Christian Hall CLA 2008-09-03 11:38:58 EDT
I came upon this plug-in and then this issue when I realized this wasn't already in the JDT! Regardless of whether it ends up in the JDT proper (which would be nice), is there a place that this type of plug-in can live more officially than a student account on a university server? Like an Eclipse "sanctioned" plug-in or the like? Is there a JDT Contrib type of project that gets vetted to prevent garbage or duplication but also doesn't need to bloat the base project...sort of like Apache's Commons project I guess...has the governance but not the maintenance? 
Comment 13 Christian Hall CLA 2008-09-03 11:41:00 EDT
Uh. Just noticed. Not sure why I thought that was a university server...oops. But the comment/question still holds barring the warped example.
Comment 14 Eric Bodden CLA 2008-09-03 13:06:46 EDT
> Not sure why I thought that was a university server...oops.

I am confused. It is a university server.
Comment 15 Christian Hall CLA 2008-09-03 14:33:06 EDT
I was going to just leave it alone, but since you are confused. I read your site...it talked of University activity. I assumed that as I wrote my initial comment. Then I was typing the URL for the update site and it didn't have .edu (which I guess is done here in the US, but not everywhere) and I visited the site and saw it was a research organization. So, I posted the oops comment. 

Then, two minutes later being bothered by the fact that I really felt it was a university I clicked to see the parent organization, which of course is the university. So...I realized my oops was unnecessary, but then it seemed like comment spam, so I just let it go.

Sorry for all the confusion.
Comment 16 Dani Megert CLA 2008-09-04 03:11:17 EDT
We won't work on this unless a good quality patch is attached to this bug report.
Comment 17 Neale Upstone CLA 2008-09-04 10:19:05 EDT
While this is in everone's thoughts, I thought I'd comment on performance and also efficacy.

I've used this plugin, but stopped using it a while back.  My recollection was that it didn't support incremental builds.

Also, I've since read "Effective Java" which has some different views of what to do when cloning.

So, if this is to be integrated, then I'd say that what is needed is:
- a performance assessment, possibly keeping to having it as being a one-shot analysis (TPTP Analyser a better place??)
- compatibility with different approaches.  There are clearly bad "smells" that can be picked up, and may be a subset of what's implemented.
- likewise, it would be good to allow people to specify their 'house style'.

...mmm... really seems like a Findbugs/TPTP feature.

What aspects of this are the equiv of warnings like: variable is declared but never read?

It would also need @SuppressWarnings support.
Comment 18 Dani Megert CLA 2008-09-04 10:25:19 EDT
Neale please note that builder related comments should go into bug 186135 as this one is only about the clone method generation wizard.