Skip to content

Commit

Permalink
8243623: [lworld] Syntax and other mechanical changes in langtools te…
Browse files Browse the repository at this point in the history
…sts for JDK-8237072
  • Loading branch information
sadayapalam committed Apr 27, 2020
1 parent 21a4dae commit b9ef3d7
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/*
* @test
* @bug 8222634
* @summary Check array creation with V and V?
* @summary Check array creation with V and V.ref
* @modules jdk.compiler/com.sun.tools.javac.util jdk.jdeps/com.sun.tools.javap
* @compile ArrayCreationWithQuestion.java
* @run main/othervm -Xverify:none ArrayCreationWithQuestion
Expand All @@ -38,8 +38,8 @@
public class ArrayCreationWithQuestion {

static inline class VT {
VT?[] a1 = new VT?[42];
VT?[] a2 = new VT?[42];
VT.ref[] a1 = new VT.ref[42];
VT.ref[] a2 = new VT.ref[42];
VT[] a3 = new VT[42];
VT[] a4 = new VT[42];
}
Expand All @@ -53,10 +53,10 @@ void run() {
Paths.get(System.getProperty("test.classes"),
"ArrayCreationWithQuestion$VT.class").toString() };
runCheck(params, new String [] {
" 6: anewarray #3 // class ArrayCreationWithQuestion$VT",
" 17: anewarray #3 // class ArrayCreationWithQuestion$VT",
" 28: anewarray #11 // class \"QArrayCreationWithQuestion$VT;\"",
" 39: anewarray #11 // class \"QArrayCreationWithQuestion$VT;\"",
" 6: anewarray #3 // class ArrayCreationWithQuestion$VT$ref",
" 17: anewarray #3 // class ArrayCreationWithQuestion$VT$ref",
" 28: anewarray #12 // class \"QArrayCreationWithQuestion$VT;\"",
" 39: anewarray #12 // class \"QArrayCreationWithQuestion$VT;\"",
});

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public inline class ArrayRelationsTest {
int x = 42;

public static void main(String [] args) {
ArrayRelationsTest? [] la = new ArrayRelationsTest?[10];
ArrayRelationsTest.ref [] la = new ArrayRelationsTest.ref[10];
ArrayRelationsTest [] qa = new ArrayRelationsTest[10];
boolean cce = false;
try {
Expand All @@ -47,7 +47,7 @@ public static void main(String [] args) {
throw new AssertionError("Missing CCE");
}
la = qa;
ArrayRelationsTest?[] la2 = qa;
ArrayRelationsTest.ref[] la2 = qa;
ArrayRelationsTest [] qa2 = (ArrayRelationsTest []) la2;
boolean npe = false;
try {
Expand All @@ -71,7 +71,7 @@ public static void main(String [] args) {

// round trip;
Object o = oa = la = qa;
qa = (ArrayRelationsTest[]) (la = (ArrayRelationsTest? []) (oa = (Object []) o));
qa = (ArrayRelationsTest[]) (la = (ArrayRelationsTest.ref []) (oa = (Object []) o));
qa [0] = new ArrayRelationsTest();

npe = false;
Expand All @@ -84,7 +84,7 @@ public static void main(String [] args) {
throw new AssertionError("Missing NPE");
}

la = new ArrayRelationsTest? [10];
la = new ArrayRelationsTest.ref [10];

cce = false;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class X {
static final MyValue1 vField = new MyValue1();

inline class MyValue2 {
final MyValue1? vBoxField;
final MyValue1.ref vBoxField;

public MyValue2() {
vBoxField = new MyValue1();
Expand All @@ -56,7 +56,7 @@ inline class MyValue3 {
class Y {

inline class MyValue4 {
final MyValue3? vBoxField = null;
final MyValue3.ref vBoxField = null;

public int test() {
return vBoxField.hash();
Expand All @@ -67,12 +67,12 @@ public static void main(String[] args) { }
}

interface MyInterface {
public void test(MyValue5? vt);
public void test(MyValue5.ref vt);
}

inline class MyValue5 implements MyInterface {
final int x = 0;

@Override
public void test(MyValue5? vt) { }
public void test(MyValue5.ref vt) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
*/

