Home » Modeling » EMF » Two fields having same name
Two fields having same name [message #897755] |
Wed, 25 July 2012 08:24 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi,
I know this can't be possible, but a debug session this morning showed a class with two distinct fields having same name -and same type, String.
Since this type is generated by EMF, I post in this forum, but I suspect this might be a bug of eclipse debugger... have any of you witnessed such a behaviour ? I'll try to make a minimal project reproducing this if I can't figure out what is wrong
the type is an EMF enum, without any operation, the name field value specified in the model is the lower case one, and the name field value used by getByName static method is the upper case one
many thx for your help,
w.
EDIT :
almost had it on a minimal sample (attached): debugger still shows the two fields, but value used in by getByName is the expected one (lower case)
-
Attachment: name.jpg
(Size: 27.64KB, Downloaded 393 times) -
Attachment: minibug.zip
(Size: 20.45KB, Downloaded 142 times)
[Updated on: Wed, 25 July 2012 08:51] Report message to a moderator
|
|
|
Re: Two fields having same name [message #897780 is a reply to message #897755] |
Wed, 25 July 2012 08:54 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
William,
Comments below.
On 25/07/2012 10:24 AM, William Delobel wrote:
> Hi,
>
> I know this can't be possible, but a debug session this morning showed a class with two distinct fields having same name -and same type, String.
You mean in Java classes...
>
> Since this type is generated by EMF, I post in this forum, but I suspect this might be a bug of eclipse debugger... have any of you witnessed such a behaviour ?
Not fields declared in the same class. A super class and a derived
class can have the same field names.
> I'll try to make a minimal project reproducing this if I can't figure out what is wrong
>
> the type is an EMF enum, without any operation, the name field value specified in the model is the lower case one, and the name field value used by getByName static method is the upper case one
Any duplicates in the Java itself is something the compiler should
complain about...
>
> many thx for your help,
> w.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Two fields having same name [message #897806 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
|
Re: Two fields having same name [message #897814 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise ;) debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
|
Re: Two fields having same name [message #897818 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise ;) debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
|
Re: Two fields having same name [message #897822 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise ;) debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
|
Re: Two fields having same name [message #897829 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise ;) debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
|
Re: Two fields having same name [message #897834 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise ;) debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
|
Re: Two fields having same name [message #897837 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise ;) debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
|
Re: Two fields having same name [message #897840 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise ;) debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
|
Re: Two fields having same name [message #897846 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise ;) debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
|
Re: Two fields having same name [message #897851 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise ;) debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
|
Re: Two fields having same name [message #897855 is a reply to message #897780] |
Wed, 25 July 2012 09:29 |
William Delobel Messages: 12 Registered: July 2012 |
Junior Member |
|
|
Hi Ed,
Right, I mean in a java class;
Regarding inheritance, I'm not discovering Java, hence my surprise ;) debug sessions I made never showed overloaded fields twice; even so, I can't figure out how these could have different values...
Got it with another test, using a 'regular' enum :
public enum EnumTest {
TRUE("true"),
FALSE("false"),
UNDEFINED("undefined");
private String name;
private EnumTest (String name) {
this.name = name;
}
public static EnumTest getByName(String name) {
for (EnumTest e : EnumTest.values()) {
if (e.name.equals(name)) {
return e;
}
}
return null;
}
}
looks like this is a feature of eclipse debugger, which makes enum constants values appear as a 'name' private field... So this is not really a bug, and has nothing to do with EMF.
Thx for your time,
w.
|
|
| |
Goto Forum:
Current Time: Tue Sep 24 21:55:05 GMT 2024
Powered by FUDForum. Page generated in 0.04918 seconds
|