What I have done is 1) import latest mauve sources into a java2script project 2) Remove/comment mauve test toolkit parts not supported by j2s (like java.io.*) 3) since this is a big project (j2s compiler takes 4 min to compile it in a fast machine) I removed all tests corresponding to those java packages/classes not supported by j2s.
I have uploaded the project to http://groups.google.com/group/java2script/web/j2sMauve.tar.bz2. It has its own j2slib since I had to correct a little bug (http://sourceforge.net/tracker/?func=detail&aid=2839956&group_id=155436&atid=795800).
I have runned some tests, mainly java.lang, and I see some tests failures and j2s errors :( My following steps will be generating a full report of all tests errors, failures and passes for java.lang and java.util.
I think mauve test suite is very exaustive and will really help j2s improving its quality but also will let us know more about j2s limitations, bugs, etc. Also, It will also help us to know how java compatibility is affected by an important change in j2s core or j2slib.
This only took me hours of work and it is only an initial proposal of how nauve can be used in j2s. I feel courious about how compatible is j2slib with java libraries, according to mauve. So, I will keep playing with this project. Nevertheless, I think it is a good idea to include these kind of java library compatibility toolkit sources toghether with j2s sources.
Well, let me know what you think. I will try to run as much tests as possible and publish my results and conclusions to the list.
--
Sebastian Gurin <sgu...@softpoint.org>
> Good job. Looking forward for more Java2Script bugs. :D
>
> By the way, I made some JUnit tests for J2SLib using Apache Harmony's JUnit
> tests, long time ago. And Java2Script's Java core library (java.lang.*,
> java.util.*) is mainly from Apache Harmony.
I can't find any reference to which apache-harmony's version was used for j2s.java.core. Do you remember it?
The thing is I'm finding bugs in apache-harmony, not related to j2s compiler. For example, consider java.util.AbstractCollection's addAll method:
/**
* Adds the objects in the specified Collection to this Collection.
*
* @param collection
* the Collection of objects
* @return true if this Collection is modified, false otherwise
*
* @throws UnsupportedOperationException
* when adding to this Collection is not supported
* @throws NullPointerException
* if null is used to invoke this method
*/
public boolean addAll(Collection<? extends E> collection) {
boolean result = false;
Iterator<? extends E> it = collection.iterator();
while (it.hasNext()) {
if (add(it.next())) {
result = true;
}
}
return result;
}
in a normal java program the following code will throw a NullPointerException, just as spected:
anAbstractCollection.addAll(null);
but not in java2script (because obj.somMethod() will raise a browser exception "obj is null" instead throwing a NullPointerException. (I have downloaded latest harmony sources and this remains the same)
The later method have to be fixed to the following so it behaves as spected in j2s:
public boolean addAll(Collection<? extends E> collection) {
if(collection==null) //cancerbero_sgx
throw new NullPointerException();
boolean result = false;
Iterator<? extends E> it = collection.iterator();
while (it.hasNext()) {
if (add(it.next())) {
result = true;
}
}
return result;
}
I had to fix this kind of errors so mauve test execute correctly. (interesting, sun jdk sources contain an if(collection==null){throw... in this kind of methods...)
In this stage I will focus only in make the test executable in j2s: I will only correct those bugs that make the test to raise a browser error. I will not focus on indentify or correct test bad asserts . If the the error is hard to correct, I will try to modify the test (and document this modification) so it can be runned correctly .
The idea is to have the larger amount of a java.lang and java.util mauve test running in j2s correctly. Then we can focus on identify and correct bad tests asserts, make a test suite and a better test result management.
--
Sebastian Gurin <sgu...@softpoint.org>