Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Objectteams » Problems with Brole playedBy Arole
Problems with Brole playedBy Arole [message #514089] Fri, 12 February 2010 12:06 Go to next message
Eugene Hutorny is currently offline Eugene HutornyFriend
Messages: 110
Registered: January 2010
Senior Member
Hi Stephan,

I've made some more experiments with OT/J and got some more questions.

My teams are declares as the following (complete source here)
public team class Ateam {
	public class Arole playedBy Aclass {
        //...
	}	
}

public team class Bteam {
	private final Ateam ateam;
	public class Brole playedBy Arole<@ateam> {
        //...
	}	
	public Brole lift(Arole<@ateam> as Brole brole) {
		return brole;
	}
}

public team class Cteam extends Ateam {
	public class Crole extends Arole playedBy Aclass {
	}
}



For the following code compiler generates error: The method lift(Arole<@bteam.ateam>) in the type Bteam is not applicable for the arguments (Arole<@ateam>)

      Arole<@ateam> arole = ateam.lift(aclass);				
      bteam.lift(arole);						


How to make the type applicable?

The following code fails with class cast exception:
    final Cteam cteam = new Cteam();
    final Bteam dteam = new Bteam(cteam);

    within(cteam) {
        within(dteam) {
            aclass.run();
         }
    }

Exception in thread "main" java.lang.ClassCastException: ua.in.hutorny.otj.exer14.Cteam$__OT__Crole
	at ua.in.hutorny.otj.exer14.Bteam$__OT__Brole._OT$run$base(Bteam.java)
	at ua.in.hutorny.otj.exer14.Bteam$__OT__Brole.run(Bteam.java:21)

Re: Problems with Brole playedBy Arole [message #514181 is a reply to message #514089] Fri, 12 February 2010 17:39 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
OK, regarding the compile error I have an answer.

To make the message less confusing I first refactored the code,
so that variable names are unique. I did this by changing the variables
in TheTest:
  • ateam -> aTeam, bteam -> bTeam....

Now we see that TheTest.aTeam is not the same variable
as Bteam.ateam, the compiler now reports:

The method lift(Arole<@bTeam.ateam>) in the type Bteam is not applicable for the arguments (Arole<@aTeam>)


Indeed the compiler doesn't see that bTeam.ateam == aTeam.
This is because passing the constructor arg in "bTeam = new Bteam(aTeam)"
is not tracked by the type checker. Luckily, there is language support
to help the compiler to see exactly this identity.

Change Bteam to start like this:

public team class Bteam<Ateam ateam> {
        public Bteam() {
		super();
	}
        ...

This makes the team itself a value dependent class
(cf. http://www.objectteams.org/def/1.3/s9.html).
Given that now the parameter ateam is a property of the
type Bteam, we need to rewrite TheTest like this:

public class TheTest {
	final Ateam aTeam = new Ateam();
	final Bteam<@aTeam> bTeam = new Bteam<@aTeam>();
	final Cteam cteam = new Cteam();
	final Bteam<@cteam> dteam = new Bteam<@cteam>();
	final Aclass aclass = new Aclass();
       ...

Note, that aTeam is still passed into the creation of bTeam,
however, now in a position that the compiler can evaluate,
so that it "knows" that bTeam.ateam == aTeam.

Does this make sense to you, or should I explain more?

-> The code now compiles fine even with the "problematic" lines.
It can be executed, but then fails with the ClassCastException
you reported. I'll look into that next.
Re: Problems with Brole playedBy Arole [message #514193 is a reply to message #514089] Fri, 12 February 2010 18:29 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
The ClassCastException is now tracked at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=302745

The fix should be straight-forward. If you like I can provide
a separate otre.jar file containing the fix (once I have it).

I'm, however, not in the position to create a full build right now,
because I'm currently waiting for the initial OK to upload
our sources into the Eclipse version repository.
Hence we are not running any nightly builds at this point.

Re: Problems with Brole playedBy Arole [message #514206 is a reply to message #514181] Fri, 12 February 2010 20:01 Go to previous messageGo to next message
Eugene Hutorny is currently offline Eugene HutornyFriend
Messages: 110
Registered: January 2010
Senior Member
Stephan Herrmann wrote on Fri, 12 February 2010 12:39
OK, regarding the compile error I have an answer.
...
Does this make sense to you, or should I explain more?




Thanks, now I understand.
Re: Problems with Brole playedBy Arole [message #514207 is a reply to message #514193] Fri, 12 February 2010 20:04 Go to previous message
Eugene Hutorny is currently offline Eugene HutornyFriend
Messages: 110
Registered: January 2010
Senior Member
Stephan Herrmann wrote on Fri, 12 February 2010 13:29
The ClassCastException is now tracked at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=302745

The fix should be straight-forward. If you like I can provide
a separate otre.jar file containing the fix (once I have it).

I'm, however, not in the position to create a full build right now,
because I'm currently waiting for the initial OK to upload
our sources into the Eclipse version repository.
Hence we are not running any nightly builds at this point.




thank you, there is no need to hurry, take your time.
Re: Problems with Brole playedBy Arole [message #568093 is a reply to message #514089] Fri, 12 February 2010 17:39 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
OK, regarding the compile error I have an answer.

To make the message less confusing I first refactored the code,
so that variable names are unique. I did this by changing the variables
in TheTest:
ateam -> aTeam, bteam -> bTeam....
Now we see that TheTest.aTeam is not the same variable
as Bteam.ateam, the compiler now reports:

The method lift(Arole<@bTeam.ateam>) in the type Bteam is not applicable for the arguments (Arole<@aTeam>)

Indeed the compiler doesn't see that bTeam.ateam == aTeam.
This is because passing the constructor arg in "bTeam = new Bteam(aTeam)"
is not tracked by the type checker. Luckily, there is language support
to help the compiler to see exactly this identity.

Change Bteam to start like this:

public team class Bteam<Ateam ateam> {
public Bteam() {
super();
}
...
This makes the team itself a value dependent class
(cf. http://www.objectteams.org/def/1.3/s9.html).
Given that now the parameter ateam is a property of the
type Bteam, we need to rewrite TheTest like this:

public class TheTest {
final Ateam aTeam = new Ateam();
final Bteam<@aTeam> bTeam = new Bteam<@aTeam>();
final Cteam cteam = new Cteam();
final Bteam<@cteam> dteam = new Bteam<@cteam>();
final Aclass aclass = new Aclass();
...
Note, that aTeam is still passed into the creation of bTeam,
however, now in a position that the compiler can evaluate,
so that it "knows" that bTeam.ateam == aTeam.

Does this make sense to you, or should I explain more?

-> The code now compiles fine even with the "problematic" lines.
It can be executed, but then fails with the ClassCastException
you reported. I'll look into that next.
Re: Problems with Brole playedBy Arole [message #568126 is a reply to message #514089] Fri, 12 February 2010 18:29 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
The ClassCastException is now tracked at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=302745

The fix should be straight-forward. If you like I can provide
a separate otre.jar file containing the fix (once I have it).

I'm, however, not in the position to create a full build right now,
because I'm currently waiting for the initial OK to upload
our sources into the Eclipse version repository.
Hence we are not running any nightly builds at this point.
Re: Problems with Brole playedBy Arole [message #568154 is a reply to message #568093] Fri, 12 February 2010 20:01 Go to previous message
Eugene Hutorny is currently offline Eugene HutornyFriend
Messages: 110
Registered: January 2010
Senior Member
Stephan Herrmann wrote on Fri, 12 February 2010 12:39
> OK, regarding the compile error I have an answer.
> ...
> Does this make sense to you, or should I explain more?


Thanks, now I understand.
Re: Problems with Brole playedBy Arole [message #568186 is a reply to message #568126] Fri, 12 February 2010 20:04 Go to previous message
Eugene Hutorny is currently offline Eugene HutornyFriend
Messages: 110
Registered: January 2010
Senior Member
Stephan Herrmann wrote on Fri, 12 February 2010 13:29
> The ClassCastException is now tracked at
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=302745
>
> The fix should be straight-forward. If you like I can provide
> a separate otre.jar file containing the fix (once I have it).
>
> I'm, however, not in the position to create a full build right now,
> because I'm currently waiting for the initial OK to upload
> our sources into the Eclipse version repository.
> Hence we are not running any nightly builds at this point.


thank you, there is no need to hurry, take your time.
Previous Topic:Problems with Brole playedBy Arole
Next Topic:A question on design motivation for callout syntax
Goto Forum:
  


Current Time: Fri Apr 19 11:00:29 GMT 2024

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

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

Back to the top