ClassWeaver generates buggy code ? [message #1014877] |
Tue, 26 February 2013 16:22 |
J LM Messages: 11 Registered: December 2012 |
Junior Member |
|
|
Hi,
using Findbugs as a quality code checker, it points me out that the generated code by the eclipselink weaver seems buggy. I use EclipseLink 2.3.3.
The two generated methods
_persistence_get
_persistence_set
use "==" instead of "equals" to compare two strings.
Example :
public Object _persistence_get(String paramString) {
if (paramString == "myfield")
return this.myfield;
return null;
}
When looking at the code of the ClassWeaver class in the trunk of EclipseLink, the comments of the generation method shows clearly that this comparaison by "==" is intended.
/**
* Add an internal generic get and set method. This is used to avoid
* reflection.
*
* public Object _persistence_get(String attribute) { if (attribute ==
* "address") { return this.address; } if (attribute == "city") { return
* this.city; } return null; }
*
* public void _persistence_set(int index, Object value) { if (attribute ==
* "address") { this.address = (String)value; } else if (attribute ==
* "city") { this.city = (String)city; } }
*/
public void addPersistenceGetSet(ClassDetails classDetails) {
.............
In fact, all the "if" conditions generated will be ignored. So the _get will always return null
Any confirmation that this behavior is the one intended ?
If not, does this code can trigger unwanted behaviors or does it degrade gracefully (apparently yes but by execution of reflection code) ?
Thx,
Jul.
[Updated on: Tue, 26 February 2013 16:25] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04097 seconds