Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8271405: [lworld] Redo test/jdk/java/lang/invoke/VarHandles changes for JDK-8269956 #516

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -44,6 +44,8 @@
import static org.testng.Assert.*;

public class VarHandleTestAccessBoolean extends VarHandleBaseTest {
static final Class<?> type = boolean.class;

static final boolean static_final_v = true;

static boolean static_v;
@@ -79,19 +81,19 @@
VarHandle vh;
try {
vh = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessBoolean.class, "final_v" + postfix, boolean.class);
VarHandleTestAccessBoolean.class, "final_v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessBoolean.class, "v" + postfix, boolean.class);
VarHandleTestAccessBoolean.class, "v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessBoolean.class, "static_final_v" + postfix, boolean.class);
VarHandleTestAccessBoolean.class, "static_final_v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessBoolean.class, "static_v" + postfix, boolean.class);
VarHandleTestAccessBoolean.class, "static_v" + postfix, type);
vhs.add(vh);

if (same) {
@@ -110,21 +112,21 @@
@BeforeClass
public void setup() throws Exception {
vhFinalField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessBoolean.class, "final_v", boolean.class);
VarHandleTestAccessBoolean.class, "final_v", type);

vhField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessBoolean.class, "v", boolean.class);
VarHandleTestAccessBoolean.class, "v", type);

vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessBoolean.class, "static_final_v", boolean.class);
VarHandleTestAccessBoolean.class, "static_final_v", type);

vhStaticField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessBoolean.class, "static_v", boolean.class);
VarHandleTestAccessBoolean.class, "static_v", type);

vhArray = MethodHandles.arrayElementVarHandle(boolean[].class);

vhValueTypeField = MethodHandles.lookup().findVarHandle(
Value.class, "boolean_v", boolean.class);
Value.class, "boolean_v", type);
}


@@ -209,7 +211,7 @@ public void testIsAccessModeSupported(VarHandle vh) {

@Test(dataProvider = "typesProvider")
public void testTypes(VarHandle vh, List<Class<?>> pts) {
assertEquals(vh.varType(), boolean.class);
assertEquals(vh.varType(), type);

assertEquals(vh.coordinateTypes(), pts);

@@ -221,25 +223,25 @@ public void testTypes(VarHandle vh, List<Class<?>> pts) {
public void testLookupInstanceToStatic() {
checkIAE("Lookup of static final field to instance final field", () -> {
MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessBoolean.class, "final_v", boolean.class);
VarHandleTestAccessBoolean.class, "final_v", type);
});

checkIAE("Lookup of static field to instance field", () -> {
MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessBoolean.class, "v", boolean.class);
VarHandleTestAccessBoolean.class, "v", type);
});
}

@Test
public void testLookupStaticToInstance() {
checkIAE("Lookup of instance final field to static final field", () -> {
MethodHandles.lookup().findVarHandle(
VarHandleTestAccessBoolean.class, "static_final_v", boolean.class);
VarHandleTestAccessBoolean.class, "static_final_v", type);
});

checkIAE("Lookup of instance field to static field", () -> {
vhStaticField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessBoolean.class, "static_v", boolean.class);
VarHandleTestAccessBoolean.class, "static_v", type);
});
}

@@ -44,6 +44,8 @@
import static org.testng.Assert.*;

public class VarHandleTestAccessByte extends VarHandleBaseTest {
static final Class<?> type = byte.class;

static final byte static_final_v = (byte)0x01;

static byte static_v;
@@ -79,19 +81,19 @@
VarHandle vh;
try {
vh = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessByte.class, "final_v" + postfix, byte.class);
VarHandleTestAccessByte.class, "final_v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessByte.class, "v" + postfix, byte.class);
VarHandleTestAccessByte.class, "v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessByte.class, "static_final_v" + postfix, byte.class);
VarHandleTestAccessByte.class, "static_final_v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessByte.class, "static_v" + postfix, byte.class);
VarHandleTestAccessByte.class, "static_v" + postfix, type);
vhs.add(vh);

