Skip to main content



      Home
Home » Language IDEs » Objectteams » Constructing instances of value-bound classes
Constructing instances of value-bound classes [message #567176] Sat, 09 January 2010 13:16 Go to next message
Eclipse UserFriend
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 08:16 Go to previous messageGo to next message
Eclipse UserFriend
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 06:44 Go to previous messageGo to next message
Eclipse UserFriend
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 09:09 Go to previous message
Eclipse UserFriend
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: Fri Jul 04 12:10:59 EDT 2025

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

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

Back to the top