Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Objectteams » Constructing instances of value-bound classes
Constructing instances of value-bound classes [message #567176] Sat, 09 January 2010 18:16 Go to next message
Eugene Hutorny is currently offline Eugene HutornyFriend
Messages: 110
Registered: January 2010
Senior Member
I have the following class:

public class Person<Gender gender> {
enum Gender { Male, Female }
public Person(String name) {
super();
this.name = name;
}
protected final String name;
}


How can I create an instance of person? :)
Re: Constructing instances of value-bound classes [message #567195 is a reply to message #567176] Sun, 10 January 2010 13:16 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Eugene Hutorny wrote on Sat, 09 January 2010 13:16
> I have the following class:
>
> public class Person<Gender gender> {
> enum Gender { Male, Female }
> public Person(String name) {
> super();
> this.name = name;
> }
> protected final String name;
> }
>
>
> How can I create an instance of person? :)


Theory says:

Person<@Gender.Female> woman = new Person<@Gender.Female>("Lisa");


Practice says:
The above generates illegal byte code
(see https://trac.objectteams.org/ot/ticket/332)

What does it tell us?
Value-dependent types are not widely used and tested as of yet.

But:
A solution for Ticket 332 is on its way.

best,
Stephan
Re: Constructing instances of value-bound classes [message #567214 is a reply to message #567195] Mon, 11 January 2010 11:44 Go to previous messageGo to next message
Eugene Hutorny is currently offline Eugene HutornyFriend
Messages: 110
Registered: January 2010
Senior Member
Thanks for the clarification.
Another related question - from the documentation I got impression that the generic's wildcards can be used for the value bound types, something like:

Person<?> woman = new Person<@Gender.Female>("Lisa");

but I did not succeed with this. Is this feature supported?
Re: Constructing instances of value-bound classes [message #567271 is a reply to message #567214] Mon, 11 January 2010 14:09 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Eugene Hutorny wrote:
> Another related question - from the documentation I got impression that
> the generic's wildcards can be used for the value bound types, something
> like:
>
> Person<?> woman = new Person<@Gender.Female>("Lisa");
>
> but I did not succeed with this. Is this feature supported?

Sorry, no. Currently, the "?" is only used in the standard Java way
to denote an unknown type, not an unknown value.

Stephan
Previous Topic:ClassCastException when instanceof is true
Next Topic:How to export metrics from the Metrics plug-in
Goto Forum:
  


Current Time: Thu Apr 25 15:05:11 GMT 2024

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

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

Back to the top