Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Two fields having same name
Two fields having same name [message #897755] Wed, 25 July 2012 08:24 Go to next message
William Delobel is currently offline William DelobelFriend
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.
index.php/fa/10851/0/
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 265 times)
  • Attachment: minibug.zip
    (Size: 20.45KB, Downloaded 96 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 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30372
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.
Re: Two fields having same name [message #897806 is a reply to message #897780] Wed, 25 July 2012 09:29 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 Wink 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 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 Go to previous messageGo to next message
William Delobel is currently offline William DelobelFriend
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 #897865 is a reply to message #897806] Wed, 25 July 2012 10:30 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6440
Registered: July 2009
Senior Member
Hi

This is very unlikely to be a feature of the Eclipse debugger; it does
occasionally fail to refresh the screen correctly, but I have seen
duplicate names myself.

The debugger is almost certainly correctly showing multiple private Java
fields from different superclasses.

If you enable Show Qualified Names, all may become clear.

Regards

Ed Willink

On 25/07/2012 10:29, William Delobel wrote:
>
> 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.
>
Previous Topic:[CDO] Pessimistic lock with EMF Transaction
Next Topic:[xcore] References lower bound value not serialized
Goto Forum:
  


Current Time: Sat Aug 24 18:02:10 GMT 2019

Powered by FUDForum. Page generated in 0.02328 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top