public class BogusIncompatibility {
MyValue? field = MyValue.create();
MyValue? field2 = MyValue.create();
MyValue.ref field = MyValue.create();
MyValue.ref field2 = MyValue.create();
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public class BoxValCastTest {

static inline class VT {
int f = 0;
static final VT? vtbox = (VT?) new VT(); // no binary cast
static final VT.ref vtbox = (VT.ref) new VT(); // no binary cast
static VT vt = (VT) vtbox; // binary cast
static VT? box = vt; // no binary cast
static VT? box2 = (VT) box; // no binary cast
static VT? box3 = id(new VT()); // no binary cast + binary cast
static VT.ref box = vt; // no binary cast
static VT.ref box2 = (VT) box; // binary cast
static VT.ref box3 = id(new VT()); // no binary cast + no binary cast

static VT id(VT? vtb) {
static VT id(VT.ref vtb) {
return (VT) vtb; // binary
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ public static void main(String[] args) throws Exception {
throw new Exception("Bad descriptor for field1");
} else if (fld.getName(cls.constant_pool).equals("f2")) {
fCount++;
if (!fld.descriptor.getValue(cls.constant_pool).equals("LCheckFieldDescriptors;"))
if (!fld.descriptor.getValue(cls.constant_pool).equals("LCheckFieldDescriptors$ref;"))
throw new Exception("Bad descriptor for field2");
} else if (fld.getName(cls.constant_pool).equals("f3")) {
fCount++;
if (!fld.descriptor.getValue(cls.constant_pool).equals("LCheckFieldDescriptors;"))
if (!fld.descriptor.getValue(cls.constant_pool).equals("LCheckFieldDescriptors$ref;"))
throw new Exception("Bad descriptor for field3");
} else if (fld.getName(cls.constant_pool).equals("a1")) {
fCount++;
if (!fld.descriptor.getValue(cls.constant_pool).equals("[LCheckFieldDescriptors;"))
if (!fld.descriptor.getValue(cls.constant_pool).equals("[LCheckFieldDescriptors$ref;"))
throw new Exception("Bad descriptor for field4");
} else if (fld.getName(cls.constant_pool).equals("a2")) {
fCount++;
if (!fld.descriptor.getValue(cls.constant_pool).equals("[LCheckFieldDescriptors;"))
if (!fld.descriptor.getValue(cls.constant_pool).equals("[LCheckFieldDescriptors$ref;"))
throw new Exception("Bad descriptor for field5");
} else if (fld.getName(cls.constant_pool).equals("a3")) {
fCount++;
Expand All @@ -83,11 +83,11 @@ public static void main(String[] args) throws Exception {
class CheckFieldDescriptorsAuxilliary {

CheckFieldDescriptors f1;
CheckFieldDescriptors? f2;
CheckFieldDescriptors? f3;
CheckFieldDescriptors.ref f2;
CheckFieldDescriptors.ref f3;

CheckFieldDescriptors?[] a1 = new CheckFieldDescriptors?[42];
CheckFieldDescriptors?[] a2 = new CheckFieldDescriptors?[42];
CheckFieldDescriptors.ref[] a1 = new CheckFieldDescriptors.ref[42];
CheckFieldDescriptors.ref[] a2 = new CheckFieldDescriptors.ref[42];
CheckFieldDescriptors[] a3 = new CheckFieldDescriptors[42];
CheckFieldDescriptors[] a4 = new CheckFieldDescriptors[42];
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@
/*
* @test
* @bug 8222634
* @summary Check null assignment/comparisons against VT?
* @summary Check null assignment/comparisons against VT.ref
* @compile CheckNullWithQuestion.java
*/

inline class CheckNullWithQuestion {
final int x = 0;
void foo(boolean flag) {
CheckNullWithQuestion? vBox = null;
CheckNullWithQuestion.ref vBox = null;
if (vBox != null) {}
CheckNullWithQuestion? val = flag ? vBox : null;
CheckNullWithQuestion.ref val = flag ? vBox : null;
}
}

class X {
void foo(boolean flag) {
CheckNullWithQuestion? vBox = null;
CheckNullWithQuestion.ref vBox = null;
if (vBox != null) {}
CheckNullWithQuestion? val = flag ? vBox : null;
CheckNullWithQuestion.ref val = flag ? vBox : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
import java.util.List;

inline class X {
List<X?> ls = new Object();
X?[] xa = new Object?[10];
List<X.ref> ls = new Object();
X.ref[] xa = new Object[10];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CheckQuestionInMessages.java:12:19: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Object, java.util.List<X?>)
CheckQuestionInMessages.java:13:15: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Object[], X?[])
CheckQuestionInMessages.java:12:22: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Object, java.util.List<X$ref>)
CheckQuestionInMessages.java:13:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Object[], X$ref[])
2 errors
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Point(int x, int y) {
}


static void testCastingFromBoxToVal(Point? p) {
static void testCastingFromBoxToVal(Point.ref p) {
boolean npe = false;
try {
Point pv = (Point) p;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

class CompilesFine {

static Point? nfspQm;
static Point.ref nfspQm;

public static void main(String[] args) {
nfspQm = null;
Expand All @@ -51,7 +51,7 @@ inline final class Point {
class CompilesJustFine {

static final inline class Value {
final PointBug2? nfpQm;
final PointBug2.ref nfpQm;

private Value() {
nfpQm = PointBug2.createPoint(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ public int orElse(int other) {
public final class ExplicitLambdaWithNullableTypes {

public static void main(String[] args) {
List<OptionalInt?> opts = new ArrayList<>();
List<OptionalInt.ref> opts = new ArrayList<>();
for (int i=0; i < 5; i++) {
opts.add(OptionalInt.of(i));
opts.add(OptionalInt.empty());
opts.add(null);
}

Integer total = opts.stream()
.map((OptionalInt? o) -> {
.map((OptionalInt.ref o) -> {
if (o == null)
return 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ public int orElse(int other) {
public final class ExplicitLambdaWithNullableTypes2 {

public static void main(String[] args) {
List<OptionalInt?> opts = new ArrayList<>();
List<OptionalInt.ref> opts = new ArrayList<>();
for (int i=0; i < 5; i++) {
opts.add(OptionalInt.of(i));
opts.add(OptionalInt.empty());
opts.add(null);
}

Stream<OptionalInt?> soi = opts.stream();
ToIntFunction<OptionalInt?> f = (OptionalInt? o) -> {
Stream<OptionalInt.ref> soi = opts.stream();
ToIntFunction<OptionalInt.ref> f = (OptionalInt.ref o) -> {
if (o == null) return 0;
OptionalInt op = (OptionalInt)o;
return op.orElse(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ public int orElse(int other) {
public final class ExplicitLambdaWithNullableTypes3 {

public static void main(String[] args) {
List<OptionalInt?> opts = new ArrayList<>();
List<OptionalInt.ref> opts = new ArrayList<>();
for (int i=0; i < 5; i++) {
opts.add(OptionalInt.of(i));
opts.add(OptionalInt.empty());
opts.add(null);
}

Stream<OptionalInt?> soi = opts.stream();
ToIntFunction<OptionalInt?> f = o -> {
Stream<OptionalInt.ref> soi = opts.stream();
ToIntFunction<OptionalInt.ref> f = o -> {
if (o == null) return 0;
OptionalInt op = (OptionalInt)o;
return op.orElse(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ inline class InlineType<E> {

interface Sample<K extends Comparable<? super K>, V> {
void doesCompile(InlineType<? extends K> argument);
void doesNotCompile(java.util.Map.Entry<InlineType<? extends K>?, ? extends V> arg);
void doesNotCompile(java.util.Map.Entry<InlineType.ref<? extends K>, ? extends V> arg);
}

private E element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ public final class GenericsAndValues5 {

public static void main(String[] args) {

List<Optional<Integer>?> opts = new ArrayList<>();
List<Optional.ref<Integer>> opts = new ArrayList<>();
for (int i=0; i < 6; i++) {
Optional<Integer> oi = Optional.of(i);
opts.add((Optional<Integer>?)oi);
opts.add((Optional.ref<Integer>)oi);
Optional<Integer> oe = Optional.empty();
opts.add((Optional<Integer>?)oe);
opts.add((Optional.ref<Integer>)oe);
}

Integer total = opts.stream()
.map((Optional<Integer>? o) -> {
.map((Optional.ref<Integer> o) -> {
Optional<Integer> op = (Optional<Integer>)o;
return op.orElse(0);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public static Inner create(int v) {
}

// Uncomment the next line, and Inner ceases to be a value type
public static final Inner? ZERO = Inner.create(0);
public static final Inner? ZERO2 = Inner.create(0);
public static final Inner.ref ZERO = Inner.create(0);
public static final Inner.ref ZERO2 = Inner.create(0);
}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/*
* @test
* @bug 8222974
* @summary javac doesn't like "?" syntax in instanceof type expression
* @summary javac doesn't like "?" syntax in instanceof type expression (syntax is dead)
* @compile InstanceofProjectionArray.java
*/

Expand All @@ -37,11 +37,11 @@ public inline class InstanceofProjectionArray {
public InstanceofProjectionArray() { this.value = 0; }

public static void main(String[] args) throws Throwable {
InstanceofProjectionArray?[] foos = new InstanceofProjectionArray?[1];
if (!(foos instanceof InstanceofProjectionArray?[])) {
InstanceofProjectionArray.ref[] foos = new InstanceofProjectionArray.ref[1];
if (!(foos instanceof InstanceofProjectionArray.ref[])) {
throw new RuntimeException("Thought that should work");
}
InstanceofProjectionArray?[][] xx = null;
if (xx instanceof InstanceofProjectionArray?[][]) {}
InstanceofProjectionArray.ref[][] xx = null;
if (xx instanceof InstanceofProjectionArray.ref[][]) {}
}
}
Loading

0 comments on commit b9ef3d7

Please sign in to comment.