Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast error in RegularLevel and Heap #1

Closed
wants to merge 1 commit into from

Conversation

Lertsenem
Copy link

Hi !

First of all, thanks for releasing the source code of your amazing game !

Unfortunately, the code does not compile as is on my station (java 6). It fails with two similar casting errors, in Heap.java and RegularLevel.java. I looked it up, and the statement

(Collection<? extends Item>) bundle.getCollection(ITEM)

seems bogus to me: Item implements Bundlable, not the opposite. The error is very similar in RegularLevel.java.

I tried to fix it but I'm not a Java Guru, so feel free to reject my pull request and provide a better version of this fix. :]

The (Collection<? extends Item>) bundle.getCollection(ITEM) cast fails
at compile time because Item extends (well, implements) Bundlable, not
the opposite.
@tehface
Copy link

tehface commented Jul 30, 2014

you might want to update to java 7

@Lertsenem
Copy link
Author

Well, you can make that pull request a "Compatibility backport for java 6" then.

@sylvia43
Copy link

sylvia43 commented Aug 1, 2014

Just get Java 7. Compatability can be really annoying at times.

@mvdan
Copy link

mvdan commented Aug 2, 2014

I tried building it with the following in ant.properties:

java.source=1.7
java.target=1.7
java.encoding=ISO-8859-1

Still getting the same error, although the encoding warnings are gone. @watabou, could you please upload your ant.properties or project.properties files so that we can use the setup that you use? Or do you build with maven, gradle or something else other than ant?

@mvdan
Copy link

mvdan commented Aug 2, 2014

Forgot to note: I'm using OpenJDK 1.7.0_65, which afaik is the latest version.

@sylvia43
Copy link

sylvia43 commented Aug 2, 2014

I can take a look at it, I'm pretty good with Java. What is bundle.getCollection(ITEM) returning?

@tehface
Copy link

tehface commented Aug 9, 2014

compile with the android sdk bundle works perfect .... ant/maven will fail other wise

@mvdan
Copy link

mvdan commented Aug 9, 2014

@tehface you mean with an IDE? building with ant is standard, getting it to work should be very easy.

@Lertsenem
Copy link
Author

compile with the android sdk bundle works perfect

Could you be more specific ? what steps are you taking to build with no error ? I didn't manage to do just that.

From what I understand, this looks like a mere casting error:

  1. class Item implements Bundlable
  2. bundle.getCollection() returns a Collection<Bundlable>
  3. You want to get a Collection<Item> from your Collection<Bundlable>

A cast as Collection<? extends Item> won't cut it: Item extends (well, implements) Bundlable, not the other way around.

@Lertsenem
Copy link
Author

This pull request has no reason to be anymore. Closing.

@Lertsenem Lertsenem closed this Dec 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants