Page 5 of 6

Re: SVN

PostPosted: 27 Oct 2009, 19:44
by silly freak
doh! sorry, I found my error... look in forge.QuestData_State, the constructor is empty...

thanks, your response was critical. i probably wouldn't have figured that out.

i'll commit it as soon as google allows it again ;)

Re: SVN

PostPosted: 28 Oct 2009, 05:01
by zerker2000
The changes I just committed should let snow mana work, represented by "S".

Re: SVN

PostPosted: 28 Oct 2009, 17:11
by DennisBergkamp
Very nice!
Due to an unfortunate incident, I had to reinstall my entire windows... I'm just redownloading Eclipse right now :(

Re: SVN

PostPosted: 28 Oct 2009, 20:40
by silly freak
don't make that mistake! switch to linux right now^^

i hope you're up again soon

Re: SVN

PostPosted: 28 Oct 2009, 22:53
by DennisBergkamp
I'm not exactly a Linux guru :lol:
Anyway, I did get things up and running... I checked out the latest version, and made a few small updates myself.

Compiling and running in Eclipse is no problem... However, when I export stuff as a JAR, running this JAR gives me the following error:

Code: Select all
An error has occured. You can copy/paste this message or save it to a file.
Please report this, plus what you tried to do, to:
   http://www.slightlymagic.net/forum/viewforum.php?f=26
If you don't want to register an account, you can mail it directly to
   mtgrares@yahoo.com

forge.Deck

Detailed error trace:
java.lang.ArrayStoreException: forge.Deck
   at java.io.ObjectInputStream.readArray(Unknown Source)
   at java.io.ObjectInputStream.readObject0(Unknown Source)
   at java.io.ObjectInputStream.readObject(Unknown Source)
   at java.util.HashMap.readObject(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
   at java.io.ObjectInputStream.readSerialData(Unknown Source)
   at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
   at java.io.ObjectInputStream.readObject0(Unknown Source)
   at java.io.ObjectInputStream.readObject(Unknown Source)
   at forge.DeckIO.readFile(DeckIO.java:174)
   at forge.DeckIO.<init>(DeckIO.java:55)
   at forge.Gui_NewGame.<init>(Gui_NewGame.java:50)
   at forge.Gui_NewGame.main(Gui_NewGame.java:118)
and right after, when I click "Close":

Code: Select all
An error has occured. You can copy/paste this message or save it to a file.
Please report this, plus what you tried to do, to:
   http://www.slightlymagic.net/forum/viewforum.php?f=26
If you don't want to register an account, you can mail it directly to
   mtgrares@yahoo.com

DeckIO : read() error, java.lang.ArrayStoreException: forge.Deck

Detailed error trace:
java.lang.RuntimeException: DeckIO : read() error, java.lang.ArrayStoreException: forge.Deck
   at forge.DeckIO.readFile(DeckIO.java:179)
   at forge.DeckIO.<init>(DeckIO.java:55)
   at forge.Gui_NewGame.<init>(Gui_NewGame.java:50)
   at forge.Gui_NewGame.main(Gui_NewGame.java:118)

Re: SVN

PostPosted: 29 Oct 2009, 00:23
by silly freak
that's shitty... this happend because an array is read from the stream, and that keeps its type, but the decks in the array are converted to the new type, meaning it can't be stored.

I hope i can sort this out, we'll see...

Re: SVN

PostPosted: 29 Oct 2009, 07:29
by zerker2000
Maybe make a "old deck to new deck" converter? I'm quite sure people would want to keep their old decks, so could you just read an ArrayList<Object> and check for "instanceof Deck_Old"? Why isn't the deck file in plain text in the first place?!

Re: SVN

PostPosted: 29 Oct 2009, 11:00
by silly freak
i think i'll clarify part of the problem that's going on here... it's not strictly necessary, but if you're interested in "behind the scenes", read on.

in a nutshell, it comes down to that generics are not there at all at runtime. Generics are just for the compiler to check, so that we can conveniently skip our cast when working with collections. arrays, on the other hand, are checked at runtime, too

this means that some code can't instantiate an array of a generic type, like in
Code: Select all
class Test<T> {
    private T[] t; //possible
    public Test() {
        t = new T[5]; //impossible
    }
   
    public Test(T[] t) {
        this.t = t; //possible
    }
}
for that reason, an ArrayList, or other collection, internally stores Object[]s, not Arrays of the declared types

when an ArrayList<Deck> is serialized, its content (Deck elements in an Object[]) are stored, but the generic information is gone. When it is deserialized as ArrayList<forge.Deck>, the content (forge.Deck, because of readResolve, in an Object[]) is restored. no problem

however, when storing a Deck[] directly, the array runtime class is stored when serializing. readResolve doesn't apply to it, because it only works for instances of Deck, not Deck[]. now we have a Deck[] array and forge.Deck elements, which doesn't work.

i posted this at the sun forums, that's what I got back:
You have a thoroughly predictable disaster on your hands. Find the original developers and their management and make them fix it. Or have them taken out and shot. There is very little you can do about this problem without a massive amount of work. You are going to have to deserialize all the old data using the old non-packaged classes and re-serialize it using the new packaged classes. While you're at it, make sure all the new serializable classes declare a serialVersionUID member so you will reduce the next most predictable problem to manageability.
as shooting you isn't an option^^, i think we'll really need some sort of a "migration tool". not the most beautiful option, but... i'll try to do that, and before we run it, we'll decide for a final location for our to-be-serialized classes

Re: SVN

PostPosted: 29 Oct 2009, 14:58
by DennisBergkamp
Yikes! Ok, that doesn't sound good :shock:

However, what does he mean exactly by "deserialize all the old data using the old non-packaged classes and re-serialize it using the new packaged classes"?

Re: SVN

PostPosted: 29 Oct 2009, 15:12
by DennisBergkamp
Silly Freak,

I just tried R50 you released (dedicated to me, very nice :) ), and when I compile + run it works, but again when I export the JAR I get the same error :

Code: Select all
An error has occured. You can copy/paste this message or save it to a file.
Please report this, plus what you tried to do, to:
   http://www.slightlymagic.net/forum/viewforum.php?f=26
If you don't want to register an account, you can mail it directly to
   mtgrares@yahoo.com

forge.Deck

Detailed error trace:
java.lang.ArrayStoreException: forge.Deck
   at java.io.ObjectInputStream.readArray(Unknown Source)
   at java.io.ObjectInputStream.readObject0(Unknown Source)
   at java.io.ObjectInputStream.readObject(Unknown Source)
   at java.util.HashMap.readObject(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
   at java.io.ObjectInputStream.readSerialData(Unknown Source)
   at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
   at java.io.ObjectInputStream.readObject0(Unknown Source)
   at java.io.ObjectInputStream.readObject(Unknown Source)
   at forge.DeckIO.readFile(DeckIO.java:172)
   at forge.DeckIO.<init>(DeckIO.java:53)
   at forge.Gui_NewGame.<init>(Gui_NewGame.java:50)
   at forge.Gui_NewGame.main(Gui_NewGame.java:118)
Code: Select all
An error has occured. You can copy/paste this message or save it to a file.
Please report this, plus what you tried to do, to:
   http://www.slightlymagic.net/forum/viewforum.php?f=26
If you don't want to register an account, you can mail it directly to
   mtgrares@yahoo.com

DeckIO : read() error, java.lang.ArrayStoreException: forge.Deck

Detailed error trace:
java.lang.RuntimeException: DeckIO : read() error, java.lang.ArrayStoreException: forge.Deck
   at forge.DeckIO.readFile(DeckIO.java:177)
   at forge.DeckIO.<init>(DeckIO.java:53)
   at forge.Gui_NewGame.<init>(Gui_NewGame.java:50)
   at forge.Gui_NewGame.main(Gui_NewGame.java:118)
:(

Re: SVN

PostPosted: 29 Oct 2009, 15:16
by DennisBergkamp
One thing that's interesting though is when I delete the all-decks2 file (big one that is included with all the releases), it runs fine (which is to be expected I suppose) if I then create a deck and save it I expect it to crash again, but it actually works! Maybe it's just this all-decks2 file that's corrupted or incompatible with the new version ?

Re: SVN

PostPosted: 29 Oct 2009, 15:37
by silly freak
incompatible of course, because of the new changes. i suspect that you tested the jar with an all-decks2 file that contains booster drafts. those are stored in arrays, that's why the error occurs. if you test the jar with the files from SVN, do you still get the error? bty, can you post your all-decks2 so i can test it myself?

Re: SVN

PostPosted: 29 Oct 2009, 20:30
by DennisBergkamp
Sure. No this is an older all-decks2 file (I don't think it contains booster draft decks though), I think it's identical to the one included with the previous beta release, but here it is again :)

So anyway, it looks like it's merely an incompatible all-decks2 file... but this probably also means that every older all-decks2 file (on other people's computers) wouldn't work either?

Re: SVN

PostPosted: 29 Oct 2009, 23:38
by zerker2000
I repeat, why can't we store decks in text format? And use an old version to make a converter for the old deck2 files...

Re: SVN

PostPosted: 30 Oct 2009, 00:59
by silly freak
should be possible. i'm currently doing the migration tool, basically a read-reformat-store batch, so it shouldn't be too hard to make plain text out of it. i'll try to find a reasonable format.