< prev index next > test/jdk/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template
Print this page
/*
- * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2024, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+ #warn
+
/*
* @test
+ #if[Value]
+ * @enablePreview
+ * @modules java.base/jdk.internal.vm.annotation
+ #end[Value]
* @run testng/othervm -Diters=10 -Xint VarHandleTestAccess$Type$
*
* @comment Set CompileThresholdScaling to 0.1 so that the warmup loop sets to 2000 iterations
* to hit compilation thresholds
*
VarHandle vhStaticFinalField;
VarHandle vhArray;
- #if[String]
+ #if[Object]
VarHandle vhArrayObject;
- #end[String]
+ #end[Object]
VarHandle[] allocate(boolean same) {
List<VarHandle> vhs = new ArrayList<>();
String postfix = same ? "" : "2";
vhStaticField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccess$Type$.class, "static_v", $type$.class);
vhArray = MethodHandles.arrayElementVarHandle($type$[].class);
- #if[String]
+ #if[Object]
vhArrayObject = MethodHandles.arrayElementVarHandle(Object[].class);
- #end[String]
+ #end[Object]
}
@DataProvider
public Object[][] varHandlesProvider() throws Exception {
vhStaticField, VarHandleTestAccess$Type$::testStaticFieldUnsupported,
false));
cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestAccess$Type$::testArray));
- #if[String]
+ #if[Object]
cases.add(new VarHandleAccessTestCase("Array Object[]",
vhArrayObject, VarHandleTestAccess$Type$::testArray));
- #end[String]
+ #end[Object]
cases.add(new VarHandleAccessTestCase("Array unsupported",
vhArray, VarHandleTestAccess$Type$::testArrayUnsupported,
false));
cases.add(new VarHandleAccessTestCase("Array index out of bounds",
vhArray, VarHandleTestAccess$Type$::testArrayIndexOutOfBounds,
false));
- #if[String]
+ #if[Object]
cases.add(new VarHandleAccessTestCase("Array store exception",
vhArrayObject, VarHandleTestAccess$Type$::testArrayStoreException,
false));
- #end[String]
+ #end[Object]
// Work around issue with jtreg summary reporting which truncates
// the String result of Object.toString to 30 characters, hence
// the first dummy argument
return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new);
}
});
#end[Bitwise]
}
}
- #if[String]
+ #if[Object]
static void testArrayStoreException(VarHandle vh) throws Throwable {
Object[] array = new $type$[10];
Arrays.fill(array, $value1$);
Object value = new Object();
// GetAndSetRelease
checkASE(() -> { // receiver reference class
$type$ x = ($type$) vh.getAndSetRelease(array, 0, value);
});
}
- #end[String]
+ #end[Object]
}
< prev index next >