8218461: test/jdk/java/lang/invoke/VarHandles should be generated rather than manually edited

Reviewed-by: bpb, vromero
This commit is contained in:
Mandy Chung 2019-02-06 15:09:05 -08:00
parent 9c2e3cffb6
commit 007d3c0143
17 changed files with 36 additions and 91 deletions

View File

@ -133,16 +133,13 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = allocate(true); VarHandle[] vhs1 = allocate(true);
VarHandle[] vhs2 = allocate(true); VarHandle[] vhs2 = allocate(true);
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -133,16 +133,13 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = allocate(true); VarHandle[] vhs1 = allocate(true);
VarHandle[] vhs2 = allocate(true); VarHandle[] vhs2 = allocate(true);
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -133,16 +133,13 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = allocate(true); VarHandle[] vhs1 = allocate(true);
VarHandle[] vhs2 = allocate(true); VarHandle[] vhs2 = allocate(true);
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -133,16 +133,13 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = allocate(true); VarHandle[] vhs1 = allocate(true);
VarHandle[] vhs2 = allocate(true); VarHandle[] vhs2 = allocate(true);
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -133,16 +133,13 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = allocate(true); VarHandle[] vhs1 = allocate(true);
VarHandle[] vhs2 = allocate(true); VarHandle[] vhs2 = allocate(true);
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -133,16 +133,13 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = allocate(true); VarHandle[] vhs1 = allocate(true);
VarHandle[] vhs2 = allocate(true); VarHandle[] vhs2 = allocate(true);
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -133,16 +133,13 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = allocate(true); VarHandle[] vhs1 = allocate(true);
VarHandle[] vhs2 = allocate(true); VarHandle[] vhs2 = allocate(true);
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -133,16 +133,13 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = allocate(true); VarHandle[] vhs1 = allocate(true);
VarHandle[] vhs2 = allocate(true); VarHandle[] vhs2 = allocate(true);
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -135,16 +135,13 @@ public class VarHandleTestAccessString extends VarHandleBaseTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = allocate(true); VarHandle[] vhs1 = allocate(true);
VarHandle[] vhs2 = allocate(true); VarHandle[] vhs2 = allocate(true);
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -83,7 +83,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = setupVarHandleSources(true).stream(). VarHandle[] vhs1 = setupVarHandleSources(true).stream().
map(vhs -> vhs.s).toArray(VarHandle[]::new); map(vhs -> vhs.s).toArray(VarHandle[]::new);
VarHandle[] vhs2 = setupVarHandleSources(true).stream(). VarHandle[] vhs2 = setupVarHandleSources(true).stream().
@ -91,10 +91,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest {
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -83,7 +83,7 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = setupVarHandleSources(true).stream(). VarHandle[] vhs1 = setupVarHandleSources(true).stream().
map(vhs -> vhs.s).toArray(VarHandle[]::new); map(vhs -> vhs.s).toArray(VarHandle[]::new);
VarHandle[] vhs2 = setupVarHandleSources(true).stream(). VarHandle[] vhs2 = setupVarHandleSources(true).stream().
@ -91,10 +91,7 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest {
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -83,7 +83,7 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = setupVarHandleSources(true).stream(). VarHandle[] vhs1 = setupVarHandleSources(true).stream().
map(vhs -> vhs.s).toArray(VarHandle[]::new); map(vhs -> vhs.s).toArray(VarHandle[]::new);
VarHandle[] vhs2 = setupVarHandleSources(true).stream(). VarHandle[] vhs2 = setupVarHandleSources(true).stream().
@ -91,10 +91,7 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest {
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -83,7 +83,7 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = setupVarHandleSources(true).stream(). VarHandle[] vhs1 = setupVarHandleSources(true).stream().
map(vhs -> vhs.s).toArray(VarHandle[]::new); map(vhs -> vhs.s).toArray(VarHandle[]::new);
VarHandle[] vhs2 = setupVarHandleSources(true).stream(). VarHandle[] vhs2 = setupVarHandleSources(true).stream().
@ -91,10 +91,7 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest {
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -83,7 +83,7 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = setupVarHandleSources(true).stream(). VarHandle[] vhs1 = setupVarHandleSources(true).stream().
map(vhs -> vhs.s).toArray(VarHandle[]::new); map(vhs -> vhs.s).toArray(VarHandle[]::new);
VarHandle[] vhs2 = setupVarHandleSources(true).stream(). VarHandle[] vhs2 = setupVarHandleSources(true).stream().
@ -91,10 +91,7 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest {
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -83,7 +83,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = setupVarHandleSources(true).stream(). VarHandle[] vhs1 = setupVarHandleSources(true).stream().
map(vhs -> vhs.s).toArray(VarHandle[]::new); map(vhs -> vhs.s).toArray(VarHandle[]::new);
VarHandle[] vhs2 = setupVarHandleSources(true).stream(). VarHandle[] vhs2 = setupVarHandleSources(true).stream().
@ -91,10 +91,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest {
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -143,18 +143,13 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = allocate(true); VarHandle[] vhs1 = allocate(true);
VarHandle[] vhs2 = allocate(true); VarHandle[] vhs2 = allocate(true);
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -87,7 +87,7 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest {
} }
@Test @Test
public void testEqualsAndHashCode() { public void testEquals() {
VarHandle[] vhs1 = setupVarHandleSources(true).stream(). VarHandle[] vhs1 = setupVarHandleSources(true).stream().
map(vhs -> vhs.s).toArray(VarHandle[]::new); map(vhs -> vhs.s).toArray(VarHandle[]::new);
VarHandle[] vhs2 = setupVarHandleSources(true).stream(). VarHandle[] vhs2 = setupVarHandleSources(true).stream().
@ -95,12 +95,7 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest {
for (int i = 0; i < vhs1.length; i++) { for (int i = 0; i < vhs1.length; i++) {
for (int j = 0; j < vhs1.length; j++) { for (int j = 0; j < vhs1.length; j++) {
if (i == j) { if (i != j) {
assertEquals(vhs1[i], vhs1[i]);
assertEquals(vhs1[i], vhs2[i]);
assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
}
else {
assertNotEquals(vhs1[i], vhs1[j]); assertNotEquals(vhs1[i], vhs1[j]);
assertNotEquals(vhs1[i], vhs2[j]); assertNotEquals(vhs1[i], vhs2[j]);
} }