if (same) {
@@ -110,21 +112,21 @@
@BeforeClass
public void setup() throws Exception {
vhFinalField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessByte.class, "final_v", byte.class);
VarHandleTestAccessByte.class, "final_v", type);

vhField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessByte.class, "v", byte.class);
VarHandleTestAccessByte.class, "v", type);

vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessByte.class, "static_final_v", byte.class);
VarHandleTestAccessByte.class, "static_final_v", type);

vhStaticField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessByte.class, "static_v", byte.class);
VarHandleTestAccessByte.class, "static_v", type);

vhArray = MethodHandles.arrayElementVarHandle(byte[].class);

vhValueTypeField = MethodHandles.lookup().findVarHandle(
Value.class, "byte_v", byte.class);
Value.class, "byte_v", type);
}


@@ -209,7 +211,7 @@ public void testIsAccessModeSupported(VarHandle vh) {

@Test(dataProvider = "typesProvider")
public void testTypes(VarHandle vh, List<Class<?>> pts) {
assertEquals(vh.varType(), byte.class);
assertEquals(vh.varType(), type);

assertEquals(vh.coordinateTypes(), pts);

@@ -221,25 +223,25 @@ public void testTypes(VarHandle vh, List<Class<?>> pts) {
public void testLookupInstanceToStatic() {
checkIAE("Lookup of static final field to instance final field", () -> {
MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessByte.class, "final_v", byte.class);
VarHandleTestAccessByte.class, "final_v", type);
});

checkIAE("Lookup of static field to instance field", () -> {
MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessByte.class, "v", byte.class);
VarHandleTestAccessByte.class, "v", type);
});
}

@Test
public void testLookupStaticToInstance() {
checkIAE("Lookup of instance final field to static final field", () -> {
MethodHandles.lookup().findVarHandle(
VarHandleTestAccessByte.class, "static_final_v", byte.class);
VarHandleTestAccessByte.class, "static_final_v", type);
});

checkIAE("Lookup of instance field to static field", () -> {
vhStaticField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessByte.class, "static_v", byte.class);
VarHandleTestAccessByte.class, "static_v", type);
});
}

@@ -44,6 +44,8 @@
import static org.testng.Assert.*;

public class VarHandleTestAccessChar extends VarHandleBaseTest {
static final Class<?> type = char.class;

static final char static_final_v = '\u0123';

static char static_v;
@@ -79,19 +81,19 @@
VarHandle vh;
try {
vh = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessChar.class, "final_v" + postfix, char.class);
VarHandleTestAccessChar.class, "final_v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessChar.class, "v" + postfix, char.class);
VarHandleTestAccessChar.class, "v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessChar.class, "static_final_v" + postfix, char.class);
VarHandleTestAccessChar.class, "static_final_v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessChar.class, "static_v" + postfix, char.class);
VarHandleTestAccessChar.class, "static_v" + postfix, type);
vhs.add(vh);

if (same) {
@@ -110,21 +112,21 @@
@BeforeClass
public void setup() throws Exception {
vhFinalField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessChar.class, "final_v", char.class);
VarHandleTestAccessChar.class, "final_v", type);

vhField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessChar.class, "v", char.class);
VarHandleTestAccessChar.class, "v", type);

vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessChar.class, "static_final_v", char.class);
VarHandleTestAccessChar.class, "static_final_v", type);

vhStaticField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessChar.class, "static_v", char.class);
VarHandleTestAccessChar.class, "static_v", type);

vhArray = MethodHandles.arrayElementVarHandle(char[].class);

vhValueTypeField = MethodHandles.lookup().findVarHandle(
Value.class, "char_v", char.class);
Value.class, "char_v", type);
}


