mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix NPE in record.equals(null) (#688)
This commit is contained in:
parent
3e1edeb90c
commit
fcb750675c
|
@ -54,7 +54,7 @@ public class ObjectMethodsSubstitutor implements BootstrapMethodSubstitutor {
|
||||||
pe.constant(1).propagateTo(result);
|
pe.constant(1).propagateTo(result);
|
||||||
pe.jump(joint);
|
pe.jump(joint);
|
||||||
});
|
});
|
||||||
ConditionProducer classCondition = () -> thisVar.isNull()
|
ConditionProducer classCondition = () -> thatVar.isNull()
|
||||||
.or(() -> thatVar.invokeVirtual("getClass", Class.class).isNotSame(pe.constant(type)));
|
.or(() -> thatVar.invokeVirtual("getClass", Class.class).isNotSame(pe.constant(type)));
|
||||||
pe.when(classCondition).thenDo(() -> {
|
pe.when(classCondition).thenDo(() -> {
|
||||||
pe.constant(0).propagateTo(result);
|
pe.constant(0).propagateTo(result);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package org.teavm.vm;
|
package org.teavm.vm;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -26,6 +27,7 @@ import org.teavm.junit.TeaVMTestRunner;
|
||||||
public class RecordTest {
|
public class RecordTest {
|
||||||
@Test
|
@Test
|
||||||
public void equalsMethod() {
|
public void equalsMethod() {
|
||||||
|
assertFalse(new A(2, "q").equals(null));
|
||||||
assertEquals(new A(2, "q"), new A(2, "q"));
|
assertEquals(new A(2, "q"), new A(2, "q"));
|
||||||
assertNotEquals(new A(2, "q"), new A(3, "q"));
|
assertNotEquals(new A(2, "q"), new A(3, "q"));
|
||||||
assertNotEquals(new A(2, "q"), new A(2, "w"));
|
assertNotEquals(new A(2, "q"), new A(2, "w"));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user