Bonjour,
Je suis en train de vérifier un code JAVA avec PMD sous Eclipse et au niveau de mon code GWT, lors de la creation d'un Component, il me dit :
"Overridable methode "addClickHander" called during object construction"

et quand je regarde la règle :

Calling overridable methods during construction poses a risk of invoking methods on an
incompletely constructed object and can be difficult to discern.
It may leave the sub-class unable to construct its superclass or forced to
replicate the construction process completely within itself, losing the ability to call
super(). If the default constructor contains a call to an overridable method,
the subclass may be completely uninstantiable. Note that this includes method calls
throughout the control flow graph - i.e., if a constructor Foo() calls a private method
bar() that calls a public method buz(), this denotes a problem.

Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
public class LiComponent extends ComplexPanel implements HasClickHandlers {
 
 
	private LIElement liElement;
 
	public LiComponent(String libelle) {
		liElement = Document.get().createLIElement();
		setElement(liElement);
		liElement.setInnerText(libelle);
	}
 
	public LiComponent(String libelle, ClickHandler clickHandler) {
		liElement = Document.get().createLIElement();
		setElement(liElement);
		liElement.setInnerText(libelle);
 
		this.addClickHandler(clickHandler);
	}
 
 
	public LiComponent(String contenu, ClickHandler clickHandler, boolean isHtml) {
		liElement = Document.get().createLIElement();
		setElement(liElement);
		if (isHtml) {
			liElement.setInnerHTML(contenu);
		} else {
			liElement.setInnerText(contenu);
		}
		this.addClickHandler(clickHandler);
	}
 
	public LiComponent(String contenu, ClickHandler[] clickHandlers, boolean isHtml) {
		liElement = Document.get().createLIElement();
		setElement(liElement);
		if (isHtml) {
			liElement.setInnerHTML(contenu);
		} else {
			liElement.setInnerText(contenu);
		}
		for( ClickHandler clickHandler:clickHandlers ) {
			this.addClickHandler(clickHandler);
		}
	}
 
	public HandlerRegistration addClickHandler(ClickHandler handler) {
		return addDomHandler(handler, ClickEvent.getType());
	}
}
PMD m'affiche 3 erreurs à chaque "this.addClickHandler(clickHandler);"

Si qlq'un peut m'aider.............merci d'avance !