Fixes java.lang.Comparable interface

This commit is contained in:
konsoletyper 2014-02-24 13:59:16 +04:00
parent 0004babe65
commit 68f9376242
3 changed files with 8 additions and 7 deletions

View File

@ -137,11 +137,12 @@ public class ClassNativeGenerator implements Generator, Injector, DependencyPlug
writer.outdent().append("}").softNewLine();
writer.append("var cls = " + self + ".$data;").softNewLine();
writer.append("var ctor = cls.$$constructor$$;").softNewLine();
writer.append("if (ctor === null) {").indent().softNewLine();
writer.append("var ex = new ").appendClass(InstantiationException.class.getName()).append("();");
writer.append("if (!ctor) {").indent().softNewLine();
/*writer.append("var ex = new ").appendClass(InstantiationException.class.getName()).append("();").softNewLine();
writer.appendMethodBody(new MethodReference(InstantiationException.class.getName(), new MethodDescriptor(
"<init>", ValueType.VOID))).append("(ex);").softNewLine();
writer.append("$rt_throw(ex);").softNewLine();
"<init>", ValueType.VOID))).append("(ex);").softNewLine();*/
//writer.append("$rt_throw(ex);").softNewLine();
writer.append("return null;").softNewLine();
writer.outdent().append("}").softNewLine();
writer.append("var instance = new cls();").softNewLine();
writer.append("ctor(instance);").softNewLine();

View File

@ -19,6 +19,6 @@ package org.teavm.classlib.java.lang;
*
* @author Alexey Andreev
*/
public interface TComparable<T extends TComparable<T>> {
public interface TComparable<T> {
int compareTo(T other);
}

View File

@ -196,9 +196,9 @@ public class TArrays extends TObject {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override public int compare(Object o1, Object o2) {
if (o1 != null) {
return ((TComparable)o1).compareTo((TComparable)o2);
return ((TComparable)o1).compareTo(o2);
} else if (o2 != null) {
return ((TComparable)o2).compareTo((TComparable)o1);
return ((TComparable)o2).compareTo(o1);
} else {
return 0;
}