mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Add record class name to toString implementation (#691)
This commit is contained in:
parent
09cdc63267
commit
25890adcf8
|
@ -156,7 +156,13 @@ public class ObjectMethodsSubstitutor implements BootstrapMethodSubstitutor {
|
|||
private ValueEmitter substituteToString(DynamicCallSite callSite, ProgramEmitter pe) {
|
||||
ValueEmitter thisVar = callSite.getArguments().get(0);
|
||||
String names = callSite.getBootstrapArguments().get(1).getString();
|
||||
ValueEmitter resultVar = pe.construct(StringBuilder.class, pe.constant("["));
|
||||
String className = ((ValueType.Object) thisVar.getType()).getClassName();
|
||||
String simpleName = callSite.getAgent().getClassSource().get(className).getSimpleName();
|
||||
if (simpleName == null) {
|
||||
int idx = className.lastIndexOf('.');
|
||||
simpleName = idx >= 0 ? className.substring(idx + 1) : className;
|
||||
}
|
||||
ValueEmitter resultVar = pe.construct(StringBuilder.class, pe.constant(simpleName + "["));
|
||||
|
||||
int argIndex = 2;
|
||||
int index = 0;
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.teavm.classlib.java.util;
|
|||
|
||||
import java.util.Arrays;
|
||||
import org.teavm.classlib.java.io.TSerializable;
|
||||
import org.teavm.classlib.java.lang.TComparable;
|
||||
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
||||
import org.teavm.classlib.java.lang.TIllegalStateException;
|
||||
import org.teavm.classlib.java.lang.TNullPointerException;
|
||||
|
@ -99,15 +98,7 @@ public class TPriorityQueue<E> extends TAbstractQueue<E> implements TSerializabl
|
|||
private void setComparator(TComparator<? super E> comparator) {
|
||||
this.originalComparator = comparator;
|
||||
if (comparator == null) {
|
||||
comparator = new TComparator<Object>() {
|
||||
@Override public int compare(Object o1, Object o2) {
|
||||
if (o1 instanceof TComparable) {
|
||||
return ((TComparable<Object>) o1).compareTo(o2);
|
||||
} else {
|
||||
return -((TComparable<Object>) o2).compareTo(o1);
|
||||
}
|
||||
}
|
||||
};
|
||||
comparator = TComparator.NaturalOrder.instance();
|
||||
}
|
||||
this.comparator = (TComparator<Object>) comparator;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.teavm.classlib.java.util;
|
|||
|
||||
import org.teavm.classlib.java.io.TSerializable;
|
||||
import org.teavm.classlib.java.lang.TCloneable;
|
||||
import org.teavm.classlib.java.lang.TComparable;
|
||||
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
||||
|
||||
public class TTreeMap<K, V> extends TAbstractMap<K, V> implements TCloneable, TSerializable, TNavigableMap<K, V> {
|
||||
|
@ -105,12 +104,7 @@ public class TTreeMap<K, V> extends TAbstractMap<K, V> implements TCloneable, TS
|
|||
public TTreeMap(TComparator<? super K> comparator) {
|
||||
this.originalComparator = comparator;
|
||||
if (comparator == null) {
|
||||
comparator = new TComparator<Object>() {
|
||||
@SuppressWarnings("unchecked") @Override public int compare(Object o1, Object o2) {
|
||||
return o1 != null ? ((TComparable<Object>) o1).compareTo(o2)
|
||||
: ((TComparable<Object>) o2).compareTo(o1);
|
||||
}
|
||||
};
|
||||
comparator = TComparator.NaturalOrder.instance();
|
||||
}
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,10 @@ public class RecordTest {
|
|||
|
||||
int index = 0;
|
||||
|
||||
index = s.indexOf("B", index);
|
||||
assertTrue(index >= 0);
|
||||
++index;
|
||||
|
||||
index = s.indexOf("x", index);
|
||||
assertTrue(index > 0);
|
||||
++index;
|
||||
|
|
Loading…
Reference in New Issue
Block a user