1 package runtime.valhalla.valuetypes; 2 3 import jdk.test.lib.Asserts; 4 5 /* 6 * @test ValueTypeCreation 7 * @summary Value Type creation test 8 * @library /test/lib 9 * @compile -XDenableValueTypes ValueTypeCreation.java Point.java Long8Value.java Person.java 10 * @run main/othervm -noverify -Xint -XX:+EnableValhalla runtime.valhalla.valuetypes.ValueTypeCreation 11 * @run main/othervm -noverify -Xcomp -XX:+EnableValhalla runtime.valhalla.valuetypes.ValueTypeCreation 12 */ 13 public class ValueTypeCreation { 14 public static void main(String[] args) { 15 ValueTypeCreation valueTypeCreation = new ValueTypeCreation(); 16 valueTypeCreation.run(); 17 } 18 19 public void run() { 20 testPoint(); 21 testLong8(); 22 // Embedded oops not yet supported 23 //testPerson(); 24 } 25 26 void testPoint() { 27 Point p = Point.createPoint(1, 2); 28 Asserts.assertEquals(p.x, 1, "invalid point x value"); 29 Asserts.assertEquals(p.y, 2, "invalid point y value"); 30 Point p2 = clonePoint(p); 31 Asserts.assertEquals(p2.x, 1, "invalid point clone x value"); 32 Asserts.assertEquals(p2.y, 2, "invalid point clone y value"); 33 } 34 35 static Point clonePoint(Point p) { 36 Point q = p; 37 return q; 38 } 39 40 void testLong8() { 41 Long8Value long8Value = Long8Value.create(1, 2, 3, 4, 5, 6, 7, 8); 42 Asserts.assertEquals(long8Value.getLongField1(), 1L, "Field 1 incorrect"); 43 Asserts.assertEquals(long8Value.getLongField8(), 8L, "Field 8 incorrect"); 44 Long8Value.check(long8Value, 1, 2, 3, 4, 5, 6, 7, 8); 45 } 46 47 void testPerson() { 48 Person person = Person.create(1, "John", "Smith"); 49 Asserts.assertEquals(person.getId(), 1L, "Id field incorrect"); 50 Asserts.assertEquals(person.getFirstName(), "John", "First name incorrect"); 51 Asserts.assertEquals(person.getLastName(), "Smith", "Last name incorrect"); 52 } 53 }