mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-14 09:53:18 +00:00
8366678: Use JUnit in test/langtools/tools/javac
Reviewed-by: liach
This commit is contained in:
parent
5efaa9970a
commit
682fd7846c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,6 @@
|
||||
|
||||
import com.sun.tools.javac.file.FSInfo;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@ -31,6 +30,7 @@ import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Manifest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@ -38,7 +38,7 @@ import java.util.jar.Manifest;
|
||||
* @summary Test com.sun.tools.javac.file.FSInfo
|
||||
* @modules jdk.compiler/com.sun.tools.javac.util
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
* @run testng FSInfoTest
|
||||
* @run junit FSInfoTest
|
||||
*/
|
||||
public class FSInfoTest {
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,14 +30,9 @@
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
* @build toolbox.ToolBox
|
||||
* @run testng MultiReleaseJarAwareSJFM
|
||||
* @run junit MultiReleaseJarAwareSJFM
|
||||
*/
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaFileManager;
|
||||
@ -50,11 +45,18 @@ import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import toolbox.JarTask;
|
||||
import toolbox.JavacTask;
|
||||
import toolbox.ToolBox;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class MultiReleaseJarAwareSJFM {
|
||||
private static final int CURRENT_VERSION = Runtime.version().major();
|
||||
|
||||
@ -113,7 +115,7 @@ public class MultiReleaseJarAwareSJFM {
|
||||
}
|
||||
};
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public void setup() throws Exception {
|
||||
tb.createDirectories("classes",
|
||||
"classes/META-INF/versions/9",
|
||||
@ -140,7 +142,7 @@ public class MultiReleaseJarAwareSJFM {
|
||||
.run();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public void teardown() throws Exception {
|
||||
tb.deleteFiles(
|
||||
"classes/META-INF/versions/" + CURRENT_VERSION + "/version/Version.class",
|
||||
@ -159,7 +161,6 @@ public class MultiReleaseJarAwareSJFM {
|
||||
);
|
||||
}
|
||||
|
||||
@DataProvider(name = "versions")
|
||||
public Object[][] data() {
|
||||
return new Object[][] {
|
||||
{"", 8},
|
||||
@ -169,7 +170,8 @@ public class MultiReleaseJarAwareSJFM {
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "versions")
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void test(String version, int expected) throws Throwable {
|
||||
StandardJavaFileManager jfm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
|
||||
jfm.setLocation(jloc, List.of(new File("multi-release.jar")));
|
||||
@ -183,7 +185,7 @@ public class MultiReleaseJarAwareSJFM {
|
||||
MethodType mt = MethodType.methodType(int.class);
|
||||
MethodHandle mh = MethodHandles.lookup().findVirtual(versionClass, "getVersion", mt);
|
||||
int v = (int)mh.invoke(versionClass.newInstance());
|
||||
Assert.assertEquals(v, expected);
|
||||
Assertions.assertEquals(expected, v);
|
||||
|
||||
jfm.close();
|
||||
}
|
||||
|
||||
@ -30,13 +30,14 @@
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
|
||||
* @run testng/timeout=480 MultiReleaseJarTest
|
||||
* @run junit/timeout=480 MultiReleaseJarTest
|
||||
*/
|
||||
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import toolbox.JarTask;
|
||||
import toolbox.JavacTask;
|
||||
@ -44,6 +45,7 @@ import toolbox.Task;
|
||||
import toolbox.ToolBox;
|
||||
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class MultiReleaseJarTest {
|
||||
|
||||
private final String main1 =
|
||||
@ -84,7 +86,7 @@ public class MultiReleaseJarTest {
|
||||
|
||||
private final ToolBox tb = new ToolBox();
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public void setup() throws Exception {
|
||||
tb.createDirectories("classes", "classes/META-INF/versions/9");
|
||||
new JavacTask(tb)
|
||||
@ -111,7 +113,7 @@ public class MultiReleaseJarTest {
|
||||
);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public void teardown() throws Exception {
|
||||
tb.deleteFiles(
|
||||
"multi-release.jar",
|
||||
@ -120,8 +122,9 @@ public class MultiReleaseJarTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test(dataProvider="modes")
|
||||
@ParameterizedTest
|
||||
// javac -d classes -cp multi-release.jar Main.java -> fails
|
||||
@MethodSource("createModes")
|
||||
public void main1Runtime(Task.Mode mode) throws Exception {
|
||||
tb.writeFile("Main.java", main1);
|
||||
Task.Result result = new JavacTask(tb, mode)
|
||||
@ -134,8 +137,9 @@ public class MultiReleaseJarTest {
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider="modes")
|
||||
@ParameterizedTest
|
||||
// javac -d classes --release 8 -cp multi-release.jar Main.java -> succeeds
|
||||
@MethodSource("createModes")
|
||||
public void main1Release8(Task.Mode mode) throws Exception {
|
||||
tb.writeFile("Main.java", main1);
|
||||
Task.Result result = new JavacTask(tb, mode)
|
||||
@ -148,8 +152,9 @@ public class MultiReleaseJarTest {
|
||||
tb.deleteFiles("Main.java");
|
||||
}
|
||||
|
||||
@Test(dataProvider="modes")
|
||||
@ParameterizedTest
|
||||
// javac -d classes --release 9 -cp multi-release.jar Main.java -> fails
|
||||
@MethodSource("createModes")
|
||||
public void main1Release9(Task.Mode mode) throws Exception {
|
||||
tb.writeFile("Main.java", main1);
|
||||
Task.Result result = new JavacTask(tb, mode)
|
||||
@ -162,8 +167,9 @@ public class MultiReleaseJarTest {
|
||||
tb.deleteFiles("Main.java");
|
||||
}
|
||||
|
||||
@Test(dataProvider="modes")
|
||||
@ParameterizedTest
|
||||
// javac -d classes -cp multi-release.jar Main.java -> succeeds
|
||||
@MethodSource("createModes")
|
||||
public void main2Runtime(Task.Mode mode) throws Exception {
|
||||
tb.writeFile("Main.java", main2);
|
||||
Task.Result result = new JavacTask(tb, mode)
|
||||
@ -176,8 +182,9 @@ public class MultiReleaseJarTest {
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider="modes")
|
||||
@ParameterizedTest
|
||||
// javac -d classes --release 8 -cp multi-release.jar Main.java -> fails
|
||||
@MethodSource("createModes")
|
||||
public void main2Release8(Task.Mode mode) throws Exception {
|
||||
tb.writeFile("Main.java", main2);
|
||||
Task.Result result = new JavacTask(tb, mode)
|
||||
@ -190,8 +197,9 @@ public class MultiReleaseJarTest {
|
||||
tb.deleteFiles("Main.java");
|
||||
}
|
||||
|
||||
@Test(dataProvider="modes")
|
||||
@ParameterizedTest
|
||||
// javac -d classes --release 9 -cp multi-release.jar Main.java -> succeeds
|
||||
@MethodSource("createModes")
|
||||
public void main2Release9(Task.Mode mode) throws Exception {
|
||||
tb.writeFile("Main.java", main2);
|
||||
Task.Result result = new JavacTask(tb, mode)
|
||||
@ -204,7 +212,6 @@ public class MultiReleaseJarTest {
|
||||
tb.deleteFiles("Main.java");
|
||||
}
|
||||
|
||||
@DataProvider(name="modes")
|
||||
public Object[][] createModes() {
|
||||
return new Object[][] {
|
||||
new Object[] {Task.Mode.API},
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,11 +25,11 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng InInterface
|
||||
* @run junit InInterface
|
||||
*/
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
interface LTII {
|
||||
|
||||
@ -51,12 +51,12 @@ interface LTII {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public class InInterface implements LTII {
|
||||
|
||||
@Test
|
||||
public void testLambdaInDefaultMethod() {
|
||||
assertEquals(t1().m(), "yo");
|
||||
assertEquals(t2().m("p"), "snurp");
|
||||
assertEquals("yo", t1().m());
|
||||
assertEquals("snurp", t2().m("p"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,18 +25,18 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng InnerConstructor
|
||||
* @run junit InnerConstructor
|
||||
*/
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Test
|
||||
public class InnerConstructor {
|
||||
|
||||
@Test
|
||||
public void testLambdaWithInnerConstructor() {
|
||||
assertEquals(seq1().m().toString(), "Cbl:nada");
|
||||
assertEquals(seq2().m("rats").toString(), "Cbl:rats");
|
||||
assertEquals("Cbl:nada", seq1().m().toString());
|
||||
assertEquals("Cbl:rats", seq2().m("rats").toString());
|
||||
}
|
||||
|
||||
Ib1 seq1() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,14 +25,12 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng/othervm -Duser.language=en -Duser.country=US LambdaTranslationTest1
|
||||
* @run junit/othervm -Duser.language=en -Duser.country=US LambdaTranslationTest1
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
@Test
|
||||
public class LambdaTranslationTest1 extends LT1Sub {
|
||||
|
||||
String cntxt = "blah";
|
||||
@ -43,7 +41,7 @@ public class LambdaTranslationTest1 extends LT1Sub {
|
||||
private static void appendResult(Object s) { result.set(result.get().toString() + s); }
|
||||
|
||||
private static void assertResult(String expected) {
|
||||
assertEquals(result.get().toString(), expected);
|
||||
assertEquals(expected, result.get().toString());
|
||||
}
|
||||
|
||||
static Integer count(String s) {
|
||||
@ -66,6 +64,7 @@ public class LambdaTranslationTest1 extends LT1Sub {
|
||||
setResult(String.format("d:%f", d));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLambdas() {
|
||||
TBlock<Object> b = t -> {setResult("Sink0::" + t);};
|
||||
b.apply("Howdy");
|
||||
@ -127,6 +126,7 @@ public class LambdaTranslationTest1 extends LT1Sub {
|
||||
assertResult("b11: *999*");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodRefs() {
|
||||
LT1IA ia = LambdaTranslationTest1::eye;
|
||||
ia.doit(1234);
|
||||
@ -147,6 +147,7 @@ public class LambdaTranslationTest1 extends LT1Sub {
|
||||
assertEquals((Integer) 6, a.doit("shower"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInner() throws Exception {
|
||||
(new In()).doInner();
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,26 +25,26 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng/othervm -Duser.language=en -Duser.country=US LambdaTranslationTest2
|
||||
* @run junit/othervm -Duser.language=en -Duser.country=US LambdaTranslationTest2
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* LambdaTranslationTest2 -- end-to-end smoke tests for lambda evaluation
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class LambdaTranslationTest2 {
|
||||
|
||||
final String dummy = "dummy";
|
||||
|
||||
@Test
|
||||
public void testLambdas() {
|
||||
TPredicate<String> isEmpty = s -> s.isEmpty();
|
||||
assertTrue(isEmpty.test(""));
|
||||
@ -100,6 +100,7 @@ public class LambdaTranslationTest2 {
|
||||
String make();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBridges() {
|
||||
Factory<String> of = () -> "y";
|
||||
Factory<?> ef = () -> "z";
|
||||
@ -112,6 +113,7 @@ public class LambdaTranslationTest2 {
|
||||
assertEquals("z", ((Factory) ef).make());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBridgesImplicitSpecialization() {
|
||||
StringFactory sf = () -> "x";
|
||||
|
||||
@ -121,6 +123,7 @@ public class LambdaTranslationTest2 {
|
||||
assertEquals("x", ((Factory) sf).make());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBridgesExplicitSpecialization() {
|
||||
StringFactory2 sf = () -> "x";
|
||||
|
||||
@ -130,6 +133,7 @@ public class LambdaTranslationTest2 {
|
||||
assertEquals("x", ((Factory) sf).make());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuperCapture() {
|
||||
class A {
|
||||
String make() { return "x"; }
|
||||
@ -201,6 +205,7 @@ public class LambdaTranslationTest2 {
|
||||
return String.format("f%f d%f", a0, a1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrimitiveWidening() {
|
||||
WidenS ws1 = LambdaTranslationTest2::pwS1;
|
||||
assertEquals("b1 s2", ws1.m((byte) 1, (short) 2));
|
||||
@ -225,11 +230,13 @@ public class LambdaTranslationTest2 {
|
||||
return String.format("b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnboxing() {
|
||||
Unbox u = LambdaTranslationTest2::pu;
|
||||
assertEquals("b1 s2 cA i4 j5 ztrue f6.000000 d7.000000", u.m((byte)1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoxing() {
|
||||
Box b = LambdaTranslationTest2::pb;
|
||||
assertEquals("b1 s2 cA i4 j5 ztrue f6.000000 d7.000000", b.m((byte) 1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0));
|
||||
@ -239,6 +246,7 @@ public class LambdaTranslationTest2 {
|
||||
return ((String) o).equals("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArgCastingAdaptation() {
|
||||
TPredicate<String> p = LambdaTranslationTest2::cc;
|
||||
assertTrue(p.test("foo"));
|
||||
@ -247,12 +255,14 @@ public class LambdaTranslationTest2 {
|
||||
|
||||
interface SonOfPredicate<T> extends TPredicate<T> { }
|
||||
|
||||
@Test
|
||||
public void testExtendsSAM() {
|
||||
SonOfPredicate<String> p = s -> s.isEmpty();
|
||||
assertTrue(p.test(""));
|
||||
assertTrue(!p.test("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorRef() {
|
||||
Factory<List<String>> lf = ArrayList<String>::new;
|
||||
List<String> list = lf.make();
|
||||
@ -266,6 +276,7 @@ public class LambdaTranslationTest2 {
|
||||
return "private";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrivateMethodRef() {
|
||||
Factory<String> sf = LambdaTranslationTest2::privateMethod;
|
||||
assertEquals("private", sf.make());
|
||||
@ -275,6 +286,7 @@ public class LambdaTranslationTest2 {
|
||||
String make();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrivateIntf() {
|
||||
PrivateIntf p = () -> "foo";
|
||||
assertEquals("foo", p.make());
|
||||
@ -284,11 +296,12 @@ public class LambdaTranslationTest2 {
|
||||
public T op(T a, T b);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoxToObject() {
|
||||
Op<Integer> maxer = Math::max;
|
||||
for (int i=-100000; i < 100000; i += 100)
|
||||
for (int j=-100000; j < 100000; j += 99) {
|
||||
assertEquals((int) maxer.op(i,j), Math.max(i,j));
|
||||
assertEquals(Math.max(i,j), (int) maxer.op(i,j));
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,6 +309,7 @@ public class LambdaTranslationTest2 {
|
||||
return "protected";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProtectedMethodRef() {
|
||||
Factory<String> sf = LambdaTranslationTest2::protectedMethod;
|
||||
assertEquals("protected", sf.make());
|
||||
@ -331,6 +345,7 @@ public class LambdaTranslationTest2 {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInnerClassMethodRef() {
|
||||
Factory<String> fs = new Inner1()::m1;
|
||||
assertEquals("Inner1.m1()", fs.make());
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,27 +25,26 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestFDCCE
|
||||
* @run junit MethodReferenceTestFDCCE
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Method references and raw types.
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public class MethodReferenceTestFDCCE {
|
||||
|
||||
static void assertCCE(Throwable t) {
|
||||
assertEquals(t.getClass().getName(), "java.lang.ClassCastException");
|
||||
assertEquals("java.lang.ClassCastException", t.getClass().getName());
|
||||
}
|
||||
|
||||
interface Pred<T> { boolean accept(T x); }
|
||||
@ -79,18 +78,21 @@ public class MethodReferenceTestFDCCE {
|
||||
return 123;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceFDPrim1() {
|
||||
Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
|
||||
Pred p2 = p;
|
||||
assertTrue(p2.accept((Byte)(byte)15));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceFDPrim2() {
|
||||
Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
|
||||
Pred p2 = p;
|
||||
assertTrue(p2.accept((byte)15));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceFDPrimICCE() {
|
||||
Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
|
||||
Pred p2 = p;
|
||||
@ -102,6 +104,7 @@ public class MethodReferenceTestFDCCE {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceFDPrimOCCE() {
|
||||
Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
|
||||
Pred p2 = p;
|
||||
@ -113,12 +116,14 @@ public class MethodReferenceTestFDCCE {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceFDRef() {
|
||||
Pred<B> p = MethodReferenceTestFDCCE::tst;
|
||||
Pred p2 = p;
|
||||
assertTrue(p2.accept(new B()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceFDRefCCE() {
|
||||
Pred<B> p = MethodReferenceTestFDCCE::tst;
|
||||
Pred p2 = p;
|
||||
@ -130,23 +135,27 @@ public class MethodReferenceTestFDCCE {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceFDPrimPrim() {
|
||||
Ps p = MethodReferenceTestFDCCE::isMinor;
|
||||
assertTrue(p.accept((byte)15));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceFDPrimBoxed() {
|
||||
Ps p = MethodReferenceTestFDCCE::stst;
|
||||
assertTrue(p.accept((byte)15));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceFDPrimRef() {
|
||||
Oo p = MethodReferenceTestFDCCE::otst;
|
||||
assertEquals(p.too(15).getClass().getName(), "java.lang.Integer");
|
||||
assertEquals("java.lang.Integer", p.too(15).getClass().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceFDRet1() {
|
||||
Reto<Short> p = MethodReferenceTestFDCCE::ritst;
|
||||
assertEquals(p.m(), (Short)(short)123);
|
||||
assertEquals((Short)(short)123, p.m());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,12 +25,11 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestInnerDefault
|
||||
* @run junit MethodReferenceTestInnerDefault
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
@ -60,9 +59,9 @@ interface InDefB extends InDefA {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestInnerDefault implements InDefB {
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceInnerDefault() {
|
||||
(new In()).testMethodReferenceInnerDefault();
|
||||
}
|
||||
@ -73,13 +72,13 @@ public class MethodReferenceTestInnerDefault implements InDefB {
|
||||
IDSs q;
|
||||
|
||||
q = MethodReferenceTestInnerDefault.this::xsA__;
|
||||
assertEquals(q.m("*"), "A__xsA:*");
|
||||
assertEquals("A__xsA:*", q.m("*"));
|
||||
|
||||
q = MethodReferenceTestInnerDefault.this::xsAB_;
|
||||
assertEquals(q.m("*"), "AB_xsB:*");
|
||||
assertEquals("AB_xsB:*", q.m("*"));
|
||||
|
||||
q = MethodReferenceTestInnerDefault.this::xs_B_;
|
||||
assertEquals(q.m("*"), "_B_xsB:*");
|
||||
assertEquals("_B_xsB:*", q.m("*"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,24 +25,24 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestInnerInstance
|
||||
* @run junit MethodReferenceTestInnerInstance
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestInnerInstance {
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceInnerInstance() {
|
||||
cia().cib().testMethodReferenceInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceInnerExternal() {
|
||||
cia().cib().testMethodReferenceExternal();
|
||||
}
|
||||
@ -63,14 +63,14 @@ public class MethodReferenceTestInnerInstance {
|
||||
SI q;
|
||||
|
||||
q = CIA.this::xI;
|
||||
assertEquals(q.m(55), "xI:55");
|
||||
assertEquals("xI:55", q.m(55));
|
||||
}
|
||||
|
||||
public void testMethodReferenceExternal() {
|
||||
SI q;
|
||||
|
||||
q = (new E())::xI;
|
||||
assertEquals(q.m(77), "ExI:77");
|
||||
assertEquals("ExI:77", q.m(77));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,19 +25,18 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestInnerVarArgsThis
|
||||
* @run junit MethodReferenceTestInnerVarArgsThis
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestInnerVarArgsThis {
|
||||
|
||||
interface NsII {
|
||||
@ -134,62 +133,62 @@ public class MethodReferenceTestInnerVarArgsThis {
|
||||
NsII q;
|
||||
|
||||
q = CIA.this::xvO;
|
||||
assertEquals(q.m(55, 66), "xvO:55*66*");
|
||||
assertEquals("xvO:55*66*", q.m(55, 66));
|
||||
}
|
||||
|
||||
public void testVarArgsNsArray() {
|
||||
Nsai q;
|
||||
|
||||
q = CIA.this::xvO;
|
||||
assertEquals(q.m(new int[]{55, 66}), "xvO:[55,66,]*");
|
||||
assertEquals("xvO:[55,66,]*", q.m(new int[]{55, 66}));
|
||||
}
|
||||
|
||||
public void testVarArgsNsII() {
|
||||
NsII q;
|
||||
|
||||
q = CIA.this::xvI;
|
||||
assertEquals(q.m(33, 7), "xvI:33-7-");
|
||||
assertEquals("xvI:33-7-", q.m(33, 7));
|
||||
|
||||
q = CIA.this::xIvI;
|
||||
assertEquals(q.m(50, 40), "xIvI:5040-");
|
||||
assertEquals("xIvI:5040-", q.m(50, 40));
|
||||
|
||||
q = CIA.this::xvi;
|
||||
assertEquals(q.m(100, 23), "xvi:123");
|
||||
assertEquals("xvi:123", q.m(100, 23));
|
||||
|
||||
q = CIA.this::xIvi;
|
||||
assertEquals(q.m(9, 21), "xIvi:(9)21");
|
||||
assertEquals("xIvi:(9)21", q.m(9, 21));
|
||||
}
|
||||
|
||||
public void testVarArgsNsiii() {
|
||||
Nsiii q;
|
||||
|
||||
q = CIA.this::xvI;
|
||||
assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
|
||||
assertEquals("xvI:3-2-1-", q.m(3, 2, 1));
|
||||
|
||||
q = CIA.this::xIvI;
|
||||
assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
|
||||
assertEquals("xIvI:88899-2-", q.m(888, 99, 2));
|
||||
|
||||
q = CIA.this::xvi;
|
||||
assertEquals(q.m(900, 80, 7), "xvi:987");
|
||||
assertEquals("xvi:987", q.m(900, 80, 7));
|
||||
|
||||
q = CIA.this::xIvi;
|
||||
assertEquals(q.m(333, 27, 72), "xIvi:(333)99");
|
||||
assertEquals("xIvi:(333)99", q.m(333, 27, 72));
|
||||
}
|
||||
|
||||
public void testVarArgsNsi() {
|
||||
Nsi q;
|
||||
|
||||
q = CIA.this::xvI;
|
||||
assertEquals(q.m(3), "xvI:3-");
|
||||
assertEquals("xvI:3-", q.m(3));
|
||||
|
||||
q = CIA.this::xIvI;
|
||||
assertEquals(q.m(888), "xIvI:888");
|
||||
assertEquals("xIvI:888", q.m(888));
|
||||
|
||||
q = CIA.this::xvi;
|
||||
assertEquals(q.m(900), "xvi:900");
|
||||
assertEquals("xvi:900", q.m(900));
|
||||
|
||||
q = CIA.this::xIvi;
|
||||
assertEquals(q.m(333), "xIvi:(333)0");
|
||||
assertEquals("xIvi:(333)0", q.m(333));
|
||||
}
|
||||
|
||||
// These should NOT be processed as var args
|
||||
@ -197,7 +196,7 @@ public class MethodReferenceTestInnerVarArgsThis {
|
||||
NsaO q;
|
||||
|
||||
q = CIA.this::xvO;
|
||||
assertEquals(q.m(new String[]{"yo", "there", "dude"}), "xvO:yo*there*dude*");
|
||||
assertEquals("xvO:yo*there*dude*", q.m(new String[]{"yo", "there", "dude"}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,28 +217,34 @@ public class MethodReferenceTestInnerVarArgsThis {
|
||||
}
|
||||
|
||||
// These should be processed as var args
|
||||
@Test
|
||||
public void testVarArgsNsSuperclass() {
|
||||
cia().cib().testVarArgsNsSuperclass();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsArray() {
|
||||
cia().cib().testVarArgsNsArray();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsII() {
|
||||
cia().cib().testVarArgsNsII();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsiii() {
|
||||
cia().cib().testVarArgsNsiii();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsi() {
|
||||
cia().cib().testVarArgsNsi();
|
||||
}
|
||||
|
||||
// These should NOT be processed as var args
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsaO() {
|
||||
cia().cib().testVarArgsNsaO();
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,12 +25,11 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestInstance
|
||||
* @run junit MethodReferenceTestInstance
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
@ -42,7 +41,6 @@ class MethodReferenceTestInstance_E {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestInstance {
|
||||
|
||||
interface SI { String m(Integer a); }
|
||||
@ -51,18 +49,20 @@ public class MethodReferenceTestInstance {
|
||||
return "xI:" + i;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceInstance() {
|
||||
SI q;
|
||||
|
||||
q = this::xI;
|
||||
assertEquals(q.m(55), "xI:55");
|
||||
assertEquals("xI:55", q.m(55));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceExternal() {
|
||||
SI q;
|
||||
|
||||
q = (new MethodReferenceTestInstance_E())::xI;
|
||||
assertEquals(q.m(77), "ExI:77");
|
||||
assertEquals("ExI:77", q.m(77));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,18 +25,16 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestKinds
|
||||
* @run junit MethodReferenceTestKinds
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestKinds extends MethodReferenceTestKindsSup {
|
||||
|
||||
interface S0 { String get(); }
|
||||
@ -65,76 +63,86 @@ public class MethodReferenceTestKinds extends MethodReferenceTestKindsSup {
|
||||
static String staticMethod0() { return "SM:0"; }
|
||||
static String staticMethod1(MethodReferenceTestKinds x) { return "SM:1-" + x; }
|
||||
|
||||
MethodReferenceTestKinds(String val) {
|
||||
super(val);
|
||||
}
|
||||
|
||||
MethodReferenceTestKinds() {
|
||||
super("blank");
|
||||
}
|
||||
|
||||
MethodReferenceTestKinds inst(String val) {
|
||||
return new MethodReferenceTestKinds(val);
|
||||
var inst = new MethodReferenceTestKinds();
|
||||
inst.val = val; // simulate `MethodReferenceTestKinds(String val)` constructor
|
||||
return inst;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRBound() {
|
||||
S0 var = this::instanceMethod0;
|
||||
assertEquals(var.get(), "IM:0-MethodReferenceTestKinds(blank)");
|
||||
assertEquals("IM:0-MethodReferenceTestKinds(blank)", var.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRBoundArg() {
|
||||
S1 var = this::instanceMethod1;
|
||||
assertEquals(var.get(inst("arg")), "IM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)");
|
||||
assertEquals("IM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)", var.get(inst("arg")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRUnbound() {
|
||||
S1 var = MethodReferenceTestKinds::instanceMethod0;
|
||||
assertEquals(var.get(inst("rcvr")), "IM:0-MethodReferenceTestKinds(rcvr)");
|
||||
assertEquals("IM:0-MethodReferenceTestKinds(rcvr)", var.get(inst("rcvr")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRUnboundArg() {
|
||||
S2 var = MethodReferenceTestKinds::instanceMethod1;
|
||||
assertEquals(var.get(inst("rcvr"), inst("arg")), "IM:1-MethodReferenceTestKinds(rcvr)MethodReferenceTestKinds(arg)");
|
||||
assertEquals("IM:1-MethodReferenceTestKinds(rcvr)MethodReferenceTestKinds(arg)", var.get(inst("rcvr"), inst("arg")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRSuper() {
|
||||
S0 var = super::instanceMethod0;
|
||||
assertEquals(var.get(), "SIM:0-MethodReferenceTestKinds(blank)");
|
||||
assertEquals("SIM:0-MethodReferenceTestKinds(blank)", var.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRSuperArg() {
|
||||
S1 var = super::instanceMethod1;
|
||||
assertEquals(var.get(inst("arg")), "SIM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)");
|
||||
assertEquals("SIM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)", var.get(inst("arg")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRStatic() {
|
||||
S0 var = MethodReferenceTestKinds::staticMethod0;
|
||||
assertEquals(var.get(), "SM:0");
|
||||
assertEquals("SM:0", var.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRStaticArg() {
|
||||
S1 var = MethodReferenceTestKinds::staticMethod1;
|
||||
assertEquals(var.get(inst("arg")), "SM:1-MethodReferenceTestKinds(arg)");
|
||||
assertEquals("SM:1-MethodReferenceTestKinds(arg)", var.get(inst("arg")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRTopLevel() {
|
||||
SN0 var = MethodReferenceTestKindsBase::new;
|
||||
assertEquals(var.make().toString(), "MethodReferenceTestKindsBase(blank)");
|
||||
assertEquals("MethodReferenceTestKindsBase(blank)", var.make().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRTopLevelArg() {
|
||||
SN1 var = MethodReferenceTestKindsBase::new;
|
||||
assertEquals(var.make("name").toString(), "MethodReferenceTestKindsBase(name)");
|
||||
assertEquals("MethodReferenceTestKindsBase(name)", var.make("name").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRImplicitInner() {
|
||||
SN0 var = MethodReferenceTestKinds.In::new;
|
||||
assertEquals(var.make().toString(), "In(blank)");
|
||||
assertEquals("In(blank)", var.make().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMRImplicitInnerArg() {
|
||||
SN1 var = MethodReferenceTestKinds.In::new;
|
||||
assertEquals(var.make("name").toString(), "In(name)");
|
||||
assertEquals("In(name)", var.make("name").toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,16 +25,15 @@
|
||||
* @test
|
||||
* @bug 8028739
|
||||
* @summary javac generates incorrect descriptor for MethodHandle::invoke
|
||||
* @run testng MethodReferenceTestMethodHandle
|
||||
* @run junit MethodReferenceTestMethodHandle
|
||||
*/
|
||||
|
||||
import java.lang.invoke.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestMethodHandle {
|
||||
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
@ -51,6 +50,7 @@ public class MethodReferenceTestMethodHandle {
|
||||
void apply(List st, int idx, Object v) throws Throwable;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVirtual() throws Throwable {
|
||||
|
||||
MethodType mt = MethodType.methodType(String.class, char.class, char.class);
|
||||
@ -69,6 +69,7 @@ public class MethodReferenceTestMethodHandle {
|
||||
assertEquals("oome otring to oearch", ((ReplaceItf) ms::invoke).apply("some string to search", 's', 'o'));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatic() throws Throwable {
|
||||
MethodType fmt = MethodType.methodType(String.class, String.class, (new Object[1]).getClass());
|
||||
MethodHandle fms = lookup.findStatic(String.class, "format", fmt);
|
||||
@ -83,6 +84,7 @@ public class MethodReferenceTestMethodHandle {
|
||||
assertEquals("Testing One 2 3 four", ff2.apply("Testing %s %d %x %s", "One", new Integer(2), 3, "four"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVoid() throws Throwable {
|
||||
MethodType pmt = MethodType.methodType(void.class, int.class, Object.class);
|
||||
MethodHandle pms = lookup.findVirtual(List.class, "add", pmt);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,18 +25,16 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestNew
|
||||
* @run junit MethodReferenceTestNew
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestNew {
|
||||
|
||||
interface M0<T> {
|
||||
@ -105,32 +103,36 @@ public class MethodReferenceTestNew {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorReference0() {
|
||||
M0<N0> q;
|
||||
|
||||
q = N0::new;
|
||||
assertEquals(q.m().getClass().getSimpleName(), "N0");
|
||||
assertEquals("N0", q.m().getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorReference1() {
|
||||
M1<N1> q;
|
||||
|
||||
q = N1::new;
|
||||
assertEquals(q.m(14).getClass().getSimpleName(), "N1");
|
||||
assertEquals("N1", q.m(14).getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorReference2() {
|
||||
M2<N2> q;
|
||||
|
||||
q = N2::new;
|
||||
assertEquals(q.m(7, "hi").toString(), "N2(7,hi)");
|
||||
assertEquals("N2(7,hi)", q.m(7, "hi").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorReferenceVarArgs() {
|
||||
MV q;
|
||||
|
||||
q = NV::new;
|
||||
assertEquals(q.m(5, 45).toString(), "NV(50)");
|
||||
assertEquals("NV(50)", q.m(5, 45).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,18 +25,16 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestNewInner
|
||||
* @run junit MethodReferenceTestNewInner
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestNewInner {
|
||||
|
||||
String note = "NO NOTE";
|
||||
@ -120,26 +118,29 @@ public class MethodReferenceTestNewInner {
|
||||
assertEquals(q.m(new MethodReferenceTestNewInner()).getClass().getSimpleName(), "N0");
|
||||
}
|
||||
*/
|
||||
@Test
|
||||
public void testConstructorReference0() {
|
||||
M0<N0> q;
|
||||
|
||||
q = N0::new;
|
||||
assertEquals(q.m().getClass().getSimpleName(), "N0");
|
||||
assertEquals("N0", q.m().getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorReference1() {
|
||||
M1<N1> q;
|
||||
|
||||
q = N1::new;
|
||||
assertEquals(q.m(14).getClass().getSimpleName(), "N1");
|
||||
assertEquals("N1", q.m(14).getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorReference2() {
|
||||
M2<N2> q;
|
||||
|
||||
note = "T2";
|
||||
q = N2::new;
|
||||
assertEquals(q.m(7, "hi").toString(), "T2:N2(7,hi)");
|
||||
assertEquals("T2:N2(7,hi)", q.m(7, "hi").toString());
|
||||
}
|
||||
|
||||
/***
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,12 +25,11 @@
|
||||
* @test
|
||||
* @bug 8011591
|
||||
* @summary BootstrapMethodError when capturing constructor ref to local classes
|
||||
* @run testng MethodReferenceTestNewInnerImplicitArgs
|
||||
* @run junit MethodReferenceTestNewInnerImplicitArgs
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test the case that a constructor has implicit parameters added to
|
||||
@ -39,7 +38,6 @@ import static org.testng.Assert.assertEquals;
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestNewInnerImplicitArgs {
|
||||
|
||||
|
||||
@ -56,7 +54,8 @@ public class MethodReferenceTestNewInnerImplicitArgs {
|
||||
S m(int i, int j);
|
||||
}
|
||||
|
||||
public static void testConstructorReferenceImplicitParameters() {
|
||||
@Test
|
||||
public void testConstructorReferenceImplicitParameters() {
|
||||
String title = "Hey";
|
||||
String a2 = "!!!";
|
||||
class MS extends S {
|
||||
@ -66,7 +65,7 @@ public class MethodReferenceTestNewInnerImplicitArgs {
|
||||
}
|
||||
|
||||
I result = MS::new;
|
||||
assertEquals(result.m().b, "Hey!!!");
|
||||
assertEquals("Hey!!!", result.m().b);
|
||||
|
||||
class MS2 extends S {
|
||||
MS2(int x, int y) {
|
||||
@ -75,6 +74,6 @@ public class MethodReferenceTestNewInnerImplicitArgs {
|
||||
}
|
||||
|
||||
I2 result2 = MS2::new;
|
||||
assertEquals(result2.m(8, 4).b, "Hey8!!!4");
|
||||
assertEquals("Hey8!!!4", result2.m(8, 4).b);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,18 +25,16 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestSueCase1
|
||||
* @run junit MethodReferenceTestSueCase1
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestSueCase1 {
|
||||
|
||||
public interface Sam2<T> { public String get(T target, String s); }
|
||||
@ -46,7 +44,8 @@ public class MethodReferenceTestSueCase1 {
|
||||
|
||||
String m() { return var.get(new MethodReferenceTestSueCase1(), ""); }
|
||||
|
||||
@Test
|
||||
public void testSueCase1() {
|
||||
assertEquals(m(), "2");
|
||||
assertEquals("2", m());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,18 +25,16 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestSueCase2
|
||||
* @run junit MethodReferenceTestSueCase2
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestSueCase2 {
|
||||
|
||||
public interface Sam2<T> { public String get(T target, String s); }
|
||||
@ -46,7 +44,8 @@ public class MethodReferenceTestSueCase2 {
|
||||
|
||||
String m() { return var.get(new MethodReferenceTestSueCase2(), ""); }
|
||||
|
||||
@Test
|
||||
public void testSueCase2() {
|
||||
assertEquals(m(), "2");
|
||||
assertEquals("2", m());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,18 +25,16 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestSueCase4
|
||||
* @run junit MethodReferenceTestSueCase4
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestSueCase4 {
|
||||
|
||||
public interface Sam2<T> { public String get(T target, String s); }
|
||||
@ -51,7 +49,8 @@ public class MethodReferenceTestSueCase4 {
|
||||
String instanceMethod(String s) { return "2"; }
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSueCase4() {
|
||||
assertEquals(m(), "2");
|
||||
assertEquals("2", m());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,12 +25,11 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestSuper
|
||||
* @run junit MethodReferenceTestSuper
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
@ -77,7 +76,6 @@ class SPRB extends SPRA {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestSuper extends SPRB {
|
||||
|
||||
String xsA_M(String s) {
|
||||
@ -93,26 +91,27 @@ public class MethodReferenceTestSuper extends SPRB {
|
||||
return "_BMxsM:" + s;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceSuper() {
|
||||
SPRI q;
|
||||
|
||||
q = super::xsA__;
|
||||
assertEquals(q.m("*"), "A__xsA:*");
|
||||
assertEquals("A__xsA:*", q.m("*"));
|
||||
|
||||
q = super::xsA_M;
|
||||
assertEquals(q.m("*"), "A_MxsA:*");
|
||||
assertEquals("A_MxsA:*", q.m("*"));
|
||||
|
||||
q = super::xsAB_;
|
||||
assertEquals(q.m("*"), "AB_xsB:*");
|
||||
assertEquals("AB_xsB:*", q.m("*"));
|
||||
|
||||
q = super::xsABM;
|
||||
assertEquals(q.m("*"), "ABMxsB:*");
|
||||
assertEquals("ABMxsB:*", q.m("*"));
|
||||
|
||||
q = super::xs_B_;
|
||||
assertEquals(q.m("*"), "_B_xsB:*");
|
||||
assertEquals("_B_xsB:*", q.m("*"));
|
||||
|
||||
q = super::xs_BM;
|
||||
assertEquals(q.m("*"), "_BMxsB:*");
|
||||
assertEquals("_BMxsB:*", q.m("*"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,12 +25,11 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestSuperDefault
|
||||
* @run junit MethodReferenceTestSuperDefault
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
@ -61,20 +60,20 @@ interface DSPRB extends DSPRA {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestSuperDefault implements DSPRB {
|
||||
|
||||
@Test
|
||||
public void testMethodReferenceSuper() {
|
||||
DSPRI q;
|
||||
|
||||
q = DSPRB.super::xsA__;
|
||||
assertEquals(q.m("*"), "A__xsA:*");
|
||||
assertEquals("A__xsA:*", q.m("*"));
|
||||
|
||||
q = DSPRB.super::xsAB_;
|
||||
assertEquals(q.m("*"), "AB_xsB:*");
|
||||
assertEquals("AB_xsB:*", q.m("*"));
|
||||
|
||||
q = DSPRB.super::xs_B_;
|
||||
assertEquals(q.m("*"), "_B_xsB:*");
|
||||
assertEquals("_B_xsB:*", q.m("*"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,12 +25,11 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestTypeConversion
|
||||
* @run junit MethodReferenceTestTypeConversion
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
@ -40,21 +39,22 @@ class MethodReferenceTestTypeConversion_E<T> {
|
||||
T xI(T t) { return t; }
|
||||
}
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestTypeConversion {
|
||||
|
||||
interface ISi { int m(Short a); }
|
||||
|
||||
interface ICc { char m(Character a); }
|
||||
|
||||
@Test
|
||||
public void testUnboxObjectToNumberWiden() {
|
||||
ISi q = (new MethodReferenceTestTypeConversion_E<Short>())::xI;
|
||||
assertEquals(q.m((short)77), (short)77);
|
||||
assertEquals((short)77, q.m((short)77));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnboxObjectToChar() {
|
||||
ICc q = (new MethodReferenceTestTypeConversion_E<Character>())::xI;
|
||||
assertEquals(q.m('@'), '@');
|
||||
assertEquals('@', q.m('@'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,19 +25,18 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestVarArgs
|
||||
* @run junit MethodReferenceTestVarArgs
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
*/
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestVarArgs {
|
||||
|
||||
interface SII {
|
||||
@ -127,75 +126,81 @@ public class MethodReferenceTestVarArgs {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsSuperclass() {
|
||||
SII q;
|
||||
|
||||
q = MethodReferenceTestVarArgs::xvO;
|
||||
assertEquals(q.m(55,66), "xvO:55*66*");
|
||||
assertEquals("xvO:55*66*", q.m(55,66));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsArray() {
|
||||
Sai q;
|
||||
|
||||
q = MethodReferenceTestVarArgs::xvO;
|
||||
assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
|
||||
assertEquals("xvO:[55,66,]*", q.m(new int[] { 55,66 } ));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsII() {
|
||||
SII q;
|
||||
|
||||
q = MethodReferenceTestVarArgs::xvI;
|
||||
assertEquals(q.m(33,7), "xvI:33-7-");
|
||||
assertEquals("xvI:33-7-", q.m(33,7));
|
||||
|
||||
q = MethodReferenceTestVarArgs::xIvI;
|
||||
assertEquals(q.m(50,40), "xIvI:5040-");
|
||||
assertEquals("xIvI:5040-", q.m(50,40));
|
||||
|
||||
q = MethodReferenceTestVarArgs::xvi;
|
||||
assertEquals(q.m(100,23), "xvi:123");
|
||||
assertEquals("xvi:123", q.m(100,23));
|
||||
|
||||
q = MethodReferenceTestVarArgs::xIvi;
|
||||
assertEquals(q.m(9,21), "xIvi:(9)21");
|
||||
assertEquals("xIvi:(9)21", q.m(9,21));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsiii() {
|
||||
Siii q;
|
||||
|
||||
q = MethodReferenceTestVarArgs::xvI;
|
||||
assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
|
||||
assertEquals("xvI:3-2-1-", q.m(3, 2, 1));
|
||||
|
||||
q = MethodReferenceTestVarArgs::xIvI;
|
||||
assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
|
||||
assertEquals("xIvI:88899-2-", q.m(888, 99, 2));
|
||||
|
||||
q = MethodReferenceTestVarArgs::xvi;
|
||||
assertEquals(q.m(900,80,7), "xvi:987");
|
||||
assertEquals("xvi:987", q.m(900,80,7));
|
||||
|
||||
q = MethodReferenceTestVarArgs::xIvi;
|
||||
assertEquals(q.m(333,27, 72), "xIvi:(333)99");
|
||||
assertEquals("xIvi:(333)99", q.m(333,27, 72));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsi() {
|
||||
Si q;
|
||||
|
||||
q = MethodReferenceTestVarArgs::xvI;
|
||||
assertEquals(q.m(3), "xvI:3-");
|
||||
assertEquals("xvI:3-", q.m(3));
|
||||
|
||||
q = MethodReferenceTestVarArgs::xIvI;
|
||||
assertEquals(q.m(888), "xIvI:888");
|
||||
assertEquals("xIvI:888", q.m(888));
|
||||
|
||||
q = MethodReferenceTestVarArgs::xvi;
|
||||
assertEquals(q.m(900), "xvi:900");
|
||||
assertEquals("xvi:900", q.m(900));
|
||||
|
||||
q = MethodReferenceTestVarArgs::xIvi;
|
||||
assertEquals(q.m(333), "xIvi:(333)0");
|
||||
assertEquals("xIvi:(333)0", q.m(333));
|
||||
}
|
||||
|
||||
// These should NOT be processed as var args
|
||||
|
||||
@Test
|
||||
public void testVarArgsaO() {
|
||||
SaO q;
|
||||
|
||||
q = MethodReferenceTestVarArgs::xvO;
|
||||
assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
|
||||
assertEquals("xvO:yo*there*dude*", q.m(new String[] { "yo", "there", "dude" }));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,13 +25,13 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestVarArgsExt
|
||||
* @run junit MethodReferenceTestVarArgsExt
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
@ -49,80 +49,85 @@ interface NXai { String m(int[] a); }
|
||||
|
||||
interface NXvi { String m(int... va); }
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestVarArgsExt {
|
||||
|
||||
// These should be processed as var args
|
||||
|
||||
@Test
|
||||
public void testVarArgsNXSuperclass() {
|
||||
NXII q;
|
||||
|
||||
q = (new Ext())::xvO;
|
||||
assertEquals(q.m(55,66), "xvO:55*66*");
|
||||
assertEquals("xvO:55*66*", q.m(55,66));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNXArray() {
|
||||
NXai q;
|
||||
|
||||
q = (new Ext())::xvO;
|
||||
assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
|
||||
assertEquals("xvO:[55,66,]*", q.m(new int[] { 55,66 } ));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNXII() {
|
||||
NXII q;
|
||||
|
||||
q = (new Ext())::xvI;
|
||||
assertEquals(q.m(33,7), "xvI:33-7-");
|
||||
assertEquals("xvI:33-7-", q.m(33,7));
|
||||
|
||||
q = (new Ext())::xIvI;
|
||||
assertEquals(q.m(50,40), "xIvI:5040-");
|
||||
assertEquals("xIvI:5040-", q.m(50,40));
|
||||
|
||||
q = (new Ext())::xvi;
|
||||
assertEquals(q.m(100,23), "xvi:123");
|
||||
assertEquals("xvi:123", q.m(100,23));
|
||||
|
||||
q = (new Ext())::xIvi;
|
||||
assertEquals(q.m(9,21), "xIvi:(9)21");
|
||||
assertEquals("xIvi:(9)21", q.m(9,21));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNXiii() {
|
||||
NXiii q;
|
||||
|
||||
q = (new Ext())::xvI;
|
||||
assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
|
||||
assertEquals("xvI:3-2-1-", q.m(3, 2, 1));
|
||||
|
||||
q = (new Ext())::xIvI;
|
||||
assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
|
||||
assertEquals("xIvI:88899-2-", q.m(888, 99, 2));
|
||||
|
||||
q = (new Ext())::xvi;
|
||||
assertEquals(q.m(900,80,7), "xvi:987");
|
||||
assertEquals("xvi:987", q.m(900,80,7));
|
||||
|
||||
q = (new Ext())::xIvi;
|
||||
assertEquals(q.m(333,27, 72), "xIvi:(333)99");
|
||||
assertEquals("xIvi:(333)99", q.m(333,27, 72));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNXi() {
|
||||
NXi q;
|
||||
|
||||
q = (new Ext())::xvI;
|
||||
assertEquals(q.m(3), "xvI:3-");
|
||||
assertEquals("xvI:3-", q.m(3));
|
||||
|
||||
q = (new Ext())::xIvI;
|
||||
assertEquals(q.m(888), "xIvI:888");
|
||||
assertEquals("xIvI:888", q.m(888));
|
||||
|
||||
q = (new Ext())::xvi;
|
||||
assertEquals(q.m(900), "xvi:900");
|
||||
assertEquals("xvi:900", q.m(900));
|
||||
|
||||
q = (new Ext())::xIvi;
|
||||
assertEquals(q.m(333), "xIvi:(333)0");
|
||||
assertEquals("xIvi:(333)0", q.m(333));
|
||||
}
|
||||
|
||||
// These should NOT be processed as var args
|
||||
|
||||
@Test
|
||||
public void testVarArgsNXaO() {
|
||||
NXaO q;
|
||||
|
||||
q = (new Ext())::xvO;
|
||||
assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
|
||||
assertEquals("xvO:yo*there*dude*", q.m(new String[] { "yo", "there", "dude" }));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,13 +25,13 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestVarArgsSuper
|
||||
* @run junit MethodReferenceTestVarArgsSuper
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
@ -95,7 +95,6 @@ class MethodReferenceTestVarArgsSuper_Sub {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestVarArgsSuper extends MethodReferenceTestVarArgsSuper_Sub {
|
||||
|
||||
interface SPRII { String m(Integer a, Integer b); }
|
||||
@ -132,74 +131,80 @@ public class MethodReferenceTestVarArgsSuper extends MethodReferenceTestVarArgsS
|
||||
|
||||
// These should be processed as var args
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRSuperclass() {
|
||||
SPRII q;
|
||||
|
||||
q = super::xvO;
|
||||
assertEquals(q.m(55,66), "xvO:55*66*");
|
||||
assertEquals("xvO:55*66*", q.m(55,66));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRArray() {
|
||||
SPRai q;
|
||||
|
||||
q = super::xvO;
|
||||
assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
|
||||
assertEquals("xvO:[55,66,]*", q.m(new int[] { 55,66 } ));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRII() {
|
||||
SPRII q;
|
||||
|
||||
q = super::xvI;
|
||||
assertEquals(q.m(33,7), "xvI:33-7-");
|
||||
assertEquals("xvI:33-7-", q.m(33,7));
|
||||
|
||||
q = super::xIvI;
|
||||
assertEquals(q.m(50,40), "xIvI:5040-");
|
||||
assertEquals("xIvI:5040-", q.m(50,40));
|
||||
|
||||
q = super::xvi;
|
||||
assertEquals(q.m(100,23), "xvi:123");
|
||||
assertEquals("xvi:123", q.m(100,23));
|
||||
|
||||
q = super::xIvi;
|
||||
assertEquals(q.m(9,21), "xIvi:(9)21");
|
||||
assertEquals("xIvi:(9)21", q.m(9,21));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRiii() {
|
||||
SPRiii q;
|
||||
|
||||
q = super::xvI;
|
||||
assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
|
||||
assertEquals("xvI:3-2-1-", q.m(3, 2, 1));
|
||||
|
||||
q = super::xIvI;
|
||||
assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
|
||||
assertEquals("xIvI:88899-2-", q.m(888, 99, 2));
|
||||
|
||||
q = super::xvi;
|
||||
assertEquals(q.m(900,80,7), "xvi:987");
|
||||
assertEquals("xvi:987", q.m(900,80,7));
|
||||
|
||||
q = super::xIvi;
|
||||
assertEquals(q.m(333,27, 72), "xIvi:(333)99");
|
||||
assertEquals("xIvi:(333)99", q.m(333,27, 72));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRi() {
|
||||
SPRi q;
|
||||
|
||||
q = super::xvI;
|
||||
assertEquals(q.m(3), "xvI:3-");
|
||||
assertEquals("xvI:3-", q.m(3));
|
||||
|
||||
q = super::xIvI;
|
||||
assertEquals(q.m(888), "xIvI:888");
|
||||
assertEquals("xIvI:888", q.m(888));
|
||||
|
||||
q = super::xvi;
|
||||
assertEquals(q.m(900), "xvi:900");
|
||||
assertEquals("xvi:900", q.m(900));
|
||||
|
||||
q = super::xIvi;
|
||||
assertEquals(q.m(333), "xIvi:(333)0");
|
||||
assertEquals("xIvi:(333)0", q.m(333));
|
||||
}
|
||||
|
||||
// These should NOT be processed as var args
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRaO() {
|
||||
SPRaO q;
|
||||
|
||||
q = super::xvO;
|
||||
assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
|
||||
assertEquals("xvO:yo*there*dude*", q.m(new String[] { "yo", "there", "dude" }));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,13 +25,13 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestVarArgsSuperDefault
|
||||
* @run junit MethodReferenceTestVarArgsSuperDefault
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
@ -95,7 +95,6 @@ interface MethodReferenceTestVarArgsSuperDefault_I {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestVarArgsSuperDefault implements MethodReferenceTestVarArgsSuperDefault_I {
|
||||
|
||||
interface DSPRII { String m(Integer a, Integer b); }
|
||||
@ -112,75 +111,81 @@ public class MethodReferenceTestVarArgsSuperDefault implements MethodReferenceTe
|
||||
|
||||
// These should be processed as var args
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRSuperclass() {
|
||||
DSPRII q;
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
|
||||
assertEquals(q.m(55,66), "xvO:55*66*");
|
||||
assertEquals("xvO:55*66*", q.m(55,66));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRArray() {
|
||||
DSPRai q;
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
|
||||
assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
|
||||
assertEquals("xvO:[55,66,]*", q.m(new int[] { 55,66 } ));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRII() {
|
||||
DSPRII q;
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
|
||||
assertEquals(q.m(33,7), "xvI:33-7-");
|
||||
assertEquals("xvI:33-7-", q.m(33,7));
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
|
||||
assertEquals(q.m(50,40), "xIvI:5040-");
|
||||
assertEquals("xIvI:5040-", q.m(50,40));
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
|
||||
assertEquals(q.m(100,23), "xvi:123");
|
||||
assertEquals("xvi:123", q.m(100,23));
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
|
||||
assertEquals(q.m(9,21), "xIvi:(9)21");
|
||||
assertEquals("xIvi:(9)21", q.m(9,21));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRiii() {
|
||||
DSPRiii q;
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
|
||||
assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
|
||||
assertEquals("xvI:3-2-1-", q.m(3, 2, 1));
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
|
||||
assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
|
||||
assertEquals("xIvI:88899-2-", q.m(888, 99, 2));
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
|
||||
assertEquals(q.m(900,80,7), "xvi:987");
|
||||
assertEquals("xvi:987", q.m(900,80,7));
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
|
||||
assertEquals(q.m(333,27, 72), "xIvi:(333)99");
|
||||
assertEquals("xIvi:(333)99", q.m(333,27, 72));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRi() {
|
||||
DSPRi q;
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
|
||||
assertEquals(q.m(3), "xvI:3-");
|
||||
assertEquals("xvI:3-", q.m(3));
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
|
||||
assertEquals(q.m(888), "xIvI:888");
|
||||
assertEquals("xIvI:888", q.m(888));
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
|
||||
assertEquals(q.m(900), "xvi:900");
|
||||
assertEquals("xvi:900", q.m(900));
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
|
||||
assertEquals(q.m(333), "xIvi:(333)0");
|
||||
assertEquals("xIvi:(333)0", q.m(333));
|
||||
}
|
||||
|
||||
// These should NOT be processed as var args
|
||||
|
||||
@Test
|
||||
public void testVarArgsSPRaO() {
|
||||
DSPRaO q;
|
||||
|
||||
q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
|
||||
assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
|
||||
assertEquals("xvO:yo*there*dude*", q.m(new String[] { "yo", "there", "dude" }));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,13 +25,13 @@
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng MethodReferenceTestVarArgsThis
|
||||
* @run junit MethodReferenceTestVarArgsThis
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Robert Field
|
||||
@ -49,7 +49,6 @@ interface Nsai { String m(int[] a); }
|
||||
|
||||
interface Nsvi { String m(int... va); }
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestVarArgsThis {
|
||||
|
||||
// These should be processed as var args
|
||||
@ -109,75 +108,81 @@ public class MethodReferenceTestVarArgsThis {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsSuperclass() {
|
||||
NsII q;
|
||||
|
||||
q = this::xvO;
|
||||
assertEquals(q.m(55,66), "xvO:55*66*");
|
||||
assertEquals("xvO:55*66*", q.m(55,66));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsArray() {
|
||||
Nsai q;
|
||||
|
||||
q = this::xvO;
|
||||
assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
|
||||
assertEquals("xvO:[55,66,]*", q.m(new int[] { 55,66 } ));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsII() {
|
||||
NsII q;
|
||||
|
||||
q = this::xvI;
|
||||
assertEquals(q.m(33,7), "xvI:33-7-");
|
||||
assertEquals("xvI:33-7-", q.m(33,7));
|
||||
|
||||
q = this::xIvI;
|
||||
assertEquals(q.m(50,40), "xIvI:5040-");
|
||||
assertEquals("xIvI:5040-", q.m(50,40));
|
||||
|
||||
q = this::xvi;
|
||||
assertEquals(q.m(100,23), "xvi:123");
|
||||
assertEquals("xvi:123", q.m(100,23));
|
||||
|
||||
q = this::xIvi;
|
||||
assertEquals(q.m(9,21), "xIvi:(9)21");
|
||||
assertEquals("xIvi:(9)21", q.m(9,21));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsiii() {
|
||||
Nsiii q;
|
||||
|
||||
q = this::xvI;
|
||||
assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
|
||||
assertEquals("xvI:3-2-1-", q.m(3, 2, 1));
|
||||
|
||||
q = this::xIvI;
|
||||
assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
|
||||
assertEquals("xIvI:88899-2-", q.m(888, 99, 2));
|
||||
|
||||
q = this::xvi;
|
||||
assertEquals(q.m(900,80,7), "xvi:987");
|
||||
assertEquals("xvi:987", q.m(900,80,7));
|
||||
|
||||
q = this::xIvi;
|
||||
assertEquals(q.m(333,27, 72), "xIvi:(333)99");
|
||||
assertEquals("xIvi:(333)99", q.m(333,27, 72));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsi() {
|
||||
Nsi q;
|
||||
|
||||
q = this::xvI;
|
||||
assertEquals(q.m(3), "xvI:3-");
|
||||
assertEquals("xvI:3-", q.m(3));
|
||||
|
||||
q = this::xIvI;
|
||||
assertEquals(q.m(888), "xIvI:888");
|
||||
assertEquals("xIvI:888", q.m(888));
|
||||
|
||||
q = this::xvi;
|
||||
assertEquals(q.m(900), "xvi:900");
|
||||
assertEquals("xvi:900", q.m(900));
|
||||
|
||||
q = this::xIvi;
|
||||
assertEquals(q.m(333), "xIvi:(333)0");
|
||||
assertEquals("xIvi:(333)0", q.m(333));
|
||||
}
|
||||
|
||||
// These should NOT be processed as var args
|
||||
|
||||
@Test
|
||||
public void testVarArgsNsaO() {
|
||||
NsaO q;
|
||||
|
||||
q = this::xvO;
|
||||
assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
|
||||
assertEquals("xvO:yo*there*dude*", q.m(new String[] { "yo", "there", "dude" }));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,16 +24,15 @@
|
||||
/**
|
||||
* @test
|
||||
* @summary test for VarHandle signature polymorphic methods
|
||||
* @run testng MethodReferenceTestVarHandle
|
||||
* @run junit MethodReferenceTestVarHandle
|
||||
*/
|
||||
|
||||
import java.lang.invoke.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Test
|
||||
public class MethodReferenceTestVarHandle {
|
||||
|
||||
interface Setter {
|
||||
@ -44,6 +43,7 @@ public class MethodReferenceTestVarHandle {
|
||||
int apply(int[] arr, int idx);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSet() throws Throwable {
|
||||
VarHandle vh = MethodHandles.arrayElementVarHandle(int[].class);
|
||||
|
||||
@ -54,6 +54,7 @@ public class MethodReferenceTestVarHandle {
|
||||
assertEquals(42, data[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet() throws Throwable {
|
||||
VarHandle vh = MethodHandles.arrayElementVarHandle(int[].class);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
TestNG.dirs = tools/javac/lambdaShapes
|
||||
JUnit.dirs = tools/javac/lambdaShapes
|
||||
|
||||
modules = \
|
||||
jdk.compiler/com.sun.tools.javac.util
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -42,12 +42,15 @@ import javax.tools.SimpleJavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import org.testng.annotations.AfterSuite;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import static org.testng.Assert.*;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedClass;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
@ParameterizedClass
|
||||
@MethodSource("caseGenerator")
|
||||
public class FDTest {
|
||||
|
||||
public enum TestKind {
|
||||
@ -63,7 +66,7 @@ public class FDTest {
|
||||
public static JavaCompiler comp;
|
||||
public static StandardJavaFileManager fm;
|
||||
|
||||
@BeforeSuite
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
// create default shared JavaCompiler - reused across multiple
|
||||
// compilations
|
||||
@ -72,7 +75,7 @@ public class FDTest {
|
||||
fm = comp.getStandardFileManager(null, null, null);
|
||||
}
|
||||
|
||||
@AfterSuite
|
||||
@AfterAll
|
||||
static void teardown() throws IOException {
|
||||
fm.close();
|
||||
}
|
||||
@ -87,14 +90,13 @@ public class FDTest {
|
||||
teardown();
|
||||
}
|
||||
|
||||
@Test(dataProvider = "fdCases")
|
||||
public void testOneCase(TestKind tk, Hierarchy hs)
|
||||
@Test
|
||||
public void testOneCase()
|
||||
throws Exception {
|
||||
FDTest.runTest(tk, hs, comp, fm);
|
||||
}
|
||||
|
||||
@DataProvider(name = "fdCases")
|
||||
public Object[][] caseGenerator() {
|
||||
public static Object[][] caseGenerator() {
|
||||
List<Pair<TestKind, Hierarchy>> cases = generateCases();
|
||||
Object[][] fdCases = new Object[cases.size()][];
|
||||
for (int i = 0; i < cases.size(); ++i) {
|
||||
@ -127,8 +129,6 @@ public class FDTest {
|
||||
DefenderTestSource source;
|
||||
DiagnosticChecker diagChecker;
|
||||
|
||||
public FDTest() {}
|
||||
|
||||
FDTest(TestKind tk, Hierarchy hs) {
|
||||
this.tk = tk;
|
||||
this.hs = hs;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,17 +23,16 @@
|
||||
|
||||
package org.openjdk.tests.separate;
|
||||
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
||||
import static org.openjdk.tests.separate.SourceModel.Class;
|
||||
import static org.openjdk.tests.separate.SourceModel.*;
|
||||
import static org.testng.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestHarness {
|
||||
|
||||
@ -69,7 +68,7 @@ public class TestHarness {
|
||||
verboseLocal.set(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
@AfterEach
|
||||
public void reset() {
|
||||
if (!this.verbose) {
|
||||
verboseLocal.set(Boolean.FALSE);
|
||||
@ -87,16 +86,6 @@ public class TestHarness {
|
||||
return flags.toArray(new Compiler.Flags[0]);
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void printError(ITestResult result) {
|
||||
if (result.getStatus() == ITestResult.FAILURE) {
|
||||
String clsName = result.getTestClass().getName();
|
||||
clsName = clsName.substring(clsName.lastIndexOf(".") + 1);
|
||||
System.out.println("Test " + clsName + "." +
|
||||
result.getName() + " FAILED");
|
||||
}
|
||||
}
|
||||
|
||||
private static final ConcreteMethod stdCM = ConcreteMethod.std("-1");
|
||||
private static final AbstractMethod stdAM =
|
||||
new AbstractMethod("int", stdMethodName);
|
||||
@ -193,7 +182,7 @@ public class TestHarness {
|
||||
Object res = m.invoke(null);
|
||||
assertNotNull(res);
|
||||
if (value != null) {
|
||||
assertEquals(res, value);
|
||||
assertEquals(value, res);
|
||||
}
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
fail("Unexpected exception thrown: " + e.getCause(), e.getCause());
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,6 @@ package org.openjdk.tests.vm;
|
||||
|
||||
import org.openjdk.tests.separate.Compiler;
|
||||
import org.openjdk.tests.separate.TestHarness;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.openjdk.tests.separate.SourceModel.AbstractMethod;
|
||||
import static org.openjdk.tests.separate.SourceModel.AccessFlag;
|
||||
@ -36,11 +35,11 @@ import static org.openjdk.tests.separate.SourceModel.Extends;
|
||||
import static org.openjdk.tests.separate.SourceModel.Interface;
|
||||
import static org.openjdk.tests.separate.SourceModel.MethodParameter;
|
||||
import static org.openjdk.tests.separate.SourceModel.TypeParameter;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Test(groups = "vm")
|
||||
public class DefaultMethodsTest extends TestHarness {
|
||||
public DefaultMethodsTest() {
|
||||
super(false, false);
|
||||
@ -51,6 +50,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
*
|
||||
* TEST: C c = new C(); c.m() == 22
|
||||
*/
|
||||
@Test
|
||||
public void testHarnessInvokeVirtual() {
|
||||
Class C = new Class("C", ConcreteMethod.std("22"));
|
||||
assertInvokeVirtualEquals(22, C);
|
||||
@ -62,6 +62,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
*
|
||||
* TEST: I i = new C(); i.m() == 33;
|
||||
*/
|
||||
@Test
|
||||
public void testHarnessInvokeInterface() {
|
||||
Interface I = new Interface("I", AbstractMethod.std());
|
||||
Class C = new Class("C", I, ConcreteMethod.std("33"));
|
||||
@ -73,6 +74,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
*
|
||||
* TEST: C c = new C(); c.m() throws NoSuchMethod
|
||||
*/
|
||||
@Test
|
||||
public void testHarnessThrows() {
|
||||
Class C = new Class("C");
|
||||
assertThrows(NoSuchMethodError.class, C);
|
||||
@ -85,6 +87,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() == 44;
|
||||
* TEST: I i = new C(); i.m() == 44;
|
||||
*/
|
||||
@Test
|
||||
public void testBasicDefault() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("44"));
|
||||
Class C = new Class("C", I);
|
||||
@ -102,6 +105,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() == 44;
|
||||
* TEST: I i = new C(); i.m() == 44;
|
||||
*/
|
||||
@Test
|
||||
public void testFarDefault() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("44"));
|
||||
Interface J = new Interface("J", I);
|
||||
@ -121,6 +125,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() == 44;
|
||||
* TEST: K k = new C(); k.m() == 44;
|
||||
*/
|
||||
@Test
|
||||
public void testOverrideAbstract() {
|
||||
Interface I = new Interface("I", AbstractMethod.std());
|
||||
Interface J = new Interface("J", I, DefaultMethod.std("44"));
|
||||
@ -138,6 +143,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() == 55;
|
||||
* TEST: I i = new C(); i.m() == 55;
|
||||
*/
|
||||
@Test
|
||||
public void testExisting() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("44"));
|
||||
Class C = new Class("C", I, ConcreteMethod.std("55"));
|
||||
@ -154,6 +160,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() == 99;
|
||||
* TEST: I i = new C(); i.m() == 99;
|
||||
*/
|
||||
@Test
|
||||
public void testInherited() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Class B = new Class("B", I);
|
||||
@ -171,6 +178,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: D d = new D(); d.m() == 11;
|
||||
* TEST: I i = new D(); i.m() == 11;
|
||||
*/
|
||||
@Test
|
||||
public void testExistingInherited() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Class C = new Class("C", ConcreteMethod.std("11"));
|
||||
@ -188,6 +196,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: D d = new D(); d.m() == 22;
|
||||
* TEST: I i = new D(); i.m() == 22;
|
||||
*/
|
||||
@Test
|
||||
public void testExistingInheritedOverride() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Class C = new Class("C", I, ConcreteMethod.std("11"));
|
||||
@ -207,6 +216,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: E e = new E(); e.m() == 22;
|
||||
* TEST: J j = new E(); j.m() == 22;
|
||||
*/
|
||||
@Test
|
||||
public void testExistingInheritedPlusDefault() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Interface J = new Interface("J", DefaultMethod.std("88"));
|
||||
@ -226,6 +236,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() == 77;
|
||||
* TEST: I i = new C(); i.m() == 77;
|
||||
*/
|
||||
@Test
|
||||
public void testInheritedWithConcrete() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Class B = new Class("B", I);
|
||||
@ -243,6 +254,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() == 66;
|
||||
* TEST: I i = new C(); i.m() == 66;
|
||||
*/
|
||||
@Test
|
||||
public void testInheritedWithConcreteAndImpl() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Class B = new Class("B", I);
|
||||
@ -259,6 +271,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
*
|
||||
* TEST: C c = new C(); c.m() throws ICCE
|
||||
*/
|
||||
@Test
|
||||
public void testConflict() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Interface J = new Interface("J", DefaultMethod.std("88"));
|
||||
@ -274,6 +287,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
*
|
||||
* TEST: C c = new C(); c.m() == 88
|
||||
*/
|
||||
@Test
|
||||
public void testAmbiguousReabstract() {
|
||||
Interface I = new Interface("I", AbstractMethod.std());
|
||||
Interface J = new Interface("J", DefaultMethod.std("88"));
|
||||
@ -293,6 +307,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: K k = new C(); k.m() == 99
|
||||
* TEST: I i = new C(); i.m() == 99
|
||||
*/
|
||||
@Test
|
||||
public void testDiamond() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Interface J = new Interface("J", I);
|
||||
@ -320,6 +335,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: L l = new C(); l.m() == 99
|
||||
* TEST: M m = new C(); m.m() == 99
|
||||
*/
|
||||
@Test
|
||||
public void testExpandedDiamond() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Interface J = new Interface("J", I);
|
||||
@ -343,6 +359,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
*
|
||||
* TEST: C c = new C(); c.m() throws AME
|
||||
*/
|
||||
@Test
|
||||
public void testReabstract() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Interface J = new Interface("J", I, AbstractMethod.std());
|
||||
@ -360,6 +377,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: J j = new C(); j.m() == 99;
|
||||
* TEST: I i = new C(); i.m() == 99;
|
||||
*/
|
||||
@Test
|
||||
public void testShadow() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("88"));
|
||||
Interface J = new Interface("J", I, DefaultMethod.std("99"));
|
||||
@ -379,6 +397,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: J j = new C(); j.m() == 99;
|
||||
* TEST: I i = new C(); i.m() == 99;
|
||||
*/
|
||||
@Test
|
||||
public void testDisqualified() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("88"));
|
||||
Interface J = new Interface("J", I, DefaultMethod.std("99"));
|
||||
@ -396,6 +415,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m("string") == 88;
|
||||
* TEST: I i = new C(); i.m("string") == 88;
|
||||
*/
|
||||
@Test
|
||||
public void testSelfFill() {
|
||||
// This test ensures that a concrete method overrides a default method
|
||||
// that matches at the language-level, but has a different method
|
||||
@ -426,6 +446,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
*
|
||||
* TEST: C.class.getMethod("m").invoke(new C()) == 99
|
||||
*/
|
||||
@Test
|
||||
public void testReflectCall() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
//workaround accessibility issue when loading C with DirectedClassLoader
|
||||
@ -468,7 +489,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
}
|
||||
assertNotNull(res);
|
||||
|
||||
assertEquals(res.intValue(), 99);
|
||||
assertEquals(99, res.intValue());
|
||||
|
||||
compiler.cleanup();
|
||||
}
|
||||
@ -485,6 +506,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: J<String,String> j = new C(); j.m("A","B","C") == 88;
|
||||
* TEST: K<String> k = new C(); k.m("A","B","C") == 88;
|
||||
*/
|
||||
@Test
|
||||
public void testBridges() {
|
||||
DefaultMethod dm = new DefaultMethod("int", stdMethodName, "return 99;",
|
||||
new MethodParameter("T", "t"), new MethodParameter("V", "v"),
|
||||
@ -538,6 +560,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() == 88;
|
||||
* TEST: I i = new C(); i.m() == 88;
|
||||
*/
|
||||
@Test
|
||||
public void testSuperBasic() {
|
||||
Interface J = new Interface("J", DefaultMethod.std("88"));
|
||||
Interface I = new Interface("I", J, new DefaultMethod(
|
||||
@ -559,6 +582,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() throws ICCE
|
||||
* TODO: add case for K k = new C(); k.m() throws ICCE
|
||||
*/
|
||||
@Test
|
||||
public void testSuperConflict() {
|
||||
Interface K = new Interface("K", DefaultMethod.std("99"));
|
||||
Interface L = new Interface("L", DefaultMethod.std("101"));
|
||||
@ -581,6 +605,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() == 99
|
||||
* TODO: add case for J j = new C(); j.m() == ???
|
||||
*/
|
||||
@Test
|
||||
public void testSuperDisqual() {
|
||||
Interface I = new Interface("I", DefaultMethod.std("99"));
|
||||
Interface J = new Interface("J", I, DefaultMethod.std("55"));
|
||||
@ -600,6 +625,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* TEST: C c = new C(); c.m() throws AME
|
||||
* TODO: add case for I i = new C(); i.m() throws AME
|
||||
*/
|
||||
@Test
|
||||
public void testSuperNull() {
|
||||
Interface J = new Interface("J", AbstractMethod.std());
|
||||
Interface I = new Interface("I", J, new DefaultMethod(
|
||||
@ -621,6 +647,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
*
|
||||
* TEST: I i = new C(); i.m("") == 88;
|
||||
*/
|
||||
@Test
|
||||
public void testSuperGeneric() {
|
||||
Interface J = new Interface("J", new TypeParameter("T"),
|
||||
new DefaultMethod("int", stdMethodName, "return 88;",
|
||||
@ -646,6 +673,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
*
|
||||
* TEST: C c = new C(); c.m("string") == 44
|
||||
*/
|
||||
@Test
|
||||
public void testSuperGenericDisqual() {
|
||||
MethodParameter t = new MethodParameter("T", "t");
|
||||
MethodParameter s = new MethodParameter("String", "s");
|
||||
@ -672,6 +700,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* class S { Object foo() { return (new D()).m(); } // link sig: ()LInteger;
|
||||
* TEST: S s = new S(); s.foo() == new Integer(99)
|
||||
*/
|
||||
@Test
|
||||
public void testCovarBridge() {
|
||||
Interface I = new Interface("I", new DefaultMethod(
|
||||
"Integer", "m", "return new Integer(88);"));
|
||||
@ -700,6 +729,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* class S { Object foo() { return (new D()).m(); } // link sig: ()LInteger;
|
||||
* TEST: S s = new S(); s.foo() == new Integer(88)
|
||||
*/
|
||||
@Test
|
||||
public void testNoCovarNoBridge() {
|
||||
Interface I = new Interface("I", new DefaultMethod(
|
||||
"Integer", "m", "return new Integer(88);"));
|
||||
@ -732,6 +762,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* It verifies that default method analysis occurs when mirandas have been
|
||||
* inherited and the supertypes don't have any overpass methods.
|
||||
*/
|
||||
@Test
|
||||
public void testNoNewMiranda() {
|
||||
Interface J = new Interface("J", AbstractMethod.std());
|
||||
Interface I = new Interface("I", J, DefaultMethod.std("99"));
|
||||
@ -755,6 +786,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
* Test that a erased-signature-matching method does not implement
|
||||
* non-language-level matching methods
|
||||
*/
|
||||
@Test
|
||||
public void testNonConcreteFill() {
|
||||
AbstractMethod ipm = new AbstractMethod("int", "m",
|
||||
new MethodParameter("T", "t"),
|
||||
@ -809,6 +841,7 @@ public class DefaultMethodsTest extends TestHarness {
|
||||
assertInvokeInterfaceEquals(99, C, I.with("String", "String", "String"), ipm, a, a, a);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStrictfpDefault() {
|
||||
try {
|
||||
java.lang.Class.forName("org.openjdk.tests.vm.StrictfpDefault");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,11 +28,8 @@ package org.openjdk.tests.vm;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.AfterSuite;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
||||
import org.openjdk.tests.separate.*;
|
||||
import org.openjdk.tests.separate.Compiler;
|
||||
@ -41,7 +38,10 @@ import org.openjdk.tests.shapegen.Hierarchy;
|
||||
import org.openjdk.tests.shapegen.HierarchyGenerator;
|
||||
import org.openjdk.tests.shapegen.ClassCase;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import static org.openjdk.tests.separate.SourceModel.*;
|
||||
import static org.openjdk.tests.separate.SourceModel.Class;
|
||||
import static org.openjdk.tests.separate.SourceModel.Method;
|
||||
@ -55,7 +55,6 @@ public class FDSeparateCompilationTest extends TestHarness {
|
||||
super(false, true);
|
||||
}
|
||||
|
||||
@DataProvider(name = "allShapes", parallel = true)
|
||||
public Object[][] hierarchyGenerator() {
|
||||
ArrayList<Object[]> allCases = new ArrayList<>();
|
||||
|
||||
@ -92,7 +91,9 @@ public class FDSeparateCompilationTest extends TestHarness {
|
||||
private static final ConcreteMethod canonicalMethod = new ConcreteMethod(
|
||||
"String", "m", "returns " + EMPTY + ";", AccessFlag.PUBLIC);
|
||||
|
||||
@Test(enabled = false, groups = "vm", dataProvider = "allShapes")
|
||||
@Disabled
|
||||
@ParameterizedTest
|
||||
@MethodSource("hierarchyGenerator")
|
||||
public void separateCompilationTest(Hierarchy hs) {
|
||||
ClassCase cc = hs.root;
|
||||
Type type = sourceTypeFrom(hs.root);
|
||||
@ -118,17 +119,8 @@ public class FDSeparateCompilationTest extends TestHarness {
|
||||
}
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void printCaseError(ITestResult result) {
|
||||
if (result.getStatus() == ITestResult.FAILURE) {
|
||||
Hierarchy hs = (Hierarchy)result.getParameters()[0];
|
||||
System.out.println("Separate compilation case " + hs);
|
||||
printCaseDetails(hs);
|
||||
}
|
||||
}
|
||||
|
||||
@AfterSuite
|
||||
public void cleanupCompilerCache() {
|
||||
@AfterAll
|
||||
public static void cleanupCompilerCache() {
|
||||
Compiler.purgeCache();
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8261847
|
||||
* @summary test the output of the toString method of records with a large number of components
|
||||
* @run testng BigRecordsToStringTest
|
||||
* @run junit BigRecordsToStringTest
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
@ -36,10 +36,9 @@ import java.lang.reflect.Parameter;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.testng.annotations.*;
|
||||
import static org.testng.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Test
|
||||
public class BigRecordsToStringTest {
|
||||
record BigInt(
|
||||
int i1,int i2,int i3,int i4,int i5,int i6,int i7,int i8,int i9,int i10,
|
||||
@ -164,6 +163,7 @@ public class BigRecordsToStringTest {
|
||||
"i111=111, i112=112, i113=113, i114=114, i115=115, i116=116, i117=117, i118=118, i119=119, i120=120, i121=121, i122=122, i123=123, " +
|
||||
"i124=124, i125=125, i126=126, i127=127]";
|
||||
|
||||
@Test
|
||||
public void testToStringOutput() {
|
||||
assertTrue(bigInt.toString().equals(BIG_INT_TO_STRING_OUTPUT));
|
||||
assertTrue(bigLong.toString().equals(BIG_LONG_TO_STRING_OUTPUT));
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8246774
|
||||
* @summary test several assertions on record classes members
|
||||
* @run testng RecordMemberTests
|
||||
* @run junit RecordMemberTests
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
@ -36,10 +36,9 @@ import java.lang.reflect.Parameter;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.testng.annotations.*;
|
||||
import static org.testng.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Test
|
||||
public class RecordMemberTests {
|
||||
public record R1(int i, int j) {}
|
||||
|
||||
@ -63,43 +62,47 @@ public class RecordMemberTests {
|
||||
R3 r3 = new R3(1, 2);
|
||||
R4 r4 = new R4(1, 2);
|
||||
|
||||
@Test
|
||||
public void testConstruction() {
|
||||
for (int i : new int[] { r1.i, r2.i, r3.i,
|
||||
r1.i(), r2.i(), r3.i() })
|
||||
assertEquals(i, 1);
|
||||
assertEquals(1, i);
|
||||
|
||||
for (int j : new int[] { r1.j, r2.j, r3.j,
|
||||
r1.j(), r2.j(), r3.j() })
|
||||
assertEquals(j, 2);
|
||||
assertEquals(2, j);
|
||||
|
||||
assertEquals(r4.i, 0);
|
||||
assertEquals(r4.j, 0);
|
||||
assertEquals(0, r4.i);
|
||||
assertEquals(0, r4.j);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorParameterNames() throws ReflectiveOperationException {
|
||||
for (Class cl : List.of(R1.class, R2.class, R3.class, R4.class)) {
|
||||
Constructor c = cl.getConstructor(int.class, int.class);
|
||||
assertNotNull(c);
|
||||
Parameter[] parameters = c.getParameters();
|
||||
assertEquals(parameters.length, 2);
|
||||
assertEquals(parameters[0].getName(), "i");
|
||||
assertEquals(parameters[1].getName(), "j");
|
||||
assertEquals(2, parameters.length);
|
||||
assertEquals("i", parameters[0].getName());
|
||||
assertEquals("j", parameters[1].getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuperclass() {
|
||||
assertEquals(R1.class.getSuperclass(), Record.class);
|
||||
assertEquals(Record.class, R1.class.getSuperclass());
|
||||
// class is final
|
||||
assertTrue((R1.class.getModifiers() & Modifier.FINAL) != 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMandatedMembersPresent() throws ReflectiveOperationException {
|
||||
// fields are present, of the right type, final and private
|
||||
assertEquals(R1.class.getDeclaredFields().length, 2);
|
||||
assertEquals(2, R1.class.getDeclaredFields().length);
|
||||
for (String s : List.of("i", "j")) {
|
||||
Field iField = R1.class.getDeclaredField(s);
|
||||
assertEquals(iField.getType(), int.class);
|
||||
assertEquals((iField.getModifiers() & Modifier.STATIC), 0);
|
||||
assertEquals(int.class, iField.getType());
|
||||
assertEquals(0, (iField.getModifiers() & Modifier.STATIC));
|
||||
assertTrue((iField.getModifiers() & Modifier.PRIVATE) != 0);
|
||||
assertTrue((iField.getModifiers() & Modifier.FINAL) != 0);
|
||||
}
|
||||
@ -107,15 +110,15 @@ public class RecordMemberTests {
|
||||
// methods are present, of the right descriptor, and public/instance/concrete
|
||||
for (String s : List.of("i", "j")) {
|
||||
Method iMethod = R1.class.getDeclaredMethod(s);
|
||||
assertEquals(iMethod.getReturnType(), int.class);
|
||||
assertEquals(iMethod.getParameterCount(), 0);
|
||||
assertEquals((iMethod.getModifiers() & (Modifier.PRIVATE | Modifier.PROTECTED | Modifier.STATIC | Modifier.ABSTRACT)), 0);
|
||||
assertEquals(int.class, iMethod.getReturnType());
|
||||
assertEquals(0, iMethod.getParameterCount());
|
||||
assertEquals(0, (iMethod.getModifiers() & (Modifier.PRIVATE | Modifier.PROTECTED | Modifier.STATIC | Modifier.ABSTRACT)));
|
||||
}
|
||||
|
||||
Constructor c = R1.class.getConstructor(int.class, int.class);
|
||||
R1 r1 = (R1) c.newInstance(1, 2);
|
||||
assertEquals(r1.i(), 1);
|
||||
assertEquals(r1.j(), 2);
|
||||
assertEquals(1, r1.i());
|
||||
assertEquals(2, r1.j());
|
||||
}
|
||||
|
||||
record OrdinaryMembers(int x) {
|
||||
@ -124,21 +127,23 @@ public class RecordMemberTests {
|
||||
public String sf () { return "instance"; }
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrdinaryMembers() {
|
||||
OrdinaryMembers.ss = "foo";
|
||||
assertEquals(OrdinaryMembers.ssf(), "foo");
|
||||
assertEquals("foo", OrdinaryMembers.ssf());
|
||||
OrdinaryMembers o = new OrdinaryMembers(3);
|
||||
assertEquals(o.sf(), "instance");
|
||||
assertEquals("instance", o.sf());
|
||||
}
|
||||
|
||||
class LocalRecordHelper {
|
||||
Class<?> m(int x) {
|
||||
record R (int x) { }
|
||||
assertEquals(new R(x).x(), x);
|
||||
assertEquals(x, new R(x).x());
|
||||
return R.class;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalRecordsStatic() {
|
||||
Class<?> c = new LocalRecordHelper().m(3);
|
||||
String message = c.toGenericString();
|
||||
@ -181,6 +186,7 @@ public class RecordMemberTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedRecordsStatic() {
|
||||
NestedRecordHelper n = new NestedRecordHelper();
|
||||
for (Class<?> c : List.of(NestedRecordHelper.R1.class,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,16 +27,15 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Parameter;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8246774
|
||||
* @summary test for varargs record components
|
||||
* @run testng VarargsRecordsTest
|
||||
* @run junit VarargsRecordsTest
|
||||
*/
|
||||
@Test
|
||||
public class VarargsRecordsTest {
|
||||
public record RI(int... xs) { }
|
||||
public record RII(int x, int... xs) { }
|
||||
@ -49,49 +48,52 @@ public class VarargsRecordsTest {
|
||||
RII r5 = new RII(1, 2);
|
||||
RII r6 = new RII(1, 2, 3);
|
||||
|
||||
@Test
|
||||
public void assertVarargsInstances() {
|
||||
assertEquals(r1.xs.length, 0);
|
||||
assertEquals(r2.xs.length, 1);
|
||||
assertEquals(r3.xs.length, 2);
|
||||
assertEquals(r4.xs.length, 0);
|
||||
assertEquals(r5.xs.length, 1);
|
||||
assertEquals(r6.xs.length, 2);
|
||||
assertEquals(0, r1.xs.length);
|
||||
assertEquals(1, r2.xs.length);
|
||||
assertEquals(2, r3.xs.length);
|
||||
assertEquals(0, r4.xs.length);
|
||||
assertEquals(1, r5.xs.length);
|
||||
assertEquals(2, r6.xs.length);
|
||||
|
||||
assertEquals(r2.xs[0], 1);
|
||||
assertEquals(r3.xs[0], 1);
|
||||
assertEquals(r3.xs[1], 2);
|
||||
assertEquals(1, r2.xs[0]);
|
||||
assertEquals(1, r3.xs[0]);
|
||||
assertEquals(2, r3.xs[1]);
|
||||
|
||||
assertEquals(r5.xs[0], 2);
|
||||
assertEquals(r6.xs[0], 2);
|
||||
assertEquals(r6.xs[1], 3);
|
||||
assertEquals(2, r5.xs[0]);
|
||||
assertEquals(2, r6.xs[0]);
|
||||
assertEquals(3, r6.xs[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMembers() throws ReflectiveOperationException {
|
||||
Constructor c = RI.class.getConstructor(int[].class);
|
||||
assertNotNull(c);
|
||||
assertTrue(c.isVarArgs());
|
||||
Parameter[] parameters = c.getParameters();
|
||||
assertEquals(parameters.length, 1);
|
||||
assertEquals(parameters[0].getName(), "xs");
|
||||
assertEquals(1, parameters.length);
|
||||
assertEquals("xs", parameters[0].getName());
|
||||
|
||||
RI ri = (RI) c.newInstance(new int[]{1, 2});
|
||||
assertEquals(ri.xs()[0], 1);
|
||||
assertEquals(ri.xs()[1], 2);
|
||||
assertEquals(1, ri.xs()[0]);
|
||||
assertEquals(2, ri.xs()[1]);
|
||||
|
||||
Field xsField = RI.class.getDeclaredField("xs");
|
||||
assertEquals(xsField.getType(), int[].class);
|
||||
assertEquals((xsField.getModifiers() & Modifier.STATIC), 0);
|
||||
assertEquals(int[].class, xsField.getType());
|
||||
assertEquals(0, (xsField.getModifiers() & Modifier.STATIC));
|
||||
assertTrue((xsField.getModifiers() & Modifier.PRIVATE) != 0);
|
||||
assertTrue((xsField.getModifiers() & Modifier.FINAL) != 0);
|
||||
assertEquals(((int[]) xsField.get(ri))[0], 1);
|
||||
assertEquals(1, ((int[]) xsField.get(ri))[0]);
|
||||
|
||||
Method xsMethod = RI.class.getDeclaredMethod("xs");
|
||||
assertEquals(xsMethod.getReturnType(), int[].class);
|
||||
assertEquals(xsMethod.getParameterCount(), 0);
|
||||
assertEquals((xsMethod.getModifiers() & (Modifier.PRIVATE | Modifier.PROTECTED | Modifier.STATIC | Modifier.ABSTRACT)), 0);
|
||||
assertEquals(((int[]) xsMethod.invoke(ri))[0], 1);
|
||||
assertEquals(int[].class, xsMethod.getReturnType());
|
||||
assertEquals(0, xsMethod.getParameterCount());
|
||||
assertEquals(0, (xsMethod.getModifiers() & (Modifier.PRIVATE | Modifier.PROTECTED | Modifier.STATIC | Modifier.ABSTRACT)));
|
||||
assertEquals(1, ((int[]) xsMethod.invoke(ri))[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotVarargs() throws ReflectiveOperationException {
|
||||
Constructor c = RX.class.getConstructor(int[].class);
|
||||
assertFalse(c.isVarArgs());
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,16 +29,15 @@
|
||||
* @modules jdk.compiler/com.sun.tools.javac.file
|
||||
* jdk.compiler/com.sun.tools.javac.tree
|
||||
* jdk.compiler/com.sun.tools.javac.util
|
||||
* @run testng T8024415
|
||||
* @run junit T8024415
|
||||
*/
|
||||
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.tree.JCTree;
|
||||
@ -47,13 +46,13 @@ import com.sun.tools.javac.tree.Pretty;
|
||||
import com.sun.tools.javac.tree.TreeMaker;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.Names;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/*
|
||||
* Test verifies that the precedence rules of conditional expressions
|
||||
* (JCConditional) are correct.
|
||||
*/
|
||||
@Test
|
||||
public class T8024415 {
|
||||
|
||||
TreeMaker maker;
|
||||
@ -72,6 +71,7 @@ public class T8024415 {
|
||||
// JLS 15.25: The conditional operator is syntactically right-associative
|
||||
// (it groups right-to-left). Thus, a?b:c?d:e?f:g means the same as
|
||||
// a?b:(c?d:(e?f:g)).
|
||||
@Test
|
||||
public void testAssociativity() throws IOException {
|
||||
|
||||
JCTree left = maker.Conditional(maker.Conditional(x, x, x), x, x);
|
||||
@ -80,8 +80,8 @@ public class T8024415 {
|
||||
String prettyLeft = prettyPrint(left);
|
||||
String prettyRight = prettyPrint(right);
|
||||
|
||||
assertEquals(prettyLeft.replaceAll("\\s", ""), "(x?x:x)?x:x");
|
||||
assertEquals(prettyRight.replaceAll("\\s", ""), "x?x:x?x:x");
|
||||
assertEquals("(x?x:x)?x:x", prettyLeft.replaceAll("\\s", ""));
|
||||
assertEquals("x?x:x?x:x", prettyRight.replaceAll("\\s", ""));
|
||||
|
||||
}
|
||||
|
||||
@ -89,6 +89,7 @@ public class T8024415 {
|
||||
// The true-part of a conditional expression is surrounded by ? and :
|
||||
// and can thus always be parsed unambiguously without surrounding
|
||||
// parentheses.
|
||||
@Test
|
||||
public void testPrecedence() throws IOException {
|
||||
|
||||
JCTree left = maker.Conditional(maker.Assign(x, x), x, x);
|
||||
@ -99,9 +100,9 @@ public class T8024415 {
|
||||
String prettyMiddle = prettyPrint(middle);
|
||||
String prettyRight = prettyPrint(right);
|
||||
|
||||
assertEquals(prettyLeft.replaceAll("\\s", ""), "(x=x)?x:x");
|
||||
assertEquals(prettyMiddle.replaceAll("\\s", ""), "x?x=x:x");
|
||||
assertEquals(prettyRight.replaceAll("\\s", ""), "x?x:(x=x)");
|
||||
assertEquals("(x=x)?x:x", prettyLeft.replaceAll("\\s", ""));
|
||||
assertEquals("x?x=x:x", prettyMiddle.replaceAll("\\s", ""));
|
||||
assertEquals("x?x:(x=x)", prettyRight.replaceAll("\\s", ""));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,14 +24,14 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 8209022
|
||||
* @run testng TypeVariableCastTest
|
||||
* @run junit TypeVariableCastTest
|
||||
* @summary Missing checkcast when casting to type parameter bounded by intersection type
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import org.testng.annotations.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Test
|
||||
public class TypeVariableCastTest {
|
||||
static <T extends List<?> & Runnable> void f() {
|
||||
Runnable r = (T) new ArrayList<>();
|
||||
@ -41,13 +41,17 @@ public class TypeVariableCastTest {
|
||||
Runnable r = (T) new ArrayList<>();
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ClassCastException.class)
|
||||
static void testMethodF() {
|
||||
f();
|
||||
@Test
|
||||
void testMethodF() {
|
||||
Assertions.assertThrows(ClassCastException.class, () -> {
|
||||
f();
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ClassCastException.class)
|
||||
static void testMethodG() {
|
||||
g();
|
||||
@Test
|
||||
void testMethodG() {
|
||||
Assertions.assertThrows(ClassCastException.class, () -> {
|
||||
g();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user