Aladinux / bsim-bccs

Automatically exported from code.google.com/p/bsim-bccs
0 stars 0 forks source link

Abstract class methods non functional on extended classes #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
For example the method

BSimParticle.intersection(Vector<BSimParticle>)

will not work on a 

Vector<BSimSomeBacteriumThatExtendsParticle> 

when compiling against BSim3.0.jar whereas it works absolutely fine compiling 
within the BSim source tree (e.g. within the 'iGEM' folder as was).

Original issue reported on code.google.com by antmatyj...@gmail.com on 14 Mar 2011 at 6:33

GoogleCodeExporter commented 8 years ago
Might be to do with warning suppression. Do the pre-compiled classes in the 
library have warnings suppressed?

Original comment by antmatyj...@gmail.com on 14 Mar 2011 at 6:36

GoogleCodeExporter commented 8 years ago
OK, fixed with the new BSim3.0.jar.
Guess the warning suppression makes a big difference. Still, this needs some 
thorough checking as BSim relies a lot on extending the base classes.

Original comment by antmatyj...@gmail.com on 14 Mar 2011 at 6:40

GoogleCodeExporter commented 8 years ago
Yeah this needs to be checked. It might be necessary to cast when using the 
intersection method to elements of the correct form, but there should be no 
problems with extended classes as the warning is related to objects that might 
not include methods or members.

Original comment by tgorochowski@gmail.com on 15 Mar 2011 at 9:58

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Have started using Java generics now, for example 

Vector<? extends BSimBacterium> someBacteria = ...

and this seems to be working deliciously so far (with no warnings or need for 
suppression) so this could actually be a good solution. Bit iffy (read hackish) 
with multiple bacteria species which is a shame, also might only be possible in 
Java 7 (at least the things I'm trying to do).

I think I need to do some more reading on generics though, as they still look 
like a good potential solution for a lot of things...

Original comment by antmatyj...@gmail.com on 10 Jun 2011 at 2:31

GoogleCodeExporter commented 8 years ago
No, this should be fine. In generics because you give the base type, it will be 
able to check (against that class) that the necessary methods or members exist. 
We shouldn't be calling anything other than standard bacterium methods on these 
though.

Check what version of Java they are supported as we may need to update the 
requirements page, but it is definitely a better solution!

Original comment by tgorochowski@gmail.com on 11 Jun 2011 at 3:28