@@ -209,7 +211,7 @@ public void testIsAccessModeSupported(VarHandle vh) {

@Test(dataProvider = "typesProvider")
public void testTypes(VarHandle vh, List<Class<?>> pts) {
assertEquals(vh.varType(), char.class);
assertEquals(vh.varType(), type);

assertEquals(vh.coordinateTypes(), pts);

@@ -221,25 +223,25 @@ public void testTypes(VarHandle vh, List<Class<?>> pts) {
public void testLookupInstanceToStatic() {
checkIAE("Lookup of static final field to instance final field", () -> {
MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessChar.class, "final_v", char.class);
VarHandleTestAccessChar.class, "final_v", type);
});

checkIAE("Lookup of static field to instance field", () -> {
MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessChar.class, "v", char.class);
VarHandleTestAccessChar.class, "v", type);
});
}

@Test
public void testLookupStaticToInstance() {
checkIAE("Lookup of instance final field to static final field", () -> {
MethodHandles.lookup().findVarHandle(
VarHandleTestAccessChar.class, "static_final_v", char.class);
VarHandleTestAccessChar.class, "static_final_v", type);
});

checkIAE("Lookup of instance field to static field", () -> {
vhStaticField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessChar.class, "static_v", char.class);
VarHandleTestAccessChar.class, "static_v", type);
});
}

@@ -44,6 +44,8 @@
import static org.testng.Assert.*;

public class VarHandleTestAccessDouble extends VarHandleBaseTest {
static final Class<?> type = double.class;

static final double static_final_v = 1.0d;

static double static_v;
@@ -79,19 +81,19 @@
VarHandle vh;
try {
vh = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessDouble.class, "final_v" + postfix, double.class);
VarHandleTestAccessDouble.class, "final_v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessDouble.class, "v" + postfix, double.class);
VarHandleTestAccessDouble.class, "v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessDouble.class, "static_final_v" + postfix, double.class);
VarHandleTestAccessDouble.class, "static_final_v" + postfix, type);
vhs.add(vh);

vh = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessDouble.class, "static_v" + postfix, double.class);
VarHandleTestAccessDouble.class, "static_v" + postfix, type);
vhs.add(vh);

if (same) {
@@ -110,21 +112,21 @@
@BeforeClass
public void setup() throws Exception {
vhFinalField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessDouble.class, "final_v", double.class);
VarHandleTestAccessDouble.class, "final_v", type);

vhField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessDouble.class, "v", double.class);
VarHandleTestAccessDouble.class, "v", type);

vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessDouble.class, "static_final_v", double.class);
VarHandleTestAccessDouble.class, "static_final_v", type);

vhStaticField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessDouble.class, "static_v", double.class);
VarHandleTestAccessDouble.class, "static_v", type);

vhArray = MethodHandles.arrayElementVarHandle(double[].class);

vhValueTypeField = MethodHandles.lookup().findVarHandle(
Value.class, "double_v", double.class);
Value.class, "double_v", type);
}


@@ -209,7 +211,7 @@ public void testIsAccessModeSupported(VarHandle vh) {

@Test(dataProvider = "typesProvider")
public void testTypes(VarHandle vh, List<Class<?>> pts) {
assertEquals(vh.varType(), double.class);
assertEquals(vh.varType(), type);

assertEquals(vh.coordinateTypes(), pts);

@@ -221,25 +223,25 @@ public void testTypes(VarHandle vh, List<Class<?>> pts) {
public void testLookupInstanceToStatic() {
checkIAE("Lookup of static final field to instance final field", () -> {
MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessDouble.class, "final_v", double.class);
VarHandleTestAccessDouble.class, "final_v", type);
});

checkIAE("Lookup of static field to instance field", () -> {
MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessDouble.class, "v", double.class);
VarHandleTestAccessDouble.class, "v", type);
});
}

@Test
public void testLookupStaticToInstance() {
checkIAE("Lookup of instance final field to static final field", () -> {
MethodHandles.lookup().findVarHandle(
VarHandleTestAccessDouble.class, "static_final_v", double.class);
VarHandleTestAccessDouble.class, "static_final_v", type);
});

checkIAE("Lookup of instance field to static field", () -> {
vhStaticField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessDouble.class, "static_v", double.class);
VarHandleTestAccessDouble.class, "static_v", type);
});
}