From ae70b68f7e7051de45ba241223692b32b2b55298 Mon Sep 17 00:00:00 2001 From: Marcus Larsson Date: Tue, 5 Apr 2016 16:51:58 +0200 Subject: [PATCH 001/296] 8150894: Unused -Xlog tag sequences are silently ignored Reviewed-by: rehn, sla --- .../src/share/vm/logging/logConfiguration.cpp | 16 +++- .../vm/logging/logTagLevelExpression.cpp | 73 ++++++++++++++++--- .../vm/logging/logTagLevelExpression.hpp | 5 ++ hotspot/src/share/vm/logging/logTagSet.hpp | 2 +- .../native/logging/test_logConfiguration.cpp | 14 +++- 5 files changed, 93 insertions(+), 17 deletions(-) diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp index 3081fe93432..bdec5d689d4 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.cpp +++ b/hotspot/src/share/vm/logging/logConfiguration.cpp @@ -289,6 +289,8 @@ void LogConfiguration::configure_stdout(LogLevelType level, bool exact_match, .. } expr.set_level(level); expr.new_combination(); + assert(expr.verify_tagsets(), + "configure_stdout() called with invalid/non-existing tag set"); // Apply configuration to stdout (output #0), with the same decorators as before. ConfigurationLock cl; @@ -334,9 +336,16 @@ bool LogConfiguration::parse_command_line_arguments(const char* opts) { char errbuf[512]; stringStream ss(errbuf, sizeof(errbuf)); bool success = parse_log_arguments(output, what, decorators, output_options, &ss); - if (!success) { - errbuf[strlen(errbuf) - 1] = '\0'; // Strip trailing newline. - log_error(logging)("%s", errbuf); + + if (ss.size() > 0) { + errbuf[strlen(errbuf) - 1] = '\0'; // Strip trailing newline + // If it failed, log the error. If it didn't fail, but something was written + // to the stream, log it as a warning. + if (!success) { + log_error(logging)("%s", ss.base()); + } else { + log_warning(logging)("%s", ss.base()); + } } os::free(copy); @@ -386,6 +395,7 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr, } configure_output(idx, expr, decorators); notify_update_listeners(); + expr.verify_tagsets(errstream); return true; } diff --git a/hotspot/src/share/vm/logging/logTagLevelExpression.cpp b/hotspot/src/share/vm/logging/logTagLevelExpression.cpp index 0770c38ba8d..6520c62d962 100644 --- a/hotspot/src/share/vm/logging/logTagLevelExpression.cpp +++ b/hotspot/src/share/vm/logging/logTagLevelExpression.cpp @@ -29,6 +29,65 @@ const char* LogTagLevelExpression::DefaultExpressionString = "all"; +static bool matches_tagset(const LogTagType tags[], + bool allow_other_tags, + const LogTagSet& ts) { + bool contains_all = true; + size_t tag_idx; + for (tag_idx = 0; tag_idx < LogTag::MaxTags && tags[tag_idx] != LogTag::__NO_TAG; tag_idx++) { + if (!ts.contains(tags[tag_idx])) { + contains_all = false; + break; + } + } + // All tags in the expression must be part of the tagset, + // and either the expression allows other tags (has a wildcard), + // or the number of tags in the expression and tagset must match. + return contains_all && (allow_other_tags || tag_idx == ts.ntags()); +} + +bool LogTagLevelExpression::verify_tagsets(outputStream* out) const { + bool valid = true; + + for (size_t i = 0; i < _ncombinations; i++) { + bool matched = false; + for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + if (matches_tagset(_tags[i], _allow_other_tags[i], *ts)) { + matched = true; + break; + } + } + + if (!matched) { + // If this was the first invalid combination, write the message header + if (valid && out != NULL) { + out->print("No tag set matches selection(s): "); + } + valid = false; + + // Break as soon as possible unless listing all invalid combinations + if (out == NULL) { + break; + } + + // List the combination on the outputStream + for (size_t t = 0; t < LogTag::MaxTags && _tags[i][t] != LogTag::__NO_TAG; t++) { + out->print("%s%s", (t == 0 ? "" : "+"), LogTag::name(_tags[i][t])); + } + if (_allow_other_tags[i]) { + out->print("*"); + } + out->print(" "); + } + } + + if (!valid && out != NULL) { + out->cr(); + } + + return valid; +} + bool LogTagLevelExpression::parse(const char* str, outputStream* errstream) { bool success = true; if (str == NULL || strcmp(str, "") == 0) { @@ -120,20 +179,10 @@ LogLevelType LogTagLevelExpression::level_for(const LogTagSet& ts) const { // Return NotMentioned if the given tagset isn't covered by this expression. LogLevelType level = LogLevel::NotMentioned; for (size_t combination = 0; combination < _ncombinations; combination++) { - bool contains_all = true; - size_t tag_idx; - for (tag_idx = 0; tag_idx < LogTag::MaxTags && _tags[combination][tag_idx] != LogTag::__NO_TAG; tag_idx++) { - if (!ts.contains(_tags[combination][tag_idx])) { - contains_all = false; - break; - } - } - // All tags in the expression must be part of the tagset, - // and either the expression allows other tags (has a wildcard), - // or the number of tags in the expression and tagset must match. - if (contains_all && (_allow_other_tags[combination] || tag_idx == ts.ntags())) { + if (matches_tagset(_tags[combination], _allow_other_tags[combination], ts)) { level = _level[combination]; } } return level; } + diff --git a/hotspot/src/share/vm/logging/logTagLevelExpression.hpp b/hotspot/src/share/vm/logging/logTagLevelExpression.hpp index 9a0d7c9cd79..e1f4cb2e94a 100644 --- a/hotspot/src/share/vm/logging/logTagLevelExpression.hpp +++ b/hotspot/src/share/vm/logging/logTagLevelExpression.hpp @@ -83,6 +83,11 @@ class LogTagLevelExpression : public StackObj { bool parse(const char* str, outputStream* errstream = NULL); LogLevelType level_for(const LogTagSet& ts) const; + + // Verify the tagsets/selections mentioned in this expression. + // Returns false if some invalid tagset was found. If given an outputstream, + // this function will list all the invalid selections on the stream. + bool verify_tagsets(outputStream* out = NULL) const; }; #endif // SHARE_VM_LOGGING_LOGTAGLEVELEXPRESSION_HPP diff --git a/hotspot/src/share/vm/logging/logTagSet.hpp b/hotspot/src/share/vm/logging/logTagSet.hpp index a40ed5175bc..e6281565ee5 100644 --- a/hotspot/src/share/vm/logging/logTagSet.hpp +++ b/hotspot/src/share/vm/logging/logTagSet.hpp @@ -86,7 +86,7 @@ class LogTagSet VALUE_OBJ_CLASS_SPEC { } bool contains(LogTagType tag) const { - for (size_t i = 0; _tag[i] != LogTag::__NO_TAG; i++) { + for (size_t i = 0; i < LogTag::MaxTags && _tag[i] != LogTag::__NO_TAG; i++) { if (tag == _tag[i]) { return true; } diff --git a/hotspot/test/native/logging/test_logConfiguration.cpp b/hotspot/test/native/logging/test_logConfiguration.cpp index 528111ef31b..035909b5070 100644 --- a/hotspot/test/native/logging/test_logConfiguration.cpp +++ b/hotspot/test/native/logging/test_logConfiguration.cpp @@ -287,5 +287,17 @@ TEST_F(LogConfigurationTest, parse_log_arguments) { const LogDecorators::Decorator decorator = static_cast(d); EXPECT_TRUE(LogConfiguration::parse_log_arguments("#0", "", LogDecorators::name(decorator), "", &ss)); } - EXPECT_STREQ("", ss.as_string()) << "Error reported while parsing: " << ss.as_string(); +} + +TEST_F(LogConfigurationTest, parse_invalid_tagset) { + static const char* invalid_tagset = "logging+start+exit+safepoint+gc"; // Must not exist for test to function. + + // Make sure warning is produced if one or more configured tagsets are invalid + ResourceMark rm; + stringStream ss; + bool success = LogConfiguration::parse_log_arguments("stdout", invalid_tagset, NULL, NULL, &ss); + const char* msg = ss.as_string(); + EXPECT_TRUE(success) << "Should only cause a warning, not an error"; + EXPECT_TRUE(string_contains_substring(msg, "No tag set matches selection(s):")); + EXPECT_TRUE(string_contains_substring(msg, invalid_tagset)); } From 8b735ce29a7aff663519645e323a12d151322cbf Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Tue, 16 Aug 2016 22:10:12 +0300 Subject: [PATCH 002/296] 8155691: Update GIFlib library to the latest up-to-date Reviewed-by: serb --- .../native/libsplashscreen/giflib/dgif_lib.c | 20 +++- .../native/libsplashscreen/giflib/gif_lib.h | 5 +- .../native/libsplashscreen/giflib/gifalloc.c | 27 ++--- .../giflib/openbsd-reallocarray.c | 106 ++++++++++++++++++ 4 files changed, 139 insertions(+), 19 deletions(-) create mode 100644 jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c index 2d3d88225e9..1c1b217654e 100644 --- a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c @@ -114,7 +114,7 @@ DGifOpenFileHandle(int FileHandle, int *Error) GifFile->SavedImages = NULL; GifFile->SColorMap = NULL; - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); + Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType)); if (Private == NULL) { if (Error != NULL) *Error = D_GIF_ERR_NOT_ENOUGH_MEM; @@ -122,6 +122,9 @@ DGifOpenFileHandle(int FileHandle, int *Error) free((char *)GifFile); return NULL; } + + /*@i1@*/memset(Private, '\0', sizeof(GifFilePrivateType)); + #ifdef _WIN32 _setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ #endif /* _WIN32 */ @@ -197,13 +200,14 @@ DGifOpen(void *userData, InputFunc readFunc, int *Error) GifFile->SavedImages = NULL; GifFile->SColorMap = NULL; - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); + Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType)); if (!Private) { if (Error != NULL) *Error = D_GIF_ERR_NOT_ENOUGH_MEM; free((char *)GifFile); return NULL; } + /*@i1@*/memset(Private, '\0', sizeof(GifFilePrivateType)); GifFile->Private = (void *)Private; Private->FileHandle = 0; @@ -417,8 +421,8 @@ DGifGetImageDesc(GifFileType *GifFile) if (GifFile->SavedImages) { SavedImage* new_saved_images = - (SavedImage *)realloc(GifFile->SavedImages, - sizeof(SavedImage) * (GifFile->ImageCount + 1)); + (SavedImage *)reallocarray(GifFile->SavedImages, + (GifFile->ImageCount + 1), sizeof(SavedImage)); if (new_saved_images == NULL) { GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM; return GIF_ERROR; @@ -788,6 +792,12 @@ DGifSetupDecompress(GifFileType *GifFile) } BitsPerPixel = CodeSize; + /* this can only happen on a severely malformed GIF */ + if (BitsPerPixel > 8) { + GifFile->Error = D_GIF_ERR_READ_FAILED; /* somewhat bogus error code */ + return GIF_ERROR; /* Failed to read Code size. */ + } + Private->Buf[0] = 0; /* Input Buffer empty. */ Private->BitsPerPixel = BitsPerPixel; Private->ClearCode = (1 << BitsPerPixel); @@ -1123,7 +1133,7 @@ DGifSlurp(GifFileType *GifFile) if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) { return GIF_ERROR; } - sp->RasterBits = (unsigned char *)malloc(ImageSize * + sp->RasterBits = (unsigned char *)reallocarray(NULL, ImageSize, sizeof(GifPixelType)); if (sp->RasterBits == NULL) { diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h index aa356362bf6..e8d7090bd10 100644 --- a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h @@ -37,7 +37,7 @@ extern "C" { #define GIFLIB_MAJOR 5 #define GIFLIB_MINOR 1 -#define GIFLIB_RELEASE 1 +#define GIFLIB_RELEASE 4 #define GIF_ERROR 0 #define GIF_OK 1 @@ -274,6 +274,9 @@ extern ColorMapObject *GifUnionColorMap(const ColorMapObject *ColorIn1, GifPixelType ColorTransIn2[]); extern int GifBitSize(int n); +extern void * reallocarray(void *optr, size_t nmemb, size_t size); + + /****************************************************************************** Support for the in-core structures allocation (slurp mode). ******************************************************************************/ diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c index f7a6a3d8f28..cc784d19bd8 100644 --- a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c @@ -212,8 +212,8 @@ GifUnionColorMap(const ColorMapObject *ColorIn1, /* perhaps we can shrink the map? */ if (RoundUpTo < ColorUnion->ColorCount) { - GifColorType *new_map = (GifColorType *)realloc(Map, - sizeof(GifColorType) * RoundUpTo); + GifColorType *new_map = (GifColorType *)reallocarray(Map, + RoundUpTo, sizeof(GifColorType)); if( new_map == NULL ) { GifFreeMapObject(ColorUnion); return ((ColorMapObject *) NULL); @@ -256,9 +256,9 @@ GifAddExtensionBlock(int *ExtensionBlockCount, if (*ExtensionBlocks == NULL) *ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock)); else { - ExtensionBlock* ep_new = (ExtensionBlock *)realloc(*ExtensionBlocks, - sizeof(ExtensionBlock) * - (*ExtensionBlockCount + 1)); + ExtensionBlock* ep_new = (ExtensionBlock *)reallocarray + (*ExtensionBlocks, (*ExtensionBlockCount + 1), + sizeof(ExtensionBlock)); if( ep_new == NULL ) return (GIF_ERROR); *ExtensionBlocks = ep_new; @@ -349,8 +349,8 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) if (GifFile->SavedImages == NULL) GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage)); else - GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages, - sizeof(SavedImage) * (GifFile->ImageCount + 1)); + GifFile->SavedImages = (SavedImage *)reallocarray(GifFile->SavedImages, + (GifFile->ImageCount + 1), sizeof(SavedImage)); if (GifFile->SavedImages == NULL) return ((SavedImage *)NULL); @@ -379,9 +379,10 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) } /* next, the raster */ - sp->RasterBits = (unsigned char *)malloc(sizeof(GifPixelType) * - CopyFrom->ImageDesc.Height * - CopyFrom->ImageDesc.Width); + sp->RasterBits = (unsigned char *)reallocarray(NULL, + (CopyFrom->ImageDesc.Height * + CopyFrom->ImageDesc.Width), + sizeof(GifPixelType)); if (sp->RasterBits == NULL) { FreeLastSavedImage(GifFile); return (SavedImage *)(NULL); @@ -392,9 +393,9 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) /* finally, the extension blocks */ if (sp->ExtensionBlocks != NULL) { - sp->ExtensionBlocks = (ExtensionBlock *)malloc( - sizeof(ExtensionBlock) * - CopyFrom->ExtensionBlockCount); + sp->ExtensionBlocks = (ExtensionBlock *)reallocarray(NULL, + CopyFrom->ExtensionBlockCount, + sizeof(ExtensionBlock)); if (sp->ExtensionBlocks == NULL) { FreeLastSavedImage(GifFile); return (SavedImage *)(NULL); diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c new file mode 100644 index 00000000000..1087671c27b --- /dev/null +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c @@ -0,0 +1,106 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* $OpenBSD: reallocarray.c,v 1.1 2014/05/08 21:43:49 deraadt Exp $ */ +/* + * Copyright (c) 2008 Otto Moerbeek + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +/* + * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX + * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW + */ +#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) + +void * +reallocarray(void *optr, size_t nmemb, size_t size) +{ + if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && + nmemb > 0 && SIZE_MAX / nmemb < size) { + errno = ENOMEM; + return NULL; + } + /* + * Head off variations in realloc behavior on different + * platforms (reported by MarkR ) + * + * The behaviour of reallocarray is implementation-defined if + * nmemb or size is zero. It can return NULL or non-NULL + * depending on the platform. + * https://www.securecoding.cert.org/confluence/display/c/MEM04-C.Beware+of+zero-lengthallocations + * + * Here are some extracts from realloc man pages on different platforms. + * + * void realloc( void memblock, size_t size ); + * + * Windows: + * + * If there is not enough available memory to expand the block + * to the given size, the original block is left unchanged, + * and NULL is returned. If size is zero, then the block + * pointed to by memblock is freed; the return value is NULL, + * and memblock is left pointing at a freed block. + * + * OpenBSD: + * + * If size or nmemb is equal to 0, a unique pointer to an + * access protected, zero sized object is returned. Access via + * this pointer will generate a SIGSEGV exception. + * + * Linux: + * + * If size was equal to 0, either NULL or a pointer suitable + * to be passed to free() is returned. + * + * OS X: + * + * If size is zero and ptr is not NULL, a new, minimum sized + * object is allocated and the original object is freed. + * + * It looks like images with zero width or height can trigger + * this, and fuzzing behaviour will differ by platform, so + * fuzzing on one platform may not detect zero-size allocation + * problems on other platforms. + */ + if (size == 0 || nmemb == 0) + return NULL; + return realloc(optr, size * nmemb); +} From c47ae75e1b43624e922c62515f09bc9953011f31 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 16 Aug 2016 23:07:35 +0300 Subject: [PATCH 003/296] 8159898: Negative array size in java/beans/Introspector/Test8027905.java Reviewed-by: alexsch, yan --- .../Window/OwnedWindowsLeak/OwnedWindowsLeak.java | 14 ++++++-------- jdk/test/java/beans/Introspector/Test8027905.java | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java b/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java index 0b6da116ede..81fdd4b049b 100644 --- a/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java +++ b/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java @@ -27,16 +27,14 @@ @bug 6758673 @summary Tests that windows are removed from owner's child windows list @author art: area=awt.toplevel - @run main OwnedWindowsLeak + @run main/othervm -mx128m OwnedWindowsLeak */ -import java.awt.*; -import java.awt.event.*; - -import java.lang.ref.*; -import java.lang.reflect.*; - -import java.util.*; +import java.awt.Frame; +import java.awt.Window; +import java.lang.ref.WeakReference; +import java.lang.reflect.Field; +import java.util.Vector; public class OwnedWindowsLeak { diff --git a/jdk/test/java/beans/Introspector/Test8027905.java b/jdk/test/java/beans/Introspector/Test8027905.java index 6c91694b4df..60318f34555 100644 --- a/jdk/test/java/beans/Introspector/Test8027905.java +++ b/jdk/test/java/beans/Introspector/Test8027905.java @@ -28,6 +28,7 @@ import java.beans.PropertyDescriptor; * @bug 8027905 * @summary Tests that GC does not affect a property type * @author Sergey Malenkov + * @run main/othervm -mx16m Test8027905 */ public class Test8027905 { From 71b91c6ce137d3b667dde9f88af290839eed3b30 Mon Sep 17 00:00:00 2001 From: Avik Niyogi Date: Wed, 17 Aug 2016 14:42:14 +0530 Subject: [PATCH 004/296] 8163169: [PIT][TEST_BUG] fix to JDK-8161470 doesn't work Reviewed-by: alexsch, rchamyal --- .../swing/JRadioButton/FocusTraversal/FocusTraversal.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java b/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java index f7146318ad0..4c773c0f7b1 100644 --- a/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java +++ b/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java @@ -23,7 +23,7 @@ /* @test * @key headful - * @bug 8129940 8132770 8161470 + * @bug 8129940 8132770 8161470 8163169 * @summary JRadioButton should run custom FocusTraversalKeys for all LaFs * @run main FocusTraversal */ @@ -61,6 +61,7 @@ public class FocusTraversal { public static void main(String[] args) throws Exception { robot = new Robot(); + robot.setAutoDelay(100); robot.waitForIdle(); UIManager.LookAndFeelInfo[] lookAndFeelArray = UIManager.getInstalledLookAndFeels(); From b446df55a53941cb9801bb927119fe95cda0165c Mon Sep 17 00:00:00 2001 From: Rajeev Chamyal Date: Wed, 17 Aug 2016 14:48:13 +0530 Subject: [PATCH 005/296] 8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails Reviewed-by: alexsch, aniyogi --- .../java/awt/Window/8159168/SetShapeTest.java | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/jdk/test/java/awt/Window/8159168/SetShapeTest.java b/jdk/test/java/awt/Window/8159168/SetShapeTest.java index 19670a5f46e..9baaea1d084 100644 --- a/jdk/test/java/awt/Window/8159168/SetShapeTest.java +++ b/jdk/test/java/awt/Window/8159168/SetShapeTest.java @@ -1,29 +1,30 @@ /* -* Copyright (c) 2016, 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. -* -* This code is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -* version 2 for more details (a copy is included in the LICENSE file that -* accompanied this code). -* -* You should have received a copy of the GNU General Public License version -* 2 along with this work; if not, write to the Free Software Foundation, -* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -* -* 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. + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. */ /** * @test - * @bug 8159168 + * @key headful + * @bug 8159168 8161913 * @summary [hidpi] Window.setShape() works incorrectly on HiDPI * @run main/othervm -Dsun.java2d.uiScale=2 SetShapeTest */ @@ -50,6 +51,7 @@ public class SetShapeTest { Rectangle rect = window.getBounds(); rect.x += rect.width - 10; rect.y += rect.height - 10; + robot.delay(1000); Color c = robot.getPixelColor(rect.x, rect.y); try { if (!c.equals(Color.RED)) { From cd6bfaf6d226d0e5563557a535313beb4522e852 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 18 Aug 2016 10:46:48 +0530 Subject: [PATCH 006/296] 8164205: [PIT][TEST_BUG] test javax/print/attribute/ServiceDlgPageRangeTest.java doesn't compile Reviewed-by: prr --- jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java b/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java index b35d687b7c0..ab17680cefc 100644 --- a/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java +++ b/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java @@ -22,13 +22,15 @@ */ /* * @test - * @bug 5080098 + * @bug 5080098 8164205 * @summary Verify if PageRanges option is disabled for Non service-formatted * flavors. * @run main/manual ServiceDlgPageRangeTest */ import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import javax.print.DocFlavor; import javax.print.PrintService; import javax.print.PrintServiceLookup; From 5390af7c2b6df679d28752a2aae19bf010f3f436 Mon Sep 17 00:00:00 2001 From: Jayathirth D V Date: Fri, 19 Aug 2016 12:22:23 +0530 Subject: [PATCH 007/296] 8163258: Getting NullPointerException from ImageIO.getReaderWriterInfo due to failure to check for null Reviewed-by: prr, psadhukhan --- .../share/classes/javax/imageio/ImageIO.java | 7 +- .../imageio/GetReaderWriterInfoNullTest.java | 161 ++++++++++++++++++ 2 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java b/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java index 7af7b77be77..523a857dbc1 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java @@ -462,10 +462,13 @@ public final class ImageIO { return new String[0]; } - HashSet s = new HashSet(); + HashSet s = new HashSet<>(); while (iter.hasNext()) { ImageReaderWriterSpi spi = iter.next(); - Collections.addAll(s, spiInfo.info(spi)); + String[] info = spiInfo.info(spi); + if (info != null) { + Collections.addAll(s, info); + } } return s.toArray(new String[s.size()]); diff --git a/jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java b/jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java new file mode 100644 index 00000000000..5e9679cfe7f --- /dev/null +++ b/jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8163258 + * @summary Test verifies that when we create our own ImageReaderSpi + * implementaion with MIMEType or FileSuffix as null, it should + * not throw NullPointerException when we call + * ImageIO.getReaderMIMETypes() or ImageIO.getReaderFileSuffixes(). + * @run main GetReaderWriterInfoNullTest + */ + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.Iterator; +import java.util.Locale; +import javax.imageio.IIOException; +import javax.imageio.ImageReadParam; +import javax.imageio.ImageReader; +import javax.imageio.ImageTypeSpecifier; +import javax.imageio.metadata.IIOMetadata; +import javax.imageio.spi.ImageReaderSpi; +import javax.imageio.stream.ImageInputStream; +import javax.imageio.ImageIO; +import javax.imageio.spi.IIORegistry; + +class TestImageReaderSpi extends ImageReaderSpi { + + public TestImageReaderSpi(String[] FORMATNAMES, String[] SUFFIXES, + String[] MIMETYPES) { + super("J Duke", // vendor + "1.0", // version + FORMATNAMES, // format names + SUFFIXES, // file suffixes + MIMETYPES, // mimetypes + "readTest.TestImageReader", // reader class name + new Class[] { ImageInputStream.class }, // input types + null, // writer class names. + true, // supports native metadata, + null, // [no] native stream metadata format + null, // [no] native stream metadata class + null, // [no] native extra stream metadata format + null, // [no] native extra stream metadata class + true, // supports standard metadata, + null, // metadata format name, + null, // metadata format class name + null, // [no] extra image metadata format + null // [no] extra image metadata format class + ); + } + + @Override + public boolean canDecodeInput(Object source) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getDescription(Locale locale) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ImageReader createReaderInstance(Object extension) + throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + +} + +class TestImageReader extends ImageReader { + + public TestImageReader(ImageReaderSpi originatingProvider) { + super(originatingProvider); + } + + @Override + public int getNumImages(boolean allowSearch) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getWidth(int imageIndex) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getHeight(int imageIndex) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Iterator getImageTypes(int imageIndex) + throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IIOMetadata getStreamMetadata() throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IIOMetadata getImageMetadata(int imageIndex) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BufferedImage read(int imageIndex, ImageReadParam param) + throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } +} +public class GetReaderWriterInfoNullTest { + static final String[] FORMATNAMES = {"readTest"}; + static final String[] SUFFIXES = {"readTest"}; + static final String[] MIMETYPES = {"readTest"}; + public static void main (String[] args) throws IIOException { + // Verify getReaderMIMETypes() behavior by keeping MIMEType as null. + TestImageReaderSpi mimeNullReadSpi = + new TestImageReaderSpi(FORMATNAMES, SUFFIXES, null); + IIORegistry.getDefaultInstance(). + registerServiceProvider(mimeNullReadSpi); + ImageIO.getReaderMIMETypes(); + IIORegistry.getDefaultInstance(). + deregisterServiceProvider(mimeNullReadSpi); + + /* + * Verify getReaderFileSuffixes() behavior by keeping + * file suffix as null. + */ + TestImageReaderSpi suffixNullReadSpi = + new TestImageReaderSpi(FORMATNAMES, null, MIMETYPES); + IIORegistry.getDefaultInstance(). + registerServiceProvider(suffixNullReadSpi); + ImageIO.getReaderFileSuffixes(); + IIORegistry.getDefaultInstance(). + deregisterServiceProvider(suffixNullReadSpi); + } +} + From 966cbcfce3b8fb280faa8747d8eccba8d8085ac7 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Fri, 19 Aug 2016 16:48:53 +0400 Subject: [PATCH 008/296] 8151303: [macosx] [hidpi] JButton's low-res. icon is visible when clicking on it 8156182: [macosx] HiDPI/Retina icons do not work for disabled JButton/JMenuItem etc Reviewed-by: flar, prr --- .../classes/com/apple/laf/AquaUtils.java | 28 ++-- .../share/classes/javax/swing/GrayFilter.java | 12 +- .../awt/image/MultiResolutionCachedImage.java | 53 ++++++- .../image/MultiResolutionToolkitImage.java | 8 ++ .../MultiResolutionDisabledImageTest.java | 119 ++++++++++++++++ .../JButton/8151303/PressedIconTest.java | 132 ++++++++++++++++++ 6 files changed, 335 insertions(+), 17 deletions(-) create mode 100644 jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java create mode 100644 jdk/test/javax/swing/JButton/8151303/PressedIconTest.java diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java index 67520fcc30b..65c38cca879 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java @@ -105,38 +105,44 @@ final class AquaUtils { } static Image generateSelectedDarkImage(final Image image) { - final ImageProducer prod = new FilteredImageSource(image.getSource(), new IconImageFilter() { + final ImageFilter filter = new IconImageFilter() { @Override int getGreyFor(final int gray) { return gray * 75 / 100; } - }); - return Toolkit.getDefaultToolkit().createImage(prod); + }; + return map(image, filter); } static Image generateDisabledImage(final Image image) { - final ImageProducer prod = new FilteredImageSource(image.getSource(), new IconImageFilter() { + final ImageFilter filter = new IconImageFilter() { @Override int getGreyFor(final int gray) { return 255 - ((255 - gray) * 65 / 100); } - }); - return Toolkit.getDefaultToolkit().createImage(prod); + }; + return map(image, filter); } static Image generateLightenedImage(final Image image, final int percent) { final GrayFilter filter = new GrayFilter(true, percent); - return (image instanceof MultiResolutionCachedImage) - ? ((MultiResolutionCachedImage) image).map( - rv -> generateLightenedImage(rv, filter)) - : generateLightenedImage(image, filter); + return map(image, filter); } - static Image generateLightenedImage(Image image, ImageFilter filter) { + static Image generateFilteredImage(Image image, ImageFilter filter) { final ImageProducer prod = new FilteredImageSource(image.getSource(), filter); return Toolkit.getDefaultToolkit().createImage(prod); } + private static Image map(Image image, ImageFilter filter) { + if (image instanceof MultiResolutionImage) { + return MultiResolutionCachedImage + .map((MultiResolutionImage) image, + (img) -> generateFilteredImage(img, filter)); + } + return generateFilteredImage(image, filter); + } + private abstract static class IconImageFilter extends RGBImageFilter { IconImageFilter() { super(); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java b/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java index af5947e5eec..65fddf32df9 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java @@ -26,6 +26,7 @@ package javax.swing; import java.awt.*; import java.awt.image.*; +import sun.awt.image.MultiResolutionCachedImage; /** * An image filter that "disables" an image by turning @@ -48,7 +49,16 @@ public class GrayFilter extends RGBImageFilter { * @param i an {@code Image} to be created as disabled * @return the new grayscale image created from {@code i} */ - public static Image createDisabledImage (Image i) { + public static Image createDisabledImage(Image i) { + if (i instanceof MultiResolutionImage) { + return MultiResolutionCachedImage + .map((MultiResolutionImage) i, + (img) -> createDisabledImageImpl(img)); + } + return createDisabledImageImpl(i); + } + + private static Image createDisabledImageImpl(Image i) { GrayFilter filter = new GrayFilter(true, 50); ImageProducer prod = new FilteredImageSource(i.getSource(), filter); Image grayImage = Toolkit.getDefaultToolkit().createImage(prod); diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java index 8d8acdcf0a3..76bbfcff0f5 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.function.Function; import java.util.function.BiFunction; import java.util.stream.Collectors; +import java.awt.image.MultiResolutionImage; import java.awt.image.AbstractMultiResolutionImage; public class MultiResolutionCachedImage extends AbstractMultiResolutionImage { @@ -44,17 +45,30 @@ public class MultiResolutionCachedImage extends AbstractMultiResolutionImage { private int availableInfo; public MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight, - BiFunction mapper) { - this(baseImageWidth, baseImageHeight, new Dimension[]{new Dimension( - baseImageWidth, baseImageHeight) + BiFunction mapper) + { + this(baseImageWidth, baseImageHeight, + new Dimension[]{new Dimension( baseImageWidth, baseImageHeight) }, mapper); } public MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight, - Dimension2D[] sizes, BiFunction mapper) { + Dimension2D[] sizes, + BiFunction mapper) + { + this(baseImageWidth, baseImageHeight, sizes, mapper, true); + } + + private MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight, + Dimension2D[] sizes, + BiFunction mapper, + boolean copySizes) + { this.baseImageWidth = baseImageWidth; this.baseImageHeight = baseImageHeight; - this.sizes = (sizes == null) ? null : Arrays.copyOf(sizes, sizes.length); + this.sizes = (copySizes && sizes != null) + ? Arrays.copyOf(sizes, sizes.length) + : sizes; this.mapper = mapper; } @@ -99,6 +113,35 @@ public class MultiResolutionCachedImage extends AbstractMultiResolutionImage { mapper.apply(getResolutionVariant(width, height))); } + public static Image map(MultiResolutionImage mrImage, + Function mapper) { + + if (mrImage instanceof MultiResolutionToolkitImage) { + MultiResolutionToolkitImage mrtImage = + (MultiResolutionToolkitImage) mrImage; + return MultiResolutionToolkitImage.map(mrtImage, mapper); + } + + BiFunction sizeMapper + = (w, h) -> mapper.apply(mrImage.getResolutionVariant(w, h)); + + if (mrImage instanceof MultiResolutionCachedImage) { + MultiResolutionCachedImage mrcImage + = (MultiResolutionCachedImage) mrImage; + + return new MultiResolutionCachedImage(mrcImage.baseImageWidth, + mrcImage.baseImageHeight, + mrcImage.sizes, + sizeMapper, + false); + } + + Image image = (Image) mrImage; + int width = image.getWidth(null); + int height = image.getHeight(null); + return new MultiResolutionCachedImage(width, height, sizeMapper); + } + @Override public int getWidth(ImageObserver observer) { updateInfo(observer, ImageObserver.WIDTH); diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java index 26a86916824..dfe08735a15 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java @@ -29,6 +29,7 @@ import java.awt.image.ImageObserver; import java.awt.image.MultiResolutionImage; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import sun.awt.SoftCache; public class MultiResolutionToolkitImage extends ToolkitImage implements MultiResolutionImage { @@ -47,6 +48,13 @@ public class MultiResolutionToolkitImage extends ToolkitImage implements MultiRe ? this : resolutionVariant; } + public static Image map(MultiResolutionToolkitImage mrImage, + Function mapper) { + Image baseImage = mapper.apply(mrImage); + Image rvImage = mapper.apply(mrImage.resolutionVariant); + return new MultiResolutionToolkitImage(baseImage, rvImage); + } + private static void checkSize(double width, double height) { if (width <= 0 || height <= 0) { throw new IllegalArgumentException(String.format( diff --git a/jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java b/jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java new file mode 100644 index 00000000000..ce5c44d0d8a --- /dev/null +++ b/jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.MediaTracker; +import java.awt.Toolkit; +import java.awt.image.BaseMultiResolutionImage; +import java.awt.image.BufferedImage; +import java.io.File; +import javax.imageio.ImageIO; +import javax.swing.GrayFilter; +import java.awt.image.MultiResolutionImage; +import javax.swing.JLabel; + +/** + * @test + * @bug 8156182 + * @summary [macosx] HiDPI/Retina icons do not work for disabled + * JButton/JMenuItem etc. + * @run main/othervm -Dsun.java2d.uiScale=2 MultiResolutionDisabledImageTest + */ +public class MultiResolutionDisabledImageTest { + + private static final String IMAGE_NAME_1X = "image.png"; + private static final String IMAGE_NAME_2X = "image@2x.png"; + private static final int IMAGE_SIZE = 100; + private static final Color COLOR_1X = Color.GREEN; + private static final Color COLOR_2X = Color.BLUE; + + public static void main(String[] args) throws Exception { + + Image baseMRImage = new BaseMultiResolutionImage(createImage(1), + createImage(2)); + testMRDisabledImage(baseMRImage); + + saveImages(); + Image toolkitMRImage = Toolkit.getDefaultToolkit().getImage(IMAGE_NAME_1X); + + if (toolkitMRImage instanceof MultiResolutionImage) { + testMRDisabledImage(toolkitMRImage); + } + } + + private static void testMRDisabledImage(Image image) throws Exception { + + Image disabledImage = GrayFilter.createDisabledImage(image); + MediaTracker mediaTracker = new MediaTracker(new JLabel()); + mediaTracker.addImage(disabledImage, 0); + mediaTracker.waitForID(0); + + BufferedImage buffImage = new BufferedImage(IMAGE_SIZE, + IMAGE_SIZE, + BufferedImage.TYPE_INT_RGB); + + int x = IMAGE_SIZE / 2; + int y = IMAGE_SIZE / 2; + + Graphics2D g = buffImage.createGraphics(); + + g.scale(1, 1); + g.drawImage(disabledImage, 0, 0, null); + int rgb1x = buffImage.getRGB(x, y); + + g.scale(2, 2); + g.drawImage(disabledImage, 0, 0, null); + int rgb2x = buffImage.getRGB(x, y); + + g.dispose(); + + if (rgb1x == rgb2x) { + throw new RuntimeException("Disabled image is the same for the base" + + "image and the resolution variant"); + } + + } + + private static BufferedImage createImage(int scale) throws Exception { + BufferedImage image = new BufferedImage(scale * 200, scale * 300, + BufferedImage.TYPE_INT_RGB); + Graphics g = image.createGraphics(); + g.setColor(scale == 1 ? COLOR_1X : COLOR_2X); + g.fillRect(0, 0, scale * 200, scale * 300); + g.dispose(); + return image; + } + + private static void saveImages() throws Exception { + saveImage(createImage(1), IMAGE_NAME_1X); + saveImage(createImage(2), IMAGE_NAME_2X); + } + + private static void saveImage(BufferedImage image, String name) throws Exception { + ImageIO.write(image, "png", new File(name)); + } +} diff --git a/jdk/test/javax/swing/JButton/8151303/PressedIconTest.java b/jdk/test/javax/swing/JButton/8151303/PressedIconTest.java new file mode 100644 index 00000000000..9bf4065b099 --- /dev/null +++ b/jdk/test/javax/swing/JButton/8151303/PressedIconTest.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.image.BaseMultiResolutionImage; +import java.awt.image.BufferedImage; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JToggleButton; +import javax.swing.SwingUtilities; + +/** + * @test + * @bug 8151303 + * @summary [macosx] [hidpi] JButton's low-res. icon is visible when clicking on it + * @run main/othervm PressedIconTest + * @run main/othervm -Dsun.java2d.uiScale=2 PressedIconTest + */ +public class PressedIconTest { + + private final static int IMAGE_SIZE = 300; + + private final static Color COLOR_1X = Color.RED; + private final static Color COLOR_2X = Color.BLUE; + private static JFrame frame; + private static volatile double scale = -1; + private static volatile int centerX; + private static volatile int centerY; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(() -> createAndShowGUI()); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> { + scale = frame.getGraphicsConfiguration().getDefaultTransform() + .getScaleX(); + Point location = frame.getLocation(); + Dimension size = frame.getSize(); + centerX = location.x + size.width / 2; + centerY = location.y + size.height / 2; + }); + robot.waitForIdle(); + + robot.mouseMove(centerX, centerY); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.waitForIdle(); + Thread.sleep(100); + Color color = robot.getPixelColor(centerX, centerY); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + SwingUtilities.invokeAndWait(() -> frame.dispose()); + + if ((scale == 1 && !similar(color, COLOR_1X)) + || (scale == 2 && !similar(color, COLOR_2X))) { + throw new RuntimeException("Colors are different!"); + } + } + + private static void createAndShowGUI() { + frame = new JFrame(); + frame.setSize(IMAGE_SIZE, IMAGE_SIZE); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JPanel panel = new JPanel(new BorderLayout()); + + BufferedImage img1x = generateImage(1, COLOR_1X); + + BufferedImage img2x = generateImage(2, COLOR_2X); + BaseMultiResolutionImage mri = new BaseMultiResolutionImage( + new BufferedImage[]{img1x, img2x}); + Icon mrIcon = new ImageIcon(mri); + + JToggleButton button = new JToggleButton(); + button.setIcon(mrIcon); + panel.add(button, BorderLayout.CENTER); + + frame.getContentPane().add(panel); + frame.setVisible(true); + } + + private static boolean similar(Color c1, Color c2) { + return similar(c1.getRed(), c2.getRed()) + && similar(c1.getGreen(), c2.getGreen()) + && similar(c1.getBlue(), c2.getBlue()); + } + + private static boolean similar(int n, int m) { + return Math.abs(n - m) <= 50; + } + + private static BufferedImage generateImage(int scale, Color c) { + + int size = IMAGE_SIZE * scale; + BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB); + Graphics g = img.createGraphics(); + g.setColor(c); + g.fillRect(0, 0, size, size); + g.dispose(); + return img; + } +} From a5e760b81c90c3e73072c3936496fb59e44623e7 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Sat, 20 Aug 2016 18:35:37 +0300 Subject: [PATCH 009/296] 8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame Reviewed-by: alanb, prr --- jdk/make/mapfiles/libawt/mapfile-mawt-vers | 6 ++- jdk/make/mapfiles/libawt/mapfile-vers-linux | 6 ++- jdk/make/mapfiles/libawt_xawt/mapfile-vers | 3 ++ .../libawt_lwawt/awt/awt_DrawingSurface.m | 48 +++++++++++++++++- .../java.desktop/macosx/native/libjawt/jawt.m | 12 +++-- .../java.desktop/share/native/include/jawt.h | 49 ++++++++++++++++++- .../native/common/awt/awt_DrawingSurface.h | 13 ++++- .../libawt_xawt/awt/awt_DrawingSurface.c | 47 +++++++++++++++++- .../java.desktop/unix/native/libjawt/jawt.c | 8 ++- .../libawt/windows/awt_DrawingSurface.cpp | 46 ++++++++++++++++- .../libawt/windows/awt_DrawingSurface.h | 12 ++++- .../windows/native/libjawt/jawt.cpp | 11 ++++- 12 files changed, 245 insertions(+), 16 deletions(-) diff --git a/jdk/make/mapfiles/libawt/mapfile-mawt-vers b/jdk/make/mapfiles/libawt/mapfile-mawt-vers index 247e29698e2..32eb88df678 100644 --- a/jdk/make/mapfiles/libawt/mapfile-mawt-vers +++ b/jdk/make/mapfiles/libawt/mapfile-mawt-vers @@ -1,5 +1,5 @@ # -# Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2001, 2016, 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 @@ -238,6 +238,10 @@ SUNWprivate_1.1 { awt_GetDrawingSurface; awt_FreeDrawingSurface; awt_GetComponent; + awt_CreateEmbeddedFrame; + awt_SetBounds; + awt_SynthesizeWindowActivation; + X11SurfaceData_GetOps; getDefaultConfig; diff --git a/jdk/make/mapfiles/libawt/mapfile-vers-linux b/jdk/make/mapfiles/libawt/mapfile-vers-linux index 5645cbd18d9..a1f8d9b6e0e 100644 --- a/jdk/make/mapfiles/libawt/mapfile-vers-linux +++ b/jdk/make/mapfiles/libawt/mapfile-vers-linux @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 2016, 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 @@ -264,6 +264,10 @@ SUNWprivate_1.1 { awt_GetDrawingSurface; awt_FreeDrawingSurface; awt_GetComponent; + awt_CreateEmbeddedFrame; + awt_SetBounds; + awt_SynthesizeWindowActivation; + X11SurfaceData_GetOps; getDefaultConfig; diff --git a/jdk/make/mapfiles/libawt_xawt/mapfile-vers b/jdk/make/mapfiles/libawt_xawt/mapfile-vers index 461c1ba9f48..04113dcf031 100644 --- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers @@ -458,6 +458,9 @@ SUNWprivate_1.1 { awt_Unlock; awt_Lock; awt_GetComponent; + awt_CreateEmbeddedFrame; + awt_SetBounds; + awt_SynthesizeWindowActivation; #XAWT entry point for CDE Java_sun_awt_motif_XsessionWMcommand; diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m index f444bc9b693..fb2cb86a617 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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,6 +27,8 @@ #import "AWTSurfaceLayers.h" +#import "jni_util.h" + JNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceInfo (JAWT_DrawingSurface* ds) { @@ -130,3 +132,47 @@ JNIEXPORT jobject JNICALL awt_GetComponent // TODO: implement return NULL; } + +// EmbeddedFrame support + +static char *const embeddedClassName = "sun/lwawt/macosx/CViewEmbeddedFrame"; + +JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame +(JNIEnv* env, void* platformInfo) +{ + static jmethodID mid = NULL; + static jclass cls; + if (mid == NULL) { + cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL_RETURN(cls, NULL); + mid = (*env)->GetMethodID(env, cls, "", "(J)V"); + CHECK_NULL_RETURN(mid, NULL); + } + return (*env)->NewObject(env, cls, mid, platformInfo); +} + +JNIEXPORT void JNICALL awt_SetBounds +(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h); +} + +JNIEXPORT void JNICALL awt_SynthesizeWindowActivation +(JNIEnv *env, jobject embeddedFrame, jboolean doActivate) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate); +} diff --git a/jdk/src/java.desktop/macosx/native/libjawt/jawt.m b/jdk/src/java.desktop/macosx/native/libjawt/jawt.m index cd9f52a8e5e..773c6482caa 100644 --- a/jdk/src/java.desktop/macosx/native/libjawt/jawt.m +++ b/jdk/src/java.desktop/macosx/native/libjawt/jawt.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -46,8 +46,9 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT return JNI_FALSE; } - if (awt->version != (JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER) && - awt->version != JAWT_VERSION_1_7) + if (awt->version != (JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER) + && awt->version != JAWT_VERSION_1_7 + && awt->version != JAWT_VERSION_9) { return JNI_FALSE; } @@ -58,6 +59,11 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT awt->Lock = awt_Lock; awt->Unlock = awt_Unlock; awt->GetComponent = awt_GetComponent; + if (awt->version >= JAWT_VERSION_9) { + awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame; + awt->SetBounds = awt_SetBounds; + awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation; + } } return JNI_TRUE; diff --git a/jdk/src/java.desktop/share/native/include/jawt.h b/jdk/src/java.desktop/share/native/include/jawt.h index e0f682f4305..8cb2cb8564d 100644 --- a/jdk/src/java.desktop/share/native/include/jawt.h +++ b/jdk/src/java.desktop/share/native/include/jawt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -33,7 +33,7 @@ extern "C" { #endif /* - * AWT native interface (new in JDK 1.3) + * AWT native interface. * * The AWT native interface allows a native C or C++ application a means * by which to access native structures in AWT. This is to facilitate moving @@ -279,6 +279,50 @@ typedef struct jawt { */ jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo); + /** + * Since 9 + * Creates a java.awt.Frame placed in a native container. Container is + * referenced by the native platform handle. For example on Windows this + * corresponds to an HWND. For other platforms, see the appropriate + * machine-dependent header file for a description. The reference returned + * by this function is a local reference that is only valid in this + * environment. This function returns a NULL reference if no frame could be + * created with matching platform information. + */ + jobject (JNICALL *CreateEmbeddedFrame) (JNIEnv *env, void* platformInfo); + + /** + * Since 9 + * Moves and resizes the embedded frame. The new location of the top-left + * corner is specified by x and y parameters relative to the native parent + * component. The new size is specified by width and height. + * + * The embedded frame should be created by CreateEmbeddedFrame() method, or + * this function will not have any effect. + * + * java.awt.Component.setLocation() and java.awt.Component.setBounds() for + * EmbeddedFrame really don't move it within the native parent. These + * methods always locate the embedded frame at (0, 0) for backward + * compatibility. To allow moving embedded frames this method was + * introduced, and it works just the same way as setLocation() and + * setBounds() for usual, non-embedded components. + * + * Using usual get/setLocation() and get/setBounds() together with this new + * method is not recommended. + */ + void (JNICALL *SetBounds) (JNIEnv *env, jobject embeddedFrame, + jint x, jint y, jint w, jint h); + /** + * Since 9 + * Synthesize a native message to activate or deactivate an EmbeddedFrame + * window depending on the value of parameter doActivate, if "true" + * activates the window; otherwise, deactivates the window. + * + * The embedded frame should be created by CreateEmbeddedFrame() method, or + * this function will not have any effect. + */ + void (JNICALL *SynthesizeWindowActivation) (JNIEnv *env, + jobject embeddedFrame, jboolean doActivate); } JAWT; /* @@ -291,6 +335,7 @@ jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt); #define JAWT_VERSION_1_3 0x00010003 #define JAWT_VERSION_1_4 0x00010004 #define JAWT_VERSION_1_7 0x00010007 +#define JAWT_VERSION_9 0x00090000 #ifdef __cplusplus } /* extern "C" */ diff --git a/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h b/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h index bb59b4658c7..bdc9830b07b 100644 --- a/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h +++ b/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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,7 +28,6 @@ #include #include -#include _JNI_IMPORT_OR_EXPORT_ JAWT_DrawingSurface* JNICALL awt_GetDrawingSurface(JNIEnv* env, jobject target); @@ -45,4 +44,14 @@ _JNI_IMPORT_OR_EXPORT_ void JNICALL _JNI_IMPORT_OR_EXPORT_ jobject JNICALL awt_GetComponent(JNIEnv* env, void* platformInfo); +_JNI_IMPORT_OR_EXPORT_ jobject JNICALL + awt_CreateEmbeddedFrame(JNIEnv* env, void* platformInfo); + +_JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SetBounds(JNIEnv *env, jobject embeddedFrame, jint x, jint y, + jint w, jint h); + +_JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SynthesizeWindowActivation(JNIEnv *env, jobject embeddedFrame, + jboolean doActivate); #endif /* !_AWT_DRAWING_SURFACE_H_ */ diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c index de7e8488985..1cc09c9acac 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -383,3 +383,48 @@ JNIEXPORT jobject JNICALL return target; } + +// EmbeddedFrame support + +static char *const embeddedClassName = "sun/awt/X11/XEmbeddedFrame"; + +JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame +(JNIEnv* env, void* platformInfo) +{ + static jmethodID mid = NULL; + static jclass cls; + if (mid == NULL) { + cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL_RETURN(cls, NULL); + mid = (*env)->GetMethodID(env, cls, "", "(JZ)V"); + CHECK_NULL_RETURN(mid, NULL); + } + return (*env)->NewObject(env, cls, mid, platformInfo, JNI_TRUE); +} + + +JNIEXPORT void JNICALL awt_SetBounds +(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h); +} + +JNIEXPORT void JNICALL awt_SynthesizeWindowActivation +(JNIEnv *env, jobject embeddedFrame, jboolean doActivate) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate); +} diff --git a/jdk/src/java.desktop/unix/native/libjawt/jawt.c b/jdk/src/java.desktop/unix/native/libjawt/jawt.c index b6a5240a7c1..59e9a55cff2 100644 --- a/jdk/src/java.desktop/unix/native/libjawt/jawt.c +++ b/jdk/src/java.desktop/unix/native/libjawt/jawt.c @@ -45,7 +45,8 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) if (awt->version != JAWT_VERSION_1_3 && awt->version != JAWT_VERSION_1_4 - && awt->version != JAWT_VERSION_1_7) { + && awt->version != JAWT_VERSION_1_7 + && awt->version != JAWT_VERSION_9) { return JNI_FALSE; } @@ -55,6 +56,11 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) awt->Lock = awt_Lock; awt->Unlock = awt_Unlock; awt->GetComponent = awt_GetComponent; + if (awt->version >= JAWT_VERSION_9) { + awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame; + awt->SetBounds = awt_SetBounds; + awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation; + } } return JNI_TRUE; diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp index 05549673564..019295ac2b5 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -272,3 +272,47 @@ extern "C" JNIEXPORT void JNICALL DSUnlockAWT(JNIEnv* env) { // Do nothing on Windows } + +// EmbeddedFrame support + +static char *const embeddedClassName = "sun/awt/windows/WEmbeddedFrame"; + +JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame +(JNIEnv* env, void* platformInfo) +{ + static jmethodID mid = NULL; + static jclass cls; + if (mid == NULL) { + cls = env->FindClass(embeddedClassName); + CHECK_NULL_RETURN(cls, NULL); + mid = env->GetMethodID(cls, "", "(J)V"); + CHECK_NULL_RETURN(mid, NULL); + } + return env->NewObject(cls, mid, platformInfo); +} + +JNIEXPORT void JNICALL awt_SetBounds +(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = env->FindClass(embeddedClassName); + CHECK_NULL(cls); + mid = env->GetMethodID(cls, "setBoundsPrivate", "(IIII)V"); + CHECK_NULL(mid); + } + env->CallVoidMethod(embeddedFrame, mid, x, y, w, h); +} + +JNIEXPORT void JNICALL awt_SynthesizeWindowActivation +(JNIEnv *env, jobject embeddedFrame, jboolean doActivate) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = env->FindClass(embeddedClassName); + CHECK_NULL(cls); + mid = env->GetMethodID(cls, "synthesizeWindowActivation", "(Z)V"); + CHECK_NULL(mid); + } + env->CallVoidMethod(embeddedFrame, mid, doActivate); +} diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h index cd135b947e2..a2a510797e9 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -162,6 +162,16 @@ extern "C" { jobject JNICALL DSGetComponent( JNIEnv* env, void* platformInfo); + _JNI_IMPORT_OR_EXPORT_ jobject JNICALL + awt_CreateEmbeddedFrame(JNIEnv* env, void* platformInfo); + + _JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SetBounds(JNIEnv *env, jobject embeddedFrame, jint x, + jint y, jint w, jint h); + + _JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SynthesizeWindowActivation(JNIEnv *env, jobject embeddedFrame, + jboolean doActivate); #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp b/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp index 218b7dd0864..1393dfcf8f6 100644 --- a/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp +++ b/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -46,7 +46,9 @@ extern "C" JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) } if (awt->version != JAWT_VERSION_1_3 - && awt->version != JAWT_VERSION_1_4) { + && awt->version != JAWT_VERSION_1_4 + && awt->version != JAWT_VERSION_1_7 + && awt->version != JAWT_VERSION_9) { return JNI_FALSE; } @@ -56,6 +58,11 @@ extern "C" JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) awt->Lock = DSLockAWT; awt->Unlock = DSUnlockAWT; awt->GetComponent = DSGetComponent; + if (awt->version >= JAWT_VERSION_9) { + awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame; + awt->SetBounds = awt_SetBounds; + awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation; + } } return JNI_TRUE; From 67814435553f08f7aa30f69dfd4f16e116f66ce6 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 22 Aug 2016 01:35:40 +0300 Subject: [PATCH 010/296] 8164104: Cleanup of javaclient related mapfiles Reviewed-by: prr --- jdk/make/mapfiles/libawt/mapfile-mawt-vers | 478 ++++++++-------- jdk/make/mapfiles/libawt/mapfile-vers | 300 +++++----- jdk/make/mapfiles/libawt/mapfile-vers-linux | 521 +++++++++--------- .../mapfiles/libawt_headless/mapfile-vers | 147 +++-- jdk/make/mapfiles/libawt_xawt/mapfile-vers | 127 +++-- jdk/make/mapfiles/libjawt/mapfile-vers | 8 +- jdk/make/mapfiles/libjpeg/mapfile-vers | 48 +- jdk/make/mapfiles/libjsound/mapfile-vers | 112 ++-- jdk/make/mapfiles/libjsoundalsa/mapfile-vers | 106 ++-- .../mapfiles/libsplashscreen/mapfile-vers | 38 +- 10 files changed, 939 insertions(+), 946 deletions(-) diff --git a/jdk/make/mapfiles/libawt/mapfile-mawt-vers b/jdk/make/mapfiles/libawt/mapfile-mawt-vers index 32eb88df678..0200c499f79 100644 --- a/jdk/make/mapfiles/libawt/mapfile-mawt-vers +++ b/jdk/make/mapfiles/libawt/mapfile-mawt-vers @@ -22,263 +22,261 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -# Java_java_awt_KeyboardFocusManager_getGlobalHeavyweightFocusOwner; # Define public interface. # These are the libmawt exports. See mapfile-vers for the libawt exports SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; - Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; - Java_java_awt_AWTEvent_nativeSetSource; - Java_java_awt_Checkbox_initIDs; - Java_java_awt_Component_initIDs; - Java_java_awt_Dialog_initIDs; - Java_java_awt_Font_initIDs; - Java_java_awt_KeyboardFocusManager_initIDs; - Java_java_awt_Menu_initIDs; - Java_java_awt_MenuComponent_initIDs; - Java_java_awt_MenuItem_initIDs; - Java_java_awt_Scrollbar_initIDs; - Java_java_awt_ScrollPane_initIDs; - Java_java_awt_TextArea_initIDs; - Java_sun_awt_FontDescriptor_initIDs; - Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; - Java_sun_awt_UNIXToolkit_check_1gtk; - Java_sun_awt_UNIXToolkit_load_1gtk; - Java_sun_awt_UNIXToolkit_unload_1gtk; - Java_sun_awt_UNIXToolkit_load_1stock_1icon; - Java_sun_awt_UNIXToolkit_load_1gtk_1icon; - Java_sun_awt_UNIXToolkit_nativeSync; - Java_sun_awt_X11InputMethod_disposeXIC; - Java_sun_awt_X11InputMethod_isCompositionEnabledNative; - Java_sun_awt_X11InputMethod_resetXIC; - Java_sun_awt_X11InputMethod_setCompositionEnabledNative; - Java_sun_awt_X11InputMethod_turnoffStatusWindow; - Java_sun_awt_SunToolkit_closeSplashScreen; - Java_sun_awt_PlatformFont_initIDs; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_dispose; - Java_sun_awt_X11GraphicsConfig_pGetBounds; - Java_sun_awt_X11GraphicsConfig_getNumColors; - Java_sun_awt_X11GraphicsConfig_getXResolution; - Java_sun_awt_X11GraphicsConfig_getYResolution; - Java_sun_awt_X11GraphicsConfig_createBackBuffer; - Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; - Java_sun_awt_X11GraphicsConfig_swapBuffers; - Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; - Java_sun_awt_X11GraphicsDevice_isDBESupported; - Java_sun_awt_X11GraphicsDevice_getDisplay; - Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; - Java_sun_awt_X11GraphicsDevice_getNumConfigs; - Java_sun_awt_X11GraphicsDevice_initIDs; - Java_sun_awt_X11GraphicsDevice_initXrandrExtension; - Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; - Java_sun_awt_X11GraphicsDevice_enumDisplayModes; - Java_sun_awt_X11GraphicsDevice_configDisplayMode; - Java_sun_awt_X11GraphicsDevice_resetNativeData; - Java_sun_awt_X11GraphicsEnvironment_checkShmExt; - Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; - Java_sun_awt_X11GraphicsEnvironment_getDisplayString; - Java_sun_awt_X11GraphicsEnvironment_getNumScreens; - Java_sun_awt_X11GraphicsEnvironment_initDisplay; - Java_sun_awt_X11GraphicsEnvironment_initGLX; - Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; - Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; - Java_sun_awt_X11GraphicsEnvironment_initXRender; - Java_java_awt_AWTEvent_initIDs; - Java_java_awt_Button_initIDs; - Java_java_awt_Container_initIDs; - Java_java_awt_Cursor_finalizeImpl; - Java_java_awt_Cursor_initIDs; - Java_java_awt_Event_initIDs; - Java_java_awt_event_InputEvent_initIDs; - Java_java_awt_event_KeyEvent_initIDs; - Java_java_awt_FileDialog_initIDs; - Java_java_awt_Frame_initIDs; - Java_java_awt_Insets_initIDs; - Java_java_awt_TextField_initIDs; - Java_java_awt_Window_initIDs; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_initIDs; - Java_sun_awt_X11GraphicsConfig_makeColorModel; - Java_sun_awt_X11GraphicsDevice_getConfigVisualId; - Java_sun_awt_X11GraphicsDevice_getConfigColormap; - Java_sun_awt_X11GraphicsDevice_getConfigDepth; + Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; + Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; + Java_java_awt_AWTEvent_nativeSetSource; + Java_java_awt_Checkbox_initIDs; + Java_java_awt_Component_initIDs; + Java_java_awt_Dialog_initIDs; + Java_java_awt_Font_initIDs; + Java_java_awt_KeyboardFocusManager_initIDs; + Java_java_awt_Menu_initIDs; + Java_java_awt_MenuComponent_initIDs; + Java_java_awt_MenuItem_initIDs; + Java_java_awt_Scrollbar_initIDs; + Java_java_awt_ScrollPane_initIDs; + Java_java_awt_TextArea_initIDs; + Java_sun_awt_FontDescriptor_initIDs; + Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; + Java_sun_awt_UNIXToolkit_check_1gtk; + Java_sun_awt_UNIXToolkit_load_1gtk; + Java_sun_awt_UNIXToolkit_unload_1gtk; + Java_sun_awt_UNIXToolkit_load_1stock_1icon; + Java_sun_awt_UNIXToolkit_load_1gtk_1icon; + Java_sun_awt_UNIXToolkit_nativeSync; + Java_sun_awt_X11InputMethod_disposeXIC; + Java_sun_awt_X11InputMethod_isCompositionEnabledNative; + Java_sun_awt_X11InputMethod_resetXIC; + Java_sun_awt_X11InputMethod_setCompositionEnabledNative; + Java_sun_awt_X11InputMethod_turnoffStatusWindow; + Java_sun_awt_SunToolkit_closeSplashScreen; + Java_sun_awt_PlatformFont_initIDs; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_dispose; + Java_sun_awt_X11GraphicsConfig_pGetBounds; + Java_sun_awt_X11GraphicsConfig_getNumColors; + Java_sun_awt_X11GraphicsConfig_getXResolution; + Java_sun_awt_X11GraphicsConfig_getYResolution; + Java_sun_awt_X11GraphicsConfig_createBackBuffer; + Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; + Java_sun_awt_X11GraphicsConfig_swapBuffers; + Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; + Java_sun_awt_X11GraphicsDevice_isDBESupported; + Java_sun_awt_X11GraphicsDevice_getDisplay; + Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; + Java_sun_awt_X11GraphicsDevice_getNumConfigs; + Java_sun_awt_X11GraphicsDevice_initIDs; + Java_sun_awt_X11GraphicsDevice_initXrandrExtension; + Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; + Java_sun_awt_X11GraphicsDevice_enumDisplayModes; + Java_sun_awt_X11GraphicsDevice_configDisplayMode; + Java_sun_awt_X11GraphicsDevice_resetNativeData; + Java_sun_awt_X11GraphicsEnvironment_checkShmExt; + Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; + Java_sun_awt_X11GraphicsEnvironment_getDisplayString; + Java_sun_awt_X11GraphicsEnvironment_getNumScreens; + Java_sun_awt_X11GraphicsEnvironment_initDisplay; + Java_sun_awt_X11GraphicsEnvironment_initGLX; + Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; + Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; + Java_sun_awt_X11GraphicsEnvironment_initXRender; + Java_java_awt_AWTEvent_initIDs; + Java_java_awt_Button_initIDs; + Java_java_awt_Container_initIDs; + Java_java_awt_Cursor_finalizeImpl; + Java_java_awt_Cursor_initIDs; + Java_java_awt_Event_initIDs; + Java_java_awt_event_InputEvent_initIDs; + Java_java_awt_event_KeyEvent_initIDs; + Java_java_awt_FileDialog_initIDs; + Java_java_awt_Frame_initIDs; + Java_java_awt_Insets_initIDs; + Java_java_awt_TextField_initIDs; + Java_java_awt_Window_initIDs; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_initIDs; + Java_sun_awt_X11GraphicsConfig_makeColorModel; + Java_sun_awt_X11GraphicsDevice_getConfigVisualId; + Java_sun_awt_X11GraphicsDevice_getConfigColormap; + Java_sun_awt_X11GraphicsDevice_getConfigDepth; - Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; - Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask; - Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; - Java_sun_java2d_x11_X11Renderer_XFillSpans; - Java_sun_java2d_x11_X11Renderer_XDrawArc; - Java_sun_java2d_x11_X11Renderer_XDrawLine; - Java_sun_java2d_x11_X11Renderer_XDrawOval; - Java_sun_java2d_x11_X11Renderer_XDrawPoly; - Java_sun_java2d_x11_X11Renderer_XDrawRect; - Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; - Java_sun_java2d_x11_X11Renderer_XDoPath; - Java_sun_java2d_x11_X11Renderer_XFillArc; - Java_sun_java2d_x11_X11Renderer_XFillOval; - Java_sun_java2d_x11_X11Renderer_XFillPoly; - Java_sun_java2d_x11_X11Renderer_XFillRect; - Java_sun_java2d_x11_X11Renderer_XFillRoundRect; - Java_sun_java2d_x11_X11Renderer_devCopyArea; - Java_sun_java2d_x11_X11SurfaceData_initIDs; - Java_sun_java2d_x11_X11SurfaceData_initOps; - Java_sun_java2d_x11_X11SurfaceData_initSurface; - Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; - Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; - Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; - Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; - Java_sun_java2d_x11_X11SurfaceData_XSetForeground; + Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; + Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask; + Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; + Java_sun_java2d_x11_X11Renderer_XFillSpans; + Java_sun_java2d_x11_X11Renderer_XDrawArc; + Java_sun_java2d_x11_X11Renderer_XDrawLine; + Java_sun_java2d_x11_X11Renderer_XDrawOval; + Java_sun_java2d_x11_X11Renderer_XDrawPoly; + Java_sun_java2d_x11_X11Renderer_XDrawRect; + Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; + Java_sun_java2d_x11_X11Renderer_XDoPath; + Java_sun_java2d_x11_X11Renderer_XFillArc; + Java_sun_java2d_x11_X11Renderer_XFillOval; + Java_sun_java2d_x11_X11Renderer_XFillPoly; + Java_sun_java2d_x11_X11Renderer_XFillRect; + Java_sun_java2d_x11_X11Renderer_XFillRoundRect; + Java_sun_java2d_x11_X11Renderer_devCopyArea; + Java_sun_java2d_x11_X11SurfaceData_initIDs; + Java_sun_java2d_x11_X11SurfaceData_initOps; + Java_sun_java2d_x11_X11SurfaceData_initSurface; + Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; + Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; + Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; + Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; + Java_sun_java2d_x11_X11SurfaceData_XSetForeground; - Java_sun_java2d_x11_XSurfaceData_initOps; - Java_sun_java2d_x11_XSurfaceData_XCreateGC; - Java_sun_java2d_x11_XSurfaceData_XResetClip; - Java_sun_java2d_x11_XSurfaceData_XSetClip; - Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; - Java_sun_java2d_x11_XSurfaceData_isDrawableValid; - Java_sun_java2d_x11_XSurfaceData_setInvalid; - Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; - Java_sun_java2d_xr_XRSurfaceData_initXRPicture; - Java_sun_java2d_xr_XRSurfaceData_initIDs; - Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; - Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; - Java_sun_java2d_xr_XRBackendNative_initIDs; - Java_sun_java2d_xr_XIDGenerator_bufferXIDs; - Java_sun_java2d_xr_XRBackendNative_freeGC; - Java_sun_java2d_xr_XRBackendNative_createGC; - Java_sun_java2d_xr_XRBackendNative_createPixmap; - Java_sun_java2d_xr_XRBackendNative_createPictureNative; - Java_sun_java2d_xr_XRBackendNative_freePicture; - Java_sun_java2d_xr_XRBackendNative_freePixmap; - Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; - Java_sun_java2d_xr_XRBackendNative_setGCExposures; - Java_sun_java2d_xr_XRBackendNative_setGCForeground; - Java_sun_java2d_xr_XRBackendNative_copyArea; - Java_sun_java2d_xr_XRBackendNative_renderComposite; - Java_sun_java2d_xr_XRBackendNative_renderRectangle; - Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; - Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_setFilter; - Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; - Java_sun_java2d_xr_XRBackendNative_putMaskNative; - Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; - Java_sun_java2d_xr_XRBackendNative_setGCMode; - Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; - Java_sun_java2d_xr_XRUtils_initFormatPtrs; - Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; - XRT_DrawGlyphList; + Java_sun_java2d_x11_XSurfaceData_initOps; + Java_sun_java2d_x11_XSurfaceData_XCreateGC; + Java_sun_java2d_x11_XSurfaceData_XResetClip; + Java_sun_java2d_x11_XSurfaceData_XSetClip; + Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; + Java_sun_java2d_x11_XSurfaceData_isDrawableValid; + Java_sun_java2d_x11_XSurfaceData_setInvalid; + Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; + Java_sun_java2d_xr_XRSurfaceData_initXRPicture; + Java_sun_java2d_xr_XRSurfaceData_initIDs; + Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; + Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; + Java_sun_java2d_xr_XRBackendNative_initIDs; + Java_sun_java2d_xr_XIDGenerator_bufferXIDs; + Java_sun_java2d_xr_XRBackendNative_freeGC; + Java_sun_java2d_xr_XRBackendNative_createGC; + Java_sun_java2d_xr_XRBackendNative_createPixmap; + Java_sun_java2d_xr_XRBackendNative_createPictureNative; + Java_sun_java2d_xr_XRBackendNative_freePicture; + Java_sun_java2d_xr_XRBackendNative_freePixmap; + Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; + Java_sun_java2d_xr_XRBackendNative_setGCExposures; + Java_sun_java2d_xr_XRBackendNative_setGCForeground; + Java_sun_java2d_xr_XRBackendNative_copyArea; + Java_sun_java2d_xr_XRBackendNative_renderComposite; + Java_sun_java2d_xr_XRBackendNative_renderRectangle; + Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; + Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_setFilter; + Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; + Java_sun_java2d_xr_XRBackendNative_putMaskNative; + Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; + Java_sun_java2d_xr_XRBackendNative_setGCMode; + Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; + Java_sun_java2d_xr_XRUtils_initFormatPtrs; + Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; + XRT_DrawGlyphList; - Java_sun_java2d_opengl_OGLContext_getOGLIdString; - Java_sun_java2d_opengl_OGLMaskFill_maskFill; - Java_sun_java2d_opengl_OGLRenderer_drawPoly; - Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer; - Java_sun_java2d_opengl_OGLSurfaceData_initTexture; - Java_sun_java2d_opengl_OGLSurfaceData_initFBObject; - Java_sun_java2d_opengl_OGLSurfaceData_initFlipBackbuffer; - Java_sun_java2d_opengl_OGLSurfaceData_getTextureID; - Java_sun_java2d_opengl_OGLSurfaceData_getTextureTarget; - Java_sun_java2d_opengl_OGLTextRenderer_drawGlyphList; - Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo; - Java_sun_java2d_opengl_GLXGraphicsConfig_initConfig; - Java_sun_java2d_opengl_GLXGraphicsConfig_getOGLCapabilities; - Java_sun_java2d_opengl_GLXSurfaceData_initOps; + Java_sun_java2d_opengl_OGLContext_getOGLIdString; + Java_sun_java2d_opengl_OGLMaskFill_maskFill; + Java_sun_java2d_opengl_OGLRenderer_drawPoly; + Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer; + Java_sun_java2d_opengl_OGLSurfaceData_initTexture; + Java_sun_java2d_opengl_OGLSurfaceData_initFBObject; + Java_sun_java2d_opengl_OGLSurfaceData_initFlipBackbuffer; + Java_sun_java2d_opengl_OGLSurfaceData_getTextureID; + Java_sun_java2d_opengl_OGLSurfaceData_getTextureTarget; + Java_sun_java2d_opengl_OGLTextRenderer_drawGlyphList; + Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo; + Java_sun_java2d_opengl_GLXGraphicsConfig_initConfig; + Java_sun_java2d_opengl_GLXGraphicsConfig_getOGLCapabilities; + Java_sun_java2d_opengl_GLXSurfaceData_initOps; - Java_sun_print_CUPSPrinter_initIDs; - Java_sun_print_CUPSPrinter_getCupsServer; - Java_sun_print_CUPSPrinter_getCupsPort; - Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; - Java_sun_print_CUPSPrinter_canConnect; - Java_sun_print_CUPSPrinter_getMedia; - Java_sun_print_CUPSPrinter_getPageSizes; - Java_sun_print_CUPSPrinter_getResolutions; + Java_sun_print_CUPSPrinter_initIDs; + Java_sun_print_CUPSPrinter_getCupsServer; + Java_sun_print_CUPSPrinter_getCupsPort; + Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; + Java_sun_print_CUPSPrinter_canConnect; + Java_sun_print_CUPSPrinter_getMedia; + Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box_1gap; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1check; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1expander; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1extension; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1flat_1box; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1focus; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1handle; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1hline; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1option; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1shadow; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1slider; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1vline; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1background; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1switch_1theme; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1get_1gtk_1setting; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeSetRangeValue; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetXThickness; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetYThickness; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetColorForState; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box_1gap; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1check; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1expander; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1extension; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1flat_1box; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1focus; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1handle; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1hline; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1option; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1shadow; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1slider; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1vline; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1background; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1switch_1theme; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1get_1gtk_1setting; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeSetRangeValue; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetXThickness; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetYThickness; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetColorForState; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName; - awt_display; - awt_Lock; - awt_Unlock; - awt_GetDrawingSurface; - awt_FreeDrawingSurface; - awt_GetComponent; + awt_display; + awt_Lock; + awt_Unlock; + awt_GetDrawingSurface; + awt_FreeDrawingSurface; + awt_GetComponent; awt_CreateEmbeddedFrame; awt_SetBounds; awt_SynthesizeWindowActivation; + X11SurfaceData_GetOps; + getDefaultConfig; + Java_sun_font_FontConfigManager_getFontConfig; + Java_sun_font_FontConfigManager_getFontConfigAASettings; + Java_sun_awt_FcFontManager_getFontPathNative; + Java_sun_font_SunFontManager_populateFontFileNameMap; - X11SurfaceData_GetOps; - getDefaultConfig; - Java_sun_font_FontConfigManager_getFontConfig; - Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_FcFontManager_getFontPathNative; - Java_sun_font_SunFontManager_populateFontFileNameMap; + # CDE private entry point + Java_sun_awt_motif_XsessionWMcommand; + Java_sun_awt_motif_XsessionWMcommand_New; - # CDE private entry point - Java_sun_awt_motif_XsessionWMcommand; - Java_sun_awt_motif_XsessionWMcommand_New; + # libfontmanager entry points + AWTIsHeadless; + AWTCountFonts; + AWTLoadFont; + AWTFreeFont; + AWTFontAscent; + AWTFontDescent; + AWTFontMinByte1; + AWTFontMaxByte1; + AWTFontMinCharOrByte2; + AWTFontMaxCharOrByte2; + AWTFontDefaultChar; + AWTFontPerChar; + AWTFontMaxBounds; + AWTFontTextExtents16; + AWTFreeChar; + AWTFontGenerateImage; + AWTCharAdvance; + AWTCharLBearing; + AWTCharRBearing; + AWTCharAscent; + AWTCharDescent; + AWTDrawGlyphList; + AccelGlyphCache_RemoveAllCellInfos; - # libfontmanager entry points - AWTIsHeadless; - AWTCountFonts; - AWTLoadFont; - AWTFreeFont; - AWTFontAscent; - AWTFontDescent; - AWTFontMinByte1; - AWTFontMaxByte1; - AWTFontMinCharOrByte2; - AWTFontMaxCharOrByte2; - AWTFontDefaultChar; - AWTFontPerChar; - AWTFontMaxBounds; - AWTFontTextExtents16; - AWTFreeChar; - AWTFontGenerateImage; - AWTCharAdvance; - AWTCharLBearing; - AWTCharRBearing; - AWTCharAscent; - AWTCharDescent; - AWTDrawGlyphList; - AccelGlyphCache_RemoveAllCellInfos; - - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt/mapfile-vers b/jdk/make/mapfiles/libawt/mapfile-vers index 4624977e75c..9d8a34d3f37 100644 --- a/jdk/make/mapfiles/libawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt/mapfile-vers @@ -27,163 +27,163 @@ # These are the libawt exports, mapfile-mawt-vers contains the libmawt exports. SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_java_awt_CheckboxMenuItem_initIDs; - Java_java_awt_Color_initIDs; - Java_java_awt_FontMetrics_initIDs; - Java_java_awt_image_BufferedImage_initIDs; - Java_sun_awt_image_DataBufferNative_getElem; - Java_sun_awt_image_DataBufferNative_setElem; - Java_java_awt_image_ColorModel_initIDs; - Java_java_awt_image_IndexColorModel_initIDs; - Java_java_awt_image_Kernel_initIDs; - Java_java_awt_image_Raster_initIDs; - Java_java_awt_image_SampleModel_initIDs; - Java_java_awt_Label_initIDs; - Java_java_awt_MenuBar_initIDs; - Java_java_awt_ScrollPaneAdjustable_initIDs; - Java_java_awt_Toolkit_initIDs; - Java_sun_awt_DebugSettings_setCTracingOn__Z; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; - Java_sun_awt_image_ByteComponentRaster_initIDs; - Java_sun_awt_image_GifImageDecoder_initIDs; - Java_sun_awt_image_GifImageDecoder_parseImage; - Java_sun_awt_image_ImageRepresentation_initIDs; - Java_sun_awt_image_ImageRepresentation_setDiffICM; - Java_sun_awt_image_ImageRepresentation_setICMpixels; - Java_sun_awt_image_ImagingLib_convolveBI; - Java_sun_awt_image_ImagingLib_convolveRaster; - Java_sun_awt_image_ImagingLib_init; - Java_sun_awt_image_ImagingLib_transformBI; - Java_sun_awt_image_ImagingLib_transformRaster; - Java_sun_awt_image_IntegerComponentRaster_initIDs; - Java_sun_awt_image_ShortComponentRaster_initIDs; - Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile; - Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; - Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; - Java_sun_java2d_pipe_SpanClipRenderer_fillTile; - Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; - Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; - Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; - Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_closePath; - Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; - Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; - Java_sun_java2d_pipe_ShapeSpanIterator_dispose; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; - Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; - Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; - Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; - Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; - Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; - Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; - Java_sun_java2d_pipe_ShapeSpanIterator_setRule; - Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; + Java_java_awt_CheckboxMenuItem_initIDs; + Java_java_awt_Color_initIDs; + Java_java_awt_FontMetrics_initIDs; + Java_java_awt_image_BufferedImage_initIDs; + Java_sun_awt_image_DataBufferNative_getElem; + Java_sun_awt_image_DataBufferNative_setElem; + Java_java_awt_image_ColorModel_initIDs; + Java_java_awt_image_IndexColorModel_initIDs; + Java_java_awt_image_Kernel_initIDs; + Java_java_awt_image_Raster_initIDs; + Java_java_awt_image_SampleModel_initIDs; + Java_java_awt_Label_initIDs; + Java_java_awt_MenuBar_initIDs; + Java_java_awt_ScrollPaneAdjustable_initIDs; + Java_java_awt_Toolkit_initIDs; + Java_sun_awt_DebugSettings_setCTracingOn__Z; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; + Java_sun_awt_image_ByteComponentRaster_initIDs; + Java_sun_awt_image_GifImageDecoder_initIDs; + Java_sun_awt_image_GifImageDecoder_parseImage; + Java_sun_awt_image_ImageRepresentation_initIDs; + Java_sun_awt_image_ImageRepresentation_setDiffICM; + Java_sun_awt_image_ImageRepresentation_setICMpixels; + Java_sun_awt_image_ImagingLib_convolveBI; + Java_sun_awt_image_ImagingLib_convolveRaster; + Java_sun_awt_image_ImagingLib_init; + Java_sun_awt_image_ImagingLib_transformBI; + Java_sun_awt_image_ImagingLib_transformRaster; + Java_sun_awt_image_IntegerComponentRaster_initIDs; + Java_sun_awt_image_ShortComponentRaster_initIDs; + Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile; + Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; + Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; + Java_sun_java2d_pipe_SpanClipRenderer_fillTile; + Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; + Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; + Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; + Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_closePath; + Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; + Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; + Java_sun_java2d_pipe_ShapeSpanIterator_dispose; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; + Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; + Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; + Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; + Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; + Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; + Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; + Java_sun_java2d_pipe_ShapeSpanIterator_setRule; + Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; - Java_java_awt_Choice_initIDs; - Java_java_awt_Dimension_initIDs; - Java_java_awt_event_MouseEvent_initIDs; - Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; - Java_java_awt_Rectangle_initIDs; - Java_sun_awt_image_BufImgSurfaceData_initIDs; - Java_sun_awt_image_BufImgSurfaceData_initRaster; - Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; - Java_sun_awt_image_BytePackedRaster_initIDs; - Java_sun_awt_image_ImagingLib_lookupByteBI; - Java_sun_awt_image_ImagingLib_lookupByteRaster; - Java_sun_java2d_SurfaceData_initIDs; - Java_sun_java2d_SurfaceData_isOpaqueGray; - Java_sun_java2d_Disposer_initIDs; - Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; - Java_sun_java2d_loops_BlitBg_BlitBg; - Java_sun_java2d_loops_Blit_Blit; - Java_sun_java2d_loops_ScaledBlit_Scale; - Java_sun_java2d_loops_DrawLine_DrawLine; - Java_sun_java2d_loops_DrawPolygons_DrawPolygons; - Java_sun_java2d_loops_DrawPath_DrawPath; - Java_sun_java2d_loops_FillPath_FillPath; + Java_java_awt_Choice_initIDs; + Java_java_awt_Dimension_initIDs; + Java_java_awt_event_MouseEvent_initIDs; + Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; + Java_java_awt_Rectangle_initIDs; + Java_sun_awt_image_BufImgSurfaceData_initIDs; + Java_sun_awt_image_BufImgSurfaceData_initRaster; + Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; + Java_sun_awt_image_BytePackedRaster_initIDs; + Java_sun_awt_image_ImagingLib_lookupByteBI; + Java_sun_awt_image_ImagingLib_lookupByteRaster; + Java_sun_java2d_SurfaceData_initIDs; + Java_sun_java2d_SurfaceData_isOpaqueGray; + Java_sun_java2d_Disposer_initIDs; + Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; + Java_sun_java2d_loops_BlitBg_BlitBg; + Java_sun_java2d_loops_Blit_Blit; + Java_sun_java2d_loops_ScaledBlit_Scale; + Java_sun_java2d_loops_DrawLine_DrawLine; + Java_sun_java2d_loops_DrawPolygons_DrawPolygons; + Java_sun_java2d_loops_DrawPath_DrawPath; + Java_sun_java2d_loops_FillPath_FillPath; - Java_sun_java2d_loops_DrawRect_DrawRect; - Java_sun_java2d_loops_FillRect_FillRect; - Java_sun_java2d_loops_FillSpans_FillSpans; - Java_sun_java2d_loops_FillParallelogram_FillParallelogram; - Java_sun_java2d_loops_DrawParallelogram_DrawParallelogram; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; - Java_sun_java2d_loops_MaskBlit_MaskBlit; - Java_sun_java2d_loops_MaskFill_MaskFill; - Java_sun_java2d_loops_MaskFill_FillAAPgram; - Java_sun_java2d_loops_MaskFill_DrawAAPgram; - Java_sun_java2d_loops_TransformHelper_Transform; - Java_sun_java2d_pipe_Region_initIDs; - Java_sun_java2d_pipe_SpanClipRenderer_initIDs; - sun_awt_image_GifImageDecoder_initIDs; + Java_sun_java2d_loops_DrawRect_DrawRect; + Java_sun_java2d_loops_FillRect_FillRect; + Java_sun_java2d_loops_FillSpans_FillSpans; + Java_sun_java2d_loops_FillParallelogram_FillParallelogram; + Java_sun_java2d_loops_DrawParallelogram_DrawParallelogram; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; + Java_sun_java2d_loops_MaskBlit_MaskBlit; + Java_sun_java2d_loops_MaskFill_MaskFill; + Java_sun_java2d_loops_MaskFill_FillAAPgram; + Java_sun_java2d_loops_MaskFill_DrawAAPgram; + Java_sun_java2d_loops_TransformHelper_Transform; + Java_sun_java2d_pipe_Region_initIDs; + Java_sun_java2d_pipe_SpanClipRenderer_initIDs; + sun_awt_image_GifImageDecoder_initIDs; - # libmawt entry points - SurfaceData_InitOps; - SurfaceData_ThrowInvalidPipeException; - SurfaceData_IntersectBlitBounds; - SurfaceData_IntersectBoundsXYXY; - Region_GetBounds; - Region_GetInfo; - Region_StartIteration; - Region_CountIterationRects; - Region_NextIteration; - Region_EndIteration; - RegionToYXBandedRectangles; - GrPrim_CompGetXorInfo; - GrPrim_CompGetAlphaInfo; - J2dTraceImpl; - J2dTraceInit; - img_makePalette; - initInverseGrayLut; - make_dither_arrays; - make_uns_ordered_dither_array; + # libmawt entry points + SurfaceData_InitOps; + SurfaceData_ThrowInvalidPipeException; + SurfaceData_IntersectBlitBounds; + SurfaceData_IntersectBoundsXYXY; + Region_GetBounds; + Region_GetInfo; + Region_StartIteration; + Region_CountIterationRects; + Region_NextIteration; + Region_EndIteration; + RegionToYXBandedRectangles; + GrPrim_CompGetXorInfo; + GrPrim_CompGetAlphaInfo; + J2dTraceImpl; + J2dTraceInit; + img_makePalette; + initInverseGrayLut; + make_dither_arrays; + make_uns_ordered_dither_array; - # variables exported to libmawt - std_img_oda_red; - std_img_oda_blue; - std_img_oda_green; - std_odas_computed; - g_CMpDataID; - colorValueID; - mul8table; - div8table; - jvm; + # variables exported to libmawt + std_img_oda_red; + std_img_oda_blue; + std_img_oda_green; + std_odas_computed; + g_CMpDataID; + colorValueID; + mul8table; + div8table; + jvm; - # ProcessPath entry points and data - doDrawPath; - doFillPath; - path2DNumTypesID; - path2DTypesID; - path2DWindingRuleID; - path2DFloatCoordsID; - sg2dStrokeHintID; - sunHints_INTVAL_STROKE_PURE; + # ProcessPath entry points and data + doDrawPath; + doFillPath; + path2DNumTypesID; + path2DTypesID; + path2DWindingRuleID; + path2DFloatCoordsID; + sg2dStrokeHintID; + sunHints_INTVAL_STROKE_PURE; - # CDE private entry points - # These are in awt_LoadLibrary.c and falls through to libmawt. - # Evidently CDE needs this for backward compatability. - Java_sun_awt_motif_XsessionWMcommand; - Java_sun_awt_motif_XsessionWMcommand_New; + # CDE private entry points + # These are in awt_LoadLibrary.c and falls through to libmawt. + # Evidently CDE needs this for backward compatability. + Java_sun_awt_motif_XsessionWMcommand; + Java_sun_awt_motif_XsessionWMcommand_New; - # libfontmanager entry points - AWTIsHeadless; - GrPrim_Sg2dGetCompInfo; - GrPrim_Sg2dGetClip; - GetNativePrim; - SurfaceData_IntersectBounds; - SurfaceData_GetOps; - Disposer_AddRecord; - GrPrim_Sg2dGetEaRGB; - GrPrim_Sg2dGetPixel; - GrPrim_Sg2dGetLCDTextContrast; + # libfontmanager entry points + AWTIsHeadless; + GrPrim_Sg2dGetCompInfo; + GrPrim_Sg2dGetClip; + GetNativePrim; + SurfaceData_IntersectBounds; + SurfaceData_GetOps; + Disposer_AddRecord; + GrPrim_Sg2dGetEaRGB; + GrPrim_Sg2dGetPixel; + GrPrim_Sg2dGetLCDTextContrast; - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt/mapfile-vers-linux b/jdk/make/mapfiles/libawt/mapfile-vers-linux index a1f8d9b6e0e..90e12f075b1 100644 --- a/jdk/make/mapfiles/libawt/mapfile-vers-linux +++ b/jdk/make/mapfiles/libawt/mapfile-vers-linux @@ -27,281 +27,278 @@ # Linux port does not use mawt, all public symbols are in libawt.so SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_java_awt_CheckboxMenuItem_initIDs; - Java_java_awt_Color_initIDs; - Java_java_awt_FontMetrics_initIDs; - Java_java_awt_image_BufferedImage_initIDs; - Java_sun_awt_image_DataBufferNative_getElem; - Java_sun_awt_image_DataBufferNative_setElem; - Java_java_awt_image_ColorModel_initIDs; - Java_java_awt_image_IndexColorModel_initIDs; - Java_java_awt_image_Kernel_initIDs; - Java_java_awt_image_Raster_initIDs; - Java_java_awt_image_SampleModel_initIDs; - Java_java_awt_Label_initIDs; - Java_java_awt_MenuBar_initIDs; - Java_java_awt_ScrollPaneAdjustable_initIDs; - Java_java_awt_Toolkit_initIDs; - Java_java_awt_TrayIcon_initIDs; - Java_sun_awt_DebugSettings_setCTracingOn__Z; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; - Java_sun_awt_image_ByteComponentRaster_initIDs; - Java_sun_awt_image_GifImageDecoder_initIDs; - Java_sun_awt_image_GifImageDecoder_parseImage; - Java_sun_awt_image_Image_initIDs; - Java_sun_awt_image_ImageRepresentation_initIDs; - Java_sun_awt_image_ImageRepresentation_setDiffICM; - Java_sun_awt_image_ImageRepresentation_setICMpixels; - Java_sun_awt_image_ImagingLib_convolveBI; - Java_sun_awt_image_ImagingLib_convolveRaster; - Java_sun_awt_image_ImagingLib_init; - Java_sun_awt_image_ImagingLib_transformBI; - Java_sun_awt_image_ImagingLib_transformRaster; - Java_sun_awt_image_IntegerComponentRaster_initIDs; - Java_sun_awt_image_ShortComponentRaster_initIDs; - Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; - Java_sun_java2d_pipe_SpanClipRenderer_fillTile; - Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; - Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; - Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; - Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_closePath; - Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; - Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; - Java_sun_java2d_pipe_ShapeSpanIterator_dispose; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; - Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; - Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; - Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; - Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; - Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; - Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; - Java_sun_java2d_pipe_ShapeSpanIterator_setRule; - Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; + Java_java_awt_CheckboxMenuItem_initIDs; + Java_java_awt_Color_initIDs; + Java_java_awt_FontMetrics_initIDs; + Java_java_awt_image_BufferedImage_initIDs; + Java_sun_awt_image_DataBufferNative_getElem; + Java_sun_awt_image_DataBufferNative_setElem; + Java_java_awt_image_ColorModel_initIDs; + Java_java_awt_image_IndexColorModel_initIDs; + Java_java_awt_image_Kernel_initIDs; + Java_java_awt_image_Raster_initIDs; + Java_java_awt_image_SampleModel_initIDs; + Java_java_awt_Label_initIDs; + Java_java_awt_MenuBar_initIDs; + Java_java_awt_ScrollPaneAdjustable_initIDs; + Java_java_awt_Toolkit_initIDs; + Java_java_awt_TrayIcon_initIDs; + Java_sun_awt_DebugSettings_setCTracingOn__Z; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; + Java_sun_awt_image_ByteComponentRaster_initIDs; + Java_sun_awt_image_GifImageDecoder_initIDs; + Java_sun_awt_image_GifImageDecoder_parseImage; + Java_sun_awt_image_Image_initIDs; + Java_sun_awt_image_ImageRepresentation_initIDs; + Java_sun_awt_image_ImageRepresentation_setDiffICM; + Java_sun_awt_image_ImageRepresentation_setICMpixels; + Java_sun_awt_image_ImagingLib_convolveBI; + Java_sun_awt_image_ImagingLib_convolveRaster; + Java_sun_awt_image_ImagingLib_init; + Java_sun_awt_image_ImagingLib_transformBI; + Java_sun_awt_image_ImagingLib_transformRaster; + Java_sun_awt_image_IntegerComponentRaster_initIDs; + Java_sun_awt_image_ShortComponentRaster_initIDs; + Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; + Java_sun_java2d_pipe_SpanClipRenderer_fillTile; + Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; + Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; + Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; + Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_closePath; + Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; + Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; + Java_sun_java2d_pipe_ShapeSpanIterator_dispose; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; + Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; + Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; + Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; + Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; + Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; + Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; + Java_sun_java2d_pipe_ShapeSpanIterator_setRule; + Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; - Java_java_awt_Choice_initIDs; - Java_java_awt_Dimension_initIDs; - Java_java_awt_event_MouseEvent_initIDs; - Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; - Java_java_awt_Rectangle_initIDs; - Java_sun_awt_image_BufImgSurfaceData_getSurfaceData; - Java_sun_awt_image_BufImgSurfaceData_initIDs; - Java_sun_awt_image_BufImgSurfaceData_initRaster; - Java_sun_awt_image_BufImgSurfaceData_setSurfaceData; - Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; - Java_sun_awt_image_BytePackedRaster_initIDs; - Java_sun_awt_image_ImagingLib_lookupByteBI; - Java_sun_awt_image_ImagingLib_lookupByteRaster; - Java_sun_java2d_SurfaceData_initIDs; - Java_sun_java2d_SurfaceData_isOpaqueGray; - Java_sun_java2d_Disposer_initIDs; - Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; - Java_sun_java2d_loops_BlitBg_BlitBg; - Java_sun_java2d_loops_Blit_Blit; - Java_sun_java2d_loops_ScaledBlit_Scale; - Java_sun_java2d_loops_DrawLine_DrawLine; - Java_sun_java2d_loops_DrawPolygons_DrawPolygons; - Java_sun_java2d_loops_DrawRect_DrawRect; - Java_sun_java2d_loops_FillRect_FillRect; - Java_sun_java2d_loops_FillSpans_FillSpans; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; - Java_sun_java2d_loops_MaskBlit_MaskBlit; - Java_sun_java2d_loops_MaskFill_MaskFill; - Java_sun_java2d_loops_MaskFill_FillAAPgram; - Java_sun_java2d_loops_MaskFill_DrawAAPgram; - Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; - Java_sun_java2d_pipe_SpanClipRenderer_initIDs; - sun_awt_image_GifImageDecoder_initIDs; + Java_java_awt_Choice_initIDs; + Java_java_awt_Dimension_initIDs; + Java_java_awt_event_MouseEvent_initIDs; + Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; + Java_java_awt_Rectangle_initIDs; + Java_sun_awt_image_BufImgSurfaceData_getSurfaceData; + Java_sun_awt_image_BufImgSurfaceData_initIDs; + Java_sun_awt_image_BufImgSurfaceData_initRaster; + Java_sun_awt_image_BufImgSurfaceData_setSurfaceData; + Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; + Java_sun_awt_image_BytePackedRaster_initIDs; + Java_sun_awt_image_ImagingLib_lookupByteBI; + Java_sun_awt_image_ImagingLib_lookupByteRaster; + Java_sun_java2d_SurfaceData_initIDs; + Java_sun_java2d_SurfaceData_isOpaqueGray; + Java_sun_java2d_Disposer_initIDs; + Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; + Java_sun_java2d_loops_BlitBg_BlitBg; + Java_sun_java2d_loops_Blit_Blit; + Java_sun_java2d_loops_ScaledBlit_Scale; + Java_sun_java2d_loops_DrawLine_DrawLine; + Java_sun_java2d_loops_DrawPolygons_DrawPolygons; + Java_sun_java2d_loops_DrawRect_DrawRect; + Java_sun_java2d_loops_FillRect_FillRect; + Java_sun_java2d_loops_FillSpans_FillSpans; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; + Java_sun_java2d_loops_MaskBlit_MaskBlit; + Java_sun_java2d_loops_MaskFill_MaskFill; + Java_sun_java2d_loops_MaskFill_FillAAPgram; + Java_sun_java2d_loops_MaskFill_DrawAAPgram; + Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; + Java_sun_java2d_pipe_SpanClipRenderer_initIDs; + sun_awt_image_GifImageDecoder_initIDs; - # libmawt entry points - SurfaceData_InitOps; - SurfaceData_ThrowInvalidPipeException; - Region_GetBounds; - Region_GetInfo; - Region_StartIteration; - Region_CountIterationRects; - Region_NextIteration; - Region_EndIteration; - GrPrim_CompGetXorInfo; - GrPrim_CompGetAlphaInfo; - img_makePalette; - initInverseGrayLut; - make_dither_arrays; - make_uns_ordered_dither_array; + # libmawt entry points + SurfaceData_InitOps; + SurfaceData_ThrowInvalidPipeException; + Region_GetBounds; + Region_GetInfo; + Region_StartIteration; + Region_CountIterationRects; + Region_NextIteration; + Region_EndIteration; + GrPrim_CompGetXorInfo; + GrPrim_CompGetAlphaInfo; + img_makePalette; + initInverseGrayLut; + make_dither_arrays; + make_uns_ordered_dither_array; - # variables exported to libmawt - std_img_oda_red; - std_img_oda_blue; - std_img_oda_green; - std_odas_computed; - g_CMpDataID; - colorValueID; - jvm; + # variables exported to libmawt + std_img_oda_red; + std_img_oda_blue; + std_img_oda_green; + std_odas_computed; + g_CMpDataID; + colorValueID; + jvm; - # CDE private entry point - # This is in awt_LoadLibrary.c and falls through to libmawt. - # Evidently CDE needs this for backward compatability. - Java_sun_awt_motif_XsessionWMcommand; + # CDE private entry point + # This is in awt_LoadLibrary.c and falls through to libmawt. + # Evidently CDE needs this for backward compatability. + Java_sun_awt_motif_XsessionWMcommand; - # libfontmanager entry points - AWTIsHeadless; - GrPrim_Sg2dGetCompInfo; - GrPrim_Sg2dGetClip; - GetNativePrim; - SurfaceData_IntersectBounds; - SurfaceData_GetOps; - Disposer_AddRecord; - GrPrim_Sg2dGetEaRGB; - GrPrim_Sg2dGetPixel; - GrPrim_Sg2dGetLCDTextContrast; + # libfontmanager entry points + AWTIsHeadless; + GrPrim_Sg2dGetCompInfo; + GrPrim_Sg2dGetClip; + GetNativePrim; + SurfaceData_IntersectBounds; + SurfaceData_GetOps; + Disposer_AddRecord; + GrPrim_Sg2dGetEaRGB; + GrPrim_Sg2dGetPixel; + GrPrim_Sg2dGetLCDTextContrast; - Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; - Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; - Java_java_awt_AWTEvent_nativeSetSource; - Java_java_awt_Checkbox_initIDs; - Java_java_awt_Component_initIDs; - Java_java_awt_Dialog_initIDs; - Java_java_awt_Font_initIDs; - Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; - Java_java_awt_KeyboardFocusManager_initIDs; - Java_java_awt_Menu_initIDs; - Java_java_awt_MenuComponent_initIDs; - Java_java_awt_MenuItem_initIDs; - Java_java_awt_Scrollbar_initIDs; - Java_java_awt_ScrollPane_initIDs; - Java_java_awt_TextArea_initIDs; - Java_sun_awt_FontDescriptor_initIDs; - Java_sun_awt_X11InputMethod_disposeXIC; - Java_sun_awt_X11InputMethod_isCompositionEnabledNative; - Java_sun_awt_X11InputMethod_resetXIC; - Java_sun_awt_X11InputMethod_setCompositionEnabledNative; - Java_sun_awt_X11InputMethod_turnoffStatusWindow; - Java_sun_awt_SunToolkit_closeSplashScreen; - Java_sun_awt_PlatformFont_initIDs; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_dispose; - Java_sun_awt_X11GraphicsConfig_pGetBounds; - Java_sun_awt_X11GraphicsConfig_getNumColors; - Java_sun_awt_X11GraphicsConfig_getXResolution; - Java_sun_awt_X11GraphicsConfig_getYResolution; - Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; - Java_sun_awt_X11GraphicsDevice_isDBESupported; - Java_sun_awt_X11GraphicsDevice_getDisplay; - Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; - Java_sun_awt_X11GraphicsDevice_getNumConfigs; - Java_sun_awt_X11GraphicsDevice_initIDs; - Java_sun_awt_X11GraphicsDevice_initXrandrExtension; - Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; - Java_sun_awt_X11GraphicsDevice_enumDisplayModes; - Java_sun_awt_X11GraphicsDevice_configDisplayMode; - Java_sun_awt_X11GraphicsDevice_resetNativeData; - Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor; - Java_sun_awt_X11GraphicsEnvironment_checkShmExt; - Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; - Java_sun_awt_X11GraphicsEnvironment_getDisplayString; - Java_sun_awt_X11GraphicsEnvironment_getNumScreens; - Java_sun_awt_X11GraphicsEnvironment_initDisplay; - Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; - Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; - Java_sun_awt_X11GraphicsEnvironment_initXRender; + Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; + Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; + Java_java_awt_AWTEvent_nativeSetSource; + Java_java_awt_Checkbox_initIDs; + Java_java_awt_Component_initIDs; + Java_java_awt_Dialog_initIDs; + Java_java_awt_Font_initIDs; + Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; + Java_java_awt_KeyboardFocusManager_initIDs; + Java_java_awt_Menu_initIDs; + Java_java_awt_MenuComponent_initIDs; + Java_java_awt_MenuItem_initIDs; + Java_java_awt_Scrollbar_initIDs; + Java_java_awt_ScrollPane_initIDs; + Java_java_awt_TextArea_initIDs; + Java_sun_awt_FontDescriptor_initIDs; + Java_sun_awt_X11InputMethod_disposeXIC; + Java_sun_awt_X11InputMethod_isCompositionEnabledNative; + Java_sun_awt_X11InputMethod_resetXIC; + Java_sun_awt_X11InputMethod_setCompositionEnabledNative; + Java_sun_awt_X11InputMethod_turnoffStatusWindow; + Java_sun_awt_SunToolkit_closeSplashScreen; + Java_sun_awt_PlatformFont_initIDs; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_dispose; + Java_sun_awt_X11GraphicsConfig_pGetBounds; + Java_sun_awt_X11GraphicsConfig_getNumColors; + Java_sun_awt_X11GraphicsConfig_getXResolution; + Java_sun_awt_X11GraphicsConfig_getYResolution; + Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; + Java_sun_awt_X11GraphicsDevice_isDBESupported; + Java_sun_awt_X11GraphicsDevice_getDisplay; + Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; + Java_sun_awt_X11GraphicsDevice_getNumConfigs; + Java_sun_awt_X11GraphicsDevice_initIDs; + Java_sun_awt_X11GraphicsDevice_initXrandrExtension; + Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; + Java_sun_awt_X11GraphicsDevice_enumDisplayModes; + Java_sun_awt_X11GraphicsDevice_configDisplayMode; + Java_sun_awt_X11GraphicsDevice_resetNativeData; + Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor; + Java_sun_awt_X11GraphicsEnvironment_checkShmExt; + Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; + Java_sun_awt_X11GraphicsEnvironment_getDisplayString; + Java_sun_awt_X11GraphicsEnvironment_getNumScreens; + Java_sun_awt_X11GraphicsEnvironment_initDisplay; + Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; + Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; + Java_sun_awt_X11GraphicsEnvironment_initXRender; - - - Java_java_awt_AWTEvent_initIDs; - Java_java_awt_Button_initIDs; - Java_java_awt_Container_initIDs; - Java_java_awt_Cursor_finalizeImpl; - Java_java_awt_Cursor_initIDs; - Java_java_awt_Event_initIDs; - Java_java_awt_event_InputEvent_initIDs; - Java_java_awt_event_KeyEvent_initIDs; - Java_java_awt_FileDialog_initIDs; - Java_java_awt_Frame_initIDs; - Java_java_awt_Insets_initIDs; - Java_java_awt_TextField_initIDs; - Java_java_awt_Window_initIDs; - Java_sun_awt_motif_X11OffScreenImage_updateBitmask; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_initIDs; - Java_sun_awt_X11GraphicsConfig_makeColorModel; - Java_sun_awt_X11GraphicsDevice_getConfigVisualId; - Java_sun_awt_X11PMBlitLoops_Blit; - Java_sun_awt_X11PMBlitBgLoops_nativeBlitBg; - Java_sun_awt_X11Renderer_devFillSpans; - Java_sun_awt_X11Renderer_doDrawArc; - Java_sun_awt_X11Renderer_doDrawLine; - Java_sun_awt_X11Renderer_doDrawOval; - Java_sun_awt_X11Renderer_doDrawPoly; - Java_sun_awt_X11Renderer_doDrawRect; - Java_sun_awt_X11Renderer_doDrawRoundRect; - Java_sun_awt_X11Renderer_doFillArc; - Java_sun_awt_X11Renderer_doFillOval; - Java_sun_awt_X11Renderer_doFillPoly; - Java_sun_awt_X11Renderer_doFillRect; - Java_sun_awt_X11Renderer_doFillRoundRect; - Java_sun_awt_X11Renderer_devCopyArea; - Java_sun_awt_X11SurfaceData_initIDs; - Java_sun_awt_X11SurfaceData_initOps; - Java_sun_awt_X11SurfaceData_initSurface; - Java_sun_awt_X11SurfaceData_isDgaAvailable; - Java_sun_awt_X11SurfaceData_setInvalid; - Java_sun_awt_X11SurfaceData_flushNativeSurface; - awt_display; - awt_lock; - awt_Lock; - awt_Unlock; - awt_GetDrawingSurface; - awt_FreeDrawingSurface; - awt_GetComponent; + Java_java_awt_AWTEvent_initIDs; + Java_java_awt_Button_initIDs; + Java_java_awt_Container_initIDs; + Java_java_awt_Cursor_finalizeImpl; + Java_java_awt_Cursor_initIDs; + Java_java_awt_Event_initIDs; + Java_java_awt_event_InputEvent_initIDs; + Java_java_awt_event_KeyEvent_initIDs; + Java_java_awt_FileDialog_initIDs; + Java_java_awt_Frame_initIDs; + Java_java_awt_Insets_initIDs; + Java_java_awt_TextField_initIDs; + Java_java_awt_Window_initIDs; + Java_sun_awt_motif_X11OffScreenImage_updateBitmask; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_initIDs; + Java_sun_awt_X11GraphicsConfig_makeColorModel; + Java_sun_awt_X11GraphicsDevice_getConfigVisualId; + Java_sun_awt_X11PMBlitLoops_Blit; + Java_sun_awt_X11PMBlitBgLoops_nativeBlitBg; + Java_sun_awt_X11Renderer_devFillSpans; + Java_sun_awt_X11Renderer_doDrawArc; + Java_sun_awt_X11Renderer_doDrawLine; + Java_sun_awt_X11Renderer_doDrawOval; + Java_sun_awt_X11Renderer_doDrawPoly; + Java_sun_awt_X11Renderer_doDrawRect; + Java_sun_awt_X11Renderer_doDrawRoundRect; + Java_sun_awt_X11Renderer_doFillArc; + Java_sun_awt_X11Renderer_doFillOval; + Java_sun_awt_X11Renderer_doFillPoly; + Java_sun_awt_X11Renderer_doFillRect; + Java_sun_awt_X11Renderer_doFillRoundRect; + Java_sun_awt_X11Renderer_devCopyArea; + Java_sun_awt_X11SurfaceData_initIDs; + Java_sun_awt_X11SurfaceData_initOps; + Java_sun_awt_X11SurfaceData_initSurface; + Java_sun_awt_X11SurfaceData_isDgaAvailable; + Java_sun_awt_X11SurfaceData_setInvalid; + Java_sun_awt_X11SurfaceData_flushNativeSurface; + awt_display; + awt_lock; + awt_Lock; + awt_Unlock; + awt_GetDrawingSurface; + awt_FreeDrawingSurface; + awt_GetComponent; awt_CreateEmbeddedFrame; awt_SetBounds; awt_SynthesizeWindowActivation; + X11SurfaceData_GetOps; + getDefaultConfig; + Java_sun_font_FontConfigManager_getFontConfig; + Java_sun_font_FontConfigManager_getFontConfigAASettings; + Java_sun_awt_FcFontManager_getFontPathNative; + Java_sun_font_SunFontManager_populateFontFileNameMap; - X11SurfaceData_GetOps; - getDefaultConfig; - Java_sun_font_FontConfigManager_getFontConfig; - Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_FcFontManager_getFontPathNative; - Java_sun_font_SunFontManager_populateFontFileNameMap; + # CDE private entry point + Java_sun_awt_motif_XsessionWMcommand; - # CDE private entry point - Java_sun_awt_motif_XsessionWMcommand; + # libfontmanager entry points + AWTIsHeadless; + AWTCountFonts; + AWTLoadFont; + AWTFreeFont; + AWTFontMinByte1; + AWTFontMaxByte1; + AWTFontMinCharOrByte2; + AWTFontMaxCharOrByte2; + AWTFontDefaultChar; + AWTFontPerChar; + AWTFontMaxBounds; + AWTFontTextExtents16; + AWTFreeChar; + AWTFontGenerateImage; + AWTCharAdvance; + AWTCharLBearing; + AWTCharRBearing; + AWTCharAscent; + AWTCharDescent; + AWTDrawGlyphList; + AccelGlyphCache_RemoveAllCellInfos; - # libfontmanager entry points - AWTIsHeadless; - AWTCountFonts; - AWTLoadFont; - AWTFreeFont; - AWTFontMinByte1; - AWTFontMaxByte1; - AWTFontMinCharOrByte2; - AWTFontMaxCharOrByte2; - AWTFontDefaultChar; - AWTFontPerChar; - AWTFontMaxBounds; - AWTFontTextExtents16; - AWTFreeChar; - AWTFontGenerateImage; - AWTCharAdvance; - AWTCharLBearing; - AWTCharRBearing; - AWTCharAscent; - AWTCharDescent; - AWTDrawGlyphList; - AccelGlyphCache_RemoveAllCellInfos; - - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt_headless/mapfile-vers b/jdk/make/mapfiles/libawt_headless/mapfile-vers index ac5101042a2..4ec723ffe0a 100644 --- a/jdk/make/mapfiles/libawt_headless/mapfile-vers +++ b/jdk/make/mapfiles/libawt_headless/mapfile-vers @@ -26,85 +26,84 @@ # Define public interface. SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; - Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; - Java_sun_java2d_x11_X11Renderer_XFillSpans; - Java_sun_java2d_x11_X11Renderer_XDrawArc; - Java_sun_java2d_x11_X11Renderer_XDrawLine; - Java_sun_java2d_x11_X11Renderer_XDrawOval; - Java_sun_java2d_x11_X11Renderer_XDrawPoly; - Java_sun_java2d_x11_X11Renderer_XDrawRect; - Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; - Java_sun_java2d_x11_X11Renderer_XDoPath; - Java_sun_java2d_x11_X11Renderer_XFillArc; - Java_sun_java2d_x11_X11Renderer_XFillOval; - Java_sun_java2d_x11_X11Renderer_XFillPoly; - Java_sun_java2d_x11_X11Renderer_XFillRect; - Java_sun_java2d_x11_X11Renderer_XFillRoundRect; - Java_sun_java2d_x11_X11Renderer_devCopyArea; - Java_sun_java2d_x11_X11SurfaceData_initIDs; - Java_sun_java2d_x11_X11SurfaceData_initSurface; - Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; - Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; - Java_sun_java2d_x11_X11SurfaceData_XSetForeground; + Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; + Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; + Java_sun_java2d_x11_X11Renderer_XFillSpans; + Java_sun_java2d_x11_X11Renderer_XDrawArc; + Java_sun_java2d_x11_X11Renderer_XDrawLine; + Java_sun_java2d_x11_X11Renderer_XDrawOval; + Java_sun_java2d_x11_X11Renderer_XDrawPoly; + Java_sun_java2d_x11_X11Renderer_XDrawRect; + Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; + Java_sun_java2d_x11_X11Renderer_XDoPath; + Java_sun_java2d_x11_X11Renderer_XFillArc; + Java_sun_java2d_x11_X11Renderer_XFillOval; + Java_sun_java2d_x11_X11Renderer_XFillPoly; + Java_sun_java2d_x11_X11Renderer_XFillRect; + Java_sun_java2d_x11_X11Renderer_XFillRoundRect; + Java_sun_java2d_x11_X11Renderer_devCopyArea; + Java_sun_java2d_x11_X11SurfaceData_initIDs; + Java_sun_java2d_x11_X11SurfaceData_initSurface; + Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; + Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; + Java_sun_java2d_x11_X11SurfaceData_XSetForeground; - Java_sun_java2d_x11_XSurfaceData_initOps; - Java_sun_java2d_x11_XSurfaceData_XCreateGC; - Java_sun_java2d_x11_XSurfaceData_XResetClip; - Java_sun_java2d_x11_XSurfaceData_XSetClip; - Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; - Java_sun_java2d_x11_XSurfaceData_isDrawableValid; - Java_sun_java2d_x11_XSurfaceData_setInvalid; - Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; + Java_sun_java2d_x11_XSurfaceData_initOps; + Java_sun_java2d_x11_XSurfaceData_XCreateGC; + Java_sun_java2d_x11_XSurfaceData_XResetClip; + Java_sun_java2d_x11_XSurfaceData_XSetClip; + Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; + Java_sun_java2d_x11_XSurfaceData_isDrawableValid; + Java_sun_java2d_x11_XSurfaceData_setInvalid; + Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; - X11SurfaceData_GetOps; - Java_java_awt_Font_initIDs; - Java_sun_font_FontConfigManager_getFontConfig; - Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_FcFontManager_getFontPathNative; + X11SurfaceData_GetOps; + Java_java_awt_Font_initIDs; + Java_sun_font_FontConfigManager_getFontConfig; + Java_sun_font_FontConfigManager_getFontConfigAASettings; + Java_sun_font_FontConfigManager_getFontConfigVersion; + Java_sun_awt_FcFontManager_getFontPathNative; - Java_sun_awt_FontDescriptor_initIDs; - Java_sun_awt_PlatformFont_initIDs; + Java_sun_awt_FontDescriptor_initIDs; + Java_sun_awt_PlatformFont_initIDs; - Java_sun_print_CUPSPrinter_initIDs; - Java_sun_print_CUPSPrinter_getCupsServer; - Java_sun_print_CUPSPrinter_getCupsPort; - Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; - Java_sun_print_CUPSPrinter_canConnect; - Java_sun_print_CUPSPrinter_getMedia; - Java_sun_print_CUPSPrinter_getPageSizes; - Java_sun_print_CUPSPrinter_getResolutions; + Java_sun_print_CUPSPrinter_initIDs; + Java_sun_print_CUPSPrinter_getCupsServer; + Java_sun_print_CUPSPrinter_getCupsPort; + Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; + Java_sun_print_CUPSPrinter_canConnect; + Java_sun_print_CUPSPrinter_getMedia; + Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; - # libfontmanager entry points - AWTIsHeadless; - AWTCountFonts; - AWTLoadFont; - AWTFreeFont; - AWTFontAscent; - AWTFontDescent; - AWTFontMinByte1; - AWTFontMaxByte1; - AWTFontMinCharOrByte2; - AWTFontMaxCharOrByte2; - AWTFontDefaultChar; - AWTFontPerChar; - AWTFontMaxBounds; - AWTFontTextExtents16; - AWTFreeChar; - AWTFontGenerateImage; - AWTCharAdvance; - AWTCharLBearing; - AWTCharRBearing; - AWTCharAscent; - AWTCharDescent; - AWTDrawGlyphList; - AccelGlyphCache_RemoveAllCellInfos; + # libfontmanager entry points + AWTIsHeadless; + AWTCountFonts; + AWTLoadFont; + AWTFreeFont; + AWTFontAscent; + AWTFontDescent; + AWTFontMinByte1; + AWTFontMaxByte1; + AWTFontMinCharOrByte2; + AWTFontMaxCharOrByte2; + AWTFontDefaultChar; + AWTFontPerChar; + AWTFontMaxBounds; + AWTFontTextExtents16; + AWTFreeChar; + AWTFontGenerateImage; + AWTCharAdvance; + AWTCharLBearing; + AWTCharRBearing; + AWTCharAscent; + AWTCharDescent; + AWTDrawGlyphList; + AccelGlyphCache_RemoveAllCellInfos; - - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt_xawt/mapfile-vers b/jdk/make/mapfiles/libawt_xawt/mapfile-vers index 04113dcf031..b56b47b8ce8 100644 --- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers @@ -26,7 +26,7 @@ # Define public interface. SUNWprivate_1.1 { - global: + global: JNI_OnLoad; Java_sun_awt_X11_XlibWrapper_copyIntArray; Java_sun_awt_X11_XlibWrapper_copyLongArray; @@ -58,8 +58,8 @@ SUNWprivate_1.1 { Java_sun_awt_X11_XlibWrapper_XSetLocaleModifiers; Java_sun_awt_X11_XlibWrapper_XPeekEvent; Java_sun_awt_X11_XlibWrapper_DefaultScreen; - Java_sun_awt_X11_XlibWrapper_ScreenOfDisplay; - Java_sun_awt_X11_XlibWrapper_DoesBackingStore; + Java_sun_awt_X11_XlibWrapper_ScreenOfDisplay; + Java_sun_awt_X11_XlibWrapper_DoesBackingStore; Java_sun_awt_X11_XlibWrapper_RootWindow; Java_sun_awt_X11_XlibWrapper_DisplayHeight; Java_sun_awt_X11_XlibWrapper_DisplayWidthMM; @@ -172,7 +172,7 @@ SUNWprivate_1.1 { Java_java_awt_Scrollbar_initIDs; Java_java_awt_Window_initIDs; Java_java_awt_Frame_initIDs; - Java_sun_awt_SunToolkit_closeSplashScreen; + Java_sun_awt_SunToolkit_closeSplashScreen; Java_sun_awt_UNIXToolkit_check_1gtk; Java_sun_awt_UNIXToolkit_load_1gtk; Java_sun_awt_UNIXToolkit_unload_1gtk; @@ -196,17 +196,16 @@ SUNWprivate_1.1 { Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_FcFontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_awt_X11GraphicsEnvironment_initDisplay; Java_sun_awt_X11GraphicsEnvironment_initGLX; - Java_sun_awt_X11GraphicsEnvironment_initXRender; + Java_sun_awt_X11GraphicsEnvironment_initXRender; Java_sun_awt_X11GraphicsEnvironment_checkShmExt; Java_sun_awt_X11GraphicsEnvironment_getNumScreens; Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; Java_sun_awt_X11GraphicsEnvironment_getDisplayString; -# Java_sun_awt_X11GraphicsEnvironment_getNativeFonts; Java_sun_awt_X11GraphicsDevice_initIDs; Java_sun_awt_X11GraphicsDevice_getConfigVisualId; Java_sun_awt_X11GraphicsDevice_getConfigDepth; @@ -231,16 +230,16 @@ SUNWprivate_1.1 { Java_sun_awt_X11GraphicsConfig_makeColorModel; Java_sun_awt_X11GraphicsConfig_pGetBounds; Java_sun_awt_X11GraphicsConfig_createBackBuffer; - Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; - Java_sun_awt_X11GraphicsConfig_swapBuffers; - Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; + Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; + Java_sun_awt_X11GraphicsConfig_swapBuffers; + Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; Java_sun_awt_X11_XToolkit_getTrayIconDisplayTimeout; Java_java_awt_Insets_initIDs; Java_java_awt_KeyboardFocusManager_initIDs; Java_java_awt_Font_initIDs; # libfontmanager entry points AWTIsHeadless; - AWTCountFonts; + AWTCountFonts; AWTLoadFont; AWTFreeFont; AWTFontAscent; @@ -303,7 +302,7 @@ SUNWprivate_1.1 { Java_sun_awt_X11_XlibWrapper_XGetIconSizes; Java_sun_awt_X11_XlibWrapper_XKeycodeToKeysym; Java_sun_awt_X11_XlibWrapper_XKeysymToKeycode; - Java_sun_awt_X11_XlibWrapper_XQueryKeymap; + Java_sun_awt_X11_XlibWrapper_XQueryKeymap; Java_sun_awt_X11_XlibWrapper_XkbGetEffectiveGroup; Java_sun_awt_X11_XlibWrapper_XkbSelectEvents; Java_sun_awt_X11_XlibWrapper_XkbSelectEventDetails; @@ -350,23 +349,23 @@ SUNWprivate_1.1 { Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask; - Java_sun_java2d_x11_X11Renderer_XFillSpans; - Java_sun_java2d_x11_X11Renderer_XDrawArc; - Java_sun_java2d_x11_X11Renderer_XDrawLine; - Java_sun_java2d_x11_X11Renderer_XDrawOval; - Java_sun_java2d_x11_X11Renderer_XDrawPoly; - Java_sun_java2d_x11_X11Renderer_XDrawRect; - Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; + Java_sun_java2d_x11_X11Renderer_XFillSpans; + Java_sun_java2d_x11_X11Renderer_XDrawArc; + Java_sun_java2d_x11_X11Renderer_XDrawLine; + Java_sun_java2d_x11_X11Renderer_XDrawOval; + Java_sun_java2d_x11_X11Renderer_XDrawPoly; + Java_sun_java2d_x11_X11Renderer_XDrawRect; + Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; Java_sun_java2d_x11_X11Renderer_XDoPath; - Java_sun_java2d_x11_X11Renderer_XFillArc; - Java_sun_java2d_x11_X11Renderer_XFillOval; - Java_sun_java2d_x11_X11Renderer_XFillPoly; - Java_sun_java2d_x11_X11Renderer_XFillRect; - Java_sun_java2d_x11_X11Renderer_XFillRoundRect; + Java_sun_java2d_x11_X11Renderer_XFillArc; + Java_sun_java2d_x11_X11Renderer_XFillOval; + Java_sun_java2d_x11_X11Renderer_XFillPoly; + Java_sun_java2d_x11_X11Renderer_XFillRect; + Java_sun_java2d_x11_X11Renderer_XFillRoundRect; Java_sun_java2d_x11_X11Renderer_devCopyArea; Java_sun_java2d_x11_X11SurfaceData_initIDs; Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; - Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; + Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; Java_sun_java2d_x11_X11SurfaceData_initSurface; Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; @@ -377,40 +376,40 @@ SUNWprivate_1.1 { Java_sun_java2d_x11_XSurfaceData_XResetClip; Java_sun_java2d_x11_XSurfaceData_XSetClip; Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; - Java_sun_java2d_x11_XSurfaceData_isDrawableValid; + Java_sun_java2d_x11_XSurfaceData_isDrawableValid; Java_sun_java2d_x11_XSurfaceData_setInvalid; Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; Java_sun_java2d_xr_XRSurfaceData_initXRPicture; Java_sun_java2d_xr_XRSurfaceData_initIDs; Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; - Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; - Java_sun_java2d_xr_XRBackendNative_initIDs; - Java_sun_java2d_xr_XRBackendNative_freeGC; - Java_sun_java2d_xr_XRBackendNative_createGC; - Java_sun_java2d_xr_XRBackendNative_createPixmap; - Java_sun_java2d_xr_XRBackendNative_createPictureNative; - Java_sun_java2d_xr_XRBackendNative_freePicture; - Java_sun_java2d_xr_XRBackendNative_freePixmap; - Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; - Java_sun_java2d_xr_XRBackendNative_setGCExposures; - Java_sun_java2d_xr_XRBackendNative_setGCForeground; - Java_sun_java2d_xr_XRBackendNative_copyArea; - Java_sun_java2d_xr_XRBackendNative_renderComposite; - Java_sun_java2d_xr_XRBackendNative_renderRectangle; - Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; - Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_setFilter; - Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; - Java_sun_java2d_xr_XRBackendNative_putMaskNative; - Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; - Java_sun_java2d_xr_XRBackendNative_setGCMode; - Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; - Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; + Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; + Java_sun_java2d_xr_XRBackendNative_initIDs; + Java_sun_java2d_xr_XRBackendNative_freeGC; + Java_sun_java2d_xr_XRBackendNative_createGC; + Java_sun_java2d_xr_XRBackendNative_createPixmap; + Java_sun_java2d_xr_XRBackendNative_createPictureNative; + Java_sun_java2d_xr_XRBackendNative_freePicture; + Java_sun_java2d_xr_XRBackendNative_freePixmap; + Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; + Java_sun_java2d_xr_XRBackendNative_setGCExposures; + Java_sun_java2d_xr_XRBackendNative_setGCForeground; + Java_sun_java2d_xr_XRBackendNative_copyArea; + Java_sun_java2d_xr_XRBackendNative_renderComposite; + Java_sun_java2d_xr_XRBackendNative_renderRectangle; + Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; + Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_setFilter; + Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; + Java_sun_java2d_xr_XRBackendNative_putMaskNative; + Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; + Java_sun_java2d_xr_XRBackendNative_setGCMode; + Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; + Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow; Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box; @@ -444,14 +443,14 @@ SUNWprivate_1.1 { Java_sun_awt_X11_GtkFileDialogPeer_toFront; Java_sun_awt_X11_GtkFileDialogPeer_setBounds; - Java_sun_print_CUPSPrinter_initIDs; - Java_sun_print_CUPSPrinter_getCupsServer; - Java_sun_print_CUPSPrinter_getCupsPort; - Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; - Java_sun_print_CUPSPrinter_canConnect; - Java_sun_print_CUPSPrinter_getMedia; - Java_sun_print_CUPSPrinter_getPageSizes; - Java_sun_print_CUPSPrinter_getResolutions; + Java_sun_print_CUPSPrinter_initIDs; + Java_sun_print_CUPSPrinter_getCupsServer; + Java_sun_print_CUPSPrinter_getCupsPort; + Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; + Java_sun_print_CUPSPrinter_canConnect; + Java_sun_print_CUPSPrinter_getMedia; + Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; awt_GetDrawingSurface; awt_FreeDrawingSurface; @@ -466,6 +465,6 @@ SUNWprivate_1.1 { Java_sun_awt_motif_XsessionWMcommand; Java_sun_awt_motif_XsessionWMcommand_New; - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libjawt/mapfile-vers b/jdk/make/mapfiles/libjawt/mapfile-vers index 1a79df0c34d..ee0ef4202cc 100644 --- a/jdk/make/mapfiles/libjawt/mapfile-vers +++ b/jdk/make/mapfiles/libjawt/mapfile-vers @@ -26,8 +26,8 @@ # Define library interface. SUNWprivate_1.1 { - global: - JAWT_GetAWT; - local: - *; + global: + JAWT_GetAWT; + local: + *; }; diff --git a/jdk/make/mapfiles/libjpeg/mapfile-vers b/jdk/make/mapfiles/libjpeg/mapfile-vers index 4534fa0944b..b82e7574598 100644 --- a/jdk/make/mapfiles/libjpeg/mapfile-vers +++ b/jdk/make/mapfiles/libjpeg/mapfile-vers @@ -26,30 +26,30 @@ # Define public interface. SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_sun_awt_image_JPEGImageDecoder_initIDs; - Java_sun_awt_image_JPEGImageDecoder_readImage; + Java_sun_awt_image_JPEGImageDecoder_initIDs; + Java_sun_awt_image_JPEGImageDecoder_readImage; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initReaderIDs; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setSource; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setOutColorSpace; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_abortRead; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetReader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_disposeReader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetLibraryState; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initWriterIDs; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initJPEGImageWriter; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_setDest; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeTables; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_abortWrite; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_resetWriter; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_disposeWriter; - local: - *; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initReaderIDs; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setSource; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setOutColorSpace; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_abortRead; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetReader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_disposeReader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetLibraryState; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initWriterIDs; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initJPEGImageWriter; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_setDest; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeTables; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_abortWrite; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_resetWriter; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_disposeWriter; + local: + *; }; diff --git a/jdk/make/mapfiles/libjsound/mapfile-vers b/jdk/make/mapfiles/libjsound/mapfile-vers index b8ebf0d8af3..4cd03a758b1 100644 --- a/jdk/make/mapfiles/libjsound/mapfile-vers +++ b/jdk/make/mapfiles/libjsound/mapfile-vers @@ -26,60 +26,60 @@ # Define library interface. SUNWprivate_1.1 { - global: - Java_com_sun_media_sound_DirectAudioDevice_nAvailable; - Java_com_sun_media_sound_DirectAudioDevice_nClose; - Java_com_sun_media_sound_DirectAudioDevice_nFlush; - Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; - Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; - Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; - Java_com_sun_media_sound_DirectAudioDevice_nOpen; - Java_com_sun_media_sound_DirectAudioDevice_nRead; - Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; - Java_com_sun_media_sound_DirectAudioDevice_nService; - Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nStart; - Java_com_sun_media_sound_DirectAudioDevice_nStop; - Java_com_sun_media_sound_DirectAudioDevice_nWrite; - Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; - Java_com_sun_media_sound_MidiInDevice_nClose; - Java_com_sun_media_sound_MidiInDevice_nGetMessages; - Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiInDevice_nOpen; - Java_com_sun_media_sound_MidiInDevice_nStart; - Java_com_sun_media_sound_MidiInDevice_nStop; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; - Java_com_sun_media_sound_MidiOutDevice_nClose; - Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiOutDevice_nOpen; - Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; - Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; - Java_com_sun_media_sound_Platform_nGetExtraLibraries; - Java_com_sun_media_sound_Platform_nGetLibraryForFeature; - Java_com_sun_media_sound_Platform_nIsBigEndian; - Java_com_sun_media_sound_PortMixer_nClose; - Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlGetIntValue; - Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlSetIntValue; - Java_com_sun_media_sound_PortMixer_nGetControls; - Java_com_sun_media_sound_PortMixer_nGetPortCount; - Java_com_sun_media_sound_PortMixer_nGetPortName; - Java_com_sun_media_sound_PortMixer_nGetPortType; - Java_com_sun_media_sound_PortMixer_nOpen; - Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; - Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; - local: - *; + global: + Java_com_sun_media_sound_DirectAudioDevice_nAvailable; + Java_com_sun_media_sound_DirectAudioDevice_nClose; + Java_com_sun_media_sound_DirectAudioDevice_nFlush; + Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; + Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; + Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; + Java_com_sun_media_sound_DirectAudioDevice_nOpen; + Java_com_sun_media_sound_DirectAudioDevice_nRead; + Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; + Java_com_sun_media_sound_DirectAudioDevice_nService; + Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nStart; + Java_com_sun_media_sound_DirectAudioDevice_nStop; + Java_com_sun_media_sound_DirectAudioDevice_nWrite; + Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; + Java_com_sun_media_sound_MidiInDevice_nClose; + Java_com_sun_media_sound_MidiInDevice_nGetMessages; + Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiInDevice_nOpen; + Java_com_sun_media_sound_MidiInDevice_nStart; + Java_com_sun_media_sound_MidiInDevice_nStop; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; + Java_com_sun_media_sound_MidiOutDevice_nClose; + Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiOutDevice_nOpen; + Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; + Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; + Java_com_sun_media_sound_Platform_nGetExtraLibraries; + Java_com_sun_media_sound_Platform_nGetLibraryForFeature; + Java_com_sun_media_sound_Platform_nIsBigEndian; + Java_com_sun_media_sound_PortMixer_nClose; + Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlGetIntValue; + Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlSetIntValue; + Java_com_sun_media_sound_PortMixer_nGetControls; + Java_com_sun_media_sound_PortMixer_nGetPortCount; + Java_com_sun_media_sound_PortMixer_nGetPortName; + Java_com_sun_media_sound_PortMixer_nGetPortType; + Java_com_sun_media_sound_PortMixer_nOpen; + Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; + Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; + local: + *; }; diff --git a/jdk/make/mapfiles/libjsoundalsa/mapfile-vers b/jdk/make/mapfiles/libjsoundalsa/mapfile-vers index 1b1c8f75be6..6228f8ad23e 100644 --- a/jdk/make/mapfiles/libjsoundalsa/mapfile-vers +++ b/jdk/make/mapfiles/libjsoundalsa/mapfile-vers @@ -26,57 +26,57 @@ # Define library interface. SUNWprivate_1.1 { - global: - Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; - Java_com_sun_media_sound_DirectAudioDevice_nAvailable; - Java_com_sun_media_sound_DirectAudioDevice_nClose; - Java_com_sun_media_sound_DirectAudioDevice_nFlush; - Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; - Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; - Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; - Java_com_sun_media_sound_DirectAudioDevice_nOpen; - Java_com_sun_media_sound_DirectAudioDevice_nRead; - Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; - Java_com_sun_media_sound_DirectAudioDevice_nService; - Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nStart; - Java_com_sun_media_sound_DirectAudioDevice_nStop; - Java_com_sun_media_sound_DirectAudioDevice_nWrite; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; - Java_com_sun_media_sound_MidiInDevice_nClose; - Java_com_sun_media_sound_MidiInDevice_nGetMessages; - Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiInDevice_nOpen; - Java_com_sun_media_sound_MidiInDevice_nStart; - Java_com_sun_media_sound_MidiInDevice_nStop; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; - Java_com_sun_media_sound_MidiOutDevice_nClose; - Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiOutDevice_nOpen; - Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; - Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; - Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; - Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; - Java_com_sun_media_sound_PortMixer_nClose; - Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlGetIntValue; - Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlSetIntValue; - Java_com_sun_media_sound_PortMixer_nGetControls; - Java_com_sun_media_sound_PortMixer_nGetPortCount; - Java_com_sun_media_sound_PortMixer_nGetPortName; - Java_com_sun_media_sound_PortMixer_nGetPortType; - Java_com_sun_media_sound_PortMixer_nOpen; - local: - *; + global: + Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; + Java_com_sun_media_sound_DirectAudioDevice_nAvailable; + Java_com_sun_media_sound_DirectAudioDevice_nClose; + Java_com_sun_media_sound_DirectAudioDevice_nFlush; + Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; + Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; + Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; + Java_com_sun_media_sound_DirectAudioDevice_nOpen; + Java_com_sun_media_sound_DirectAudioDevice_nRead; + Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; + Java_com_sun_media_sound_DirectAudioDevice_nService; + Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nStart; + Java_com_sun_media_sound_DirectAudioDevice_nStop; + Java_com_sun_media_sound_DirectAudioDevice_nWrite; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; + Java_com_sun_media_sound_MidiInDevice_nClose; + Java_com_sun_media_sound_MidiInDevice_nGetMessages; + Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiInDevice_nOpen; + Java_com_sun_media_sound_MidiInDevice_nStart; + Java_com_sun_media_sound_MidiInDevice_nStop; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; + Java_com_sun_media_sound_MidiOutDevice_nClose; + Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiOutDevice_nOpen; + Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; + Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; + Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; + Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; + Java_com_sun_media_sound_PortMixer_nClose; + Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlGetIntValue; + Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlSetIntValue; + Java_com_sun_media_sound_PortMixer_nGetControls; + Java_com_sun_media_sound_PortMixer_nGetPortCount; + Java_com_sun_media_sound_PortMixer_nGetPortName; + Java_com_sun_media_sound_PortMixer_nGetPortType; + Java_com_sun_media_sound_PortMixer_nOpen; + local: + *; }; diff --git a/jdk/make/mapfiles/libsplashscreen/mapfile-vers b/jdk/make/mapfiles/libsplashscreen/mapfile-vers index fec7b037f0d..b948ef474a6 100644 --- a/jdk/make/mapfiles/libsplashscreen/mapfile-vers +++ b/jdk/make/mapfiles/libsplashscreen/mapfile-vers @@ -26,24 +26,24 @@ # Define public interface. SUNWprivate_1.1 { - global: - Java_java_awt_SplashScreen__1update; - Java_java_awt_SplashScreen__1isVisible; - Java_java_awt_SplashScreen__1getBounds; - Java_java_awt_SplashScreen__1getInstance; - Java_java_awt_SplashScreen__1close; - Java_java_awt_SplashScreen__1getImageFileName; - Java_java_awt_SplashScreen__1getImageJarName; - Java_java_awt_SplashScreen__1setImageData; - Java_java_awt_SplashScreen__1getScaleFactor; + global: + Java_java_awt_SplashScreen__1update; + Java_java_awt_SplashScreen__1isVisible; + Java_java_awt_SplashScreen__1getBounds; + Java_java_awt_SplashScreen__1getInstance; + Java_java_awt_SplashScreen__1close; + Java_java_awt_SplashScreen__1getImageFileName; + Java_java_awt_SplashScreen__1getImageJarName; + Java_java_awt_SplashScreen__1setImageData; + Java_java_awt_SplashScreen__1getScaleFactor; - SplashLoadMemory; - SplashLoadFile; - SplashInit; - SplashClose; - SplashSetFileJarName; - SplashSetScaleFactor; - SplashGetScaledImageName; - local: - *; + SplashLoadMemory; + SplashLoadFile; + SplashInit; + SplashClose; + SplashSetFileJarName; + SplashSetScaleFactor; + SplashGetScaledImageName; + local: + *; }; From f149873fe6b00027b567a9a056593b296a4f50b1 Mon Sep 17 00:00:00 2001 From: Rajeev Chamyal Date: Mon, 22 Aug 2016 14:41:36 +0530 Subject: [PATCH 011/296] 8163160: [PIT][TEST_BUG] Some issues in java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java Reviewed-by: serb, yan --- .../multiresolution/MultiResolutionIcon/IconTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java b/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java index 985041f6a1c..6083366e925 100644 --- a/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java +++ b/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java @@ -23,10 +23,10 @@ /** * @test - * @bug 8147648 + * @bug 8147648 8163160 * @summary [hidpi] multiresolution image: wrong resolution variant is used as * icon in the Unity panel - * @run main/othervm -Dsun.java2d.uiScale=2 IconTest + * @run main/manual/othervm -Dsun.java2d.uiScale=2 IconTest */ import java.awt.Color; import java.awt.Graphics; @@ -67,7 +67,7 @@ public class IconTest { if (g != null) { g.setColor(c); g.fillRect(0, 0, x, x); - g.setColor(Color.YELLOW); + g.setColor(Color.GREEN); g.drawRect(0, 0, x-1, x-1); } } finally { @@ -91,7 +91,8 @@ public class IconTest { GridBagConstraints gbc = new GridBagConstraints(); String instructions = "INSTRUCTIONS:
" - + "Check if test button and unity icons are both blue with yellow border.

" + + "Check if test button icon and unity icon are both " + + "blue with green border.

" + "If Icon color is blue press pass" + " else press fail.

"; From 66b521e8a9547a032a04e58016aeb3adfcb28574 Mon Sep 17 00:00:00 2001 From: Manajit Halder Date: Mon, 22 Aug 2016 18:23:46 +0530 Subject: [PATCH 012/296] 8156099: [macosx] Drag and drop of link from web browser, DataFlavor types application/x-java-url and text/uri-list, getTransferData returns null Reviewed-by: mcherkas, serb --- .../sun/lwawt/macosx/CDataTransferer.java | 31 ++- .../dnd/URLDragTest/DragLinkFromBrowser.java | 232 ++++++++++++++++++ 2 files changed, 257 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java index 3f05185c091..150c6e92ad1 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java @@ -36,7 +36,7 @@ import java.nio.charset.Charset; import java.text.Normalizer; import java.text.Normalizer.Form; import java.util.*; - +import java.util.regex.*; import java.awt.datatransfer.*; import sun.awt.datatransfer.*; @@ -129,12 +129,21 @@ public class CDataTransferer extends DataTransferer { long format, Transferable transferable) throws IOException { if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass())) { - String[] strings = dragQueryFile(bytes); - if(strings == null || strings.length == 0) { - return null; + String charset = Charset.defaultCharset().name(); + if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) { + try { + charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), "UTF-8"); + } catch (UnsupportedFlavorException cannotHappen) { + } } - return new URL(strings[0]); - } else if(isUriListFlavor(flavor)) { + + String xml = new String(bytes, charset); + // macosx pasteboard returns a property list that consists of one URL + // let's extract it. + return new URL(extractURL(xml)); + } + + if(isUriListFlavor(flavor) && format == CF_FILE) { // dragQueryFile works fine with files and url, // it parses and extracts values from property list. // maxosx always returns property list for @@ -156,6 +165,16 @@ public class CDataTransferer extends DataTransferer { return super.translateBytes(bytes, flavor, format, transferable); } + private String extractURL(String xml) { + Pattern urlExtractorPattern = Pattern.compile("(.*)"); + Matcher matcher = urlExtractorPattern.matcher(xml); + if (matcher.find()) { + return matcher.group(1); + } else { + return null; + } + } + @Override protected synchronized Long getFormatForNativeAsLong(String str) { Long format = predefinedClipboardNameMap.get(str); diff --git a/jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java b/jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java new file mode 100644 index 00000000000..6eacad3a7a3 --- /dev/null +++ b/jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + + /* + @test + @bug 8156099 + @summary Drag and drop of link from web browser, DataFlavor types + application/x-java-url and text/uri-list, getTransferData returns null + @run main/manual DragLinkFromBrowser + */ + +import java.awt.Frame; +import java.awt.Button; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.Color; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.IOException; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.TransferHandler; +import javax.swing.SwingUtilities; +import javax.swing.JOptionPane; + +public class DragLinkFromBrowser implements ActionListener { + + private static GridBagLayout layout; + private static Panel mainControlPanel; + private static Panel resultButtonPanel; + private static TextArea instructionTextArea; + private static Button passButton; + private static Button failButton; + private static Frame mainFrame; + private static Thread mainThread = null; + private static volatile boolean testPassed = false; + private static volatile boolean isInterrupted = false; + private static volatile String failMessage; + private static final int testTimeOut = 300000; + private static JFrame urlFrame; + private static JPanel urlPanel; + + public static void dragLinkFromWebBrowser() { + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + + urlFrame = new JFrame(); + urlPanel = new JPanel(); + failMessage = "Dragging link from web browser Failed. " + + "getTransferData returns null"; + urlFrame.getContentPane().add(urlPanel); + urlPanel.setTransferHandler(new TransferHandler() { + @Override + public boolean canImport(final TransferSupport support) { + return true; + } + + @Override + public boolean importData(final TransferSupport support) { + final Transferable transferable = + support.getTransferable(); + final DataFlavor[] flavors + = transferable.getTransferDataFlavors(); + + for (final DataFlavor flavor : flavors) { + try { + final Object transferData + = transferable.getTransferData(flavor); + + if (transferData == null) { + JOptionPane.showMessageDialog(urlPanel, + failMessage); + break; + } else { + String flavorMessage = flavor.toString(); + String transferDataMessage = + transferData.toString(); + if (flavorMessage.contains("error") + || transferDataMessage.contains("null")) { + JOptionPane.showMessageDialog(urlPanel, + failMessage); + break; + } + } + } catch (UnsupportedFlavorException e) { + testFailed("UnsupportedFlavorException - " + + "test Failed"); + } catch (IOException e) { + testFailed("IOException - test Failed"); + } + } + + return true; + } + }); + + urlFrame.setBounds(500, 10, 200, 200); + urlFrame.setVisible(true); + } + }); + } + + private void createInstructionUI() { + mainFrame = new Frame("Drag and drop link from web browser"); + layout = new GridBagLayout(); + mainControlPanel = new Panel(layout); + resultButtonPanel = new Panel(layout); + + GridBagConstraints gbc = new GridBagConstraints(); + String instructions + = "INSTRUCTIONS:" + + "\n 1. Open any browser." + + "\n 2. Select and drag URL from the browser page and " + + "drop it on the panel" + + "\n 3. If test fails, then a popup message will be displayed," + + " click Ok and \n click Fail button." + + "\n 5. Otherwise test passed. Click Pass button."; + + instructionTextArea = new TextArea(); + instructionTextArea.setText(instructions); + instructionTextArea.setEnabled(false); + instructionTextArea.setBackground(Color.white); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + mainControlPanel.add(instructionTextArea, gbc); + + passButton = new Button("Pass"); + passButton.setName("Pass"); + passButton.addActionListener(this); + + failButton = new Button("Fail"); + failButton.setName("Fail"); + failButton.addActionListener(this); + + gbc.gridx = 0; + gbc.gridy = 0; + resultButtonPanel.add(passButton, gbc); + gbc.gridx = 1; + gbc.gridy = 0; + resultButtonPanel.add(failButton, gbc); + gbc.gridx = 0; + gbc.gridy = 1; + mainControlPanel.add(resultButtonPanel, gbc); + + mainFrame.add(mainControlPanel); + mainFrame.pack(); + mainFrame.setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent ae) { + if (ae.getSource() instanceof Button) { + Button btn = (Button) ae.getSource(); + switch (btn.getName()) { + case "Pass": + testPassed = true; + isInterrupted = true; + mainThread.interrupt(); + break; + + case "Fail": + testFailed("Dragging link from web browser Failed"); + break; + } + } + } + + public static void cleanUp() { + urlFrame.dispose(); + mainFrame.dispose(); + } + + public static void testFailed(String message) { + testPassed = false; + isInterrupted = true; + failMessage = message; + mainThread.interrupt(); + } + + public static void main(final String[] args) throws Exception { + + DragLinkFromBrowser linkFromBrowser = new DragLinkFromBrowser(); + linkFromBrowser.createInstructionUI(); + linkFromBrowser.dragLinkFromWebBrowser(); + + mainThread = Thread.currentThread(); + try { + mainThread.sleep(testTimeOut); + } catch (InterruptedException ex) { + if (!testPassed) { + throw new RuntimeException(failMessage); + } + } finally { + cleanUp(); + } + + if (!isInterrupted) { + throw new RuntimeException("Test Timed out after " + + testTimeOut / 1000 + " seconds"); + } + } +} + From 5935292ae022e970bd4075de4d704719f3b05575 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Mon, 22 Aug 2016 10:35:16 -0700 Subject: [PATCH 013/296] 8145901: Printed content is overlapping Reviewed-by: serb, psadhukhan --- .../share/native/libfontmanager/HBShaper.c | 14 ++++++++++---- .../share/native/libfontmanager/hb-jdk-font.cc | 6 ++++-- .../share/native/libfontmanager/hb-jdk.h | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c index 485c42a7b96..d8de3e36d92 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c +++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c @@ -72,12 +72,13 @@ static int init_JNI_IDs(JNIEnv *env) { int storeGVData(JNIEnv* env, jobject gvdata, jint slot, jint baseIndex, jobject startPt, int glyphCount, hb_glyph_info_t *glyphInfo, - hb_glyph_position_t *glyphPos, hb_direction_t direction) { + hb_glyph_position_t *glyphPos, hb_direction_t direction, + float devScale) { int i; float x=0, y=0; float startX, startY; - float scale = 1.0f/64.0f; + float scale = 1.0f/64.0f/devScale; unsigned int* glyphs; float* positions; int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv; @@ -216,7 +217,11 @@ JDKFontInfo* fi->ptSize = ptSize; fi->xPtSize = euclidianDistance(fi->matrix[0], fi->matrix[1]); fi->yPtSize = euclidianDistance(fi->matrix[2], fi->matrix[3]); - + if (!aat && (getenv("HB_NODEVTX") != NULL)) { + fi->devScale = fi->xPtSize / fi->ptSize; + } else { + fi->devScale = 1.0f; + } return fi; } @@ -309,7 +314,8 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape // by calling code. storeGVData(env, gvdata, slot, baseIndex, startPt, - glyphCount, glyphInfo, glyphPos, direction); + glyphCount, glyphInfo, glyphPos, direction, + jdkFontInfo->devScale); hb_buffer_destroy (buffer); hb_font_destroy(hbfont); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc index 1727bb80ea3..f7df0f27cbe 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc @@ -52,6 +52,7 @@ hb_jdk_get_glyph (hb_font_t *font HB_UNUSED, *glyph = (hb_codepoint_t) env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, u); +printf("unicode=%x glyph=%x\n", unicode, *glyph); return (*glyph != 0); } @@ -81,6 +82,7 @@ hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, return 0; } fadv = env->GetFloatField(pt, sunFontIDs.xFID); + fadv *= jdkFontInfo->devScale; env->DeleteLocalRef(pt); return FloatToF26Dot6(fadv); // should this round ? @@ -324,8 +326,8 @@ static hb_font_t* _hb_jdk_font_create(JDKFontInfo *jdkFontInfo, _hb_jdk_get_font_funcs (), jdkFontInfo, (hb_destroy_func_t) _do_nothing); hb_font_set_scale (font, - FloatToF26Dot6(jdkFontInfo->xPtSize), - FloatToF26Dot6(jdkFontInfo->yPtSize)); + FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale), + FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale)); return font; } diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h index c17ea12ebbc..1cd8d5ba241 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h @@ -43,6 +43,7 @@ typedef struct JDKFontInfo_Struct { float ptSize; float xPtSize; float yPtSize; + float devScale; // How much applying the full glyph tx scales x distance. jboolean aat; } JDKFontInfo; From 82a6f087209635f3d01d0afd0f078daaaae98f22 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 23 Aug 2016 10:27:47 +0530 Subject: [PATCH 014/296] 8163922: Print-to-file is disabled for SERVICE_FORMATTED docflavor in linux Reviewed-by: prr, jdv --- .../classes/sun/print/ServiceDialog.java | 4 +++ .../attribute/ServiceDialogValidateTest.java | 29 +++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java index 59797508b2e..5dd2b4de046 100644 --- a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java +++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java @@ -944,6 +944,10 @@ public class ServiceDialog extends JDialog implements ActionListener { } catch (MalformedURLException ex) { dstSupported = true; } + } else { + if (psCurrent.isAttributeCategorySupported(dstCategory)) { + dstSupported = true; + } } cbPrintToFile.setEnabled(dstSupported && dstAllowed); cbPrintToFile.setSelected(dstSelected && dstAllowed diff --git a/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java b/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java index 4216da6f015..929f76869cf 100644 --- a/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java +++ b/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java @@ -22,7 +22,7 @@ */ /* * @test - * @bug 5049012 + * @bug 5049012 8163922 * @summary Verify if PrintToFile option is disabled for flavors that do not * support Destination * @requires (os.family == "linux") @@ -30,6 +30,8 @@ */ import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.io.File; import javax.print.DocFlavor; import javax.print.PrintService; @@ -72,6 +74,9 @@ public class ServiceDialogValidateTest { defService = ServiceUI.printDialog(null, 100, 100, service, defService, flavor, prSet); + ServiceUI.printDialog(null, 100, 100, service, defService, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, + new HashPrintRequestAttributeSet()); } /** @@ -87,7 +92,8 @@ public class ServiceDialogValidateTest { } catch (InterruptedException e) { if (!testPassed && testGeneratedInterrupt) { throw new RuntimeException("PrintToFile option is not disabled " - + "for flavors that do not support destination"); + + "for flavors that do not support destination and/or" + + " disabled for flavors that supports destination"); } } if (!testGeneratedInterrupt) { @@ -110,10 +116,15 @@ public class ServiceDialogValidateTest { private static void doTest(Runnable action) { String description = " Visual inspection of print dialog is required.\n" - + " A print dialog will be shown.\n " - + " Please verify Print-To-File option is disabled.\n" + + " 2 print dialog will be shown.\n " + + " Please verify Print-To-File option is disabled " + + " in the 1st print dialog.\n" + " Press Cancel to close the print dialog.\n" - + " If Print-To-File option is disabled, press PASS else press FAIL"; + + " Please verify Print-To-File option is enabled " + + " in 2nd print dialog\n" + + " Press Cancel to close the print dialog.\n" + + " If the print dialog's Print-to-File behaves as mentioned, " + + " press PASS else press FAIL"; final JDialog dialog = new JDialog(); dialog.setTitle("printSelectionTest"); @@ -148,6 +159,14 @@ public class ServiceDialogValidateTest { dialog.add(mainPanel); dialog.pack(); dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); } } From f423e1290ff0e1b897bfd4f2d8b12e7b25238b6b Mon Sep 17 00:00:00 2001 From: Rachna Goel Date: Tue, 23 Aug 2016 15:35:44 +0900 Subject: [PATCH 015/296] 8163362: Reconsider reflection usage in java.awt.font.JavaAWTFontAccessImpl class Reviewed-by: naoto, okutsu, prr --- .../java/awt/font/JavaAWTFontAccessImpl.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java b/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java index cd4c9fdf224..ff2849807ba 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java +++ b/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016 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 java.awt.font; -import java.lang.reflect.Field; import jdk.internal.misc.JavaAWTFontAccess; class JavaAWTFontAccessImpl implements JavaAWTFontAccess { @@ -33,19 +32,17 @@ class JavaAWTFontAccessImpl implements JavaAWTFontAccess { // java.awt.font.TextAttribute constants public Object getTextAttributeConstant(String name) { switch (name) { - case "RUN_DIRECTION": - case "NUMERIC_SHAPING": - case "BIDI_EMBEDDING": - case "RUN_DIRECTION_LTR": - try { - Field f = TextAttribute.class.getField(name); - return f.get(null); - } catch (NoSuchFieldException | IllegalAccessException x) { - throw new AssertionError(x); - } + case "RUN_DIRECTION": + return TextAttribute.RUN_DIRECTION; + case "NUMERIC_SHAPING": + return TextAttribute.NUMERIC_SHAPING; + case "BIDI_EMBEDDING": + return TextAttribute.BIDI_EMBEDDING; + case "RUN_DIRECTION_LTR": + return TextAttribute.RUN_DIRECTION_LTR; + default: + throw new AssertionError("Constant name is not recognized"); } - - throw new AssertionError("Constant name is not recognized"); } // java.awt.font.NumericShaper From 5a41e81056fd71c7ee557080624c3c5ef73f95d6 Mon Sep 17 00:00:00 2001 From: Prahalad Kumar Narayanan Date: Tue, 23 Aug 2016 14:47:53 +0530 Subject: [PATCH 016/296] 8158524: Adding a test case to compare the rendered output of VolatileImage with that of BufferedImage Reviewed-by: serb, psadhukhan --- .../VolatileImage/TransparentVImage.java | 260 ++++++++++++++++++ .../java/awt/image/VolatileImage/duke.gif | Bin 0 -> 1929 bytes 2 files changed, 260 insertions(+) create mode 100644 jdk/test/java/awt/image/VolatileImage/TransparentVImage.java create mode 100644 jdk/test/java/awt/image/VolatileImage/duke.gif diff --git a/jdk/test/java/awt/image/VolatileImage/TransparentVImage.java b/jdk/test/java/awt/image/VolatileImage/TransparentVImage.java new file mode 100644 index 00000000000..525099e24ff --- /dev/null +++ b/jdk/test/java/awt/image/VolatileImage/TransparentVImage.java @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 4881082 4916294 5002129 8158524 + * @summary The test verifies whether the rendering operations on transparent + * and translucent VolatileImage objects generate identical output + * as generated with transparent and translucent BufferedImages. + * @key headful + * @run main/othervm -Dsun.java2d.uiScale=1 TransparentVImage + * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.opengl=True -Dsun.java2d.opengl.fbobject=false TransparentVImage + * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.opengl=True -Dsun.java2d.opengl.fbobject=true TransparentVImage + */ +import java.awt.GraphicsConfiguration; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.awt.image.VolatileImage; +import java.awt.Color; +import javax.swing.JFrame; +import javax.swing.JComponent; +import javax.swing.ImageIcon; +import javax.swing.SwingUtilities; + +/* + * This test draws the same contents to 4 images: 2 BufferedImages that are + * transparent and translucent and 2 VolatileImages that are transparent and + * translucent. It compares the results pixel-by-pixel and fails if the + * results are not the same. + */ +public class TransparentVImage + extends JComponent { + + BufferedImage cImgTransparent, cImgTranslucent; + VolatileImage vImgTransparent, vImgTranslucent; + Image sprite; + static final int IMAGE_SIZE = 250; + static final int WINDOW_SIZE = 600; + static boolean doneComparing = false; + static JFrame testFrame = null; + + @Override + public void paint(Graphics g) { + if (cImgTransparent == null) { + GraphicsConfiguration gc = getGraphicsConfiguration(); + // doesn't exist yet: create it (and the other images) + cImgTransparent = (BufferedImage) + gc.createCompatibleImage(IMAGE_SIZE, IMAGE_SIZE, + Transparency.BITMASK); + cImgTranslucent = (BufferedImage) + gc.createCompatibleImage(IMAGE_SIZE, IMAGE_SIZE, + Transparency.TRANSLUCENT); + vImgTransparent = gc.createCompatibleVolatileImage(IMAGE_SIZE, + IMAGE_SIZE, Transparency.BITMASK); + vImgTranslucent = gc.createCompatibleVolatileImage(IMAGE_SIZE, + IMAGE_SIZE, Transparency.TRANSLUCENT); + + String fileName = "duke.gif"; + String separator = System.getProperty("file.separator"); + String dirPath = System.getProperty("test.src", "."); + String filePath = dirPath + separator + fileName; + sprite = new ImageIcon(filePath).getImage(); + + // Now they exist; render to them + Graphics gImg[] = new Graphics[4]; + gImg[0] = cImgTransparent.getGraphics(); + gImg[1] = cImgTranslucent.getGraphics(); + gImg[2] = vImgTransparent.getGraphics(); + gImg[3] = vImgTranslucent.getGraphics(); + + for (int i = 0; i < gImg.length; ++i) { + /* + * VolatileImage utilizes the power of accelerated rendering + * using GPU. The GPU drivers for D3d and OpenGL are supplied + * by OEM vendors and are external to graphics subsystem. Thus + * one cannot guarentee that the drivers will render the + * primitives using exactly the same algorithms as those used + * by BufferedImage. This could result in minor differences in + * pixel values between BufferedImage and VolatileImage. + * + * The pipelines for D3d and OpenGL adjust the rendering with + * fudge factors to align output of GPU rendering with that of + * CPU rendering. Some of the draw calls in this paint method + * are commented indicating a need to fine tune the fudge + * factors in the future. Once they are found to work on all + * hardware, the draw calls will be enabled. + */ + // rectangular fill + gImg[i].setColor(Color.blue); + gImg[i].fillRect(0, 0, IMAGE_SIZE, IMAGE_SIZE); + + /* + * Image copy. Copy it 3 times to get any image management + * acceleration going + */ + int spriteW = sprite.getWidth(null); + gImg[i].drawImage(sprite, 0, 0, null); + gImg[i].drawImage(sprite, spriteW, 0, null); + gImg[i].drawImage(sprite, 2 * spriteW, 0, null); + + // horizontal/vertical/diagonal lines + gImg[i].setColor(Color.red); + gImg[i].drawLine(0, 0, + IMAGE_SIZE - 1, IMAGE_SIZE - 1); + gImg[i].drawLine(IMAGE_SIZE / 2, 0, + IMAGE_SIZE / 2, IMAGE_SIZE - 1); + //gImg[i].drawLine(IMAGE_SIZE, 0, + // 0, IMAGE_SIZE - 1); + gImg[i].drawLine(0, IMAGE_SIZE / 2, + IMAGE_SIZE - 1, IMAGE_SIZE / 2); + + // filled circle + //gImg[i].setColor(Color.yellow); + //gImg[i].fillOval(IMAGE_SIZE / 2 - 20, IMAGE_SIZE / 2 - 20, + // 40, 40); + } + + /* + * Now everything is drawn: let's compare pixels + * First, grab the pixel arrays + */ + int cRgbTransparent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + int cRgbTranslucent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + int vRgbTransparent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + int vRgbTranslucent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + cImgTransparent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + cRgbTransparent, 0, IMAGE_SIZE); + cImgTranslucent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + cRgbTranslucent, 0, IMAGE_SIZE); + BufferedImage bImgTransparent = vImgTransparent.getSnapshot(); + bImgTransparent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + vRgbTransparent, 0, IMAGE_SIZE); + BufferedImage bImgTranslucent = vImgTranslucent.getSnapshot(); + bImgTranslucent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + vRgbTranslucent, 0, IMAGE_SIZE); + + boolean failed = false; + for (int pixel = 0; pixel < cRgbTransparent.length; ++pixel) { + if (cRgbTransparent[pixel] != vRgbTransparent[pixel]) { + failed = true; + System.out.println("Error in transparent image: " + + "BI[" + pixel + "] = " + + Integer.toHexString(cRgbTransparent[pixel]) + + "VI[" + pixel + "] = " + + Integer.toHexString(vRgbTransparent[pixel])); + break; + } + if (cRgbTranslucent[pixel] != vRgbTranslucent[pixel]) { + failed = true; + System.out.println("Error in translucent image: " + + "BI[" + pixel + "] = " + + Integer.toHexString(cRgbTranslucent[pixel]) + + "VI[" + pixel + "] = " + + Integer.toHexString(vRgbTranslucent[pixel])); + break; + } + } + if (failed) { + throw new RuntimeException("Failed: Pixel mis-match observed"); + } + else { + System.out.println("Passed"); + } + doneComparing = true; + } + + g.drawImage(cImgTransparent, 0, 0, null); + g.drawImage(cImgTranslucent, getWidth() - IMAGE_SIZE, 0, null); + g.drawImage(vImgTransparent, 0, getHeight() - IMAGE_SIZE, null); + g.drawImage(vImgTranslucent, getWidth() - IMAGE_SIZE, + getHeight() - IMAGE_SIZE, null); + } + + private static void constructTestUI() { + testFrame = new JFrame(); + testFrame.setSize(600, 600); + testFrame.setResizable(false); + testFrame.getContentPane().add(new TransparentVImage()); + + testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + testFrame.setLocationRelativeTo(null); + testFrame.setVisible(true); + } + + private static void destroyTestUI() { + testFrame.dispose(); + } + + public static void main(String args[]) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + // Construct the test interface + constructTestUI(); + } catch (Exception ex) { + // Throw an exception indicating error while creating UI + throw new RuntimeException("Test Failed: Error while" + + " creating the test interface."); + } + } + }); + + /* + * Wait until the image comparison between VolatileImage and + * BufferedImage is complete. + */ + while (!doneComparing) { + try { + Thread.sleep(100); + } + catch (Exception e) {} + } + + /* + * Now sleep just a little longer to let the user see the resulting + * images in the frame + */ + try { + Thread.sleep(5000); + } + catch (Exception e) {} + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + // Destroy the test interface + destroyTestUI(); + } catch (Exception ex) { + // Throw an exception indicating error while deleting UI + throw new RuntimeException("Test Failed: Error while" + + " deleting the test interface."); + } + } + }); + } +} diff --git a/jdk/test/java/awt/image/VolatileImage/duke.gif b/jdk/test/java/awt/image/VolatileImage/duke.gif new file mode 100644 index 0000000000000000000000000000000000000000..ed32e0ff79b05c07b82863ce6fb07fa9898adaa2 GIT binary patch literal 1929 zcmWlYe^AtB8pi`HvM4_?{J2I$8$dLc1#@!R2zwgXMWdj^k;9xr+bDW&4{JlE8WpDj z7F-cwwK{H<)?L&#SJz$!;hJ{%BY2FYf)Wp^xl?aq!5Xcdi$c#hV~>m9_n-Hl=Xsy+ z=li^?*Q~;pZ+R1N1J40KRkeWM7ew3~jLM24A{CM-A}~TzqzYpq&od0GC=z71!w_=b z-==B0rt2t*nA}((5YSLs6a*Z@X__WqiSjTW6oLo{5km&|K1mGAimYjhs#wwZtvV8SV~7LCFpgub+-TTAk%UQb0dE_cj+pc?!+0o?qG$?% zVFD)%!w7Z;g)ndE8Uk6Aky=+kLaUQ{UW`XS?Nn*s@SQ{VmFgGdkV{&&98EcEQ5hjc@H$`e)fX zj@&GdchxpMUo|-A^M4iBP3(#Ib53Ap?5{nGT7SBA_V!o!TTzL5R~FUWe)4X?@iTd8 z1;TcF^rQLj?4p0uy?@ikb2eUSXdHVa_jIn=@W%a<6~57D>am6&Z!{lzc=@ZbuGB8` zpU38H8d~@82Da!+qdYG5ls&Cx?~|oPMnbqTHMw%I*KlV~?fc{rSwe29?Om}fsknG# z@n5IwY=4Mx>>0WJLG>=yJX^WbHA30iQ$H!X)3<4K zBe1|sf3NKKTS;)mg{$k(2eDJG^u5=&x{@M!V>EWgzRA((>}?o{WQBehp1mIHU!BGG zYz5_6B(+KIVdCVoum2ItM&gXZd+SB^vQTN=a zeYbbah=i-xCho2{4Pazv_i%2mH`EkM{r8XYDLbdY@(a7Ud}$%!$QrTN_DqwNXA9~g zTGKxKyfto7NDp;5A3O5zgb(hyxjN@OAG!(zy^*Ug4!yjF=Y*8aHA@ovB1({&a4;sR zTf1CVC{>Pgy`m$lG;P1$pC_6F7u%iP+qz0q4{lXT`i9g-ThiYgO^GXC`f?JNo*|@p zr{b%U-tSKw99q0|YJa9{Va?`H{IaNICo>p5lGEY*+IDR4bfIUwq~CTRuC_mGWA%~W zea{@eKJ(Iq^7MvdsPsR%&vt$@4i&s?bPptz#y#!FcRZEaMS0WFTyXMCUEfsNxnJ_9 zPwpt`Er4O>``2G{7=4r1GCSTO8#0xw+{<^L4X(K8y1wKj72KLrYD}Y7SJuY7y==wf z;UkI5?(v?h+4r;vR{P*U`ul~=D@U7K5$eV8c!%rX-38vE>azU80UrhFXCv#d`(ylZS4+i2a^vI91MTIxCx%9gd2&N&D9RC&xcpx8#f=GZv%9;F z#?CEVT%UV$nk;L%RJA+d=f8ZB@U*Xz-TZbG?HKKT(VJZMBH!)$#qRuwbFc%Aljqha zoNBs8od~V$_^vux0ZSk!iP!hI($t35SxY8`FV{pxCjpU}Ova2VIg1&>V)CvvMb_ Date: Tue, 23 Aug 2016 18:15:27 +0300 Subject: [PATCH 017/296] 8162840: Desktop. enableSuddenTermination() has no effect Reviewed-by: serb --- .../macosx/classes/com/apple/eawt/_AppEventHandler.java | 7 ++++++- .../macosx/classes/com/apple/eawt/_AppMiscHandlers.java | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java index a417f692ab8..e64e9b158b5 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java @@ -171,7 +171,8 @@ class _AppEventHandler { currentQuitResponse = null; try { - if (defaultQuitAction == QuitStrategy.NORMAL_EXIT) System.exit(0); + if (defaultQuitAction == QuitStrategy.NORMAL_EXIT + || _AppMiscHandlers.isSuddenTerminationEnbaled()) System.exit(0); if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) { throw new RuntimeException("Unknown quit action"); @@ -422,6 +423,10 @@ class _AppEventHandler { } void performUsing(final QuitHandler handler, final _NativeEvent event) { + if (_AppMiscHandlers.isSuddenTerminationEnbaled()) { + performDefaultAction(event); + return; + } final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response handler.handleQuitRequestWith(new QuitEvent(), response); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java index 6f892caaa91..1851e2aa90c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java @@ -26,6 +26,8 @@ package com.apple.eawt; class _AppMiscHandlers { + private static boolean isSuddenTerminationEnabled; + private static native void nativeOpenHelpViewer(); private static native void nativeRequestActivation(final boolean allWindows); @@ -47,10 +49,16 @@ class _AppMiscHandlers { } static void enableSuddenTermination() { + isSuddenTerminationEnabled = true; nativeEnableSuddenTermination(); } static void disableSuddenTermination() { + isSuddenTerminationEnabled = false; nativeDisableSuddenTermination(); } + + public static boolean isSuddenTerminationEnbaled() { + return isSuddenTerminationEnabled; + } } From 201065a6bad37162b03329a36d2e3b23631a601f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 23 Aug 2016 20:45:35 +0300 Subject: [PATCH 018/296] 8160217: JavaSound should clean up resources better Reviewed-by: prr --- .../com/sun/media/sound/ModelByteBuffer.java | 14 ++++++++------ .../ModelByteBuffer/GetInputStream.java | 18 +++++++++++------- .../midi/Gervill/ModelByteBuffer/GetRoot.java | 12 +++++++----- .../midi/Gervill/ModelByteBuffer/Load.java | 13 +++++++------ .../midi/Gervill/ModelByteBuffer/LoadAll.java | 13 +++++++------ .../NewModelByteBufferByteArray.java | 12 +++++++----- .../NewModelByteBufferByteArrayIntInt.java | 12 +++++++----- .../NewModelByteBufferFile.java | 12 +++++++----- .../NewModelByteBufferFileLongLong.java | 12 +++++++----- .../RandomFileInputStream/Available.java | 13 +++++++------ .../RandomFileInputStream/Close.java | 13 +++++++------ .../RandomFileInputStream/MarkReset.java | 13 +++++++------ .../RandomFileInputStream/MarkSupported.java | 13 +++++++------ .../RandomFileInputStream/Read.java | 13 +++++++------ .../RandomFileInputStream/ReadByte.java | 13 +++++++------ .../RandomFileInputStream/ReadByteIntInt.java | 13 +++++++------ .../RandomFileInputStream/Skip.java | 13 +++++++------ .../Gervill/ModelByteBuffer/SubbufferLong.java | 12 +++++++----- .../ModelByteBuffer/SubbufferLongLong.java | 12 +++++++----- .../SubbufferLongLongBoolean.java | 12 +++++++----- .../midi/Gervill/ModelByteBuffer/Unload.java | 13 +++++++------ .../midi/Gervill/ModelByteBuffer/WriteTo.java | 14 ++++++++------ .../ModelByteBufferWavetable/OpenStream.java | 13 +++++++------ .../FrameLengthAfterConversion.java | 4 +++- .../WriteUnsupportedAudioFormat.java | 4 +++- 25 files changed, 173 insertions(+), 133 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java index 028efffbd12..ead39be2867 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -200,11 +200,13 @@ public final class ModelByteBuffer { public void writeTo(OutputStream out) throws IOException { if (root.file != null && root.buffer == null) { - InputStream is = getInputStream(); - byte[] buff = new byte[1024]; - int ret; - while ((ret = is.read(buff)) != -1) - out.write(buff, 0, ret); + try (InputStream is = getInputStream()) { + byte[] buff = new byte[1024]; + int ret; + while ((ret = is.read(buff)) != -1) { + out.write(buff, 0, ret); + } + } } else out.write(array(), (int) arrayOffset(), (int) capacity()); } diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java index e1a39d3c500..72a19c9e80a 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,7 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -54,13 +56,13 @@ public class GetInputStream { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { @@ -76,7 +78,9 @@ public class GetInputStream { buff = new ModelByteBuffer(test_byte_array); byte[] b = new byte[test_byte_array.length]; - buff.getInputStream().read(b); + try (InputStream is = buff.getInputStream()) { + is.read(b); + } for (int j = 0; j < b.length; j++) if(b[i] != test_byte_array[i]) throw new RuntimeException("Byte array compare fails!"); diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java index b9928253678..829900f8ba9 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class GetRoot { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java index 734ed37b4ac..b589048ff98 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,7 +28,8 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -54,13 +55,13 @@ public class Load { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java index e912ee98698..5549393fcda 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,7 +28,8 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -56,13 +57,13 @@ public class LoadAll { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java index edcef873e0a..801926a5c5e 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferByteArray { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java index 3d1ad726598..4c193b9e484 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferByteArrayIntInt { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java index 5a200045671..90b4be57bf2 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferFile { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java index d55466ae5e8..85f93bd852b 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferFileLongLong { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java index c4da3ad8183..659f33c66d0 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Available { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java index 2bfd5891953..4785d4097d0 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Close { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java index bcd8584834e..f8a3570aef7 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class MarkReset { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java index e505d0b9d96..41ed42e08fa 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class MarkSupported { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java index e8fb2818fca..523adf4eaca 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Read { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java index a847b56783b..ceb33fb25fd 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class ReadByte { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java index c8c0a0fe64d..1570df03fae 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class ReadByteIntInt { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java index 96ce0fef5e8..d80a1c6ada5 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Skip { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java index 14eba08157e..ad4dc48ea6e 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class SubbufferLong { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java index d6f9cd82521..75b7bbc45c2 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class SubbufferLongLong { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java index d59349ce709..df84eaf6601 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class SubbufferLongLongBoolean { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java index 1c15fa3a176..8d8895f0266 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,7 +28,8 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -54,13 +55,13 @@ public class Unload { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java index 61ebd221659..2f0b1960c90 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,7 +29,9 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +57,13 @@ public class WriteTo { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java index 01e3b7a26af..7e659d46499 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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,6 +30,8 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -99,16 +101,15 @@ public class OpenStream { buffer_wave = new ModelByteBuffer(baos.toByteArray()); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(baos.toByteArray()); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(baos.toByteArray()); + } buffer_wave_ondisk = new ModelByteBuffer(test_file); } static void tearDown() throws Exception { - if (!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void testOpenStream(ModelByteBufferWavetable wavetable) diff --git a/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java b/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java index e32e7723db5..f61126bd609 100644 --- a/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java +++ b/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java @@ -26,6 +26,8 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -162,7 +164,7 @@ public final class FrameLengthAfterConversion { ais = AudioSystem.getAudioInputStream(temp); final long frameLength = ais.getFrameLength(); ais.close(); - temp.delete(); + Files.delete(Paths.get(temp.getAbsolutePath())); validate(frameLength); } catch (IllegalArgumentException | UnsupportedAudioFileException | IOException ignored) { diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java b/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java index 893205944c3..8b0d8993e87 100644 --- a/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java +++ b/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java @@ -27,6 +27,8 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -91,7 +93,6 @@ public final class WriteUnsupportedAudioFormat { } catch (final IOException e) { throw new RuntimeException(e); } - FILE.deleteOnExit(); for (final Boolean end : new boolean[]{false, true}) { for (final int sampleSize : sampleBits) { @@ -134,6 +135,7 @@ public final class WriteUnsupportedAudioFormat { } } } + Files.delete(Paths.get(FILE.getAbsolutePath())); } /** From 494e502e0cab046eca312e1c05f844029515c3c5 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Wed, 24 Aug 2016 00:23:49 +0400 Subject: [PATCH 019/296] 8129854: Remove reflection from AWT/Swing classes Reviewed-by: serb --- .../classes/apple/laf/JRSUIConstants.java | 41 ++++++++----- .../com/apple/eawt/_AppDockIconHandler.java | 18 ++---- .../classes/com/apple/laf/AquaIcon.java | 5 +- .../com/apple/laf/AquaImageFactory.java | 4 +- .../classes/com/apple/laf/AquaUtils.java | 39 +------------ .../sun/lwawt/macosx/CAccessibility.java | 24 +------- .../classes/sun/lwawt/macosx/CAccessible.java | 32 +++------- .../classes/sun/lwawt/macosx/CImage.java | 19 ++++++ .../share/classes/java/awt/AWTEvent.java | 58 +++---------------- .../share/classes/java/awt/Component.java | 42 +++----------- .../java/awt/KeyboardFocusManager.java | 31 ++-------- .../classes/java/awt/SequencedEvent.java | 4 ++ .../classes/java/awt/event/InputEvent.java | 6 ++ .../classes/java/awt/event/KeyEvent.java | 5 ++ .../javax/accessibility/AccessibleBundle.java | 12 ++++ .../accessibility/AccessibleContext.java | 10 ++++ .../share/classes/javax/swing/ImageIcon.java | 9 +-- .../share/classes/javax/swing/JComponent.java | 16 +++++ .../classes/javax/swing/text/GlyphView.java | 18 +----- .../javax/swing/text/ParagraphView.java | 16 +---- .../javax/swing/text/html/HTMLEditorKit.java | 7 +-- .../share/classes/sun/applet/AppletPanel.java | 30 +--------- .../share/classes/sun/awt/AWTAccessor.java | 58 +++++++++++++++++-- .../share/classes/sun/awt/SunToolkit.java | 20 ------- .../classes/sun/swing/SwingAccessor.java | 33 +++++++++++ .../classes/sun/awt/X11/XComponentPeer.java | 42 +------------- .../awt/X11/XMouseDragGestureRecognizer.java | 4 -- .../unix/classes/sun/awt/X11/XWindow.java | 3 - 28 files changed, 244 insertions(+), 362 deletions(-) diff --git a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java index 272b1f1f25b..8e105132eaa 100644 --- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java +++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java @@ -25,7 +25,6 @@ package apple.laf; -import java.lang.reflect.Field; import java.nio.ByteBuffer; import java.lang.annotation.Native; @@ -70,6 +69,21 @@ public final class JRSUIConstants { throw new RuntimeException("Constant not implemented in native: " + this); } + private String getConstantName(Key hit) { + if (hit == VALUE) { + return "VALUE"; + } else if (hit == THUMB_PROPORTION) { + return "THUMB_PROPORTION"; + } else if (hit == THUMB_START) { + return "THUMB_START"; + } else if (hit == WINDOW_TITLE_BAR_HEIGHT) { + return "WINDOW_TITLE_BAR_HEIGHT"; + } else if (hit == THUMB_START) { + return "ANIMATION_FRAME"; + } + return getClass().getSimpleName(); + } + public String toString() { return getConstantName(this) + (ptr == 0 ? "(unlinked)" : ""); } @@ -138,7 +152,7 @@ public final class JRSUIConstants { } public String toString() { - return getConstantName(this); + return getClass().getSimpleName(); } } @@ -779,6 +793,17 @@ public final class JRSUIConstants { return hit > 0; } + private String getConstantName(Hit hit) { + if (hit == UNKNOWN) { + return "UNKNOWN"; + } else if (hit == NONE) { + return "NONE"; + } else if (hit == HIT) { + return "HIT"; + } + return getClass().getSimpleName(); + } + public String toString() { return getConstantName(this); } @@ -829,16 +854,4 @@ public final class JRSUIConstants { } return Hit.UNKNOWN; } - - static String getConstantName(final Object object) { - final Class clazz = object.getClass(); - try { - for (final Field field : clazz.getFields()) { - if (field.get(null) == object) { - return field.getName(); - } - } - } catch (final Exception e) {} - return clazz.getSimpleName(); - } } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java index eab1efb3447..c9c0c9bcf4d 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java @@ -72,7 +72,7 @@ class _AppDockIconHandler { public void setDockIconImage(final Image image) { try { - final CImage cImage = getCImageCreator().createFromImage(image); + final CImage cImage = CImage.createFromImage(image); final long nsImagePtr = getNSImagePtrFrom(cImage); nativeSetDockIconImage(nsImagePtr); } catch (final Throwable e) { @@ -84,7 +84,11 @@ class _AppDockIconHandler { try { final long dockNSImage = nativeGetDockIconImage(); if (dockNSImage == 0) return null; - return getCImageCreator().createImageUsingNativeSize(dockNSImage); + final Method getCreatorMethod = CImage.class.getDeclaredMethod( + "getCreator", new Class[]{}); + getCreatorMethod.setAccessible(true); + Creator imageCreator = (Creator) getCreatorMethod.invoke(null, new Object[]{}); + return imageCreator.createImageUsingNativeSize(dockNSImage); } catch (final Throwable e) { throw new RuntimeException(e); } @@ -98,16 +102,6 @@ class _AppDockIconHandler { nativeSetDockIconProgress(value); } - static Creator getCImageCreator() { - try { - final Method getCreatorMethod = CImage.class.getDeclaredMethod("getCreator", new Class[] {}); - getCreatorMethod.setAccessible(true); - return (Creator)getCreatorMethod.invoke(null, new Object[] {}); - } catch (final Throwable e) { - throw new RuntimeException(e); - } - } - static long getNSImagePtrFrom(final CImage cImage) { if (cImage == null) return 0; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java index b4bc1e69d58..936fe567c66 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java @@ -37,6 +37,7 @@ import apple.laf.*; import com.apple.laf.AquaUtilControlSize.*; import com.apple.laf.AquaUtils.RecyclableSingleton; +import sun.lwawt.macosx.CImage; public class AquaIcon { interface InvertableIcon extends Icon { @@ -226,7 +227,7 @@ public class AquaIcon { } Image createImage() { - return AquaUtils.getCImageCreator().createImageOfFile(file.getAbsolutePath(), getIconWidth(), getIconHeight()); + return CImage.createImageOfFile(file.getAbsolutePath(), getIconWidth(), getIconHeight()); } } @@ -299,7 +300,7 @@ public class AquaIcon { } Image createImage() { - return AquaUtils.getCImageCreator().createSystemImageFromSelector( + return CImage.createSystemImageFromSelector( selector, getIconWidth(), getIconHeight()); } } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java index c26bcae3d06..5d43a41e502 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java @@ -46,8 +46,8 @@ import com.apple.laf.AquaIcon.JRSUIControlSpec; import com.apple.laf.AquaIcon.SystemIcon; import com.apple.laf.AquaUtils.RecyclableObject; import com.apple.laf.AquaUtils.RecyclableSingleton; -import java.awt.image.MultiResolutionImage; import sun.awt.image.MultiResolutionCachedImage; +import sun.lwawt.macosx.CImage; public class AquaImageFactory { public static IconUIResource getConfirmImageIcon() { @@ -73,7 +73,7 @@ public class AquaImageFactory { public static IconUIResource getLockImageIcon() { // public, because UIDefaults.ProxyLazyValue uses reflection to get this value if (JRSUIUtils.Images.shouldUseLegacySecurityUIPath()) { - final Image lockIcon = AquaUtils.getCImageCreator().createImageFromFile("/System/Library/CoreServices/SecurityAgent.app/Contents/Resources/Security.icns", kAlertIconSize, kAlertIconSize); + final Image lockIcon = CImage.createImageFromFile("/System/Library/CoreServices/SecurityAgent.app/Contents/Resources/Security.icns", kAlertIconSize, kAlertIconSize); return getAppIconCompositedOn(lockIcon); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java index 65c38cca879..5e7d160943c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java @@ -41,8 +41,6 @@ import jdk.internal.loader.ClassLoaders; import sun.awt.AppContext; -import sun.lwawt.macosx.CImage; -import sun.lwawt.macosx.CImage.Creator; import sun.lwawt.macosx.CPlatformWindow; import sun.reflect.misc.ReflectUtil; import sun.security.action.GetPropertyAction; @@ -50,6 +48,7 @@ import sun.swing.SwingUtilities2; import com.apple.laf.AquaImageFactory.SlicedImageControl; import sun.awt.image.MultiResolutionCachedImage; +import sun.swing.SwingAccessor; final class AquaUtils { @@ -78,32 +77,6 @@ final class AquaUtils { } } - private static Creator getCImageCreatorInternal() { - return AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Creator run() { - try { - final Method getCreatorMethod = CImage.class.getDeclaredMethod( - "getCreator", new Class[] {}); - getCreatorMethod.setAccessible(true); - return (Creator)getCreatorMethod.invoke(null, new Object[] {}); - } catch (final Exception ignored) { - return null; - } - } - }); - } - - private static final RecyclableSingleton cImageCreator = new RecyclableSingleton() { - @Override - protected Creator getInstance() { - return getCImageCreatorInternal(); - } - }; - static Creator getCImageCreator() { - return cImageCreator.get(); - } - static Image generateSelectedDarkImage(final Image image) { final ImageFilter filter = new IconImageFilter() { @Override @@ -405,15 +378,9 @@ final class AquaUtils { } }; - private static final Integer OPAQUE_SET_FLAG = 24; // private int JComponent.OPAQUE_SET + private static final int OPAQUE_SET_FLAG = 24; // private int JComponent.OPAQUE_SET static boolean hasOpaqueBeenExplicitlySet(final JComponent c) { - final Method method = getJComponentGetFlagMethod.get(); - if (method == null) return false; - try { - return Boolean.TRUE.equals(method.invoke(c, OPAQUE_SET_FLAG)); - } catch (final Throwable ignored) { - return false; - } + return SwingAccessor.getJComponentAccessor().getFlag(c, OPAQUE_SET_FLAG); } private static boolean isWindowTextured(final Component c) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java index 00cb5274be2..3307e5b0e86 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java @@ -37,6 +37,7 @@ import sun.awt.AWTAccessor; import javax.accessibility.*; import javax.swing.*; +import sun.awt.AWTAccessor; class CAccessibility implements PropertyChangeListener { private static Set ignoredRoles; @@ -205,33 +206,12 @@ class CAccessibility implements PropertyChangeListener { }, c); } - static Field getAccessibleBundleKeyFieldWithReflection() { - try { - final Field fieldKey = AccessibleBundle.class.getDeclaredField("key"); - fieldKey.setAccessible(true); - return fieldKey; - } catch (final SecurityException e) { - e.printStackTrace(); - } catch (final NoSuchFieldException e) { - e.printStackTrace(); - } - return null; - } - private static final Field FIELD_KEY = getAccessibleBundleKeyFieldWithReflection(); - static String getAccessibleRoleFor(final Accessible a) { final AccessibleContext ac = a.getAccessibleContext(); if (ac == null) return null; final AccessibleRole role = ac.getAccessibleRole(); - try { - return (String)FIELD_KEY.get(role); - } catch (final IllegalArgumentException e) { - e.printStackTrace(); - } catch (final IllegalAccessException e) { - e.printStackTrace(); - } - return null; + return AWTAccessor.getAccessibleBundleAccessor().getKey(role); } public static String getAccessibleRole(final Accessible a, final Component c) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java index 6ac0a07ca0f..d3d3dca9538 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java @@ -28,7 +28,6 @@ package sun.lwawt.macosx; import java.awt.Component; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.lang.reflect.Field; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; @@ -41,36 +40,23 @@ import static javax.accessibility.AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT import static javax.accessibility.AccessibleContext.ACCESSIBLE_CARET_PROPERTY; import static javax.accessibility.AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY; import static javax.accessibility.AccessibleContext.ACCESSIBLE_TEXT_PROPERTY; +import sun.awt.AWTAccessor; class CAccessible extends CFRetainedResource implements Accessible { - static Field getNativeAXResourceField() { - try { - final Field field = AccessibleContext.class.getDeclaredField("nativeAXResource"); - field.setAccessible(true); - return field; - } catch (final Exception e) { - e.printStackTrace(); - return null; - } - } - - private static Field nativeAXResourceField = getNativeAXResourceField(); public static CAccessible getCAccessible(final Accessible a) { if (a == null) return null; AccessibleContext context = a.getAccessibleContext(); - try { - final CAccessible cachedCAX = (CAccessible) nativeAXResourceField.get(context); - if (cachedCAX != null) return cachedCAX; - - final CAccessible newCAX = new CAccessible(a); - nativeAXResourceField.set(context, newCAX); - return newCAX; - } catch (final Exception e) { - e.printStackTrace(); - return null; + AWTAccessor.AccessibleContextAccessor accessor + = AWTAccessor.getAccessibleContextAccessor(); + final CAccessible cachedCAX = (CAccessible) accessor.getNativeAXResource(context); + if (cachedCAX != null) { + return cachedCAX; } + final CAccessible newCAX = new CAccessible(a); + accessor.setNativeAXResource(context, newCAX); + return newCAX; } private static native void unregisterFromCocoaAXSystem(long ptr); diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java index a5504cbee25..61f41a2c70f 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java @@ -56,6 +56,25 @@ public class CImage extends CFRetainedResource { return creator; } + // This is used to create a CImage that represents the icon of the given file. + public static Image createImageOfFile(String file, int width, int height) { + return getCreator().createImageOfFile(file, width, height); + } + + public static Image createSystemImageFromSelector(String iconSelector, + int width, int height) { + return getCreator().createSystemImageFromSelector(iconSelector, width, height); + } + + public static Image createImageFromFile(String file, double width, double height) { + return getCreator().createImageFromFile(file, width, height); + } + + // This is used to create a CImage from a Image + public static CImage createFromImage(final Image image) { + return getCreator().createFromImage(image); + } + public static class Creator { Creator() { } diff --git a/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java b/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java index 1c723aeb133..9250597ac81 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java @@ -284,35 +284,6 @@ public abstract class AWTEvent extends EventObject { }); } - private static synchronized Field get_InputEvent_CanAccessSystemClipboard() { - if (inputEvent_CanAccessSystemClipboard_Field == null) { - inputEvent_CanAccessSystemClipboard_Field = - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Field run() { - Field field = null; - try { - field = InputEvent.class. - getDeclaredField("canAccessSystemClipboard"); - field.setAccessible(true); - return field; - } catch (SecurityException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got SecurityException ", e); - } - } catch (NoSuchFieldException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got NoSuchFieldException ", e); - } - } - return null; - } - }); - } - - return inputEvent_CanAccessSystemClipboard_Field; - } - /** * Initialize JNI field and method IDs for fields that may be * accessed from C. @@ -593,33 +564,20 @@ public abstract class AWTEvent extends EventObject { that.bdata = this.bdata; // Copy canAccessSystemClipboard value from this into that. if (this instanceof InputEvent && that instanceof InputEvent) { - Field field = get_InputEvent_CanAccessSystemClipboard(); - if (field != null) { - try { - boolean b = field.getBoolean(this); - field.setBoolean(that, b); - } catch(IllegalAccessException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e); - } - } - } + + AWTAccessor.InputEventAccessor accessor + = AWTAccessor.getInputEventAccessor(); + + boolean b = accessor.canAccessSystemClipboard((InputEvent) this); + accessor.setCanAccessSystemClipboard((InputEvent) that, b); } that.isSystemGenerated = this.isSystemGenerated; } void dispatched() { if (this instanceof InputEvent) { - Field field = get_InputEvent_CanAccessSystemClipboard(); - if (field != null) { - try { - field.setBoolean(this, false); - } catch(IllegalAccessException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.dispatched() got IllegalAccessException ", e); - } - } - } + AWTAccessor.getInputEventAccessor(). + setCanAccessSystemClipboard((InputEvent) this, false); } } } // class AWTEvent diff --git a/jdk/src/java.desktop/share/classes/java/awt/Component.java b/jdk/src/java.desktop/share/classes/java/awt/Component.java index c2a021fd595..25c6ee2b1aa 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Component.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java @@ -53,13 +53,11 @@ import java.beans.Transient; import java.awt.im.InputContext; import java.awt.im.InputMethodRequests; import java.awt.dnd.DropTarget; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.AccessControlContext; import javax.accessibility.*; import java.applet.Applet; +import javax.swing.JComponent; import sun.awt.ComponentFactory; import sun.security.action.GetPropertyAction; @@ -81,6 +79,7 @@ import sun.java2d.pipe.hw.ExtendedBufferCapabilities; import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*; import sun.awt.RequestFocusController; import sun.java2d.SunGraphicsEnvironment; +import sun.swing.SwingAccessor; import sun.util.logging.PlatformLogger; /** @@ -8695,6 +8694,9 @@ public abstract class Component implements ImageObserver, MenuContainer, * the Swing package private method {@code compWriteObjectNotify}. */ private void doSwingSerialization() { + if (!(this instanceof JComponent)) { + return; + } @SuppressWarnings("deprecation") Package swingPackage = Package.getPackage("javax.swing"); // For Swing serialization to correctly work Swing needs to @@ -8707,36 +8709,10 @@ public abstract class Component implements ImageObserver, MenuContainer, klass = klass.getSuperclass()) { if (klass.getPackage() == swingPackage && klass.getClassLoader() == null) { - final Class swingClass = klass; - // Find the first override of the compWriteObjectNotify method - Method[] methods = AccessController.doPrivileged( - new PrivilegedAction() { - public Method[] run() { - return swingClass.getDeclaredMethods(); - } - }); - for (int counter = methods.length - 1; counter >= 0; - counter--) { - final Method method = methods[counter]; - if (method.getName().equals("compWriteObjectNotify")){ - // We found it, use doPrivileged to make it accessible - // to use. - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - method.setAccessible(true); - return null; - } - }); - // Invoke the method - try { - method.invoke(this, (Object[]) null); - } catch (IllegalAccessException iae) { - } catch (InvocationTargetException ite) { - } - // We're done, bail. - return; - } - } + + SwingAccessor.getJComponentAccessor() + .compWriteObjectNotify((JComponent) this); + return; } } } diff --git a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java index aa9d64367a4..1e9e2f4bfd0 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java +++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java @@ -40,8 +40,6 @@ import java.beans.VetoableChangeSupport; import java.lang.ref.WeakReference; -import java.lang.reflect.Field; - import java.security.AccessController; import java.security.PrivilegedAction; @@ -140,6 +138,10 @@ public abstract class KeyboardFocusManager public void removeLastFocusRequest(Component heavyweight) { KeyboardFocusManager.removeLastFocusRequest(heavyweight); } + @Override + public Component getMostRecentFocusOwner(Window window) { + return KeyboardFocusManager.getMostRecentFocusOwner(window); + } public void setMostRecentFocusOwner(Window window, Component component) { KeyboardFocusManager.setMostRecentFocusOwner(window, component); } @@ -3053,32 +3055,9 @@ public abstract class KeyboardFocusManager } } - static Field proxyActive; // Accessor to private field isProxyActive of KeyEvent private static boolean isProxyActiveImpl(KeyEvent e) { - if (proxyActive == null) { - proxyActive = AccessController.doPrivileged(new PrivilegedAction() { - public Field run() { - Field field = null; - try { - field = KeyEvent.class.getDeclaredField("isProxyActive"); - if (field != null) { - field.setAccessible(true); - } - } catch (NoSuchFieldException nsf) { - assert(false); - } - return field; - } - }); - } - - try { - return proxyActive.getBoolean(e); - } catch (IllegalAccessException iae) { - assert(false); - } - return false; + return AWTAccessor.getKeyEventAccessor().isProxyActive(e); } // Returns the value of this KeyEvent's field isProxyActive diff --git a/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java b/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java index 678067ab143..394686a7ba3 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java @@ -63,6 +63,10 @@ class SequencedEvent extends AWTEvent implements ActiveEvent { public boolean isSequencedEvent(AWTEvent event) { return event instanceof SequencedEvent; } + + public AWTEvent create(AWTEvent event) { + return new SequencedEvent(event); + } }); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java index d332d2d2735..ec9bd0be0a1 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java @@ -302,6 +302,12 @@ public abstract class InputEvent extends ComponentEvent { public boolean canAccessSystemClipboard(InputEvent event) { return event.canAccessSystemClipboard; } + + @Override + public void setCanAccessSystemClipboard(InputEvent event, + boolean canAccessSystemClipboard) { + event.canAccessSystemClipboard = canAccessSystemClipboard; + } }); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java index f103d525271..0ca378d556b 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java @@ -1091,6 +1091,11 @@ public class KeyEvent extends InputEvent { public Component getOriginalSource( KeyEvent ev ) { return ev.originalSource; } + + @Override + public boolean isProxyActive(KeyEvent ev) { + return ev.isProxyActive; + } }); } diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java index 936322af467..5e2d97b43e5 100644 --- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java +++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java @@ -31,6 +31,7 @@ import java.util.Vector; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; +import sun.awt.AWTAccessor; /** *

Base class used to maintain a strongly typed enumeration. This is @@ -53,6 +54,17 @@ public abstract class AccessibleBundle { private final String defaultResourceBundleName = "com.sun.accessibility.internal.resources.accessibility"; + static { + AWTAccessor.setAccessibleBundleAccessor( + new AWTAccessor.AccessibleBundleAccessor() { + + @Override + public String getKey(AccessibleBundle accessibleBundle) { + return accessibleBundle.key; + } + }); + } + /** * Construct an {@code AccessibleBundle}. */ diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java index 65a163fa4ca..c3a30f3a5ae 100644 --- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java +++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java @@ -99,6 +99,16 @@ public abstract class AccessibleContext { public AppContext getAppContext(AccessibleContext accessibleContext) { return accessibleContext.targetAppContext; } + + @Override + public Object getNativeAXResource(AccessibleContext accessibleContext) { + return accessibleContext.nativeAXResource; + } + + @Override + public void setNativeAXResource(AccessibleContext accessibleContext, Object value) { + accessibleContext.nativeAXResource = value; + } }); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java b/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java index 8a63fe74cab..e12241f5771 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java @@ -40,8 +40,8 @@ import java.util.Locale; import javax.accessibility.*; import sun.awt.AppContext; -import java.lang.reflect.Field; import java.security.*; +import sun.awt.AWTAccessor; /** * An implementation of the Icon interface that paints Icons @@ -106,11 +106,8 @@ public class ImageIcon implements Icon, Serializable, Accessible { final Component component = createNoPermsComponent(); // 6482575 - clear the appContext field so as not to leak it - Field appContextField = - - Component.class.getDeclaredField("appContext"); - appContextField.setAccessible(true); - appContextField.set(component, null); + AWTAccessor.getComponentAccessor(). + setAppContext(component, null); return component; } catch (Throwable e) { diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java index 3d6025407d9..74abca7dc54 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java @@ -55,6 +55,7 @@ import javax.accessibility.*; import sun.awt.AWTAccessor; import sun.awt.SunToolkit; +import sun.swing.SwingAccessor; import sun.swing.SwingUtilities2; /** @@ -376,6 +377,21 @@ public abstract class JComponent extends Container implements Serializable, private transient Object aaHint; private transient Object lcdRenderingHint; + static { + SwingAccessor.setJComponentAccessor(new SwingAccessor.JComponentAccessor() { + + @Override + public boolean getFlag(JComponent comp, int aFlag) { + return comp.getFlag(aFlag); + } + + @Override + public void compWriteObjectNotify(JComponent comp) { + comp.compWriteObjectNotify(); + } + }); + } + static Graphics safelyGetGraphics(Component c) { return safelyGetGraphics(c, SwingUtilities.getRoot(c)); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java index 2698c90bc6e..894f3fabe18 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java @@ -261,23 +261,7 @@ public class GlyphView extends View implements TabableView, Cloneable { if (painter == null) { if (defaultPainter == null) { // the classname should probably come from a property file. - String classname = "javax.swing.text.GlyphPainter1"; - try { - Class c; - ClassLoader loader = getClass().getClassLoader(); - if (loader != null) { - c = loader.loadClass(classname); - } else { - c = Class.forName(classname); - } - Object o = c.newInstance(); - if (o instanceof GlyphPainter) { - defaultPainter = (GlyphPainter) o; - } - } catch (Throwable e) { - throw new StateInvariantError("GlyphView: Can't load glyph painter: " - + classname); - } + defaultPainter = new GlyphPainter1(); } setGlyphPainter(defaultPainter.getPainter(this, getStartOffset(), getEndOffset())); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java index 154db5cf7ef..fc96021ccc3 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java @@ -61,20 +61,8 @@ public class ParagraphView extends FlowView implements TabExpander { Object i18nFlag = doc.getProperty(AbstractDocument.I18NProperty); if ((i18nFlag != null) && i18nFlag.equals(Boolean.TRUE)) { try { - if (i18nStrategy == null) { - // the classname should probably come from a property file. - String classname = "javax.swing.text.TextLayoutStrategy"; - ClassLoader loader = getClass().getClassLoader(); - if (loader != null) { - i18nStrategy = loader.loadClass(classname); - } else { - i18nStrategy = Class.forName(classname); - } - } - Object o = i18nStrategy.newInstance(); - if (o instanceof FlowStrategy) { - strategy = (FlowStrategy) o; - } + // the classname should probably come from a property file. + strategy = new TextLayoutStrategy(); } catch (Throwable e) { throw new StateInvariantError("ParagraphView: Can't create i18n strategy: " + e.getMessage()); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java index 78157460653..57beae1ddb9 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java @@ -40,6 +40,7 @@ import javax.accessibility.*; import java.lang.ref.*; import java.security.AccessController; import java.security.PrivilegedAction; +import javax.swing.text.html.parser.ParserDelegator; /** * The Swing JEditorPane text component supports different kinds @@ -610,11 +611,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { */ protected Parser getParser() { if (defaultParser == null) { - try { - Class c = Class.forName("javax.swing.text.html.parser.ParserDelegator"); - defaultParser = (Parser) c.newInstance(); - } catch (Throwable e) { - } + defaultParser = new ParserDelegator(); } return defaultParser; } diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java index 404131827fe..d03e5be0527 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java @@ -616,34 +616,8 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable { * calls KeyboardFocusManager directly. */ private Component getMostRecentFocusOwnerForWindow(Window w) { - Method meth = AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Method run() { - Method meth = null; - try { - meth = KeyboardFocusManager.class.getDeclaredMethod( - "getMostRecentFocusOwner", - new Class[]{Window.class}); - meth.setAccessible(true); - } catch (Exception e) { - // Must never happen - e.printStackTrace(); - } - return meth; - } - }); - if (meth != null) { - // Meth refers static method - try { - return (Component)meth.invoke(null, new Object[] {w}); - } catch (Exception e) { - // Must never happen - e.printStackTrace(); - } - } - // Will get here if exception was thrown or meth is null - return w.getMostRecentFocusOwner(); + return AWTAccessor.getKeyboardFocusManagerAccessor() + .getMostRecentFocusOwner(w); } /* diff --git a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java index 796b7ab5d79..f59f064c111 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java @@ -34,6 +34,7 @@ import java.awt.dnd.DragSourceContext; import java.awt.dnd.DropTargetContext; import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.dnd.peer.DropTargetContextPeer; +import java.awt.event.AWTEventListener; import java.awt.event.InputEvent; import java.awt.event.InvocationEvent; import java.awt.event.KeyEvent; @@ -48,6 +49,7 @@ import java.security.AccessControlContext; import java.io.File; import java.util.ResourceBundle; import java.util.Vector; +import javax.accessibility.AccessibleBundle; /** * The AWTAccessor utility class. @@ -406,6 +408,8 @@ public final class AWTAccessor { * Accessor for InputEvent.canAccessSystemClipboard field */ boolean canAccessSystemClipboard(InputEvent event); + void setCanAccessSystemClipboard(InputEvent event, + boolean canAccessSystemClipboard); } /* @@ -454,6 +458,11 @@ public final class AWTAccessor { */ void removeLastFocusRequest(Component heavyweight); + /** + * Gets the most recent focus owner in the window. + */ + Component getMostRecentFocusOwner(Window window); + /** * Sets the most recent focus owner in the window. */ @@ -708,6 +717,11 @@ public final class AWTAccessor { * Gets original source for KeyEvent */ Component getOriginalSource(KeyEvent ev); + + /** + * Gets isProxyActive field for KeyEvent + */ + boolean isProxyActive(KeyEvent ev); } /** @@ -758,6 +772,11 @@ public final class AWTAccessor { * Returns true if the event is an instances of SequencedEvent. */ boolean isSequencedEvent(AWTEvent event); + + /* + * Creates SequencedEvent with the given nested event + */ + AWTEvent create(AWTEvent event); } /* @@ -787,6 +806,15 @@ public final class AWTAccessor { public interface AccessibleContextAccessor { void setAppContext(AccessibleContext accessibleContext, AppContext appContext); AppContext getAppContext(AccessibleContext accessibleContext); + Object getNativeAXResource(AccessibleContext accessibleContext); + void setNativeAXResource(AccessibleContext accessibleContext, Object value); + } + + /* + * An accessor object for the AccessibleContext class + */ + public interface AccessibleBundleAccessor { + String getKey(AccessibleBundle accessibleBundle); } /* @@ -845,6 +873,7 @@ public final class AWTAccessor { private static InvocationEventAccessor invocationEventAccessor; private static SystemColorAccessor systemColorAccessor; private static AccessibleContextAccessor accessibleContextAccessor; + private static AccessibleBundleAccessor accessibleBundleAccessor; private static DragSourceContextAccessor dragSourceContextAccessor; private static DropTargetContextAccessor dropTargetContextAccessor; @@ -1235,9 +1264,13 @@ public final class AWTAccessor { * Get the accessor object for the java.awt.SequencedEvent class. */ public static SequencedEventAccessor getSequencedEventAccessor() { - // The class is not public. So we can't ensure it's initialized. - // Null returned value means it's not initialized - // (so not a single instance of the event has been created). + if (sequencedEventAccessor == null) { + try { + unsafe.ensureClassInitialized( + Class.forName("java.awt.SequencedEvent")); + } catch (ClassNotFoundException ignore) { + } + } return sequencedEventAccessor; } @@ -1301,6 +1334,23 @@ public final class AWTAccessor { return accessibleContextAccessor; } + /* + * Set the accessor object for the javax.accessibility.AccessibleBundle class. + */ + public static void setAccessibleBundleAccessor(AccessibleBundleAccessor accessor) { + AWTAccessor.accessibleBundleAccessor = accessor; + } + + /* + * Get the accessor object for the javax.accessibility.AccessibleBundle class. + */ + public static AccessibleBundleAccessor getAccessibleBundleAccessor() { + if (accessibleBundleAccessor == null) { + unsafe.ensureClassInitialized(AccessibleBundle.class); + } + return accessibleBundleAccessor; + } + /* * Set the accessor object for the javax.accessibility.AccessibleContext class. */ @@ -1342,4 +1392,4 @@ public final class AWTAccessor { AWTAccessor.dropTargetContextAccessor = accessor; } -} +} \ No newline at end of file diff --git a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java index 8461974375f..c017454ec0f 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java @@ -372,26 +372,6 @@ public abstract class SunToolkit extends Toolkit cont.setFocusTraversalPolicy(defaultPolicy); } - private static FocusTraversalPolicy createLayoutPolicy() { - FocusTraversalPolicy policy = null; - try { - Class layoutPolicyClass = - Class.forName("javax.swing.LayoutFocusTraversalPolicy"); - policy = (FocusTraversalPolicy)layoutPolicyClass.newInstance(); - } - catch (ClassNotFoundException e) { - assert false; - } - catch (InstantiationException e) { - assert false; - } - catch (IllegalAccessException e) { - assert false; - } - - return policy; - } - /* * Insert a mapping from target to AppContext, for later retrieval * via targetToAppContext() above. diff --git a/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java b/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java index 66d20f2458b..76a9f63ec1b 100644 --- a/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java +++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java @@ -50,6 +50,16 @@ public final class SwingAccessor { private SwingAccessor() { } + /** + * An accessor for the JComponent class. + */ + public interface JComponentAccessor { + + boolean getFlag(JComponent comp, int aFlag); + + void compWriteObjectNotify(JComponent comp); + } + /** * An accessor for the JTextComponent class. * Note that we intentionally introduce the JTextComponentAccessor, @@ -105,6 +115,29 @@ public final class SwingAccessor { KeyStroke create(); } + /** + * The javax.swing.JComponent class accessor object. + */ + private static JComponentAccessor jComponentAccessor; + + /** + * Set an accessor object for the javax.swing.JComponent class. + */ + public static void setJComponentAccessor(JComponentAccessor jCompAccessor) { + jComponentAccessor = jCompAccessor; + } + + /** + * Retrieve the accessor object for the javax.swing.JComponent class. + */ + public static JComponentAccessor getJComponentAccessor() { + if (jComponentAccessor == null) { + unsafe.ensureClassInitialized(JComponent.class); + } + + return jComponentAccessor; + } + /** * The javax.swing.text.JTextComponent class accessor object. */ diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java index c65a7c79f96..846e06bb864 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java @@ -57,8 +57,6 @@ import java.awt.image.ImageProducer; import java.awt.image.VolatileImage; import java.awt.peer.ComponentPeer; import java.awt.peer.ContainerPeer; -import java.lang.reflect.*; -import java.security.*; import java.util.Collection; import java.util.Objects; import java.util.Set; @@ -241,46 +239,8 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget return false; } - private static Class seClass; - private static Constructor seCtor; - static final AWTEvent wrapInSequenced(AWTEvent event) { - try { - if (seClass == null) { - seClass = Class.forName("java.awt.SequencedEvent"); - } - - if (seCtor == null) { - seCtor = AccessController.doPrivileged(new - PrivilegedExceptionAction>() { - public Constructor run() throws Exception { - Constructor ctor = seClass.getConstructor( - new Class[] { AWTEvent.class }); - ctor.setAccessible(true); - return ctor; - } - }); - } - - return (AWTEvent) seCtor.newInstance(new Object[] { event }); - } - catch (ClassNotFoundException e) { - throw new NoClassDefFoundError("java.awt.SequencedEvent."); - } - catch (PrivilegedActionException ex) { - throw new NoClassDefFoundError("java.awt.SequencedEvent."); - } - catch (InstantiationException e) { - assert false; - } - catch (IllegalAccessException e) { - assert false; - } - catch (InvocationTargetException e) { - assert false; - } - - return null; + return AWTAccessor.getSequencedEventAccessor().create(event); } // TODO: consider moving it to KeyboardFocusManagerPeerImpl diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java index 4422e7a8b35..e457c43e91e 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java @@ -36,10 +36,6 @@ import java.awt.dnd.DragGestureListener; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; - -import java.lang.reflect.*; import sun.awt.dnd.SunDragSourceContextPeer; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java index 907446ad81c..0c5cc361c76 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java @@ -32,8 +32,6 @@ import java.awt.image.ColorModel; import java.lang.ref.WeakReference; -import java.lang.reflect.Method; - import sun.awt.AWTAccessor.ComponentAccessor; import sun.util.logging.PlatformLogger; @@ -395,7 +393,6 @@ class XWindow extends XBaseWindow implements X11ComponentPeer { return false; } - static Method m_sendMessage; static void sendEvent(final AWTEvent e) { // The uses of this method imply that the incoming event is system-generated SunToolkit.setSystemGenerated(e); From 21d1580782cd6091be4467a307082f9406fc8f30 Mon Sep 17 00:00:00 2001 From: Yuka Kamiya Date: Wed, 24 Aug 2016 09:45:20 +0900 Subject: [PATCH 020/296] 8164628: update copyright header in java.awt.font.JavaAWTFontAccessImpl class Reviewed-by: prr, iris --- .../share/classes/java/awt/font/JavaAWTFontAccessImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java b/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java index ff2849807ba..738cd6c9dc9 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java +++ b/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 From 60eccdede5062e8db3a998114f874f78f54cda98 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Wed, 24 Aug 2016 10:59:17 -0700 Subject: [PATCH 021/296] 8149562: TIFFField#createFromMetadataNode javadoc should provide information about sibling/child nodes that should be part of parameter node Add a throws clause to the TIFFField.createFromMetadataNode method specification stating that the supplied Node parameter must adhere to the TIFFField element structure defined by the TIFF native image metadata DTD. Reviewed-by: prr, darcy, serb --- .../javax/imageio/plugins/tiff/TIFFField.java | 34 +++++++++++++------ .../imageio/plugins/tiff/TIFFFieldTest.java | 15 ++++++-- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java index edcb086cb45..da9ade0d8f7 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -412,7 +412,7 @@ public class TIFFField implements Cloneable { /** * Creates a {@code TIFFField} from a TIFF native image - * metadata node. If the value of the "number" attribute + * metadata node. If the value of the {@code "number"} attribute * of the node is not found in {@code tagSet} then a new * {@code TIFFTag} with name {@code TIFFTag.UNKNOWN_TAG_NAME} * will be created and assigned to the field. @@ -420,20 +420,22 @@ public class TIFFField implements Cloneable { * @param tagSet The {@code TIFFTagSet} to which the * {@code TIFFTag} of the field belongs. * @param node A native TIFF image metadata {@code TIFFField} node. - * @throws NullPointerException if {@code node} is - * {@code null}. - * @throws IllegalArgumentException if the name of the node is not - * {@code "TIFFField"}. - * @throws NullPointerException if the node does not contain any data. - * @throws IllegalArgumentException if the combination of node attributes - * and data is not legal per the {@link #TIFFField(TIFFTag,int,int,Object)} - * constructor specification. + * @throws IllegalArgumentException If the {@code Node} parameter content + * does not adhere to the {@code TIFFField} element structure defined by + * the + * TIFF native image metadata format specification, or if the + * combination of node attributes and data is not legal per the + * {@link #TIFFField(TIFFTag,int,int,Object)} constructor specification. + * Note that a cause might be set on such an exception. * @return A new {@code TIFFField}. */ public static TIFFField createFromMetadataNode(TIFFTagSet tagSet, Node node) { if (node == null) { - throw new NullPointerException("node == null!"); + // This method is specified to throw only IllegalArgumentExceptions + // so we create an IAE with a NullPointerException as its cause. + throw new IllegalArgumentException(new NullPointerException + ("node == null!")); } String name = node.getNodeName(); if (!name.equals("TIFFField")) { @@ -487,7 +489,17 @@ public class TIFFField implements Cloneable { tag = new TIFFTag(TIFFTag.UNKNOWN_TAG_NAME, tagNumber, 1 << type); } - return new TIFFField(tag, type, count, data); + TIFFField field; + try { + field = new TIFFField(tag, type, count, data); + } catch (NullPointerException npe) { + // This method is specified to throw only IllegalArgumentExceptions + // so we catch the NullPointerException and set it as the cause of + // the IAE which is thrown. + throw new IllegalArgumentException(npe); + } + + return field; } /** diff --git a/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java b/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java index a50929e8a46..936a5e3af68 100644 --- a/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java +++ b/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java @@ -23,7 +23,7 @@ /** * @test - * @bug 8152183 + * @bug 8152183 8149562 * @author a.stepanov * @summary Some checks for TIFFField methods * @run main TIFFFieldTest @@ -455,8 +455,17 @@ public class TIFFFieldTest { TIFFTagSet ts = new TIFFTagSet(tags); boolean ok = false; - try { TIFFField.createFromMetadataNode(ts, null); } - catch (NullPointerException e) { ok = true; } + try { + TIFFField.createFromMetadataNode(ts, null); + } catch (IllegalArgumentException e) { + // createFromMetadataNode() formerly threw a NullPointerException + // if its Node parameter was null, but the specification has been + // modified to allow only IllegalArgumentExceptions, perhaps with + // a cause set. In the present invocation the cause would be set + // to a NullPointerException but this is not explicitly specified + // hence not verified here. + ok = true; + } check(ok, "can create TIFFField from a null node"); TIFFField f = new TIFFField(tag, v); From 1e96a6f24b4f5fd71b2c4e10b42ec94eee5dd0d0 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 24 Aug 2016 12:56:51 -0700 Subject: [PATCH 022/296] 8164752: Extraneous debugging printf in hb-jdk-font.cc Reviewed-by: bpb --- jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc index f7df0f27cbe..93ac190b4d1 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc @@ -52,7 +52,6 @@ hb_jdk_get_glyph (hb_font_t *font HB_UNUSED, *glyph = (hb_codepoint_t) env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, u); -printf("unicode=%x glyph=%x\n", unicode, *glyph); return (*glyph != 0); } From b9b87f5a33788b889aeda2ccd1ebabf6a7dd572e Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 24 Aug 2016 13:36:46 -0700 Subject: [PATCH 023/296] 8139176: [macosx] java.awt.TextLayout does not handle correctly the bolded logical fonts Reviewed-by: serb, vadim --- .../macosx/classes/sun/font/CFont.java | 12 ++ .../font/TextLayout/StyledFontLayoutTest.java | 118 ++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java index dcc4b5793eb..049dbb58619 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java +++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java @@ -278,6 +278,18 @@ public final class CFont extends PhysicalFont implements FontSubstitution { return getStrike(font, DEFAULT_FRC); } + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + + return ((Font2D)o).getStyle() == this.getStyle(); + } + + public int hashCode() { + return super.hashCode() ^ this.getStyle(); + } + public String toString() { return "CFont { fullName: " + fullName + ", familyName: " + familyName + ", style: " + style + diff --git a/jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java b/jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java new file mode 100644 index 00000000000..806381451df --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8139176 + * @summary Test layout uses correct styled font. + * @run main StyledFontLayoutTest + */ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; + +public class StyledFontLayoutTest extends JPanel { + + static final int W=600, H=400; + static boolean interactive; + static BufferedImage im; + public static void main(String[] args) { + + interactive = args.length > 0; + + runTest(); + + if (!interactive) { + return; + } + SwingUtilities.invokeLater(() -> { + JFrame frame = new JFrame("Styled Font Layout Test"); + frame.add(new StyledFontLayoutTest()); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.setSize(W, H); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + } + + @Override + protected void paintComponent(Graphics g) { + g.drawImage(im, 0, 0, null); + } + + private static void runTest() { + im = new BufferedImage(W, H, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = im.createGraphics(); + g2d.setColor(Color.white); + g2d.fillRect(0, 0, W, H); + g2d.setColor(Color.black); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + char[] chs = "Sample Text.".toCharArray(); + int len = chs.length; + + int x = 50, y = 100; + + FontRenderContext frc = g2d.getFontRenderContext(); + Font plain = new Font("Serif", Font.PLAIN, 48); + GlyphVector pgv = plain.layoutGlyphVector(frc, chs, 0, len, 0); + g2d.setFont(plain); + g2d.drawChars(chs, 0, len, x, y); y +=50; + + g2d.drawGlyphVector(pgv, x, y); y += 50; + Rectangle2D plainStrBounds = plain.getStringBounds(chs, 0, len, frc); + Rectangle2D plainGVBounds = pgv.getLogicalBounds(); + Font bold = new Font("Serif", Font.BOLD, 48); + GlyphVector bgv = bold.layoutGlyphVector(frc, chs, 0, len, 0); + Rectangle2D boldStrBounds = bold.getStringBounds(chs, 0, len, frc); + Rectangle2D boldGVBounds = bgv.getLogicalBounds(); + g2d.setFont(bold); + g2d.drawChars(chs, 0, len, x, y); y +=50; + g2d.drawGlyphVector(bgv, x, y); + System.out.println("Plain String Bounds = " + plainStrBounds); + System.out.println("Bold String Bounds = " + boldStrBounds); + System.out.println("Plain GlyphVector Bounds = " + plainGVBounds); + System.out.println("Bold GlyphVector Bounds = " + boldGVBounds); + if (!plainStrBounds.equals(boldStrBounds) && + plainGVBounds.equals(boldGVBounds)) + { + System.out.println("Test failed: Plain GV bounds same as Bold"); + if (!interactive) { + throw new RuntimeException("Plain GV bounds same as Bold"); + } + } + + }; +} From 93fe235cf7b099cc4eaa2f40a61c40ad0ab53ce9 Mon Sep 17 00:00:00 2001 From: Avik Niyogi Date: Thu, 25 Aug 2016 13:46:17 +0530 Subject: [PATCH 024/296] 8163161: [PIT][TEST_BUG] increase timeout in javax/swing/plaf/nimbus/8057791/bug8057791.java Reviewed-by: alexsch, rchamyal --- jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java b/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java index d8146b61b09..3731bed23ea 100644 --- a/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java +++ b/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java @@ -22,9 +22,10 @@ */ /* @test - @bug 8057791 8160438 - @summary Selection in JList is drawn with wrong colors in Nimbus L&F - @run main bug8057791 + @key headful + @bug 8057791 8160438 8163161 + @summary Selection in JList is drawn with wrong colors in Nimbus L&F + @run main/timeout=500 bug8057791 */ import java.awt.Color; import java.awt.Font; From e1726f30e883e6c1d3257dbb8227e38bb0d552c2 Mon Sep 17 00:00:00 2001 From: Ajit Ghaisas Date: Thu, 25 Aug 2016 14:12:13 +0530 Subject: [PATCH 025/296] 8158356: SIGSEGV when attempting to rotate BufferedImage using AffineTransform by NaN degrees Reviewed-by: flar, prr --- .../libawt/awt/medialib/awt_ImagingLib.c | 25 +++- .../native/libmlib_image/mlib_ImageScanPoly.c | 18 ++- .../share/native/libmlib_image/safe_math.h | 7 +- .../InvalidTransformParameterTest.java | 138 ++++++++++++++++++ 4 files changed, 185 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java diff --git a/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c b/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c index 472b5eed491..15c705a5fec 100644 --- a/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c +++ b/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -772,6 +772,7 @@ Java_sun_awt_image_ImagingLib_transformBI(JNIEnv *env, jobject this, mlib_image *src; mlib_image *dst; int i; + int j = 0; int retStatus = 1; mlib_status status; double *matrix; @@ -824,6 +825,15 @@ Java_sun_awt_image_ImagingLib_transformBI(JNIEnv *env, jobject this, return 0; } + /* Check for invalid double value in transformation matrix */ + for (j = 0; j < 6; j++) { + + if (!(IS_FINITE(matrix[j]))) { + (*env)->ReleasePrimitiveArrayCritical(env, jmatrix, matrix, JNI_ABORT); + return 0; + } + } + if (s_printIt) { printf("matrix is %g %g %g %g %g %g\n", matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); @@ -980,6 +990,7 @@ Java_sun_awt_image_ImagingLib_transformRaster(JNIEnv *env, jobject this, mlib_image *src; mlib_image *dst; int i; + int j = 0; int retStatus = 1; mlib_status status; double *matrix; @@ -1044,6 +1055,18 @@ Java_sun_awt_image_ImagingLib_transformRaster(JNIEnv *env, jobject this, return 0; } + /* Check for invalid double value in transformation matrix */ + for (j = 0; j < 6; j++) { + + if (!(IS_FINITE(matrix[j]))) { + (*env)->ReleasePrimitiveArrayCritical(env, jmatrix, matrix, JNI_ABORT); + free(srcRasterP); + free(dstRasterP); + + return 0; + } + } + if (s_printIt) { printf("matrix is %g %g %g %g %g %g\n", matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c index 34c2171274e..e151de73cc9 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -33,6 +33,8 @@ #include "mlib_image.h" #include "mlib_SysMath.h" #include "mlib_ImageAffine.h" +#include "safe_math.h" + /***************************************************************/ mlib_status mlib_AffineEdges(mlib_affine_param *param, @@ -83,6 +85,12 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, dstYStride = mlib_ImageGetStride(dst); paddings = mlib_ImageGetPaddings(src); + /* All the transformation matrix parameters should be finite. if not, return failure */ + if (!(IS_FINITE(a) && IS_FINITE(b) && IS_FINITE(c) && IS_FINITE(d) && + IS_FINITE(tx) && IS_FINITE(ty))) { + return MLIB_FAILURE; + } + if (srcWidth >= (1 << 15) || srcHeight >= (1 << 15)) { return MLIB_FAILURE; } @@ -288,6 +296,10 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, if (dY1 == dY2) continue; + if (!(IS_FINITE(slope))) { + continue; + } + if (dY1 < 0.0) y1 = 0; else { @@ -328,6 +340,10 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, if (dY1 == dY2) continue; + if (!(IS_FINITE(slope))) { + continue; + } + if (dY1 < 0.0) y1 = 0; else { diff --git a/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h b/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h index 34c1fc56e9a..a87eba11723 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h +++ b/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -26,10 +26,15 @@ #ifndef __SAFE_MATH_H__ #define __SAFE_MATH_H__ +#include "mlib_types.h" + #define SAFE_TO_MULT(a, b) \ (((a) > 0) && ((b) >= 0) && ((0x7fffffff / (a)) > (b))) #define SAFE_TO_ADD(a, b) \ (((a) >= 0) && ((b) >= 0) && ((0x7fffffff - (a)) > (b))) +#define IS_FINITE(a) \ + (((a) >= MLIB_D64_MIN) && ((a) <= MLIB_D64_MAX)) + #endif // __SAFE_MATH_H__ diff --git a/jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java b/jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java new file mode 100644 index 00000000000..f8c36ec21e7 --- /dev/null +++ b/jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* @test + * @bug 8158356 + * @summary Test AffineTransform transformations do not result in SIGSEGV + * if NaN or infinity parameter is passed as argument. + * @run main InvalidTransformParameterTest + */ + +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; +import java.awt.image.BufferedImage; +import java.awt.image.ImagingOpException; +import java.awt.Point; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.PixelInterleavedSampleModel; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; +import java.awt.image.RasterOp; +import java.awt.image.SampleModel; + +public class InvalidTransformParameterTest { + + public static void main(String[] args) { + int count = 0; + final int testScenarios = 12; + double NaNArg = 0.0 / 0.0; + double positiveInfArg = 1.0 / 0.0; + double negativeInfArg = -1.0 / 0.0; + + BufferedImage img = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB); + + AffineTransform[] inputTransforms = new AffineTransform[testScenarios]; + + for (int i = 0; i < inputTransforms.length; i++) { + inputTransforms[i] = new AffineTransform(); + } + + inputTransforms[0].rotate(NaNArg, img.getWidth()/2, img.getHeight()/2); + inputTransforms[1].translate(NaNArg, NaNArg); + inputTransforms[2].scale(NaNArg, NaNArg); + inputTransforms[3].shear(NaNArg, NaNArg); + + inputTransforms[4].rotate(positiveInfArg, img.getWidth()/2, img.getHeight()/2); + inputTransforms[5].translate(positiveInfArg, positiveInfArg); + inputTransforms[6].scale(positiveInfArg, positiveInfArg); + inputTransforms[7].shear(positiveInfArg, positiveInfArg); + + inputTransforms[8].rotate(negativeInfArg, img.getWidth()/2, img.getHeight()/2); + inputTransforms[9].translate(negativeInfArg, negativeInfArg); + inputTransforms[10].scale(negativeInfArg, negativeInfArg); + inputTransforms[11].shear(negativeInfArg, negativeInfArg); + + // Test BufferedImage AffineTransform --------------------------------- + + for (int i = 0; i < inputTransforms.length; i++) { + try { + testImageTransform(img, inputTransforms[i]); + } catch (ImagingOpException ex) { + count++; + } + } + + if (count != testScenarios) { + throw new RuntimeException("Test failed. All test scenarios did not" + + " result in exception as expected."); + } + + // Test Raster AffineTransform --------------------------------- + + count = 0; + int[] bandOffsets = {0}; + Point location = new Point(0, 0); + DataBuffer db = new DataBufferByte(10 * 10); + SampleModel sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, + 10, 10, 1, 10, + bandOffsets); + + Raster src = Raster.createRaster(sm, db, location); + WritableRaster dst = Raster.createWritableRaster(sm, db, location); + + for (int i = 0; i < inputTransforms.length; i++) { + try { + testRasterTransform(src, dst, inputTransforms[i]); + } catch (ImagingOpException ex) { + count++; + } + } + + if (count != testScenarios) { + throw new RuntimeException("Test failed. All test scenarios did not" + + " result in exception as expected."); + } + } + + public static BufferedImage testImageTransform(BufferedImage image, + AffineTransform transform) { + AffineTransformOp op = + new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); + + BufferedImage transformedImage = new BufferedImage(image.getWidth(), + image.getHeight(), + image.getType()); + + return op.filter(image, transformedImage); + } + + public static Raster testRasterTransform(Raster src, WritableRaster dst, + AffineTransform transform) { + AffineTransformOp op = + new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); + + return op.filter(src, dst); + } +} + From e576ea3b90596a0d5baac1c07ad9cc0feffc2a3a Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 25 Aug 2016 16:01:44 +0530 Subject: [PATCH 026/296] 8154218: Non-usage of owner Frame when Frame object is passed to getPrintJob() Reviewed-by: prr, jdv --- .../share/classes/javax/print/ServiceUI.java | 6 +- .../TestPrintJobFrameAssociation.java | 170 ++++++++++++++++++ 2 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java diff --git a/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java b/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java index 82566e9f804..615de409bdf 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java +++ b/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java @@ -40,6 +40,7 @@ import javax.print.attribute.AttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.Fidelity; +import sun.print.DialogOwner; import sun.print.ServiceDialog; import sun.print.SunAlternateMedia; @@ -187,9 +188,8 @@ public class ServiceUI { defaultIndex = 0; } - // For now we set owner to null. In the future, it may be passed - // as an argument. - Window owner = null; + DialogOwner dlgOwner = (DialogOwner)attributes.get(DialogOwner.class); + Window owner = (dlgOwner != null) ? dlgOwner.getOwner() : null; Rectangle gcBounds = (gc == null) ? GraphicsEnvironment. getLocalGraphicsEnvironment().getDefaultScreenDevice(). diff --git a/jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java b/jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java new file mode 100644 index 00000000000..1dd861cf325 --- /dev/null +++ b/jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ +/* + * @test + * @bug 8154218 + * @summary Verifies if owner Frame is associated with print dialog + * @run main/manual TestPrintJobFrameAssociation + */ +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.JobAttributes; +import java.awt.PrintJob; +import java.awt.Toolkit; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class TestPrintJobFrameAssociation { + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static Button print; + private static Label dialogName; + private static Frame frame; + private static boolean start; + private static Thread t; + + public static void main(String args[]) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(TestPrintJobFrameAssociation::frameTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(60000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Print dialog not disposed." + + " Print dialog is not associated with owner Frame`"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void frameTest() { + Panel panel =new Panel(); + + print = new Button("Print"); + print.setActionCommand("Print"); + print.addActionListener((e) -> { + JobAttributes ja = new JobAttributes(); + ja.setDialog(JobAttributes.DialogType.COMMON); + + t.start(); + start = true; + PrintJob pjob = Toolkit.getDefaultToolkit().getPrintJob(frame, + "Printing Test", + ja,null); + }); + + panel.add(print); + + frame = new Frame("Test Frame"); + frame.setLayout (new BorderLayout ()); + frame.add(panel,"South"); + frame.pack(); + frame.setVisible(true); + + t = new Thread (() -> { + if (start) { + try { + Thread.sleep(5000); + } catch (InterruptedException ex) {} + frame.dispose(); + } + }); + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " A Frame with Print Button is shown. Press Print.\n" + + " A cross-platform print dialog will be shown. After 5 secs\n" + + " the frame along with this print dialog will be disposed.\n" + + " If the print dialog is not disposed, press FAIL else press PASS"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printSelectionTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); + + } +} From 8ae9e471290aeef876e7edbfb66d0d02471b7a08 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 20 Jul 2016 15:07:48 +0200 Subject: [PATCH 027/296] 8161923: Fix free in awt_PrintControl Reviewed-by: vadim --- .../windows/native/libawt/windows/awt_PrintControl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp index 6c36d177fb2..6f75291d62f 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp @@ -1132,7 +1132,7 @@ BOOL AwtPrintControl::getDevmode( HANDLE hPrinter, if (dwRet != IDOK) { /* if failure, cleanup and return failure */ - GlobalFree(pDevMode); + GlobalFree(*pDevMode); *pDevMode = NULL; return FALSE; } From fe2f9368759e85e8230906ecbd971893c33104b2 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Mon, 15 Aug 2016 13:18:35 +0300 Subject: [PATCH 028/296] 8163860: Convert TestOldFreeSpaceCalculation_test to GTest Reviewed-by: iignatyev, dfazunen --- .../vm/gc/parallel/psAdaptiveSizePolicy.cpp | 17 +----- .../share/vm/utilities/internalVMTests.cpp | 1 - .../gc/parallel/test_psAdaptiveSizePolicy.cpp | 61 +++++++++++++++++++ 3 files changed, 62 insertions(+), 17 deletions(-) create mode 100644 hotspot/test/native/gc/parallel/test_psAdaptiveSizePolicy.cpp diff --git a/hotspot/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp b/hotspot/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp index c8554287512..8f27dd13729 100644 --- a/hotspot/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp +++ b/hotspot/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -1133,18 +1133,3 @@ bool PSAdaptiveSizePolicy::print() const { return false; } - -#ifndef PRODUCT - -void TestOldFreeSpaceCalculation_test() { - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 20) == 25, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 50) == 100, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 60) == 150, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 75) == 300, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 20) == 100, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 50) == 400, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 60) == 600, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 75) == 1200, "Calculation of free memory failed"); -} - -#endif /* !PRODUCT */ diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp index bdeb84abedf..a9aaaf22aeb 100644 --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp @@ -87,7 +87,6 @@ void InternalVMTests::run() { run_unit_test(VMStructs_test); #endif #if INCLUDE_ALL_GCS - run_unit_test(TestOldFreeSpaceCalculation_test); run_unit_test(TestG1BiasedArray_test); run_unit_test(TestBufferingOopClosure_test); run_unit_test(TestCodeCacheRemSet_test); diff --git a/hotspot/test/native/gc/parallel/test_psAdaptiveSizePolicy.cpp b/hotspot/test/native/gc/parallel/test_psAdaptiveSizePolicy.cpp new file mode 100644 index 00000000000..a3971c69257 --- /dev/null +++ b/hotspot/test/native/gc/parallel/test_psAdaptiveSizePolicy.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + * + */ + +#include "precompiled.hpp" +#include "utilities/macros.hpp" +#include "gc/parallel/psAdaptiveSizePolicy.hpp" +#include "unittest.hpp" + +#if INCLUDE_ALL_GCS + + TEST_VM(gc, oldFreeSpaceCalculation) { + + struct TestCase { + size_t live; + uintx ratio; + size_t expectedResult; + }; + + TestCase test_cases[] = { + {100, 20, 25}, + {100, 50, 100}, + {100, 60, 150}, + {100, 75, 300}, + {400, 20, 100}, + {400, 50, 400}, + {400, 60, 600}, + {400, 75, 1200}, + }; + + size_t array_len = sizeof(test_cases) / sizeof(TestCase); + for (size_t i = 0; i < array_len; ++i) { + ASSERT_EQ(PSAdaptiveSizePolicy::calculate_free_based_on_live( + test_cases[i].live, test_cases[i].ratio), + test_cases[i].expectedResult) + << " Calculation of free memory failed" + << " - Test case " << i << ": live = " << test_cases[i].live + << "; ratio = " << test_cases[i].ratio; + } + } +#endif From b0223431854248157eb9ebed41322ef379b13814 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Thu, 18 Aug 2016 13:19:38 +0300 Subject: [PATCH 029/296] 8157236: attach on ARMv7 fails with com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file Add more diagnostic to attach code Reviewed-by: dholmes, alanb --- .../sun/tools/attach/VirtualMachineImpl.java | 23 ++++++--- .../sun/tools/attach/VirtualMachineImpl.java | 47 +++++++------------ .../sun/tools/attach/VirtualMachineImpl.java | 34 ++++++++++---- .../native/libattach/VirtualMachineImpl.c | 2 +- .../tools/attach/HotSpotVirtualMachine.java | 2 +- .../sun/tools/attach/VirtualMachineImpl.java | 31 +++++++----- 6 files changed, 80 insertions(+), 59 deletions(-) diff --git a/jdk/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java b/jdk/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java index 0981b9cfaf5..8054ca86adc 100644 --- a/jdk/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/jdk/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java @@ -76,20 +76,29 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { sendQuitTo(pid); // give the target VM time to start the attach mechanism - int i = 0; - long delay = 200; - int retries = (int)(attachTimeout() / delay); + final int delay_step = 100; + final long timeout = attachTimeout(); + long time_spend = 0; + long delay = 0; do { + // Increase timeout on each attempt to reduce polling + delay += delay_step; try { Thread.sleep(delay); } catch (InterruptedException x) { } path = findSocketFile(pid); - i++; - } while (i <= retries && path == null); + + time_spend += delay; + if (time_spend > timeout/2 && path == null) { + // Send QUIT again to give target VM the last chance to react + sendQuitTo(pid); + } + } while (time_spend <= timeout && path == null); if (path == null) { throw new AttachNotSupportedException( - "Unable to open socket file: target process not responding " + - "or HotSpot VM not loaded"); + String.format("Unable to open socket file %s: " + + "target process %d doesn't respond within %dms " + + "or HotSpot VM not loaded", f.getPath(), pid, time_spend)); } } finally { f.delete(); diff --git a/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java b/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java index 2bf3e74a8bd..5cc81e9a2d0 100644 --- a/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java @@ -44,9 +44,6 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { // Any changes to this needs to be synchronized with HotSpot. private static final String tmpdir = "/tmp"; - // Indicates if this machine uses the old LinuxThreads - static boolean isLinuxThreads; - // The patch to the socket file created by the target VM String path; @@ -73,44 +70,37 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { if (path == null) { File f = createAttachFile(pid); try { - // On LinuxThreads each thread is a process and we don't have the - // pid of the VMThread which has SIGQUIT unblocked. To workaround - // this we get the pid of the "manager thread" that is created - // by the first call to pthread_create. This is parent of all - // threads (except the initial thread). - if (isLinuxThreads) { - int mpid; - try { - mpid = getLinuxThreadsManager(pid); - } catch (IOException x) { - throw new AttachNotSupportedException(x.getMessage()); - } - assert(mpid >= 1); - sendQuitToChildrenOf(mpid); - } else { - sendQuitTo(pid); - } + sendQuitTo(pid); // give the target VM time to start the attach mechanism - int i = 0; - long delay = 200; - int retries = (int)(attachTimeout() / delay); + final int delay_step = 100; + final long timeout = attachTimeout(); + long time_spend = 0; + long delay = 0; do { + // Increase timeout on each attempt to reduce polling + delay += delay_step; try { Thread.sleep(delay); } catch (InterruptedException x) { } path = findSocketFile(pid); - i++; - } while (i <= retries && path == null); + + time_spend += delay; + if (time_spend > timeout/2 && path == null) { + // Send QUIT again to give target VM the last chance to react + sendQuitTo(pid); + } + } while (time_spend <= timeout && path == null); if (path == null) { throw new AttachNotSupportedException( - "Unable to open socket file: target process not responding " + - "or HotSpot VM not loaded"); + String.format("Unable to open socket file %s: " + + "target process %d doesn't respond within %dms " + + "or HotSpot VM not loaded", f.getPath(), pid, time_spend)); } } finally { f.delete(); } - } + } // Check that the file owner/permission to avoid attaching to // bogus process @@ -340,6 +330,5 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { static { System.loadLibrary("attach"); - isLinuxThreads = isLinuxThreads(); } } diff --git a/jdk/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java b/jdk/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java index 0e304d0347d..9ed16330922 100644 --- a/jdk/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/jdk/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java @@ -70,26 +70,34 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { // Then we attempt to find the socket file again. path = findSocketFile(pid); if (path == null) { - File f = new File(tmpdir, ".attach_pid" + pid); - createAttachFile(f.getPath()); + File f = createAttachFile(pid); try { sendQuitTo(pid); // give the target VM time to start the attach mechanism - int i = 0; - long delay = 200; - int retries = (int)(attachTimeout() / delay); + final int delay_step = 100; + final long timeout = attachTimeout(); + long time_spend = 0; + long delay = 0; do { + // Increase timeout on each attempt to reduce polling + delay += delay_step; try { Thread.sleep(delay); } catch (InterruptedException x) { } path = findSocketFile(pid); - i++; - } while (i <= retries && path == null); + + time_spend += delay; + if (time_spend > timeout/2 && path == null) { + // Send QUIT again to give target VM the last chance to react + sendQuitTo(pid); + } + } while (time_spend <= timeout && path == null); if (path == null) { throw new AttachNotSupportedException( - "Unable to open socket file: target process not responding " + - "or HotSpot VM not loaded"); + String.format("Unable to open socket file %s: " + + "target process %d doesn't respond within %dms " + + "or HotSpot VM not loaded", f.getPath(), pid, time_spend)); } } finally { f.delete(); @@ -282,6 +290,12 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { write(fd, b, 0, 1); } + private File createAttachFile(int pid) throws IOException { + String fn = ".attach_pid" + pid; + File f = new File(tmpdir, fn); + createAttachFile0(f.getPath()); + return f; + } //-- native methods @@ -299,7 +313,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { static native void write(int fd, byte buf[], int off, int bufLen) throws IOException; - static native void createAttachFile(String path); + static native void createAttachFile0(String path); static native String getTempDir(); diff --git a/jdk/src/jdk.attach/macosx/native/libattach/VirtualMachineImpl.c b/jdk/src/jdk.attach/macosx/native/libattach/VirtualMachineImpl.c index 0f75dfe4e3d..42c4a256601 100644 --- a/jdk/src/jdk.attach/macosx/native/libattach/VirtualMachineImpl.c +++ b/jdk/src/jdk.attach/macosx/native/libattach/VirtualMachineImpl.c @@ -270,7 +270,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_write * Method: createAttachFile * Signature: (Ljava.lang.String;)V */ -JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_createAttachFile(JNIEnv *env, jclass cls, jstring path) +JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_createAttachFile0(JNIEnv *env, jclass cls, jstring path) { const char* _path; jboolean isCopy; diff --git a/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java b/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java index a5e965e5ec3..98d0ddc7e44 100644 --- a/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java +++ b/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java @@ -319,7 +319,7 @@ public abstract class HotSpotVirtualMachine extends VirtualMachine { // -- attach timeout support - private static long defaultAttachTimeout = 5000; + private static long defaultAttachTimeout = 10000; private volatile long attachTimeout; /* diff --git a/jdk/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java b/jdk/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java index b93f745475e..4d0a3bc3dec 100644 --- a/jdk/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/jdk/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java @@ -71,27 +71,36 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { } catch (FileNotFoundException fnf1) { File f = createAttachFile(pid); try { - // kill -QUIT will tickle target VM to check for the - // attach file. sigquit(pid); // give the target VM time to start the attach mechanism - int i = 0; - long delay = 200; - int retries = (int)(attachTimeout() / delay); + final int delay_step = 100; + final long timeout = attachTimeout(); + long time_spend = 0; + long delay = 0; do { + // Increase timeout on each attempt to reduce polling + delay += delay_step; try { Thread.sleep(delay); } catch (InterruptedException x) { } try { fd = openDoor(pid); - } catch (FileNotFoundException fnf2) { } - i++; - } while (i <= retries && fd == -1); - if (fd == -1) { + } catch (FileNotFoundException fnf2) { + // pass + } + + time_spend += delay; + if (time_spend > timeout/2 && fd == -1) { + // Send QUIT again to give target VM the last chance to react + sigquit(pid); + } + } while (time_spend <= timeout && fd == -1); + if (fd == -1) { throw new AttachNotSupportedException( - "Unable to open door: target process not responding or " + - "HotSpot VM not loaded"); + String.format("Unable to open door %s: " + + "target process %d doesn't respond within %dms " + + "or HotSpot VM not loaded", f.getPath(), pid, time_spend)); } } finally { f.delete(); From 42a009f5dd16610b2d97f3cc0ad8ab457ac86f7d Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Fri, 19 Aug 2016 16:02:11 +0200 Subject: [PATCH 030/296] 8164297: Jtreg test exeinvoke fails to link on Ubuntu Reviewed-by: tbell, dholmes --- make/common/TestFilesCompilation.gmk | 1 + 1 file changed, 1 insertion(+) diff --git a/make/common/TestFilesCompilation.gmk b/make/common/TestFilesCompilation.gmk index 1dd40a0a877..74414a9ca30 100644 --- a/make/common/TestFilesCompilation.gmk +++ b/make/common/TestFilesCompilation.gmk @@ -86,6 +86,7 @@ define SetupTestFilesCompilationBody LANG := C, \ CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$($1_PREFIX)$$(name)), \ LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$($1_PREFIX)$$(name)), \ + LIBS := $$($1_LIBS_$$($1_PREFIX)$$(name)), \ OPTIMIZATION := LOW, \ )) \ $$(eval $1 += $$(BUILD_TEST_$$(name)) ) \ From 830cf57fbd0838381106c8b288647d5b2a63da34 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Fri, 19 Aug 2016 10:09:25 -0400 Subject: [PATCH 031/296] 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder Reviewed-by: coleenp, gtriantafill, mseledtsov, iignatyev, dholmes, dsamersoff --- make/test/BuildTestLib.gmk | 4 +- test/lib/ClassFileInstaller.java | 257 +++++++++ test/lib/RedefineClassHelper.java | 79 +++ .../classes => }/jdk/test/lib/Asserts.java | 2 +- test/lib/jdk/test/lib/BuildHelper.java | 106 ++++ test/lib/jdk/test/lib/ByteCodeLoader.java | 90 +++ test/lib/jdk/test/lib/DynamicVMOption.java | 165 ++++++ test/lib/jdk/test/lib/FileInstaller.java | 97 ++++ .../jdk/test/lib/InMemoryJavaCompiler.java | 153 +++++ .../jdk/test/lib/JDKToolFinder.java | 2 +- .../jdk/test/lib/JDKToolLauncher.java | 4 +- .../classes => }/jdk/test/lib/Platform.java | 7 +- .../classes => }/jdk/test/lib/Utils.java | 58 +- .../jdk/test/lib/apps/LingeredApp.java | 2 +- .../lib/apps/LingeredAppWithDeadlock.java | 2 +- .../cli/CPUSpecificCommandLineOptionTest.java | 65 +++ .../test/lib/cli/CommandLineOptionTest.java | 524 ++++++++++++++++++ .../test/lib/cli/predicate/AndPredicate.java | 41 ++ .../cli/predicate/CPUSpecificPredicate.java | 71 +++ .../test/lib/cli/predicate/NotPredicate.java | 40 ++ .../test/lib/cli/predicate/OrPredicate.java | 42 ++ .../jdk/test/lib/dcmd/CommandExecutor.java | 75 +++ .../lib/dcmd/CommandExecutorException.java | 36 ++ .../jdk/test/lib/dcmd/FileJcmdExecutor.java | 81 +++ test/lib/jdk/test/lib/dcmd/JMXExecutor.java | 187 +++++++ test/lib/jdk/test/lib/dcmd/JcmdExecutor.java | 58 ++ .../test/lib/dcmd/MainClassJcmdExecutor.java | 57 ++ .../jdk/test/lib/dcmd/PidJcmdExecutor.java | 63 +++ .../jdk/test/lib/hprof/HprofParser.java | 2 +- .../classes => }/jdk/test/lib/hprof/README | 0 .../model/AbstractJavaHeapObjectVisitor.java | 2 +- .../test/lib/hprof/model/ArrayTypeCodes.java | 2 +- .../test/lib/hprof/model/HackJavaValue.java | 2 +- .../jdk/test/lib/hprof/model/JavaBoolean.java | 2 +- .../jdk/test/lib/hprof/model/JavaByte.java | 2 +- .../jdk/test/lib/hprof/model/JavaChar.java | 2 +- .../jdk/test/lib/hprof/model/JavaClass.java | 2 +- .../jdk/test/lib/hprof/model/JavaDouble.java | 2 +- .../jdk/test/lib/hprof/model/JavaField.java | 2 +- .../jdk/test/lib/hprof/model/JavaFloat.java | 2 +- .../test/lib/hprof/model/JavaHeapObject.java | 2 +- .../hprof/model/JavaHeapObjectVisitor.java | 2 +- .../jdk/test/lib/hprof/model/JavaInt.java | 2 +- .../lib/hprof/model/JavaLazyReadObject.java | 2 +- .../jdk/test/lib/hprof/model/JavaLong.java | 2 +- .../jdk/test/lib/hprof/model/JavaObject.java | 2 +- .../test/lib/hprof/model/JavaObjectArray.java | 2 +- .../test/lib/hprof/model/JavaObjectRef.java | 2 +- .../jdk/test/lib/hprof/model/JavaShort.java | 2 +- .../jdk/test/lib/hprof/model/JavaStatic.java | 2 +- .../jdk/test/lib/hprof/model/JavaThing.java | 2 +- .../jdk/test/lib/hprof/model/JavaValue.java | 2 +- .../test/lib/hprof/model/JavaValueArray.java | 2 +- .../lib/hprof/model/ReachableExcludes.java | 2 +- .../hprof/model/ReachableExcludesImpl.java | 2 +- .../lib/hprof/model/ReachableObjects.java | 2 +- .../test/lib/hprof/model/ReferenceChain.java | 2 +- .../jdk/test/lib/hprof/model/Root.java | 2 +- .../jdk/test/lib/hprof/model/Snapshot.java | 2 +- .../jdk/test/lib/hprof/model/StackFrame.java | 2 +- .../jdk/test/lib/hprof/model/StackTrace.java | 2 +- .../test/lib/hprof/parser/FileReadBuffer.java | 2 +- .../test/lib/hprof/parser/HprofReader.java | 2 +- .../lib/hprof/parser/MappedReadBuffer.java | 2 +- .../hprof/parser/PositionDataInputStream.java | 2 +- .../lib/hprof/parser/PositionInputStream.java | 2 +- .../jdk/test/lib/hprof/parser/ReadBuffer.java | 2 +- .../jdk/test/lib/hprof/parser/Reader.java | 2 +- .../jdk/test/lib/hprof/util/ArraySorter.java | 2 +- .../jdk/test/lib/hprof/util/Comparer.java | 2 +- .../lib/hprof/util/CompositeEnumeration.java | 2 +- .../jdk/test/lib/hprof/util/Misc.java | 2 +- .../jdk/test/lib/hprof/util/VectorSorter.java | 2 +- test/lib/jdk/test/lib/process/ExitCode.java | 40 ++ .../jdk/test/lib/process/OutputAnalyzer.java | 16 +- .../jdk/test/lib/process/OutputBuffer.java | 2 +- .../jdk/test/lib/process/ProcessTools.java | 47 +- .../jdk/test/lib/process/StreamPumper.java | 2 +- test/lib/jdk/test/lib/util/Pair.java | 68 +++ test/lib/jdk/test/lib/util/Triple.java | 90 +++ .../jdk/test/lib/wrappers/InfiniteLoop.java | 66 +++ .../test/lib/wrappers/TimeLimitedRunner.java | 86 +++ 82 files changed, 2795 insertions(+), 78 deletions(-) create mode 100644 test/lib/ClassFileInstaller.java create mode 100644 test/lib/RedefineClassHelper.java rename test/lib/{share/classes => }/jdk/test/lib/Asserts.java (99%) create mode 100644 test/lib/jdk/test/lib/BuildHelper.java create mode 100644 test/lib/jdk/test/lib/ByteCodeLoader.java create mode 100644 test/lib/jdk/test/lib/DynamicVMOption.java create mode 100644 test/lib/jdk/test/lib/FileInstaller.java create mode 100644 test/lib/jdk/test/lib/InMemoryJavaCompiler.java rename test/lib/{share/classes => }/jdk/test/lib/JDKToolFinder.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/JDKToolLauncher.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/Platform.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/Utils.java (91%) rename test/lib/{share/classes => }/jdk/test/lib/apps/LingeredApp.java (99%) rename test/lib/{share/classes => }/jdk/test/lib/apps/LingeredAppWithDeadlock.java (97%) create mode 100644 test/lib/jdk/test/lib/cli/CPUSpecificCommandLineOptionTest.java create mode 100644 test/lib/jdk/test/lib/cli/CommandLineOptionTest.java create mode 100644 test/lib/jdk/test/lib/cli/predicate/AndPredicate.java create mode 100644 test/lib/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java create mode 100644 test/lib/jdk/test/lib/cli/predicate/NotPredicate.java create mode 100644 test/lib/jdk/test/lib/cli/predicate/OrPredicate.java create mode 100644 test/lib/jdk/test/lib/dcmd/CommandExecutor.java create mode 100644 test/lib/jdk/test/lib/dcmd/CommandExecutorException.java create mode 100644 test/lib/jdk/test/lib/dcmd/FileJcmdExecutor.java create mode 100644 test/lib/jdk/test/lib/dcmd/JMXExecutor.java create mode 100644 test/lib/jdk/test/lib/dcmd/JcmdExecutor.java create mode 100644 test/lib/jdk/test/lib/dcmd/MainClassJcmdExecutor.java create mode 100644 test/lib/jdk/test/lib/dcmd/PidJcmdExecutor.java rename test/lib/{share/classes => }/jdk/test/lib/hprof/HprofParser.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/README (100%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/ArrayTypeCodes.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/HackJavaValue.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaBoolean.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaByte.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaChar.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaClass.java (99%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaDouble.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaField.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaFloat.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaHeapObject.java (99%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaInt.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaLazyReadObject.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaLong.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaObject.java (99%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaObjectArray.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaObjectRef.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaShort.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaStatic.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaThing.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaValue.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/JavaValueArray.java (99%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/ReachableExcludes.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/ReachableExcludesImpl.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/ReachableObjects.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/ReferenceChain.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/Root.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/Snapshot.java (99%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/StackFrame.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/model/StackTrace.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/parser/FileReadBuffer.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/parser/HprofReader.java (99%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/parser/MappedReadBuffer.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/parser/PositionDataInputStream.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/parser/PositionInputStream.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/parser/ReadBuffer.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/parser/Reader.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/util/ArraySorter.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/util/Comparer.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/util/CompositeEnumeration.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/util/Misc.java (98%) rename test/lib/{share/classes => }/jdk/test/lib/hprof/util/VectorSorter.java (98%) create mode 100644 test/lib/jdk/test/lib/process/ExitCode.java rename test/lib/{share/classes => }/jdk/test/lib/process/OutputAnalyzer.java (97%) rename test/lib/{share/classes => }/jdk/test/lib/process/OutputBuffer.java (96%) rename test/lib/{share/classes => }/jdk/test/lib/process/ProcessTools.java (93%) rename test/lib/{share/classes => }/jdk/test/lib/process/StreamPumper.java (99%) create mode 100644 test/lib/jdk/test/lib/util/Pair.java create mode 100644 test/lib/jdk/test/lib/util/Triple.java create mode 100644 test/lib/jdk/test/lib/wrappers/InfiniteLoop.java create mode 100644 test/lib/jdk/test/lib/wrappers/TimeLimitedRunner.java diff --git a/make/test/BuildTestLib.gmk b/make/test/BuildTestLib.gmk index 382341a47e4..7593ac74766 100644 --- a/make/test/BuildTestLib.gmk +++ b/make/test/BuildTestLib.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2016, 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 @@ -48,7 +48,7 @@ TARGETS += $(BUILD_WB_JAR) # test-lib.jar will contain only hprof classes until JDK-8081381 is resolved $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \ SETUP := GENERATE_USINGJDKBYTECODE, \ - SRC := $(TEST_LIB_SOURCE_DIR)/share/classes/jdk/test/lib/hprof, \ + SRC := $(TEST_LIB_SOURCE_DIR)/jdk/test/lib/hprof, \ BIN := $(TEST_LIB_SUPPORT)/test-lib_classes, \ JAR := $(TEST_LIB_SUPPORT)/test-lib.jar, \ )) diff --git a/test/lib/ClassFileInstaller.java b/test/lib/ClassFileInstaller.java new file mode 100644 index 00000000000..2486bd2ef81 --- /dev/null +++ b/test/lib/ClassFileInstaller.java @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +/** + * Dump a class file for a class on the class path in the current directory, or + * in the specified JAR file. This class is usually used when you build a class + * from a test library, but want to use this class in a sub-process. + * + * For example, to build the following library class: + * test/lib/sun/hotspot/WhiteBox.java + * + * You would use the following tags: + * + * @library /test/lib + * @build sun.hotspot.WhiteBox + * + * JTREG would build the class file under + * ${JTWork}/classes/test/lib/sun/hotspot/WhiteBox.class + * + * With you run your main test class using "@run main MyMainClass", JTREG would setup the + * -classpath to include "${JTWork}/classes/test/lib/", so MyMainClass would be able to + * load the WhiteBox class. + * + * However, if you run a sub process, and do not wish to use the exact same -classpath, + * You can use ClassFileInstaller to ensure that WhiteBox is available in the current + * directory of your test: + * + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * + * Or, you can use the -jar option to store the class in the specified JAR file. If a relative + * path name is given, the JAR file would be relative to the current directory of + * + * @run main ClassFileInstaller -jar myjar.jar sun.hotspot.WhiteBox + */ +public class ClassFileInstaller { + /** + * You can enable debug tracing of ClassFileInstaller by running JTREG with + * jtreg -DClassFileInstaller.debug=true ... + */ + public static boolean DEBUG = Boolean.getBoolean("ClassFileInstaller.debug"); + + /** + * @param args The names of the classes to dump + * @throws Exception + */ + public static void main(String... args) throws Exception { + if (args.length > 1 && args[0].equals("-jar")) { + if (args.length < 2) { + throw new RuntimeException("Usage: ClassFileInstaller \n" + + "where possible options include:\n" + + " -jar Write to the JAR file "); + } + writeJar(args[1], null, args, 2, args.length); + } else { + if (DEBUG) { + System.out.println("ClassFileInstaller: Writing to " + System.getProperty("user.dir")); + } + for (String arg : args) { + writeClassToDisk(arg); + } + } + } + + public static class Manifest { + private InputStream in; + + private Manifest(InputStream in) { + this.in = in; + } + + static Manifest fromSourceFile(String fileName) throws Exception { + String pathName = System.getProperty("test.src") + File.separator + fileName; + return new Manifest(new FileInputStream(pathName)); + } + + // Example: + // String manifest = "Premain-Class: RedefineClassHelper\n" + + // "Can-Redefine-Classes: true\n"; + // ClassFileInstaller.writeJar("redefineagent.jar", + // ClassFileInstaller.Manifest.fromString(manifest), + // "RedefineClassHelper"); + static Manifest fromString(String manifest) throws Exception { + return new Manifest(new ByteArrayInputStream(manifest.getBytes())); + } + + public InputStream getInputStream() { + return in; + } + } + + private static void writeJar(String jarFile, Manifest manifest, String classes[], int from, int to) throws Exception { + if (DEBUG) { + System.out.println("ClassFileInstaller: Writing to " + getJarPath(jarFile)); + } + + (new File(jarFile)).delete(); + FileOutputStream fos = new FileOutputStream(jarFile); + ZipOutputStream zos = new ZipOutputStream(fos); + + // The manifest must be the first or second entry. See comments in JarInputStream + // constructor and JDK-5046178. + if (manifest != null) { + writeToDisk(zos, "META-INF/MANIFEST.MF", manifest.getInputStream()); + } + + for (int i=from; i 0) { + pathName = prependPath + "/" + pathName; + } + writeToDisk(zos, pathName, is); + } + + public static void writeClassToDisk(String className, byte[] bytecode) throws Exception { + writeClassToDisk(null, className, bytecode); + } + private static void writeClassToDisk(ZipOutputStream zos, String className, byte[] bytecode) throws Exception { + writeClassToDisk(zos, className, bytecode, ""); + } + + public static void writeClassToDisk(String className, byte[] bytecode, String prependPath) throws Exception { + writeClassToDisk(null, className, bytecode, prependPath); + } + private static void writeClassToDisk(ZipOutputStream zos, String className, byte[] bytecode, String prependPath) throws Exception { + // Convert dotted class name to a path to a class file + String pathName = className.replace('.', '/').concat(".class"); + if (prependPath.length() > 0) { + pathName = prependPath + "/" + pathName; + } + writeToDisk(zos, pathName, new ByteArrayInputStream(bytecode)); + } + + private static void writeToDisk(ZipOutputStream zos, String pathName, InputStream is) throws Exception { + if (DEBUG) { + System.out.println("ClassFileInstaller: Writing " + pathName); + } + if (zos != null) { + ZipEntry ze = new ZipEntry(pathName); + zos.putNextEntry(ze); + byte[] buf = new byte[1024]; + int len; + while ((len = is.read(buf))>0){ + zos.write(buf, 0, len); + } + } else { + // Create the class file's package directory + Path p = Paths.get(pathName); + if (pathName.contains("/")) { + Files.createDirectories(p.getParent()); + } + // Create the class file + Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING); + } + is.close(); + } +} diff --git a/test/lib/RedefineClassHelper.java b/test/lib/RedefineClassHelper.java new file mode 100644 index 00000000000..75768092365 --- /dev/null +++ b/test/lib/RedefineClassHelper.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.PrintWriter; +import java.lang.instrument.*; +import jdk.test.lib.InMemoryJavaCompiler; + +/* + * Helper class to write tests that redefine classes. + * When main method is run, it will create a redefineagent.jar that can be used + * with the -javaagent option to support redefining classes in jtreg tests. + * + * See sample test in test/testlibrary_tests/RedefineClassTest.java + */ +public class RedefineClassHelper { + + public static Instrumentation instrumentation; + public static void premain(String agentArgs, Instrumentation inst) { + instrumentation = inst; + } + + /** + * Redefine a class + * + * @param clazz Class to redefine + * @param javacode String with the new java code for the class to be redefined + */ + public static void redefineClass(Class clazz, String javacode) throws Exception { + byte[] bytecode = InMemoryJavaCompiler.compile(clazz.getName(), javacode); + redefineClass(clazz, bytecode); + } + + /** + * Redefine a class + * + * @param clazz Class to redefine + * @param bytecode byte[] with the new class + */ + public static void redefineClass(Class clazz, byte[] bytecode) throws Exception { + instrumentation.redefineClasses(new ClassDefinition(clazz, bytecode)); + } + + /** + * Main method to be invoked before test to create the redefineagent.jar + */ + public static void main(String[] args) throws Exception { + ClassFileInstaller.main("RedefineClassHelper"); + + PrintWriter pw = new PrintWriter("MANIFEST.MF"); + pw.println("Premain-Class: RedefineClassHelper"); + pw.println("Can-Redefine-Classes: true"); + pw.close(); + + sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar"); + if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineClassHelper.class" })) { + throw new Exception("jar operation failed"); + } + } +} diff --git a/test/lib/share/classes/jdk/test/lib/Asserts.java b/test/lib/jdk/test/lib/Asserts.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/Asserts.java rename to test/lib/jdk/test/lib/Asserts.java index f0be92ef331..8aa0105d994 100644 --- a/test/lib/share/classes/jdk/test/lib/Asserts.java +++ b/test/lib/jdk/test/lib/Asserts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 diff --git a/test/lib/jdk/test/lib/BuildHelper.java b/test/lib/jdk/test/lib/BuildHelper.java new file mode 100644 index 00000000000..1e9d697b35b --- /dev/null +++ b/test/lib/jdk/test/lib/BuildHelper.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib; + +import java.io.File; +import java.io.FileReader; +import java.util.Properties; + +public class BuildHelper { + + /** + * Commercial builds should have the BUILD_TYPE set to commercial + * within the release file, found at the root of the JDK. + */ + public static boolean isCommercialBuild() throws Exception { + String buildType = getReleaseProperty("BUILD_TYPE","notFound"); + return buildType.equals("commercial"); + } + + + /** + * Return the value for property key, or defaultValue if no property not found. + * If present, double quotes are trimmed. + */ + public static String getReleaseProperty(String key, String defaultValue) throws Exception { + Properties properties = getReleaseProperties(); + String value = properties.getProperty(key, defaultValue); + return trimDoubleQuotes(value); + } + + /** + * Return the value for property key, or null if no property not found. + * If present, double quotes are trimmed. + */ + public static String getReleaseProperty(String key) throws Exception { + return getReleaseProperty(key, null); + } + + /** + * Get properties from the release file + */ + public static Properties getReleaseProperties() throws Exception { + Properties properties = new Properties(); + properties.load(new FileReader(getReleaseFile())); + return properties; + } + + /** + * Every JDK has a release file in its root. + * @return A handler to the release file. + */ + public static File getReleaseFile() throws Exception { + String jdkPath = getJDKRoot(); + File releaseFile = new File(jdkPath,"release"); + if ( ! releaseFile.canRead() ) { + throw new Exception("Release file is not readable, or it is absent: " + + releaseFile.getCanonicalPath()); + } + return releaseFile; + } + + /** + * Returns path to the JDK under test. + * This path is obtained through the test.jdk property, usually set by JTREG. + */ + public static String getJDKRoot() { + String jdkPath = System.getProperty("test.jdk"); + if (jdkPath == null) { + throw new RuntimeException("System property 'test.jdk' not set. This property is normally set by jtreg. " + + "When running test separately, set this property using '-Dtest.jdk=/path/to/jdk'."); + } + return jdkPath; + } + + /** + * Trim double quotes from the beginning and the end of the given string. + * @param original string to trim. + * @return a new trimmed string. + */ + public static String trimDoubleQuotes(String original) { + if (original == null) { return null; } + String trimmed = original.replaceAll("^\"+|\"+$", ""); + return trimmed; + } +} diff --git a/test/lib/jdk/test/lib/ByteCodeLoader.java b/test/lib/jdk/test/lib/ByteCodeLoader.java new file mode 100644 index 00000000000..14f98f8747b --- /dev/null +++ b/test/lib/jdk/test/lib/ByteCodeLoader.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2013, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib; + +import java.security.SecureClassLoader; + +/** + * {@code ByteCodeLoader} can be used for easy loading of byte code already + * present in memory. + * + * {@code InMemoryCompiler} can be used for compiling source code in a string + * into byte code, which then can be loaded with {@code ByteCodeLoader}. + * + * @see InMemoryCompiler + */ +public class ByteCodeLoader extends SecureClassLoader { + private final String className; + private final byte[] byteCode; + private volatile Class holder; + + /** + * Creates a new {@code ByteCodeLoader} ready to load a class with the + * given name and the given byte code. + * + * @param className The name of the class + * @param byteCode The byte code of the class + */ + public ByteCodeLoader(String className, byte[] byteCode) { + this.className = className; + this.byteCode = byteCode; + } + + @Override + public Class loadClass(String name) throws ClassNotFoundException { + if (!name.equals(className)) { + return super.loadClass(name); + } + if (holder == null) { + synchronized(this) { + if (holder == null) { + holder = findClass(name); + } + } + } + return holder; + } + + @Override + protected Class findClass(String name) throws ClassNotFoundException { + if (!name.equals(className)) { + throw new ClassNotFoundException(name); + } + + return defineClass(name, byteCode, 0, byteCode.length); + } + + /** + * Utility method for creating a new {@code ByteCodeLoader} and then + * directly load the given byte code. + * + * @param className The name of the class + * @param byteCode The byte code for the class + * @throws ClassNotFoundException if the class can't be loaded + * @return A {@see Class} object representing the class + */ + public static Class load(String className, byte[] byteCode) throws ClassNotFoundException { + return new ByteCodeLoader(className, byteCode).loadClass(className); + } +} diff --git a/test/lib/jdk/test/lib/DynamicVMOption.java b/test/lib/jdk/test/lib/DynamicVMOption.java new file mode 100644 index 00000000000..17f545e126e --- /dev/null +++ b/test/lib/jdk/test/lib/DynamicVMOption.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ +package jdk.test.lib; + +import com.sun.management.HotSpotDiagnosticMXBean; +import java.lang.management.ManagementFactory; + +/** + * A utility class to work with VM options which could be altered during + * execution. + * + * This class is a wrapper around {@code com.sun.management.VMOption}. + * It provides more convenient interface to read/write the values. + * + */ +public class DynamicVMOption { + + private final HotSpotDiagnosticMXBean mxBean; + + /** + * VM option name, like "MinHeapFreeRatio". + */ + public final String name; + + /** + * Creates an instance of DynamicVMOption. + * + * @param name the VM option name + */ + public DynamicVMOption(String name) { + this.name = name; + mxBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class); + } + + /** + * Sets a new value for the option. + * Trying to set not applicable value will cause IllegalArgumentException. + * Behavior with null is undefined, most likely NPE will be thrown. + * + * @param newValue the value to be set + * @see #getValue() + * @throws IllegalArgumentException if newValue is not applicable to the option + */ + public final void setValue(String newValue) { + mxBean.setVMOption(name, newValue); + } + + /** + * Returns the value of option. + * + * @return the current option value + * @see #setValue(java.lang.String) + */ + public final String getValue() { + return mxBean.getVMOption(name).getValue(); + } + + /** + * Returns true, if option is writable, false otherwise. + * + * @return true, if option is writable, false otherwise + */ + public final boolean isWriteable() { + return mxBean.getVMOption(name).isWriteable(); + } + + /** + * Checks if the given value is applicable for the option. + * + * This method tries to set the option to the new value. If no exception + * has been thrown the value is treated as valid. + * + * Calling this method will not change the option value. After an attempt + * to set a new value, the option will be restored to its previous value. + * + * @param value the value to verify + * @return true if option could be set to the given value + */ + public boolean isValidValue(String value) { + boolean isValid = true; + String oldValue = getValue(); + try { + setValue(value); + } catch (NullPointerException e) { + if (value == null) { + isValid = false; + } + } catch (IllegalArgumentException e) { + isValid = false; + } finally { + setValue(oldValue); + } + return isValid; + } + + /** + * Returns the value of the given VM option as String. + * + * This is a simple shortcut for {@code new DynamicVMOption(name).getValue()} + * + * @param name the name of VM option + * @return value as a string + * @see #getValue() + */ + public static String getString(String name) { + return new DynamicVMOption(name).getValue(); + } + + /** + * Returns the value of the given option as int. + * + * @param name the name of VM option + * @return value parsed as integer + * @see #getString(java.lang.String) + * + */ + public static int getInt(String name) { + return Integer.parseInt(getString(name)); + } + + /** + * Sets the VM option to a new value. + * + * This is a simple shortcut for {@code new DynamicVMOption(name).setValue(value)} + * + * @param name the name of VM option + * @param value the value to be set + * @see #setValue(java.lang.String) + */ + public static void setString(String name, String value) { + new DynamicVMOption(name).setValue(value); + } + + /** + * Sets the VM option value to a new integer value. + * + * @param name the name of VM option + * @param value the integer value to be set + * @see #setString(java.lang.String, java.lang.String) + */ + public static void setInt(String name, int value) { + new DynamicVMOption(name).setValue(Integer.toString(value)); + } + +} diff --git a/test/lib/jdk/test/lib/FileInstaller.java b/test/lib/jdk/test/lib/FileInstaller.java new file mode 100644 index 00000000000..1247deedcb1 --- /dev/null +++ b/test/lib/jdk/test/lib/FileInstaller.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.BasicFileAttributes; + +/** + * Copy a resource: file or directory recursively, using relative path(src and dst) + * which are applied to test source directory(src) and current directory(dst) + */ +public class FileInstaller { + /** + * @param args source and destination + * @throws IOException if an I/O error occurs + */ + public static void main(String[] args) throws IOException { + if (args.length != 2) { + throw new IllegalArgumentException("Unexpected number of arguments for file copy"); + } + Path src = Paths.get(Utils.TEST_SRC, args[0]).toAbsolutePath(); + Path dst = Paths.get(args[1]).toAbsolutePath(); + if (src.toFile().exists()) { + if (src.toFile().isDirectory()) { + Files.walkFileTree(src, new CopyFileVisitor(src, dst)); + } else { + Path dstDir = dst.getParent(); + if (!dstDir.toFile().exists()) { + Files.createDirectories(dstDir); + } + Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING); + } + } else { + throw new IOException("Can't find source " + src); + } + } + + private static class CopyFileVisitor extends SimpleFileVisitor { + private final Path copyFrom; + private final Path copyTo; + + public CopyFileVisitor(Path copyFrom, Path copyTo) { + this.copyFrom = copyFrom; + this.copyTo = copyTo; + } + + @Override + public FileVisitResult preVisitDirectory(Path file, + BasicFileAttributes attrs) throws IOException { + Path relativePath = file.relativize(copyFrom); + Path destination = copyTo.resolve(relativePath); + if (!destination.toFile().exists()) { + Files.createDirectories(destination); + } + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFile(Path file, + BasicFileAttributes attrs) throws IOException { + if (!file.toFile().isFile()) { + return FileVisitResult.CONTINUE; + } + Path relativePath = copyFrom.relativize(file); + Path destination = copyTo.resolve(relativePath); + Files.copy(file, destination, StandardCopyOption.COPY_ATTRIBUTES); + return FileVisitResult.CONTINUE; + } + } +} diff --git a/test/lib/jdk/test/lib/InMemoryJavaCompiler.java b/test/lib/jdk/test/lib/InMemoryJavaCompiler.java new file mode 100644 index 00000000000..5fb78e4441f --- /dev/null +++ b/test/lib/jdk/test/lib/InMemoryJavaCompiler.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2013, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import java.net.URI; +import java.util.Arrays; + +import javax.tools.ForwardingJavaFileManager; +import javax.tools.FileObject; +import javax.tools.JavaCompiler; +import javax.tools.JavaCompiler.CompilationTask; +import javax.tools.JavaFileObject; +import javax.tools.JavaFileObject.Kind; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +/** + * {@code InMemoryJavaCompiler} can be used for compiling a {@link + * CharSequence} to a {@code byte[]}. + * + * The compiler will not use the file system at all, instead using a {@link + * ByteArrayOutputStream} for storing the byte code. For the source code, any + * kind of {@link CharSequence} can be used, e.g. {@link String}, {@link + * StringBuffer} or {@link StringBuilder}. + * + * The {@code InMemoryCompiler} can easily be used together with a {@code + * ByteClassLoader} to easily compile and load source code in a {@link String}: + * + *

+ * {@code
+ * import jdk.test.lib.InMemoryJavaCompiler;
+ * import jdk.test.lib.ByteClassLoader;
+ *
+ * class Example {
+ *     public static void main(String[] args) {
+ *         String className = "Foo";
+ *         String sourceCode = "public class " + className + " {" +
+ *                             "    public void bar() {" +
+ *                             "        System.out.println("Hello from bar!");" +
+ *                             "    }" +
+ *                             "}";
+ *         byte[] byteCode = InMemoryJavaCompiler.compile(className, sourceCode);
+ *         Class fooClass = ByteClassLoader.load(className, byteCode);
+ *     }
+ * }
+ * }
+ * 
+ */ +public class InMemoryJavaCompiler { + private static class MemoryJavaFileObject extends SimpleJavaFileObject { + private final String className; + private final CharSequence sourceCode; + private final ByteArrayOutputStream byteCode; + + public MemoryJavaFileObject(String className, CharSequence sourceCode) { + super(URI.create("string:///" + className.replace('.','/') + Kind.SOURCE.extension), Kind.SOURCE); + this.className = className; + this.sourceCode = sourceCode; + this.byteCode = new ByteArrayOutputStream(); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return sourceCode; + } + + @Override + public OutputStream openOutputStream() throws IOException { + return byteCode; + } + + public byte[] getByteCode() { + return byteCode.toByteArray(); + } + + public String getClassName() { + return className; + } + } + + private static class FileManagerWrapper extends ForwardingJavaFileManager { + private MemoryJavaFileObject file; + + public FileManagerWrapper(MemoryJavaFileObject file) { + super(getCompiler().getStandardFileManager(null, null, null)); + this.file = file; + } + + @Override + public JavaFileObject getJavaFileForOutput(Location location, String className, + Kind kind, FileObject sibling) + throws IOException { + if (!file.getClassName().equals(className)) { + throw new IOException("Expected class with name " + file.getClassName() + + ", but got " + className); + } + return file; + } + } + + /** + * Compiles the class with the given name and source code. + * + * @param className The name of the class + * @param sourceCode The source code for the class with name {@code className} + * @param options additional command line options + * @throws RuntimeException if the compilation did not succeed + * @return The resulting byte code from the compilation + */ + public static byte[] compile(String className, CharSequence sourceCode, String... options) { + MemoryJavaFileObject file = new MemoryJavaFileObject(className, sourceCode); + CompilationTask task = getCompilationTask(file, options); + + if(!task.call()) { + throw new RuntimeException("Could not compile " + className + " with source code " + sourceCode); + } + + return file.getByteCode(); + } + + private static JavaCompiler getCompiler() { + return ToolProvider.getSystemJavaCompiler(); + } + + private static CompilationTask getCompilationTask(MemoryJavaFileObject file, String... options) { + return getCompiler().getTask(null, new FileManagerWrapper(file), null, Arrays.asList(options), null, Arrays.asList(file)); + } +} diff --git a/test/lib/share/classes/jdk/test/lib/JDKToolFinder.java b/test/lib/jdk/test/lib/JDKToolFinder.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/JDKToolFinder.java rename to test/lib/jdk/test/lib/JDKToolFinder.java index 3ad008e0005..a9a3598f10d 100644 --- a/test/lib/share/classes/jdk/test/lib/JDKToolFinder.java +++ b/test/lib/jdk/test/lib/JDKToolFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/JDKToolLauncher.java b/test/lib/jdk/test/lib/JDKToolLauncher.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/JDKToolLauncher.java rename to test/lib/jdk/test/lib/JDKToolLauncher.java index 3948d474ec1..38e7b4530bf 100644 --- a/test/lib/share/classes/jdk/test/lib/JDKToolLauncher.java +++ b/test/lib/jdk/test/lib/JDKToolLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -26,7 +26,7 @@ package jdk.test.lib; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import jdk.test.lib.process.*; +import jdk.test.lib.process.ProcessTools; /** * A utility for constructing command lines for starting JDK tool processes. diff --git a/test/lib/share/classes/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/Platform.java rename to test/lib/jdk/test/lib/Platform.java index 8c55f091467..ec4fa8b63ba 100644 --- a/test/lib/share/classes/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -31,7 +31,7 @@ public class Platform { private static final String osName = System.getProperty("os.name"); private static final String dataModel = System.getProperty("sun.arch.data.model"); private static final String vmVersion = System.getProperty("java.vm.version"); - private static final String javaVersion = System.getProperty("java.version"); + private static final String jdkDebug = System.getProperty("jdk.debug"); private static final String osArch = System.getProperty("os.arch"); private static final String userName = System.getProperty("user.name"); private static final String compiler = System.getProperty("sun.management.compiler"); @@ -113,8 +113,7 @@ public class Platform { } public static boolean isDebugBuild() { - return (vmVersion.toLowerCase().contains("debug") || - javaVersion.toLowerCase().contains("debug")); + return (jdkDebug.toLowerCase().contains("debug")); } public static String getVMVersion() { diff --git a/test/lib/share/classes/jdk/test/lib/Utils.java b/test/lib/jdk/test/lib/Utils.java similarity index 91% rename from test/lib/share/classes/jdk/test/lib/Utils.java rename to test/lib/jdk/test/lib/Utils.java index 95e2bbab48a..aececb0301f 100644 --- a/test/lib/share/classes/jdk/test/lib/Utils.java +++ b/test/lib/jdk/test/lib/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -40,7 +40,10 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; +import java.util.Map; +import java.util.HashMap; import java.util.List; +import java.util.Objects; import java.util.Random; import java.util.function.BooleanSupplier; import java.util.concurrent.TimeUnit; @@ -50,8 +53,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import jdk.internal.misc.Unsafe; -import jdk.test.lib.process.*; import static jdk.test.lib.Asserts.assertTrue; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; /** * Common library for various test helper functions. @@ -446,6 +450,23 @@ public final class Utils { return iterator.next(); } + /** + * Returns random element of non empty array + * + * @param a type of array element + * @param array array of elements + * @return random element of array + * @throws IllegalArgumentException if array is empty + */ + public static T getRandomElement(T[] array) + throws IllegalArgumentException { + if (array == null || array.length == 0) { + throw new IllegalArgumentException("Empty or null array"); + } + Random random = getRandomInstance(); + return array[random.nextInt(array.length)]; + } + /** * Wait for condition to be true * @@ -636,5 +657,38 @@ public final class Utils { } return result; } + + public static Object[] getNullValues(Class... types) { + Object[] result = new Object[types.length]; + int i = 0; + for (Class type : types) { + result[i++] = NULL_VALUES.get(type); + } + return result; + } + private static Map, Object> NULL_VALUES = new HashMap<>(); + static { + NULL_VALUES.put(boolean.class, false); + NULL_VALUES.put(byte.class, (byte) 0); + NULL_VALUES.put(short.class, (short) 0); + NULL_VALUES.put(char.class, '\0'); + NULL_VALUES.put(int.class, 0); + NULL_VALUES.put(long.class, 0L); + NULL_VALUES.put(float.class, 0.0f); + NULL_VALUES.put(double.class, 0.0d); + } + + /** + * Returns mandatory property value + * @param propName is a name of property to request + * @return a String with requested property value + */ + public static String getMandatoryProperty(String propName) { + Objects.requireNonNull(propName, "Requested null property"); + String prop = System.getProperty(propName); + Objects.requireNonNull(prop, + String.format("A mandatory property '%s' isn't set", propName)); + return prop; + } } diff --git a/test/lib/share/classes/jdk/test/lib/apps/LingeredApp.java b/test/lib/jdk/test/lib/apps/LingeredApp.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/apps/LingeredApp.java rename to test/lib/jdk/test/lib/apps/LingeredApp.java index d5675a3f635..ac375b62faf 100644 --- a/test/lib/share/classes/jdk/test/lib/apps/LingeredApp.java +++ b/test/lib/jdk/test/lib/apps/LingeredApp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/apps/LingeredAppWithDeadlock.java b/test/lib/jdk/test/lib/apps/LingeredAppWithDeadlock.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/apps/LingeredAppWithDeadlock.java rename to test/lib/jdk/test/lib/apps/LingeredAppWithDeadlock.java index 85d96f29f95..2b52c1523db 100644 --- a/test/lib/share/classes/jdk/test/lib/apps/LingeredAppWithDeadlock.java +++ b/test/lib/jdk/test/lib/apps/LingeredAppWithDeadlock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 diff --git a/test/lib/jdk/test/lib/cli/CPUSpecificCommandLineOptionTest.java b/test/lib/jdk/test/lib/cli/CPUSpecificCommandLineOptionTest.java new file mode 100644 index 00000000000..121d81d8d95 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/CPUSpecificCommandLineOptionTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.cli; + +import jdk.test.lib.cli.predicate.CPUSpecificPredicate; + +/** + * Base class for command line options tests that + * requires specific CPU arch or specific CPU features. + */ +public abstract class CPUSpecificCommandLineOptionTest + extends CommandLineOptionTest { + /** + * Creates new CPU specific test instance that does not + * require any CPU features. + * + * @param cpuArchPattern Regular expression that should + * match os.arch. + */ + public CPUSpecificCommandLineOptionTest(String cpuArchPattern) { + this(cpuArchPattern, null, null); + } + + /** + * Creates new CPU specific test instance that does not + * require from CPU support of {@code supportedCPUFeatures} features + * and no support of {@code unsupportedCPUFeatures}. + * + * @param cpuArchPattern Regular expression that should + * match os.arch. + * @param supportedCPUFeatures Array with names of features that + * should be supported by CPU. If {@code null}, + * then no features have to be supported. + * @param unsupportedCPUFeatures Array with names of features that + * should not be supported by CPU. + * If {@code null}, then CPU may support any + * features. + */ + public CPUSpecificCommandLineOptionTest(String cpuArchPattern, + String supportedCPUFeatures[], String unsupportedCPUFeatures[]) { + super(new CPUSpecificPredicate(cpuArchPattern, supportedCPUFeatures, + unsupportedCPUFeatures)); + } +} diff --git a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java new file mode 100644 index 00000000000..f794ef36090 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java @@ -0,0 +1,524 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.cli; + +import java.util.List; +import java.util.ArrayList; +import java.util.Collections; +import java.util.function.BooleanSupplier; + +import jdk.test.lib.process.ExitCode; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.Platform; +import jdk.test.lib.Utils; + +/** + * Base class for command line option tests. + */ +public abstract class CommandLineOptionTest { + public static final String UNLOCK_DIAGNOSTIC_VM_OPTIONS + = "-XX:+UnlockDiagnosticVMOptions"; + public static final String UNLOCK_EXPERIMENTAL_VM_OPTIONS + = "-XX:+UnlockExperimentalVMOptions"; + protected static final String UNRECOGNIZED_OPTION_ERROR_FORMAT + = "Unrecognized VM option '[+-]?%s(=.*)?'"; + protected static final String EXPERIMENTAL_OPTION_ERROR_FORMAT + = "VM option '%s' is experimental and must be enabled via " + + "-XX:\\+UnlockExperimentalVMOptions."; + protected static final String DIAGNOSTIC_OPTION_ERROR_FORMAT + = " VM option '%s' is diagnostic and must be enabled via " + + "-XX:\\+UnlockDiagnosticVMOptions."; + private static final String PRINT_FLAGS_FINAL_FORMAT = "%s\\s*:?=\\s*%s"; + + /** + * Verifies that JVM startup behavior matches our expectations. + * + * @param option an option that should be passed to JVM + * @param expectedMessages an array of patterns that should occur + * in JVM output. If {@code null} then + * JVM output could be empty. + * @param unexpectedMessages an array of patterns that should not + * occur in JVM output. If {@code null} then + * JVM output could be empty. + * @param exitErrorMessage message that will be shown if exit code is not + * as expected. + * @param wrongWarningMessage message that will be shown if warning + * messages are not as expected. + * @param exitCode expected exit code. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyJVMStartup(String option, + String expectedMessages[], String unexpectedMessages[], + String exitErrorMessage, String wrongWarningMessage, + ExitCode exitCode) throws Throwable { + CommandLineOptionTest.verifyJVMStartup(expectedMessages, + unexpectedMessages, exitErrorMessage, + wrongWarningMessage, exitCode, false, option); + } + + /** + * Verifies that JVM startup behavior matches our expectations. + * + * @param expectedMessages an array of patterns that should occur + * in JVM output. If {@code null} then + * JVM output could be empty. + * @param unexpectedMessages an array of patterns that should not + * occur in JVM output. If {@code null} then + * JVM output could be empty. + * @param exitErrorMessage message that will be shown if exit code is not + * as expected. + * @param wrongWarningMessage message that will be shown if warning + * messages are not as expected. + * @param exitCode expected exit code. + * @param addTestVMOptions if {@code true} then test VM options will be + * passed to VM. + * @param options options that should be passed to VM in addition to mode + * flag. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyJVMStartup(String expectedMessages[], + String unexpectedMessages[], String exitErrorMessage, + String wrongWarningMessage, ExitCode exitCode, + boolean addTestVMOptions, String... options) + throws Throwable { + List finalOptions = new ArrayList<>(); + if (addTestVMOptions) { + Collections.addAll(finalOptions, ProcessTools.getVmInputArgs()); + Collections.addAll(finalOptions, Utils.getTestJavaOpts()); + } + Collections.addAll(finalOptions, options); + finalOptions.add("-version"); + + ProcessBuilder processBuilder + = ProcessTools.createJavaProcessBuilder(finalOptions.toArray( + new String[finalOptions.size()])); + OutputAnalyzer outputAnalyzer + = new OutputAnalyzer(processBuilder.start()); + + try { + outputAnalyzer.shouldHaveExitValue(exitCode.value); + } catch (RuntimeException e) { + String errorMessage = String.format( + "JVM process should have exit value '%d'.%n%s", + exitCode.value, exitErrorMessage); + throw new AssertionError(errorMessage, e); + } + + verifyOutput(expectedMessages, unexpectedMessages, + wrongWarningMessage, outputAnalyzer); + } + + /** + * Verifies that JVM startup behavior matches our expectations. + * + * @param expectedMessages an array of patterns that should occur in JVM + * output. If {@code null} then + * JVM output could be empty. + * @param unexpectedMessages an array of patterns that should not occur + * in JVM output. If {@code null} then + * JVM output could be empty. + * @param wrongWarningMessage message that will be shown if messages are + * not as expected. + * @param outputAnalyzer OutputAnalyzer instance + * @throws AssertionError if verification fails. + */ + public static void verifyOutput(String[] expectedMessages, + String[] unexpectedMessages, String wrongWarningMessage, + OutputAnalyzer outputAnalyzer) { + if (expectedMessages != null) { + for (String expectedMessage : expectedMessages) { + try { + outputAnalyzer.shouldMatch(expectedMessage); + } catch (RuntimeException e) { + String errorMessage = String.format( + "Expected message not found: '%s'.%n%s", + expectedMessage, wrongWarningMessage); + throw new AssertionError(errorMessage, e); + } + } + } + + if (unexpectedMessages != null) { + for (String unexpectedMessage : unexpectedMessages) { + try { + outputAnalyzer.shouldNotMatch(unexpectedMessage); + } catch (RuntimeException e) { + String errorMessage = String.format( + "Unexpected message found: '%s'.%n%s", + unexpectedMessage, wrongWarningMessage); + throw new AssertionError(errorMessage, e); + } + } + } + } + + /** + * Verifies that JVM startup behavior matches our expectations when type + * of newly started VM is the same as the type of current. + * + * @param expectedMessages an array of patterns that should occur + * in JVM output. If {@code null} then + * JVM output could be empty. + * @param unexpectedMessages an array of patterns that should not + * occur in JVM output. If {@code null} then + * JVM output could be empty. + * @param exitErrorMessage Message that will be shown if exit value is not + * as expected. + * @param wrongWarningMessage message that will be shown if warning + * messages are not as expected. + * @param exitCode expected exit code. + * @param options options that should be passed to VM in addition to mode + * flag. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifySameJVMStartup(String expectedMessages[], + String unexpectedMessages[], String exitErrorMessage, + String wrongWarningMessage, ExitCode exitCode, String... options) + throws Throwable { + List finalOptions = new ArrayList<>(); + finalOptions.add(CommandLineOptionTest.getVMTypeOption()); + Collections.addAll(finalOptions, options); + + CommandLineOptionTest.verifyJVMStartup(expectedMessages, + unexpectedMessages, exitErrorMessage, + wrongWarningMessage, exitCode, false, + finalOptions.toArray(new String[finalOptions.size()])); + } + + /** + * Verifies that value of specified JVM option is the same as + * expected value. + * This method filter out option with {@code optionName} + * name from test java options. + * + * @param optionName a name of tested option. + * @param expectedValue expected value of tested option. + * @param optionErrorString message will be shown if option value is not as + * expected. + * @param additionalVMOpts additional options that should be + * passed to JVM. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyOptionValue(String optionName, + String expectedValue, String optionErrorString, + String... additionalVMOpts) throws Throwable { + verifyOptionValue(optionName, expectedValue, optionErrorString, + true, additionalVMOpts); + } + + /** + * Verifies that value of specified JVM option is the same as + * expected value. + * This method filter out option with {@code optionName} + * name from test java options. + * + * @param optionName a name of tested option. + * @param expectedValue expected value of tested option. + * @param addTestVmOptions if {@code true}, then test VM options + * will be used. + * @param optionErrorString message will be shown if option value is not as + * expected. + * @param additionalVMOpts additional options that should be + * passed to JVM. + * @throws Throwable if verification fails or some other issues + * occur. + */ + public static void verifyOptionValue(String optionName, + String expectedValue, String optionErrorString, + boolean addTestVmOptions, String... additionalVMOpts) + throws Throwable { + List vmOpts = new ArrayList<>(); + + if (addTestVmOptions) { + Collections.addAll(vmOpts, + Utils.getFilteredTestJavaOpts(optionName)); + } + Collections.addAll(vmOpts, additionalVMOpts); + Collections.addAll(vmOpts, "-XX:+PrintFlagsFinal", "-version"); + + ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + vmOpts.toArray(new String[vmOpts.size()])); + + OutputAnalyzer outputAnalyzer + = new OutputAnalyzer(processBuilder.start()); + + try { + outputAnalyzer.shouldHaveExitValue(0); + } catch (RuntimeException e) { + String errorMessage = String.format( + "JVM should start with option '%s' without errors.", + optionName); + throw new AssertionError(errorMessage, e); + } + verifyOptionValue(optionName, expectedValue, optionErrorString, + outputAnalyzer); + } + + /** + * Verifies that value of specified JVM option is the same as + * expected value. + * + * @param optionName a name of tested option. + * @param expectedValue expected value of tested option. + * @param optionErrorString message will be shown if option value is not + * as expected. + * @param outputAnalyzer OutputAnalyzer instance + * @throws AssertionError if verification fails + */ + public static void verifyOptionValue(String optionName, + String expectedValue, String optionErrorString, + OutputAnalyzer outputAnalyzer) { + try { + outputAnalyzer.shouldMatch(String.format( + CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT, + optionName, expectedValue)); + } catch (RuntimeException e) { + String errorMessage = String.format( + "Option '%s' is expected to have '%s' value%n%s", + optionName, expectedValue, + optionErrorString); + throw new AssertionError(errorMessage, e); + } + } + + /** + * Start VM with given options and values. + * Generates command line option flags from + * {@code optionNames} and {@code optionValues}. + * + * @param optionNames names of options to pass in + * @param optionValues values of option + * @param additionalVMOpts additional options that should be + * passed to JVM. + * @return output from vm process + */ + public static OutputAnalyzer startVMWithOptions(String[] optionNames, + String[] optionValues, + String... additionalVMOpts) throws Throwable { + List vmOpts = new ArrayList<>(); + if (optionNames == null || optionValues == null || optionNames.length != optionValues.length) { + throw new IllegalArgumentException("optionNames and/or optionValues"); + } + + for (int i = 0; i < optionNames.length; i++) { + vmOpts.add(prepareFlag(optionNames[i], optionValues[i])); + } + Collections.addAll(vmOpts, additionalVMOpts); + Collections.addAll(vmOpts, "-version"); + + ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + vmOpts.toArray(new String[vmOpts.size()])); + + return new OutputAnalyzer(processBuilder.start()); + } + + /** + * Verifies from the output that values of specified JVM options were the same as + * expected values. + * + * @param outputAnalyzer search output for expect options and values. + * @param optionNames names of tested options. + * @param expectedValues expected values of tested options. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyOptionValuesFromOutput(OutputAnalyzer outputAnalyzer, + String[] optionNames, + String[] expectedValues) throws Throwable { + outputAnalyzer.shouldHaveExitValue(0); + for (int i = 0; i < optionNames.length; i++) { + outputAnalyzer.shouldMatch(String.format( + CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT, + optionNames[i], expectedValues[i])); + } + } + + /** + * Verifies that value of specified JVM options are the same as + * expected values. + * Generates command line option flags from + * {@code optionNames} and {@code expectedValues}. + * + * @param optionNames names of tested options. + * @param expectedValues expected values of tested options. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyOptionValues(String[] optionNames, + String[] expectedValues) throws Throwable { + OutputAnalyzer outputAnalyzer = startVMWithOptions(optionNames, expectedValues, "-XX:+PrintFlagsFinal"); + verifyOptionValuesFromOutput(outputAnalyzer, optionNames, expectedValues); + } + + /** + * Verifies that value of specified JVM when type of newly started VM + * is the same as the type of current. + * This method filter out option with {@code optionName} + * name from test java options. + * Only mode flag will be passed to VM in addition to + * {@code additionalVMOpts} + * + * @param optionName name of tested option. + * @param expectedValue expected value of tested option. + * @param optionErrorString message to show if option has another value + * @param additionalVMOpts additional options that should be + * passed to JVM. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyOptionValueForSameVM(String optionName, + String expectedValue, String optionErrorString, + String... additionalVMOpts) throws Throwable { + List finalOptions = new ArrayList<>(); + finalOptions.add(CommandLineOptionTest.getVMTypeOption()); + Collections.addAll(finalOptions, additionalVMOpts); + + CommandLineOptionTest.verifyOptionValue(optionName, expectedValue, + optionErrorString, false, + finalOptions.toArray(new String[finalOptions.size()])); + } + + /** + * Prepares boolean command line flag with name {@code name} according + * to it's {@code value}. + * + * @param name the name of option to be prepared + * @param value the value of option + * @return prepared command line flag + */ + public static String prepareBooleanFlag(String name, boolean value) { + return String.format("-XX:%c%s", (value ? '+' : '-'), name); + } + + /** + * Prepares numeric command line flag with name {@code name} by setting + * it's value to {@code value}. + * + * @param name the name of option to be prepared + * @param value the value of option + * @return prepared command line flag + */ + public static String prepareNumericFlag(String name, Number value) { + return String.format("-XX:%s=%s", name, value.toString()); + } + + /** + * Prepares generic command line flag with name {@code name} by setting + * it's value to {@code value}. + * + * @param name the name of option to be prepared + * @param value the value of option ("+" or "-" can be used instead of "true" or "false") + * @return prepared command line flag + */ + public static String prepareFlag(String name, String value) { + if (value.equals("+") || value.equalsIgnoreCase("true")) { + return "-XX:+" + name; + } else if (value.equals("-") || value.equalsIgnoreCase("false")) { + return "-XX:-" + name; + } else { + return "-XX:" + name + "=" + value; + } + } + + /** + * Returns message that should occur in VM output if option + * {@code optionName} if unrecognized. + * + * @param optionName the name of option for which message should be returned + * @return message saying that option {@code optionName} is unrecognized + */ + public static String getUnrecognizedOptionErrorMessage(String optionName) { + return String.format( + CommandLineOptionTest.UNRECOGNIZED_OPTION_ERROR_FORMAT, + optionName); + } + + /** + * Returns message that should occur in VM output if option + * {@code optionName} is experimental and + * -XX:+UnlockExperimentalVMOptions was not passed to VM. + * + * @param optionName the name of option for which message should be returned + * @return message saying that option {@code optionName} is experimental + */ + public static String getExperimentalOptionErrorMessage(String optionName) { + return String.format( + CommandLineOptionTest.EXPERIMENTAL_OPTION_ERROR_FORMAT, + optionName); + } + + /** + * Returns message that should occur in VM output if option + * {@code optionName} is diagnostic and -XX:+UnlockDiagnosticVMOptions + * was not passed to VM. + * + * @param optionName the name of option for which message should be returned + * @return message saying that option {@code optionName} is diganostic + */ + public static String getDiagnosticOptionErrorMessage(String optionName) { + return String.format( + CommandLineOptionTest.DIAGNOSTIC_OPTION_ERROR_FORMAT, + optionName); + } + + /** + * @return option required to start a new VM with the same type as current. + * @throws RuntimeException when VM type is unknown. + */ + private static String getVMTypeOption() { + if (Platform.isServer()) { + return "-server"; + } else if (Platform.isClient()) { + return "-client"; + } else if (Platform.isMinimal()) { + return "-minimal"; + } else if (Platform.isGraal()) { + return "-graal"; + } + throw new RuntimeException("Unknown VM mode."); + } + + private final BooleanSupplier predicate; + + /** + * Constructs new CommandLineOptionTest that will be executed only if + * predicate {@code predicate} return {@code true}. + * @param predicate a predicate responsible for test's preconditions check. + */ + public CommandLineOptionTest(BooleanSupplier predicate) { + this.predicate = predicate; + } + + /** + * Runs command line option test. + */ + public final void test() throws Throwable { + if (predicate.getAsBoolean()) { + runTestCases(); + } + } + + /** + * @throws Throwable if some issue happened during test cases execution. + */ + protected abstract void runTestCases() throws Throwable; +} diff --git a/test/lib/jdk/test/lib/cli/predicate/AndPredicate.java b/test/lib/jdk/test/lib/cli/predicate/AndPredicate.java new file mode 100644 index 00000000000..1e70abc2e00 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/predicate/AndPredicate.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.cli.predicate; + +import java.util.function.BooleanSupplier; + +public class AndPredicate implements BooleanSupplier { + private final BooleanSupplier a; + private final BooleanSupplier b; + + public AndPredicate(BooleanSupplier a, BooleanSupplier b) { + this.a = a; + this.b = b; + } + + @Override + public boolean getAsBoolean() { + return a.getAsBoolean() && b.getAsBoolean(); + } +} diff --git a/test/lib/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java b/test/lib/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java new file mode 100644 index 00000000000..69f753f5a84 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.cli.predicate; + +import jdk.test.lib.Platform; +import sun.hotspot.cpuinfo.CPUInfo; + +import java.util.function.BooleanSupplier; + +public class CPUSpecificPredicate implements BooleanSupplier { + private final String cpuArchPattern; + private final String supportedCPUFeatures[]; + private final String unsupportedCPUFeatures[]; + + public CPUSpecificPredicate(String cpuArchPattern, + String supportedCPUFeatures[], + String unsupportedCPUFeatures[]) { + this.cpuArchPattern = cpuArchPattern; + this.supportedCPUFeatures = supportedCPUFeatures; + this.unsupportedCPUFeatures = unsupportedCPUFeatures; + } + + @Override + public boolean getAsBoolean() { + if (!Platform.getOsArch().matches(cpuArchPattern)) { + System.out.println("CPU arch " + Platform.getOsArch() + " does not match " + cpuArchPattern); + return false; + } + + if (supportedCPUFeatures != null) { + for (String feature : supportedCPUFeatures) { + if (!CPUInfo.hasFeature(feature)) { + System.out.println("CPU does not support " + feature + + " feature"); + return false; + } + } + } + + if (unsupportedCPUFeatures != null) { + for (String feature : unsupportedCPUFeatures) { + if (CPUInfo.hasFeature(feature)) { + System.out.println("CPU support " + feature + " feature"); + return false; + } + } + } + return true; + } +} diff --git a/test/lib/jdk/test/lib/cli/predicate/NotPredicate.java b/test/lib/jdk/test/lib/cli/predicate/NotPredicate.java new file mode 100644 index 00000000000..481f878e228 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/predicate/NotPredicate.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + * + */ + +package jdk.test.lib.cli.predicate; + +import java.util.function.BooleanSupplier; + +public class NotPredicate implements BooleanSupplier { + private final BooleanSupplier s; + + public NotPredicate(BooleanSupplier s) { + this.s = s; + } + + @Override + public boolean getAsBoolean() { + return !s.getAsBoolean(); + } +} diff --git a/test/lib/jdk/test/lib/cli/predicate/OrPredicate.java b/test/lib/jdk/test/lib/cli/predicate/OrPredicate.java new file mode 100644 index 00000000000..35f5e979966 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/predicate/OrPredicate.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + * + */ + +package jdk.test.lib.cli.predicate; + +import java.util.function.BooleanSupplier; + +public class OrPredicate implements BooleanSupplier { + private final BooleanSupplier a; + private final BooleanSupplier b; + + public OrPredicate(BooleanSupplier a, BooleanSupplier b) { + this.a = a; + this.b = b; + } + + @Override + public boolean getAsBoolean() { + return a.getAsBoolean() || b.getAsBoolean(); + } +} diff --git a/test/lib/jdk/test/lib/dcmd/CommandExecutor.java b/test/lib/jdk/test/lib/dcmd/CommandExecutor.java new file mode 100644 index 00000000000..e8c5791f487 --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/CommandExecutor.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.dcmd; + +import jdk.test.lib.process.OutputAnalyzer; + +/** + * Abstract base class for Diagnostic Command executors + */ +public abstract class CommandExecutor { + + /** + * Execute a diagnostic command + * + * @param cmd The diagnostic command to execute + * @return an {@link jdk.testlibrary.OutputAnalyzer} encapsulating the output of the command + * @throws CommandExecutorException if there is an exception on the "calling side" while trying to execute the + * Diagnostic Command. Exceptions thrown on the remote side are available as textual representations in + * stderr, regardless of the specific executor used. + */ + public final OutputAnalyzer execute(String cmd) throws CommandExecutorException { + return execute(cmd, false); + } + + /** + * Execute a diagnostic command + * + * @param cmd The diagnostic command to execute + * @param silent Do not print the command output + * @return an {@link jdk.testlibrary.OutputAnalyzer} encapsulating the output of the command + * @throws CommandExecutorException if there is an exception on the "calling side" while trying to execute the + * Diagnostic Command. Exceptions thrown on the remote side are available as textual representations in + * stderr, regardless of the specific executor used. + */ + public final OutputAnalyzer execute(String cmd, boolean silent) throws CommandExecutorException { + if (!silent) { + System.out.printf("Running DCMD '%s' through '%s'%n", cmd, this.getClass().getSimpleName()); + } + + OutputAnalyzer oa = executeImpl(cmd); + + if (!silent) { + System.out.println("---------------- stdout ----------------"); + System.out.println(oa.getStdout()); + System.out.println("---------------- stderr ----------------"); + System.out.println(oa.getStderr()); + System.out.println("----------------------------------------"); + System.out.println(); + } + return oa; + } + + protected abstract OutputAnalyzer executeImpl(String cmd) throws CommandExecutorException; +} diff --git a/test/lib/jdk/test/lib/dcmd/CommandExecutorException.java b/test/lib/jdk/test/lib/dcmd/CommandExecutorException.java new file mode 100644 index 00000000000..89aa1b3dee0 --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/CommandExecutorException.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.dcmd; + +/** + * CommandExecutorException encapsulates exceptions thrown (on the "calling side") from the execution of Diagnostic + * Commands + */ +public class CommandExecutorException extends RuntimeException { + private static final long serialVersionUID = -7039597746579144280L; + + public CommandExecutorException(String message, Throwable e) { + super(message, e); + } +} diff --git a/test/lib/jdk/test/lib/dcmd/FileJcmdExecutor.java b/test/lib/jdk/test/lib/dcmd/FileJcmdExecutor.java new file mode 100644 index 00000000000..563b65fd20e --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/FileJcmdExecutor.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.dcmd; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.List; + +/** + * Executes Diagnostic Commands on the target VM (specified by pid) using the jcmd tool and its ability to read + * Diagnostic Commands from a file. + */ +public class FileJcmdExecutor extends PidJcmdExecutor { + + /** + * Instantiates a new FileJcmdExecutor targeting the current VM + */ + public FileJcmdExecutor() { + super(); + } + + /** + * Instantiates a new FileJcmdExecutor targeting the VM indicated by the given pid + * + * @param target Pid of the target VM + */ + public FileJcmdExecutor(String target) { + super(target); + } + + protected List createCommandLine(String cmd) throws CommandExecutorException { + File cmdFile = createTempFile(); + writeCommandToTemporaryFile(cmd, cmdFile); + + return Arrays.asList(jcmdBinary, Long.toString(pid), + "-f", cmdFile.getAbsolutePath()); + } + + private void writeCommandToTemporaryFile(String cmd, File cmdFile) { + try (PrintWriter pw = new PrintWriter(cmdFile)) { + pw.println(cmd); + } catch (IOException e) { + String message = "Could not write to file: " + cmdFile.getAbsolutePath(); + throw new CommandExecutorException(message, e); + } + } + + private File createTempFile() { + try { + File cmdFile = File.createTempFile("input", "jcmd"); + cmdFile.deleteOnExit(); + return cmdFile; + } catch (IOException e) { + throw new CommandExecutorException("Could not create temporary file", e); + } + } + +} diff --git a/test/lib/jdk/test/lib/dcmd/JMXExecutor.java b/test/lib/jdk/test/lib/dcmd/JMXExecutor.java new file mode 100644 index 00000000000..677b5db0def --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/JMXExecutor.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.dcmd; + +import jdk.test.lib.process.OutputAnalyzer; + +import javax.management.*; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; + +import java.lang.management.ManagementFactory; + +import java.util.HashMap; + +/** + * Executes Diagnostic Commands on the target VM (specified by a host/port combination or a full JMX Service URL) using + * the JMX interface. If the target is not the current VM, the JMX Remote interface must be enabled beforehand. + */ +public class JMXExecutor extends CommandExecutor { + + private final MBeanServerConnection mbs; + + /** + * Instantiates a new JMXExecutor targeting the current VM + */ + public JMXExecutor() { + super(); + mbs = ManagementFactory.getPlatformMBeanServer(); + } + + /** + * Instantiates a new JMXExecutor targeting the VM indicated by the given host/port combination or a full JMX + * Service URL + * + * @param target a host/port combination on the format "host:port" or a full JMX Service URL of the target VM + */ + public JMXExecutor(String target) { + String urlStr; + + if (target.matches("^\\w[\\w\\-]*(\\.[\\w\\-]+)*:\\d+$")) { + /* Matches "hostname:port" */ + urlStr = String.format("service:jmx:rmi:///jndi/rmi://%s/jmxrmi", target); + } else if (target.startsWith("service:")) { + urlStr = target; + } else { + throw new IllegalArgumentException("Could not recognize target string: " + target); + } + + try { + JMXServiceURL url = new JMXServiceURL(urlStr); + JMXConnector c = JMXConnectorFactory.connect(url, new HashMap<>()); + mbs = c.getMBeanServerConnection(); + } catch (IOException e) { + throw new CommandExecutorException("Could not initiate connection to target: " + target, e); + } + } + + protected OutputAnalyzer executeImpl(String cmd) throws CommandExecutorException { + String stdout = ""; + String stderr = ""; + + String[] cmdParts = cmd.split(" ", 2); + String operation = commandToMethodName(cmdParts[0]); + Object[] dcmdArgs = produceArguments(cmdParts); + String[] signature = {String[].class.getName()}; + + ObjectName beanName = getMBeanName(); + + try { + stdout = (String) mbs.invoke(beanName, operation, dcmdArgs, signature); + } + + /* Failures on the "local" side, the one invoking the command. */ + catch (ReflectionException e) { + Throwable cause = e.getCause(); + if (cause instanceof NoSuchMethodException) { + /* We want JMXExecutor to match the behavior of the other CommandExecutors */ + String message = "Unknown diagnostic command: " + operation; + stderr = exceptionTraceAsString(new IllegalArgumentException(message, e)); + } else { + rethrowExecutorException(operation, dcmdArgs, e); + } + } + + /* Failures on the "local" side, the one invoking the command. */ + catch (InstanceNotFoundException | IOException e) { + rethrowExecutorException(operation, dcmdArgs, e); + } + + /* Failures on the remote side, the one executing the invoked command. */ + catch (MBeanException e) { + stdout = exceptionTraceAsString(e); + } + + return new OutputAnalyzer(stdout, stderr); + } + + private void rethrowExecutorException(String operation, Object[] dcmdArgs, + Exception e) throws CommandExecutorException { + String message = String.format("Could not invoke: %s %s", operation, + String.join(" ", (String[]) dcmdArgs[0])); + throw new CommandExecutorException(message, e); + } + + private ObjectName getMBeanName() throws CommandExecutorException { + String MBeanName = "com.sun.management:type=DiagnosticCommand"; + + try { + return new ObjectName(MBeanName); + } catch (MalformedObjectNameException e) { + String message = "MBean not found: " + MBeanName; + throw new CommandExecutorException(message, e); + } + } + + private Object[] produceArguments(String[] cmdParts) { + Object[] dcmdArgs = {new String[0]}; /* Default: No arguments */ + + if (cmdParts.length == 2) { + dcmdArgs[0] = cmdParts[1].split(" "); + } + return dcmdArgs; + } + + /** + * Convert from diagnostic command to MBean method name + * + * Examples: + * help --> help + * VM.version --> vmVersion + * VM.command_line --> vmCommandLine + */ + private static String commandToMethodName(String cmd) { + String operation = ""; + boolean up = false; /* First letter is to be lower case */ + + /* + * If a '.' or '_' is encountered it is not copied, + * instead the next character will be converted to upper case + */ + for (char c : cmd.toCharArray()) { + if (('.' == c) || ('_' == c)) { + up = true; + } else if (up) { + operation = operation.concat(Character.toString(c).toUpperCase()); + up = false; + } else { + operation = operation.concat(Character.toString(c).toLowerCase()); + } + } + + return operation; + } + + private static String exceptionTraceAsString(Throwable cause) { + StringWriter sw = new StringWriter(); + cause.printStackTrace(new PrintWriter(sw)); + return sw.toString(); + } + +} diff --git a/test/lib/jdk/test/lib/dcmd/JcmdExecutor.java b/test/lib/jdk/test/lib/dcmd/JcmdExecutor.java new file mode 100644 index 00000000000..6bf940cda6e --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/JcmdExecutor.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.dcmd; + +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import java.util.List; + +/** + * Base class for Diagnostic Command Executors using the jcmd tool + */ +public abstract class JcmdExecutor extends CommandExecutor { + protected String jcmdBinary; + + protected abstract List createCommandLine(String cmd) throws CommandExecutorException; + + protected JcmdExecutor() { + jcmdBinary = JDKToolFinder.getJDKTool("jcmd"); + } + + protected OutputAnalyzer executeImpl(String cmd) throws CommandExecutorException { + List commandLine = createCommandLine(cmd); + + try { + System.out.printf("Executing command '%s'%n", commandLine); + OutputAnalyzer output = ProcessTools.executeProcess(new ProcessBuilder(commandLine)); + System.out.printf("Command returned with exit code %d%n", output.getExitValue()); + + return output; + } catch (Exception e) { + String message = String.format("Caught exception while executing '%s'", commandLine); + throw new CommandExecutorException(message, e); + } + } +} diff --git a/test/lib/jdk/test/lib/dcmd/MainClassJcmdExecutor.java b/test/lib/jdk/test/lib/dcmd/MainClassJcmdExecutor.java new file mode 100644 index 00000000000..84608c11632 --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/MainClassJcmdExecutor.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.dcmd; + +import java.util.Arrays; +import java.util.List; + +/** + * Executes Diagnostic Commands on the target VM (specified by main class) using the jcmd tool + */ +public class MainClassJcmdExecutor extends JcmdExecutor { + private final String mainClass; + + /** + * Instantiates a new MainClassJcmdExecutor targeting the current VM + */ + public MainClassJcmdExecutor() { + super(); + mainClass = System.getProperty("sun.java.command").split(" ")[0]; + } + + /** + * Instantiates a new MainClassJcmdExecutor targeting the VM indicated by the given main class + * + * @param target Main class of the target VM + */ + public MainClassJcmdExecutor(String target) { + super(); + mainClass = target; + } + + protected List createCommandLine(String cmd) throws CommandExecutorException { + return Arrays.asList(jcmdBinary, mainClass, cmd); + } + +} diff --git a/test/lib/jdk/test/lib/dcmd/PidJcmdExecutor.java b/test/lib/jdk/test/lib/dcmd/PidJcmdExecutor.java new file mode 100644 index 00000000000..25b3f532fc6 --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/PidJcmdExecutor.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.dcmd; + +import jdk.test.lib.process.ProcessTools; + +import java.util.Arrays; +import java.util.List; + +/** + * Executes Diagnostic Commands on the target VM (specified by pid) using the jcmd tool + */ +public class PidJcmdExecutor extends JcmdExecutor { + protected final long pid; + + /** + * Instantiates a new PidJcmdExecutor targeting the current VM + */ + public PidJcmdExecutor() { + super(); + try { + pid = ProcessTools.getProcessId(); + } catch (Exception e) { + throw new CommandExecutorException("Could not determine own pid", e); + } + } + + /** + * Instantiates a new PidJcmdExecutor targeting the VM indicated by the given pid + * + * @param target Pid of the target VM + */ + public PidJcmdExecutor(String target) { + super(); + pid = Long.valueOf(target); + } + + protected List createCommandLine(String cmd) throws CommandExecutorException { + return Arrays.asList(jcmdBinary, Long.toString(pid), cmd); + } + +} diff --git a/test/lib/share/classes/jdk/test/lib/hprof/HprofParser.java b/test/lib/jdk/test/lib/hprof/HprofParser.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/HprofParser.java rename to test/lib/jdk/test/lib/hprof/HprofParser.java index cb39c0d9ac0..88841f9e6d4 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/HprofParser.java +++ b/test/lib/jdk/test/lib/hprof/HprofParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/README b/test/lib/jdk/test/lib/hprof/README similarity index 100% rename from test/lib/share/classes/jdk/test/lib/hprof/README rename to test/lib/jdk/test/lib/hprof/README diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java b/test/lib/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java rename to test/lib/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java index dcaf3624085..4624347ff6b 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java +++ b/test/lib/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/ArrayTypeCodes.java b/test/lib/jdk/test/lib/hprof/model/ArrayTypeCodes.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/ArrayTypeCodes.java rename to test/lib/jdk/test/lib/hprof/model/ArrayTypeCodes.java index d3c9a9eaeb4..c6ac3ac372a 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/ArrayTypeCodes.java +++ b/test/lib/jdk/test/lib/hprof/model/ArrayTypeCodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/HackJavaValue.java b/test/lib/jdk/test/lib/hprof/model/HackJavaValue.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/HackJavaValue.java rename to test/lib/jdk/test/lib/hprof/model/HackJavaValue.java index fda40a9c07f..6da7b2df648 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/HackJavaValue.java +++ b/test/lib/jdk/test/lib/hprof/model/HackJavaValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaBoolean.java b/test/lib/jdk/test/lib/hprof/model/JavaBoolean.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaBoolean.java rename to test/lib/jdk/test/lib/hprof/model/JavaBoolean.java index 3c298457856..e96766ddba6 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaBoolean.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaByte.java b/test/lib/jdk/test/lib/hprof/model/JavaByte.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaByte.java rename to test/lib/jdk/test/lib/hprof/model/JavaByte.java index aa32ca532c2..e4a1d330008 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaByte.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaChar.java b/test/lib/jdk/test/lib/hprof/model/JavaChar.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaChar.java rename to test/lib/jdk/test/lib/hprof/model/JavaChar.java index 629af171d9e..7c04f503efd 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaChar.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaClass.java b/test/lib/jdk/test/lib/hprof/model/JavaClass.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaClass.java rename to test/lib/jdk/test/lib/hprof/model/JavaClass.java index c25e8adcf79..c2a9563e0aa 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaClass.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaDouble.java b/test/lib/jdk/test/lib/hprof/model/JavaDouble.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaDouble.java rename to test/lib/jdk/test/lib/hprof/model/JavaDouble.java index 347fd4f9c86..3b643029896 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaDouble.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaField.java b/test/lib/jdk/test/lib/hprof/model/JavaField.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaField.java rename to test/lib/jdk/test/lib/hprof/model/JavaField.java index 87dc48e679b..d343f913abd 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaField.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaFloat.java b/test/lib/jdk/test/lib/hprof/model/JavaFloat.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaFloat.java rename to test/lib/jdk/test/lib/hprof/model/JavaFloat.java index 838b72b2ad5..44692125024 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaFloat.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObject.java b/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObject.java rename to test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java index 6ab1242473b..dbe54f0ef28 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObject.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java b/test/lib/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java rename to test/lib/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java index d31d382dab8..77607655a8e 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaInt.java b/test/lib/jdk/test/lib/hprof/model/JavaInt.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaInt.java rename to test/lib/jdk/test/lib/hprof/model/JavaInt.java index 4b2e7d2ad8f..9360f858eb8 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaInt.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaLazyReadObject.java b/test/lib/jdk/test/lib/hprof/model/JavaLazyReadObject.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaLazyReadObject.java rename to test/lib/jdk/test/lib/hprof/model/JavaLazyReadObject.java index 3baaf3ca1dd..5428a2b5ede 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaLazyReadObject.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaLazyReadObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaLong.java b/test/lib/jdk/test/lib/hprof/model/JavaLong.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaLong.java rename to test/lib/jdk/test/lib/hprof/model/JavaLong.java index d86dc50658d..28aca95670b 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaLong.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObject.java b/test/lib/jdk/test/lib/hprof/model/JavaObject.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaObject.java rename to test/lib/jdk/test/lib/hprof/model/JavaObject.java index a419348eff8..74bdb0d6c28 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObject.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectArray.java b/test/lib/jdk/test/lib/hprof/model/JavaObjectArray.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectArray.java rename to test/lib/jdk/test/lib/hprof/model/JavaObjectArray.java index 4ed0afeaea6..98ae116cafb 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectArray.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaObjectArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectRef.java b/test/lib/jdk/test/lib/hprof/model/JavaObjectRef.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectRef.java rename to test/lib/jdk/test/lib/hprof/model/JavaObjectRef.java index 009c03b0dc7..f0958f7db4c 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectRef.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaObjectRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaShort.java b/test/lib/jdk/test/lib/hprof/model/JavaShort.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaShort.java rename to test/lib/jdk/test/lib/hprof/model/JavaShort.java index d3bf75952b3..7c4e46acc02 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaShort.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaStatic.java b/test/lib/jdk/test/lib/hprof/model/JavaStatic.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaStatic.java rename to test/lib/jdk/test/lib/hprof/model/JavaStatic.java index b9dc399cf8b..79a5b0d64b7 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaStatic.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaStatic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaThing.java b/test/lib/jdk/test/lib/hprof/model/JavaThing.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaThing.java rename to test/lib/jdk/test/lib/hprof/model/JavaThing.java index 5b14eb68b94..2a663ab443e 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaThing.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaThing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaValue.java b/test/lib/jdk/test/lib/hprof/model/JavaValue.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaValue.java rename to test/lib/jdk/test/lib/hprof/model/JavaValue.java index 30ac6653d28..e7cad68b4d0 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaValue.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaValueArray.java b/test/lib/jdk/test/lib/hprof/model/JavaValueArray.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaValueArray.java rename to test/lib/jdk/test/lib/hprof/model/JavaValueArray.java index 7c0c2c6773f..d65780d527f 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaValueArray.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaValueArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludes.java b/test/lib/jdk/test/lib/hprof/model/ReachableExcludes.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludes.java rename to test/lib/jdk/test/lib/hprof/model/ReachableExcludes.java index 6133e539b80..b95183251ab 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludes.java +++ b/test/lib/jdk/test/lib/hprof/model/ReachableExcludes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludesImpl.java b/test/lib/jdk/test/lib/hprof/model/ReachableExcludesImpl.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludesImpl.java rename to test/lib/jdk/test/lib/hprof/model/ReachableExcludesImpl.java index 8a15e635523..5038f71ddc0 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludesImpl.java +++ b/test/lib/jdk/test/lib/hprof/model/ReachableExcludesImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableObjects.java b/test/lib/jdk/test/lib/hprof/model/ReachableObjects.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/ReachableObjects.java rename to test/lib/jdk/test/lib/hprof/model/ReachableObjects.java index da7a4a1e58a..c3fcd7521d4 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableObjects.java +++ b/test/lib/jdk/test/lib/hprof/model/ReachableObjects.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/ReferenceChain.java b/test/lib/jdk/test/lib/hprof/model/ReferenceChain.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/ReferenceChain.java rename to test/lib/jdk/test/lib/hprof/model/ReferenceChain.java index b21ed0bb95e..3b217519447 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/ReferenceChain.java +++ b/test/lib/jdk/test/lib/hprof/model/ReferenceChain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/Root.java b/test/lib/jdk/test/lib/hprof/model/Root.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/Root.java rename to test/lib/jdk/test/lib/hprof/model/Root.java index 54a893b9dcd..ae7c08bfeb1 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/Root.java +++ b/test/lib/jdk/test/lib/hprof/model/Root.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/Snapshot.java b/test/lib/jdk/test/lib/hprof/model/Snapshot.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/model/Snapshot.java rename to test/lib/jdk/test/lib/hprof/model/Snapshot.java index 6150543b36b..fcef29a1b85 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/Snapshot.java +++ b/test/lib/jdk/test/lib/hprof/model/Snapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/StackFrame.java b/test/lib/jdk/test/lib/hprof/model/StackFrame.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/model/StackFrame.java rename to test/lib/jdk/test/lib/hprof/model/StackFrame.java index f6e2996b005..723cf64986e 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/StackFrame.java +++ b/test/lib/jdk/test/lib/hprof/model/StackFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/StackTrace.java b/test/lib/jdk/test/lib/hprof/model/StackTrace.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/model/StackTrace.java rename to test/lib/jdk/test/lib/hprof/model/StackTrace.java index d581257430c..75c92fc9cdf 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/StackTrace.java +++ b/test/lib/jdk/test/lib/hprof/model/StackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/FileReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/FileReadBuffer.java rename to test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java index 716b9469868..7beb2e7dd28 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/FileReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/HprofReader.java b/test/lib/jdk/test/lib/hprof/parser/HprofReader.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/HprofReader.java rename to test/lib/jdk/test/lib/hprof/parser/HprofReader.java index 15bd6af7fda..693bec6b9b7 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/HprofReader.java +++ b/test/lib/jdk/test/lib/hprof/parser/HprofReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/MappedReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/MappedReadBuffer.java rename to test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java index b3657e6f0c5..c7247fae68f 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/MappedReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/PositionDataInputStream.java b/test/lib/jdk/test/lib/hprof/parser/PositionDataInputStream.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/PositionDataInputStream.java rename to test/lib/jdk/test/lib/hprof/parser/PositionDataInputStream.java index b27e1dc1927..8435dd12a3a 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/PositionDataInputStream.java +++ b/test/lib/jdk/test/lib/hprof/parser/PositionDataInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/PositionInputStream.java b/test/lib/jdk/test/lib/hprof/parser/PositionInputStream.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/PositionInputStream.java rename to test/lib/jdk/test/lib/hprof/parser/PositionInputStream.java index aecc72629ad..0c0e43de8e5 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/PositionInputStream.java +++ b/test/lib/jdk/test/lib/hprof/parser/PositionInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/ReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/ReadBuffer.java rename to test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java index 99c15e5698f..fe548a74ff8 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/ReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/Reader.java b/test/lib/jdk/test/lib/hprof/parser/Reader.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/Reader.java rename to test/lib/jdk/test/lib/hprof/parser/Reader.java index 19ddad5997c..5263035df72 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/Reader.java +++ b/test/lib/jdk/test/lib/hprof/parser/Reader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/util/ArraySorter.java b/test/lib/jdk/test/lib/hprof/util/ArraySorter.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/util/ArraySorter.java rename to test/lib/jdk/test/lib/hprof/util/ArraySorter.java index 4101529dabb..04dbad7ff0b 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/util/ArraySorter.java +++ b/test/lib/jdk/test/lib/hprof/util/ArraySorter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/util/Comparer.java b/test/lib/jdk/test/lib/hprof/util/Comparer.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/util/Comparer.java rename to test/lib/jdk/test/lib/hprof/util/Comparer.java index b6ae50364ee..182f37edf61 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/util/Comparer.java +++ b/test/lib/jdk/test/lib/hprof/util/Comparer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/util/CompositeEnumeration.java b/test/lib/jdk/test/lib/hprof/util/CompositeEnumeration.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/util/CompositeEnumeration.java rename to test/lib/jdk/test/lib/hprof/util/CompositeEnumeration.java index 2c49fad85c1..ddebd0fb3ed 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/util/CompositeEnumeration.java +++ b/test/lib/jdk/test/lib/hprof/util/CompositeEnumeration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/util/Misc.java b/test/lib/jdk/test/lib/hprof/util/Misc.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/util/Misc.java rename to test/lib/jdk/test/lib/hprof/util/Misc.java index 98592f634e2..e654d71d4ce 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/util/Misc.java +++ b/test/lib/jdk/test/lib/hprof/util/Misc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/util/VectorSorter.java b/test/lib/jdk/test/lib/hprof/util/VectorSorter.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/util/VectorSorter.java rename to test/lib/jdk/test/lib/hprof/util/VectorSorter.java index 112d90959b6..fb2ac13e175 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/util/VectorSorter.java +++ b/test/lib/jdk/test/lib/hprof/util/VectorSorter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/jdk/test/lib/process/ExitCode.java b/test/lib/jdk/test/lib/process/ExitCode.java new file mode 100644 index 00000000000..bb66da17911 --- /dev/null +++ b/test/lib/jdk/test/lib/process/ExitCode.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.process; + +/** + * Exit code values that could be returned by the JVM. + */ +public enum ExitCode { + OK(0), + FAIL(1), + CRASH(134); + + public final int value; + + ExitCode(int value) { + this.value = value; + } +} + diff --git a/test/lib/share/classes/jdk/test/lib/process/OutputAnalyzer.java b/test/lib/jdk/test/lib/process/OutputAnalyzer.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/process/OutputAnalyzer.java rename to test/lib/jdk/test/lib/process/OutputAnalyzer.java index fc3a4de2905..97d9ae0db50 100644 --- a/test/lib/share/classes/jdk/test/lib/process/OutputAnalyzer.java +++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -374,14 +374,14 @@ public final class OutputAnalyzer { * - exit code * Note: the command line is printed by the ProcessTools */ - private void reportDiagnosticSummary() { - String msg = - " stdout: [" + stdout + "];\n" + - " stderr: [" + stderr + "]\n" + - " exitValue = " + getExitValue() + "\n"; + public void reportDiagnosticSummary() { + String msg = + " stdout: [" + stdout + "];\n" + + " stderr: [" + stderr + "]\n" + + " exitValue = " + getExitValue() + "\n"; - System.err.println(msg); - } + System.err.println(msg); + } /** diff --git a/test/lib/share/classes/jdk/test/lib/process/OutputBuffer.java b/test/lib/jdk/test/lib/process/OutputBuffer.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/process/OutputBuffer.java rename to test/lib/jdk/test/lib/process/OutputBuffer.java index 23976d8272f..a41e8436ba0 100644 --- a/test/lib/share/classes/jdk/test/lib/process/OutputBuffer.java +++ b/test/lib/jdk/test/lib/process/OutputBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java similarity index 93% rename from test/lib/share/classes/jdk/test/lib/process/ProcessTools.java rename to test/lib/jdk/test/lib/process/ProcessTools.java index 3189a0fe277..3f4bbb7fa79 100644 --- a/test/lib/share/classes/jdk/test/lib/process/ProcessTools.java +++ b/test/lib/jdk/test/lib/process/ProcessTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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,10 +28,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.concurrent.CountDownLatch; +import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -301,6 +304,16 @@ public final class ProcessTools { public static long getProcessId() throws Exception { return ProcessHandle.current().getPid(); } + /** + * Gets the array of strings containing input arguments passed to the VM + * + * @return arguments + */ + public static String[] getVmInputArgs() { + RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); + List args = runtime.getInputArguments(); + return args.toArray(new String[args.size()]); + } /** * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris) @@ -342,16 +355,10 @@ public final class ProcessTools { args.add(javapath); Collections.addAll(args, getPlatformSpecificVMArgs()); + args.add("-cp"); + args.add(System.getProperty("java.class.path")); + if (addTestVmAndJavaOptions) { - // -cp is needed to make sure the same classpath is used whether the test is - // run in AgentVM mode or OtherVM mode. It was added to the hotspot version - // of this API as part of 8077608. However, for the jdk version it is only - // added when addTestVmAndJavaOptions is true in order to minimize - // disruption to existing JDK tests, which have yet to be tested with -cp - // being added. At some point -cp should always be added to be consistent - // with what the hotspot version does. - args.add("-cp"); - args.add(System.getProperty("java.class.path")); Collections.addAll(args, Utils.getTestJavaOpts()); } @@ -377,6 +384,26 @@ public final class ProcessTools { } } + /** + * Executes a test jvm process, waits for it to finish and returns the process output. + * The default jvm options from the test's run command, jtreg, test.vm.opts and test.java.opts, are added. + * The java from the test.jdk is used to execute the command. + * + * The command line will be like: + * {test.jdk}/bin/java {test.fromRun.opts} {test.vm.opts} {test.java.opts} cmds + * + * @param cmds User specifed arguments. + * @return The output from the process. + */ + public static OutputAnalyzer executeTestJvmAllArgs(String... cmds) throws Throwable { + List argsList = new ArrayList<>(); + String[] testArgs = getVmInputArgs(); + Collections.addAll(argsList, testArgs); + Collections.addAll(argsList, Utils.addTestJavaOpts(cmds)); + ProcessBuilder pb = createJavaProcessBuilder(argsList.toArray(new String[argsList.size()])); + return executeProcess(pb); + } + /** * Executes a test jvm process, waits for it to finish and returns the process output. * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added. diff --git a/test/lib/share/classes/jdk/test/lib/process/StreamPumper.java b/test/lib/jdk/test/lib/process/StreamPumper.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/process/StreamPumper.java rename to test/lib/jdk/test/lib/process/StreamPumper.java index b1780c4ef08..8dd7f0cf0ec 100644 --- a/test/lib/share/classes/jdk/test/lib/process/StreamPumper.java +++ b/test/lib/jdk/test/lib/process/StreamPumper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 diff --git a/test/lib/jdk/test/lib/util/Pair.java b/test/lib/jdk/test/lib/util/Pair.java new file mode 100644 index 00000000000..ca29586b045 --- /dev/null +++ b/test/lib/jdk/test/lib/util/Pair.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.util; + +import java.util.Objects; + +/** + * Pair - a two element tuple + * + * @param first type + * @param second type + */ +public class Pair { + public final F first; + public final S second; + + public Pair(F first, S second) { + this.first = first; + this.second = second; + } + + @Override + public String toString() { + return "(" + first + ":" + second + ")"; + } + + @Override + public boolean equals(Object other) { + if (other instanceof Pair) { + Pair otherPair = (Pair) other; + return Objects.equals(first, otherPair.first) && + Objects.equals(second, otherPair.second); + } + return false; + } + + @Override + public int hashCode() { + if (first == null) { + return (second == null) ? 0 : second.hashCode(); + } else if (second == null) { + return first.hashCode(); + } else { + return first.hashCode() * 17 + second.hashCode(); + } + } +} diff --git a/test/lib/jdk/test/lib/util/Triple.java b/test/lib/jdk/test/lib/util/Triple.java new file mode 100644 index 00000000000..fbc82532286 --- /dev/null +++ b/test/lib/jdk/test/lib/util/Triple.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.util; + +import java.util.Objects; + +/** + * Triple - a three element tuple + * + * @param first element type + * @param second element type + * @param third element type + */ +public class Triple { + private final Pair> container; + + /** + * Constructor + * + * @param first first element of the triple + * @param second second element of the triple + * @param third third element of the triple + */ + public Triple(F first, S second, T third) { + container = new Pair<>(first, new Pair<>(second, third)); + } + + /** + * Gets first element of the triple + */ + public F getFirst() { + return container.first; + } + + /** + * Gets second element of the triple + */ + public S getSecond() { + return container.second.first; + } + + /** + * Gets third element of the triple + */ + public T getThird() { + return container.second.second; + } + + @Override + public int hashCode() { + return container.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof Triple) { + Triple objTriple = (Triple) obj; + return Objects.equals(container.first, objTriple.container.first) + && Objects.equals(container.second, + objTriple.container.second); + } + return false; + } + + @Override + public String toString() { + return "(" + getFirst() + " : " + getSecond() + " : " + getThird() + ")"; + } +} diff --git a/test/lib/jdk/test/lib/wrappers/InfiniteLoop.java b/test/lib/jdk/test/lib/wrappers/InfiniteLoop.java new file mode 100644 index 00000000000..dbee901f8c0 --- /dev/null +++ b/test/lib/jdk/test/lib/wrappers/InfiniteLoop.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.wrappers; + +import java.util.Objects; + +/** + * Class which runs another Runnable in infinite loop with certain pauses + * between cycles. + */ +public class InfiniteLoop implements Runnable { + private final Runnable target; + private final long mills; + + + /** + * @param target a target to run in a loop + * @param mills the length of pause time in milliseconds + * @throws NullPointerException if target is null + * @throws IllegalArgumentException if the value of millis is negative + */ + public InfiniteLoop(Runnable target, long mills) { + Objects.requireNonNull(target); + if (mills < 0) { + throw new IllegalArgumentException("mills < 0"); + } + this.target = target; + this.mills = mills; + } + + @Override + public void run() { + try { + while (true) { + target.run(); + if (mills > 0) { + Thread.sleep(mills); + } + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new Error(e); + } + } +} diff --git a/test/lib/jdk/test/lib/wrappers/TimeLimitedRunner.java b/test/lib/jdk/test/lib/wrappers/TimeLimitedRunner.java new file mode 100644 index 00000000000..73d53b43b12 --- /dev/null +++ b/test/lib/jdk/test/lib/wrappers/TimeLimitedRunner.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.wrappers; + +import java.util.Objects; +import java.util.concurrent.Callable; + +/** + * Auxiliary class to run target w/ given timeout. + */ +public class TimeLimitedRunner implements Callable { + private final long stoptime; + private final long timeout; + private final double factor; + private final Callable target; + + /** + * @param timeout a timeout. zero means no time limitation + * @param factor a multiplier used to estimate next iteration time + * @param target a target to run + * @throws NullPointerException if target is null + * @throws IllegalArgumentException if timeout is negative or + factor isn't positive + */ + public TimeLimitedRunner(long timeout, double factor, + Callable target) { + Objects.requireNonNull(target, "target must not be null"); + if (timeout < 0) { + throw new IllegalArgumentException("timeout[" + timeout + "] < 0"); + } + if (factor <= 0d) { + throw new IllegalArgumentException("factor[" + factor + "] <= 0"); + } + this.stoptime = System.currentTimeMillis() + timeout; + this.timeout = timeout; + this.factor = factor; + this.target = target; + } + + /** + * Runs @{linkplan target} while it returns true and timeout isn't exceeded + */ + @Override + public Void call() throws Exception { + long maxDuration = 0L; + long iterStart = System.currentTimeMillis(); + if (timeout != 0 && iterStart > stoptime) { + return null; + } + while (target.call()) { + if (timeout != 0) { + long iterDuration = System.currentTimeMillis() - iterStart; + maxDuration = Math.max(maxDuration, iterDuration); + iterStart = System.currentTimeMillis(); + if (iterStart + (maxDuration * factor) > stoptime) { + System.out.println("Not enough time to continue execution. " + + "Interrupted."); + break; + } + } + } + return null; + } + +} From 0731886f09d6d2505dc9df578f4ff8267d146fcd Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Fri, 19 Aug 2016 10:09:53 -0400 Subject: [PATCH 032/296] 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder Reviewed-by: coleenp, gtriantafill, mseledtsov, iignatyev, dholmes, dsamersoff --- jdk/test/com/sun/jdi/SunBootClassPathEmptyTest.java | 2 +- .../com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java | 4 ++-- jdk/test/java/lang/ProcessHandle/Basic.java | 1 - jdk/test/java/lang/ProcessHandle/InfoTest.java | 2 +- jdk/test/java/lang/ProcessHandle/OnExitTest.java | 2 +- jdk/test/java/lang/ProcessHandle/TreeTest.java | 2 +- jdk/test/java/lang/ref/CleanerTest.java | 2 +- jdk/test/java/security/SecureRandom/DrbgParametersSpec.java | 2 +- jdk/test/jdk/internal/ref/Cleaner/ExitOnThrow.java | 2 +- jdk/test/lib/testlibrary/jdk/testlibrary/Asserts.java | 4 ++-- jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolFinder.java | 4 ++-- jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java | 4 ++-- jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java | 4 ++-- jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java | 4 ++-- jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java | 2 +- jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java | 4 ++-- jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java | 4 ++-- jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java | 4 ++-- .../sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java | 4 ++-- jdk/test/sun/misc/SunMiscSignalTest.java | 2 +- jdk/test/sun/security/tools/jarsigner/AltProvider.java | 2 +- jdk/test/sun/tools/jhsdb/BasicLauncherTest.java | 2 +- jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java | 4 ++-- jdk/test/sun/tools/jinfo/JInfoTest.java | 2 +- jdk/test/sun/tools/jmap/BasicJMapTest.java | 2 +- jdk/test/sun/tools/jps/TestJpsSanity.java | 4 ++-- jdk/test/sun/tools/jstack/DeadlockDetectionTest.java | 4 ++-- jdk/test/tools/jar/multiRelease/Basic.java | 2 +- 28 files changed, 40 insertions(+), 41 deletions(-) diff --git a/jdk/test/com/sun/jdi/SunBootClassPathEmptyTest.java b/jdk/test/com/sun/jdi/SunBootClassPathEmptyTest.java index e062996ee6a..b1eacad1e90 100644 --- a/jdk/test/com/sun/jdi/SunBootClassPathEmptyTest.java +++ b/jdk/test/com/sun/jdi/SunBootClassPathEmptyTest.java @@ -32,7 +32,7 @@ import jdk.test.lib.Asserts; * @summary Verifies that PathSearchingVirtualMachine.bootClassPath() * returns an empty list in case no bootclass path specified * regardless of sun.boot.class.path option, which is now obsolete - * @library /test/lib/share/classes + * @library /test/lib * @compile TestClass.java * @compile SunBootClassPathEmptyTest.java * @run main/othervm SunBootClassPathEmptyTest diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java index 8a2c224f461..ac8e4f9c2a9 100644 --- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java +++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, 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 @@ -38,7 +38,7 @@ import com.sun.management.HotSpotDiagnosticMXBean; * @bug 6455258 * @summary Sanity test for com.sun.management.HotSpotDiagnosticMXBean.dumpHeap method * @library /lib/testlibrary - * @library /test/lib/share/classes + * @library /test/lib * @build jdk.testlibrary.* * @build jdk.test.lib.hprof.* * @build jdk.test.lib.hprof.model.* diff --git a/jdk/test/java/lang/ProcessHandle/Basic.java b/jdk/test/java/lang/ProcessHandle/Basic.java index b759e9c7c39..72dbe852139 100644 --- a/jdk/test/java/lang/ProcessHandle/Basic.java +++ b/jdk/test/java/lang/ProcessHandle/Basic.java @@ -36,7 +36,6 @@ import org.testng.annotations.Test; /* * @test - * @library /test/lib/share/classes * @modules java.base/jdk.internal.misc * jdk.management * @run testng Basic diff --git a/jdk/test/java/lang/ProcessHandle/InfoTest.java b/jdk/test/java/lang/ProcessHandle/InfoTest.java index 7d8867d67da..fbd855db91d 100644 --- a/jdk/test/java/lang/ProcessHandle/InfoTest.java +++ b/jdk/test/java/lang/ProcessHandle/InfoTest.java @@ -48,7 +48,7 @@ import org.testng.annotations.Test; /* * @test * @bug 8077350 8081566 8081567 8098852 8136597 - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.management * @build jdk.test.lib.Platform jdk.test.lib.Utils diff --git a/jdk/test/java/lang/ProcessHandle/OnExitTest.java b/jdk/test/java/lang/ProcessHandle/OnExitTest.java index c797f4a705b..ff9f4c2607c 100644 --- a/jdk/test/java/lang/ProcessHandle/OnExitTest.java +++ b/jdk/test/java/lang/ProcessHandle/OnExitTest.java @@ -38,7 +38,7 @@ import org.testng.TestNG; /* * @test - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.management * @build jdk.test.lib.Platform jdk.test.lib.Utils diff --git a/jdk/test/java/lang/ProcessHandle/TreeTest.java b/jdk/test/java/lang/ProcessHandle/TreeTest.java index bb62d06353c..a1493b65882 100644 --- a/jdk/test/java/lang/ProcessHandle/TreeTest.java +++ b/jdk/test/java/lang/ProcessHandle/TreeTest.java @@ -44,7 +44,7 @@ import org.testng.annotations.Test; /* * @test - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.management * @build jdk.test.lib.Utils diff --git a/jdk/test/java/lang/ref/CleanerTest.java b/jdk/test/java/lang/ref/CleanerTest.java index 25c50dc24c1..c6778669f00 100644 --- a/jdk/test/java/lang/ref/CleanerTest.java +++ b/jdk/test/java/lang/ref/CleanerTest.java @@ -49,7 +49,7 @@ import org.testng.annotations.Test; /* * @test - * @library /test/lib/share/classes /lib/testlibrary /test/lib + * @library /lib/testlibrary /test/lib * @build sun.hotspot.WhiteBox * @build jdk.test.lib.Utils * @modules java.base/jdk.internal diff --git a/jdk/test/java/security/SecureRandom/DrbgParametersSpec.java b/jdk/test/java/security/SecureRandom/DrbgParametersSpec.java index 07ada993a35..f633576f4f0 100644 --- a/jdk/test/java/security/SecureRandom/DrbgParametersSpec.java +++ b/jdk/test/java/security/SecureRandom/DrbgParametersSpec.java @@ -24,7 +24,7 @@ /* @test * @bug 8051408 8158534 * @summary Make sure DrbgParameters coded as specified - * @library /test/lib/share/classes + * @library /test/lib */ import jdk.test.lib.Asserts; diff --git a/jdk/test/jdk/internal/ref/Cleaner/ExitOnThrow.java b/jdk/test/jdk/internal/ref/Cleaner/ExitOnThrow.java index f3308c480e6..aff92170577 100644 --- a/jdk/test/jdk/internal/ref/Cleaner/ExitOnThrow.java +++ b/jdk/test/jdk/internal/ref/Cleaner/ExitOnThrow.java @@ -24,7 +24,7 @@ /* * @test * @bug 4954921 8009259 - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.ref * java.base/jdk.internal.misc * @build jdk.test.lib.* diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Asserts.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Asserts.java index 594b12e3ede..621885ae50c 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Asserts.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Asserts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -44,7 +44,7 @@ import java.util.Objects; * * * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib} + * {@code /test/lib/jdk/test/lib} */ @Deprecated public class Asserts { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolFinder.java b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolFinder.java index c4815229eb7..7b16a600d78 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolFinder.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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,7 +29,7 @@ import java.nio.file.Paths; /** * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib} + * {@code /test/lib/jdk/test/lib} */ @Deprecated public final class JDKToolFinder { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java index 777e8cf5336..cd3b7cea022 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -46,7 +46,7 @@ import java.util.List; * } * * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib} + * {@code /test/lib/jdk/test/lib} */ @Deprecated public class JDKToolLauncher { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java index 839c3228294..1a641efde90 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -36,7 +36,7 @@ import java.util.regex.Pattern; * Utility class for verifying output and exit value from a {@code Process}. * * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib/process} + * {@code /test/lib/jdk/test/lib/process} * */ @Deprecated diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java index c8a5d7aab12..9759f22b9e9 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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,7 +30,7 @@ import java.util.concurrent.Future; /** * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib/process} + * {@code /test/lib/jdk/test/lib/process} */ @Deprecated class OutputBuffer { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java index 635f37f0b82..59b6d7c04c9 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java @@ -29,7 +29,7 @@ import java.io.IOException; /** * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib} + * {@code /test/lib/jdk/test/lib} */ @Deprecated public class Platform { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java index e2c2f110fc5..224ab0e067d 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -43,7 +43,7 @@ import java.util.stream.Collectors; /** * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib/process} + * {@code /test/lib/jdk/test/lib/process} */ @Deprecated public final class ProcessTools { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java b/jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java index 2f3c205db3c..1107563738f 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicBoolean; /** * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib/process} + * {@code /test/lib/jdk/test/lib/process} */ @Deprecated public final class StreamPumper implements Runnable { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java index c76339107c8..31008f554f2 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -43,7 +43,7 @@ import java.util.function.Function; * Common library for various test helper functions. * * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib} + * {@code /test/lib/jdk/test/lib} */ @Deprecated public final class Utils { diff --git a/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java b/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java index 826edfb4e58..3d521ad5bc5 100644 --- a/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java +++ b/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, 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,7 +42,7 @@ import sun.jvmstat.monitor.VmIdentifier; * @summary setInterval() for local MonitoredHost and local MonitoredVm * @modules jdk.jvmstat/sun.jvmstat.monitor * @library /lib/testlibrary - * @library /test/lib/share/classes + * @library /test/lib * @build jdk.testlibrary.* * @build jdk.test.lib.apps.* * @run main TestPollingInterval diff --git a/jdk/test/sun/misc/SunMiscSignalTest.java b/jdk/test/sun/misc/SunMiscSignalTest.java index 2e998ba8d77..33d4d3ac41c 100644 --- a/jdk/test/sun/misc/SunMiscSignalTest.java +++ b/jdk/test/sun/misc/SunMiscSignalTest.java @@ -43,7 +43,7 @@ import sun.misc.SignalHandler; /* * @test - * @library /test/lib/share/classes + * @library /test/lib * @modules jdk.unsupported * java.base/jdk.internal.misc * @build jdk.test.lib.Platform jdk.test.lib.Utils diff --git a/jdk/test/sun/security/tools/jarsigner/AltProvider.java b/jdk/test/sun/security/tools/jarsigner/AltProvider.java index b93455670b9..2717ef9e22e 100644 --- a/jdk/test/sun/security/tools/jarsigner/AltProvider.java +++ b/jdk/test/sun/security/tools/jarsigner/AltProvider.java @@ -25,7 +25,7 @@ * @test * @bug 4906940 8130302 * @summary -providerPath, -providerClass, -addprovider, and -providerArg - * @library /lib/testlibrary /test/lib/share/classes + * @library /lib/testlibrary /test/lib * @modules java.base/jdk.internal.misc */ diff --git a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java index e18b5c76c1d..31384717ac9 100644 --- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java +++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java @@ -24,7 +24,7 @@ /* * @test * @summary Basic test for jhsdb launcher - * @library /test/lib/share/classes + * @library /test/lib * @library /lib/testlibrary * @build jdk.testlibrary.* * @build jdk.test.lib.apps.* diff --git a/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java b/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java index c768dd6eb01..1f88fd325b1 100644 --- a/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java +++ b/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -37,7 +37,7 @@ import jdk.testlibrary.Platform; * @bug 8042397 * @summary Unit test for jmap utility test heap configuration reader * @modules jdk.hotspot.agent/sun.jvm.hotspot - * @library /test/lib/share/classes + * @library /test/lib * @library /lib/testlibrary * @build jdk.testlibrary.* * @build jdk.test.lib.apps.* diff --git a/jdk/test/sun/tools/jinfo/JInfoTest.java b/jdk/test/sun/tools/jinfo/JInfoTest.java index 4710cfb974a..720874ba567 100644 --- a/jdk/test/sun/tools/jinfo/JInfoTest.java +++ b/jdk/test/sun/tools/jinfo/JInfoTest.java @@ -37,7 +37,7 @@ import jdk.test.lib.apps.LingeredApp; * @test * @summary Unit test for jinfo utility * @modules java.base/jdk.internal.misc - * @library /test/lib/share/classes + * @library /test/lib * @build jdk.test.lib.* * @build jdk.test.lib.apps.* * @build jdk.test.lib.process.* diff --git a/jdk/test/sun/tools/jmap/BasicJMapTest.java b/jdk/test/sun/tools/jmap/BasicJMapTest.java index fa333cddea7..c0432deded8 100644 --- a/jdk/test/sun/tools/jmap/BasicJMapTest.java +++ b/jdk/test/sun/tools/jmap/BasicJMapTest.java @@ -37,7 +37,7 @@ import jdk.testlibrary.ProcessTools; * @summary Unit test for jmap utility * @key intermittent * @library /lib/testlibrary - * @library /test/lib/share/classes + * @library /test/lib * @build jdk.testlibrary.* * @build jdk.test.lib.hprof.* * @build jdk.test.lib.hprof.model.* diff --git a/jdk/test/sun/tools/jps/TestJpsSanity.java b/jdk/test/sun/tools/jps/TestJpsSanity.java index 457a667a251..47d15635961 100644 --- a/jdk/test/sun/tools/jps/TestJpsSanity.java +++ b/jdk/test/sun/tools/jps/TestJpsSanity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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,7 +29,7 @@ import jdk.test.lib.apps.LingeredApp; * @test * @summary This test verifies jps usage and checks that appropriate error message is shown * when running jps with illegal arguments. - * @library /lib/testlibrary /test/lib/share/classes + * @library /lib/testlibrary /test/lib * @modules jdk.jartool/sun.tools.jar * java.management * java.base/jdk.internal.misc diff --git a/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java b/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java index 771fd128ff7..c51e402e06d 100644 --- a/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java +++ b/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -37,7 +37,7 @@ import jdk.testlibrary.ProcessTools; /* * @test * @summary Test deadlock detection - * @library /test/lib/share/classes + * @library /test/lib * @library /lib/testlibrary * @build jdk.testlibrary.* * @build jdk.test.lib.apps.* diff --git a/jdk/test/tools/jar/multiRelease/Basic.java b/jdk/test/tools/jar/multiRelease/Basic.java index 589615ad1e9..9f76b36e06d 100644 --- a/jdk/test/tools/jar/multiRelease/Basic.java +++ b/jdk/test/tools/jar/multiRelease/Basic.java @@ -23,7 +23,7 @@ /* * @test - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.misc * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Platform * @run testng Basic From a5637c9afab9f2f50c38369995fad91159b762b6 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Sat, 20 Aug 2016 09:36:35 -0400 Subject: [PATCH 033/296] 8164520: java/lang/ProcessHandle/Basic.java is missing @library tag Reviewed-by: coleenp --- jdk/test/java/lang/ProcessHandle/Basic.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/java/lang/ProcessHandle/Basic.java b/jdk/test/java/lang/ProcessHandle/Basic.java index 72dbe852139..c34bcab098b 100644 --- a/jdk/test/java/lang/ProcessHandle/Basic.java +++ b/jdk/test/java/lang/ProcessHandle/Basic.java @@ -36,6 +36,7 @@ import org.testng.annotations.Test; /* * @test + * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.management * @run testng Basic From d65aa31fd5c107729eb461ed7095b352695c39db Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Mon, 22 Aug 2016 16:43:56 +0300 Subject: [PATCH 034/296] 8164028: Convert TestPredictions_test to GTest Reviewed-by: jwilhelm, dfazunen, ehelin --- hotspot/src/share/vm/gc/g1/g1Predictions.cpp | 98 ------------------- hotspot/src/share/vm/gc/g1/g1Predictions.hpp | 6 +- .../share/vm/utilities/internalVMTests.cpp | 1 - .../test/native/gc/g1/test_g1Predictions.cpp | 98 +++++++++++++++++++ 4 files changed, 99 insertions(+), 104 deletions(-) delete mode 100644 hotspot/src/share/vm/gc/g1/g1Predictions.cpp create mode 100644 hotspot/test/native/gc/g1/test_g1Predictions.cpp diff --git a/hotspot/src/share/vm/gc/g1/g1Predictions.cpp b/hotspot/src/share/vm/gc/g1/g1Predictions.cpp deleted file mode 100644 index 12092beeca4..00000000000 --- a/hotspot/src/share/vm/gc/g1/g1Predictions.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2015, 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * 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. - * - */ - -#include "precompiled.hpp" -#include "gc/g1/g1Predictions.hpp" - -#ifndef PRODUCT - -void G1Predictions::test() { - double const epsilon = 1e-6; - { - // Some basic formula tests with confidence = 0.0 - G1Predictions predictor(0.0); - TruncatedSeq s; - - double p0 = predictor.get_new_prediction(&s); - assert(p0 < epsilon, "Initial prediction of empty sequence must be 0.0 but is %f", p0); - - s.add(5.0); - double p1 = predictor.get_new_prediction(&s); - assert(fabs(p1 - 5.0) < epsilon, "Prediction should be 5.0 but is %f", p1); - for (int i = 0; i < 40; i++) { - s.add(5.0); - } - double p2 = predictor.get_new_prediction(&s); - assert(fabs(p2 - 5.0) < epsilon, "Prediction should be 5.0 but is %f", p1); - } - - { - // The following tests checks that the initial predictions are based on the - // average of the sequence and not on the stddev (which is 0). - G1Predictions predictor(0.5); - TruncatedSeq s; - - s.add(1.0); - double p1 = predictor.get_new_prediction(&s); - assert(p1 > 1.0, "First prediction must be larger than average, but avg is %f and prediction %f", s.davg(), p1); - s.add(1.0); - double p2 = predictor.get_new_prediction(&s); - assert(p2 < p1, "First prediction must be larger than second, but they are %f %f", p1, p2); - s.add(1.0); - double p3 = predictor.get_new_prediction(&s); - assert(p3 < p2, "Second prediction must be larger than third, but they are %f %f", p2, p3); - s.add(1.0); - s.add(1.0); // Five elements are now in the sequence. - double p5 = predictor.get_new_prediction(&s); - assert(p5 < p3, "Fifth prediction must be smaller than third, but they are %f %f", p3, p5); - assert(fabs(p5 - 1.0) < epsilon, "Prediction must be 1.0+epsilon, but is %f", p5); - } - - { - // The following tests checks that initially prediction based on the average is - // used, that gets overridden by the stddev prediction at the end. - G1Predictions predictor(0.5); - TruncatedSeq s; - - s.add(0.5); - double p1 = predictor.get_new_prediction(&s); - assert(p1 > 0.5, "First prediction must be larger than average, but avg is %f and prediction %f", s.davg(), p1); - s.add(0.2); - double p2 = predictor.get_new_prediction(&s); - assert(p2 < p1, "First prediction must be larger than second, but they are %f %f", p1, p2); - s.add(0.5); - double p3 = predictor.get_new_prediction(&s); - assert(p3 < p2, "Second prediction must be larger than third, but they are %f %f", p2, p3); - s.add(0.2); - s.add(2.0); - double p5 = predictor.get_new_prediction(&s); - assert(p5 > p3, "Fifth prediction must be bigger than third, but they are %f %f", p3, p5); - } -} - -void TestPredictions_test() { - G1Predictions::test(); -} - -#endif diff --git a/hotspot/src/share/vm/gc/g1/g1Predictions.hpp b/hotspot/src/share/vm/gc/g1/g1Predictions.hpp index 6dad458e546..bcd430e7385 100644 --- a/hotspot/src/share/vm/gc/g1/g1Predictions.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Predictions.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -57,10 +57,6 @@ class G1Predictions VALUE_OBJ_CLASS_SPEC { double get_new_prediction(TruncatedSeq const* seq) const { return seq->davg() + _sigma * stddev_estimate(seq); } - -#ifndef PRODUCT - static void test(); -#endif }; #endif // SHARE_VM_GC_G1_G1PREDICTIONS_HPP diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp index a9aaaf22aeb..03737b6a213 100644 --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp @@ -95,7 +95,6 @@ void InternalVMTests::run() { run_unit_test(IHOP_test); } run_unit_test(test_memset_with_concurrent_readers); - run_unit_test(TestPredictions_test); run_unit_test(WorkerDataArray_test); run_unit_test(ParallelCompact_test); #endif diff --git a/hotspot/test/native/gc/g1/test_g1Predictions.cpp b/hotspot/test/native/gc/g1/test_g1Predictions.cpp new file mode 100644 index 00000000000..6b08390d1f6 --- /dev/null +++ b/hotspot/test/native/gc/g1/test_g1Predictions.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + * + */ + +#include "precompiled.hpp" +#include "gc/g1/g1Predictions.hpp" +#include "unittest.hpp" + +static const double epsilon = 1e-6; + +// Some basic formula tests with confidence = 0.0 +TEST_VM(G1Predictions, basic_predictions) { + G1Predictions predictor(0.0); + TruncatedSeq s; + + double p0 = predictor.get_new_prediction(&s); + ASSERT_LT(p0, epsilon) << "Initial prediction of empty sequence must be 0.0"; + + s.add(5.0); + double p1 = predictor.get_new_prediction(&s); + ASSERT_NEAR(p1, 5.0, epsilon); + + for (int i = 0; i < 40; i++) { + s.add(5.0); + } + double p2 = predictor.get_new_prediction(&s); + ASSERT_NEAR(p2, 5.0, epsilon); +} + +// The following tests checks that the initial predictions are based on +// the average of the sequence and not on the stddev (which is 0). +TEST_VM(G1Predictions, average_not_stdev_predictions) { + G1Predictions predictor(0.5); + TruncatedSeq s; + + s.add(1.0); + double p1 = predictor.get_new_prediction(&s); + ASSERT_GT(p1, s.davg()) << "First prediction must be greater than average"; + + s.add(1.0); + double p2 = predictor.get_new_prediction(&s); + ASSERT_GT(p1, p2) << "First prediction must be greater than second"; + + s.add(1.0); + double p3 = predictor.get_new_prediction(&s); + ASSERT_GT(p2, p3) << "Second prediction must be greater than third"; + + s.add(1.0); + s.add(1.0); // Five elements are now in the sequence. + double p4 = predictor.get_new_prediction(&s); + ASSERT_LT(p4, p3) << "Fourth prediction must be smaller than third"; + ASSERT_NEAR(p4, 1.0, epsilon); +} + +// The following tests checks that initially prediction based on +// the average is used, that gets overridden by the stddev prediction at +// the end. +TEST_VM(G1Predictions, average_stdev_predictions) { + G1Predictions predictor(0.5); + TruncatedSeq s; + + s.add(0.5); + double p1 = predictor.get_new_prediction(&s); + ASSERT_GT(p1, s.davg()) << "First prediction must be greater than average"; + + s.add(0.2); + double p2 = predictor.get_new_prediction(&s); + ASSERT_GT(p1, p2) << "First prediction must be greater than second"; + + s.add(0.5); + double p3 = predictor.get_new_prediction(&s); + ASSERT_GT(p2, p3) << "Second prediction must be greater than third"; + + s.add(0.2); + s.add(2.0); + double p4 = predictor.get_new_prediction(&s); + ASSERT_GT(p4, p3) << "Fourth prediction must be greater than third"; +} From 2e533f4c602ef8c8e386718f41e7f28a13a388e2 Mon Sep 17 00:00:00 2001 From: Amit Sapre Date: Mon, 22 Aug 2016 21:37:37 +0300 Subject: [PATCH 035/296] 8162530: src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c doesn't handle JNI exceptions properly Exceptions are checked after calling NewStringUTF Reviewed-by: dholmes, sla --- .../native/libmanagement_ext/GcInfoBuilder.c | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c b/jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c index 8fb337b8ecd..b457950e0d9 100644 --- a/jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c +++ b/jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c @@ -87,9 +87,32 @@ JNIEXPORT void JNICALL Java_com_sun_management_internal_GcInfoBuilder_fillGcAttr for (i = 0; i < num_attributes; i++) { nativeTypes[i] = ext_att_info[i].type; attName = (*env)->NewStringUTF(env, ext_att_info[i].name); - desc = (*env)->NewStringUTF(env, ext_att_info[i].description); + if ((*env)->ExceptionCheck(env)) { + free(ext_att_info); + free(nativeTypes); + return; + } + (*env)->SetObjectArrayElement(env, attributeNames, i, attName); + if ((*env)->ExceptionCheck(env)) { + free(ext_att_info); + free(nativeTypes); + return; + } + + desc = (*env)->NewStringUTF(env, ext_att_info[i].description); + if ((*env)->ExceptionCheck(env)) { + free(ext_att_info); + free(nativeTypes); + return; + } + (*env)->SetObjectArrayElement(env, descriptions, i, desc); + if ((*env)->ExceptionCheck(env)) { + free(ext_att_info); + free(nativeTypes); + return; + } } (*env)->SetCharArrayRegion(env, types, 0, num_attributes, nativeTypes); From 0391d651efc713183972f1bb5e128929005b8332 Mon Sep 17 00:00:00 2001 From: Dmitrij Pochepko Date: Tue, 23 Aug 2016 19:30:35 +0300 Subject: [PATCH 036/296] 8164608: [TESTBUG] compiler/profiling tests fail to compile Reviewed-by: ctornqvi --- test/lib/jdk/test/lib/Utils.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/lib/jdk/test/lib/Utils.java b/test/lib/jdk/test/lib/Utils.java index aececb0301f..752624272f6 100644 --- a/test/lib/jdk/test/lib/Utils.java +++ b/test/lib/jdk/test/lib/Utils.java @@ -87,6 +87,16 @@ public final class Utils { */ public static final String TEST_SRC = System.getProperty("test.src", "").trim(); + /* + * Returns the value of 'test.jdk' system property + */ + public static final String TEST_JDK = System.getProperty("test.jdk"); + + /** + * Returns the value of 'test.classes' system property + */ + public static final String TEST_CLASSES = System.getProperty("test.classes", "."); + private static Unsafe unsafe = null; /** From ddfcdd9299d73b70f3d5b28002a063016bd3a6bd Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Wed, 31 Aug 2016 19:41:57 -0400 Subject: [PATCH 037/296] 8165014: Unaligned unsafe access should throw InternalError on Solaris Reviewed-by: dholmes, coleenp --- hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp index a4a4e3da963..cf782a2f75f 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp @@ -444,7 +444,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (thread->thread_state() == _thread_in_vm) { - if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { + if (sig == SIGBUS && thread->doing_unsafe_access()) { stub = SharedRuntime::handle_unsafe_access(thread, npc); } } From d67d71f44c3a2626877760bb85e37da59fb1584f Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Thu, 1 Sep 2016 08:30:17 +0200 Subject: [PATCH 038/296] 8163589: Add back class id intrinsic method for event based tracing Reviewed-by: kvn, mgronlun --- hotspot/src/share/vm/c1/c1_Compiler.cpp | 3 ++ hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 34 ++++++++++++++++ hotspot/src/share/vm/c1/c1_LIRGenerator.hpp | 4 ++ hotspot/src/share/vm/classfile/vmSymbols.cpp | 1 + hotspot/src/share/vm/opto/c2compiler.cpp | 1 + hotspot/src/share/vm/opto/library_call.cpp | 41 ++++++++++++++++++++ 6 files changed, 84 insertions(+) diff --git a/hotspot/src/share/vm/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp index e292574e80c..08f2fdddb85 100644 --- a/hotspot/src/share/vm/c1/c1_Compiler.cpp +++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp @@ -221,6 +221,9 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) { case vmIntrinsics::_putCharStringU: #ifdef TRACE_HAVE_INTRINSICS case vmIntrinsics::_counterTime: +#if defined(_LP64) || !defined(TRACE_ID_CLASS_SHIFT) + case vmIntrinsics::_getClassId: +#endif #endif break; default: diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index a0f94545a7e..81f353ba184 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -3083,6 +3083,37 @@ void LIRGenerator::do_IfOp(IfOp* x) { __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type())); } +#ifdef TRACE_HAVE_INTRINSICS +void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) { + CodeEmitInfo* info = state_for(x); + CodeEmitInfo* info2 = new CodeEmitInfo(info); // Clone for the second null check + + assert(info != NULL, "must have info"); + LIRItem arg(x->argument_at(0), this); + + arg.load_item(); + LIR_Opr klass = new_register(T_METADATA); + __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), T_ADDRESS), klass, info); + LIR_Opr id = new_register(T_LONG); + ByteSize offset = TRACE_KLASS_TRACE_ID_OFFSET; + LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG); + + __ move(trace_id_addr, id); + __ logical_or(id, LIR_OprFact::longConst(0x01l), id); + __ store(id, trace_id_addr); + +#ifdef TRACE_ID_META_BITS + __ logical_and(id, LIR_OprFact::longConst(~TRACE_ID_META_BITS), id); +#endif +#ifdef TRACE_ID_CLASS_SHIFT + __ unsigned_shift_right(id, TRACE_ID_CLASS_SHIFT, id); +#endif + + __ move(id, rlock_result(x)); +} +#endif + + void LIRGenerator::do_RuntimeCall(address routine, Intrinsic* x) { assert(x->number_of_arguments() == 0, "wrong type"); // Enforce computation of _reserved_argument_area_size which is required on some platforms. @@ -3108,6 +3139,9 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) { } #ifdef TRACE_HAVE_INTRINSICS + case vmIntrinsics::_getClassId: + do_ClassIDIntrinsic(x); + break; case vmIntrinsics::_counterTime: do_RuntimeCall(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), x); break; diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp index 91536455821..cda06580660 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp @@ -438,6 +438,10 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { SwitchRangeArray* create_lookup_ranges(LookupSwitch* x); void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux); +#ifdef TRACE_HAVE_INTRINSICS + void do_ClassIDIntrinsic(Intrinsic* x); +#endif + void do_RuntimeCall(address routine, Intrinsic* x); ciKlass* profile_type(ciMethodData* md, int md_first_offset, int md_offset, intptr_t profiled_k, diff --git a/hotspot/src/share/vm/classfile/vmSymbols.cpp b/hotspot/src/share/vm/classfile/vmSymbols.cpp index a52570c17c5..10a77f3f4f7 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.cpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp @@ -366,6 +366,7 @@ bool vmIntrinsics::can_trap(vmIntrinsics::ID id) { switch(id) { #ifdef TRACE_HAVE_INTRINSICS case vmIntrinsics::_counterTime: + case vmIntrinsics::_getClassId: #endif case vmIntrinsics::_currentTimeMillis: case vmIntrinsics::_nanoTime: diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp index c80ca6eaa8c..ddbaa6b8de6 100644 --- a/hotspot/src/share/vm/opto/c2compiler.cpp +++ b/hotspot/src/share/vm/opto/c2compiler.cpp @@ -530,6 +530,7 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt case vmIntrinsics::_isInterrupted: #ifdef TRACE_HAVE_INTRINSICS case vmIntrinsics::_counterTime: + case vmIntrinsics::_getClassId: #endif case vmIntrinsics::_currentTimeMillis: case vmIntrinsics::_nanoTime: diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 2fae1704c8f..205d72bf664 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -254,6 +254,9 @@ class LibraryCallKit : public GraphKit { bool inline_native_currentThread(); bool inline_native_time_funcs(address method, const char* funcName); +#ifdef TRACE_HAVE_INTRINSICS + bool inline_native_classID(); +#endif bool inline_native_isInterrupted(); bool inline_native_Class_query(vmIntrinsics::ID id); bool inline_native_subtype_check(); @@ -708,6 +711,7 @@ bool LibraryCallKit::try_to_inline(int predicate) { #ifdef TRACE_HAVE_INTRINSICS case vmIntrinsics::_counterTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), "counterTime"); + case vmIntrinsics::_getClassId: return inline_native_classID(); #endif case vmIntrinsics::_currentTimeMillis: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis"); case vmIntrinsics::_nanoTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime"); @@ -3132,6 +3136,43 @@ bool LibraryCallKit::inline_native_time_funcs(address funcAddr, const char* func return true; } +#ifdef TRACE_HAVE_INTRINSICS + +/* +* oop -> myklass +* myklass->trace_id |= USED +* return myklass->trace_id & ~0x3 +*/ +bool LibraryCallKit::inline_native_classID() { + Node* cls = null_check(argument(0), T_OBJECT); + Node* kls = load_klass_from_mirror(cls, false, NULL, 0); + kls = null_check(kls, T_OBJECT); + + ByteSize offset = TRACE_KLASS_TRACE_ID_OFFSET; + Node* insp = basic_plus_adr(kls, in_bytes(offset)); + Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG, MemNode::unordered); + + Node* clsused = longcon(0x01l); // set the class bit + Node* orl = _gvn.transform(new OrLNode(tvalue, clsused)); + const TypePtr *adr_type = _gvn.type(insp)->isa_ptr(); + store_to_memory(control(), insp, orl, T_LONG, adr_type, MemNode::unordered); + +#ifdef TRACE_ID_META_BITS + Node* mbits = longcon(~TRACE_ID_META_BITS); + tvalue = _gvn.transform(new AndLNode(tvalue, mbits)); +#endif +#ifdef TRACE_ID_CLASS_SHIFT + Node* cbits = intcon(TRACE_ID_CLASS_SHIFT); + tvalue = _gvn.transform(new URShiftLNode(tvalue, cbits)); +#endif + + set_result(tvalue); + return true; + +} + +#endif + //------------------------inline_native_currentThread------------------ bool LibraryCallKit::inline_native_currentThread() { Node* junk = NULL; From 635fad4510390d064aa4dbabcca9271b0749f717 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Wed, 24 Aug 2016 18:10:09 +0300 Subject: [PATCH 039/296] 8164738: Convert AltHashing_test to GTest Reviewed-by: dholmes, coleenp --- hotspot/src/share/vm/classfile/altHashing.cpp | 102 +---------------- hotspot/src/share/vm/classfile/altHashing.hpp | 14 +-- .../share/vm/utilities/internalVMTests.cpp | 1 - .../test/native/classfile/test_AltHashing.cpp | 107 ++++++++++++++++++ 4 files changed, 111 insertions(+), 113 deletions(-) create mode 100644 hotspot/test/native/classfile/test_AltHashing.cpp diff --git a/hotspot/src/share/vm/classfile/altHashing.cpp b/hotspot/src/share/vm/classfile/altHashing.cpp index ee6b810d1e6..df3f9446aef 100644 --- a/hotspot/src/share/vm/classfile/altHashing.cpp +++ b/hotspot/src/share/vm/classfile/altHashing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -205,103 +205,3 @@ juint AltHashing::murmur3_32(juint seed, const int* data, int len) { juint AltHashing::murmur3_32(const int* data, int len) { return murmur3_32(0, data, len); } - -#ifndef PRODUCT -// Overloaded versions for internal test. -juint AltHashing::murmur3_32(const jbyte* data, int len) { - return murmur3_32(0, data, len); -} - -juint AltHashing::murmur3_32(const jchar* data, int len) { - return murmur3_32(0, data, len); -} - -// Internal test for alternate hashing. Translated from JDK version -// test/sun/misc/Hashing.java -static const jbyte ONE_BYTE[] = { (jbyte) 0x80}; -static const jbyte TWO_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81}; -static const jchar ONE_CHAR[] = { (jchar) 0x8180}; -static const jbyte THREE_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82}; -static const jbyte FOUR_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83}; -static const jchar TWO_CHAR[] = { (jchar) 0x8180, (jchar) 0x8382}; -static const jint ONE_INT[] = { (jint)0x83828180}; -static const jbyte SIX_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85}; -static const jchar THREE_CHAR[] = { (jchar) 0x8180, (jchar) 0x8382, (jchar) 0x8584}; -static const jbyte EIGHT_BYTE[] = { - (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, - (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85, - (jbyte) 0x86, (jbyte) 0x87}; -static const jchar FOUR_CHAR[] = { - (jchar) 0x8180, (jchar) 0x8382, - (jchar) 0x8584, (jchar) 0x8786}; - -static const jint TWO_INT[] = { (jint)0x83828180, (jint)0x87868584}; - -static const juint MURMUR3_32_X86_CHECK_VALUE = 0xB0F57EE3; - -void AltHashing::testMurmur3_32_ByteArray() { - // printf("testMurmur3_32_ByteArray\n"); - - jbyte vector[256]; - jbyte hashes[4 * 256]; - - for (int i = 0; i < 256; i++) { - vector[i] = (jbyte) i; - } - - // Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255} - for (int i = 0; i < 256; i++) { - juint hash = murmur3_32(256 - i, vector, i); - hashes[i * 4] = (jbyte) hash; - hashes[i * 4 + 1] = (jbyte)(hash >> 8); - hashes[i * 4 + 2] = (jbyte)(hash >> 16); - hashes[i * 4 + 3] = (jbyte)(hash >> 24); - } - - // hash to get const result. - juint final_hash = murmur3_32(hashes, 4*256); - - assert (MURMUR3_32_X86_CHECK_VALUE == final_hash, - "Calculated hash result not as expected. Expected %08X got %08X\n", - MURMUR3_32_X86_CHECK_VALUE, - final_hash); -} - -void AltHashing::testEquivalentHashes() { - juint jbytes, jchars, ints; - - // printf("testEquivalentHashes\n"); - - jbytes = murmur3_32(TWO_BYTE, 2); - jchars = murmur3_32(ONE_CHAR, 1); - assert (jbytes == jchars, - "Hashes did not match. b:%08x != c:%08x\n", jbytes, jchars); - - jbytes = murmur3_32(FOUR_BYTE, 4); - jchars = murmur3_32(TWO_CHAR, 2); - ints = murmur3_32(ONE_INT, 1); - assert ((jbytes == jchars) && (jbytes == ints), - "Hashes did not match. b:%08x != c:%08x != i:%08x\n", jbytes, jchars, ints); - - jbytes = murmur3_32(SIX_BYTE, 6); - jchars = murmur3_32(THREE_CHAR, 3); - assert (jbytes == jchars, - "Hashes did not match. b:%08x != c:%08x\n", jbytes, jchars); - - jbytes = murmur3_32(EIGHT_BYTE, 8); - jchars = murmur3_32(FOUR_CHAR, 4); - ints = murmur3_32(TWO_INT, 2); - assert ((jbytes == jchars) && (jbytes == ints), - "Hashes did not match. b:%08x != c:%08x != i:%08x\n", jbytes, jchars, ints); -} - -// Returns true if the alternate hashcode is correct -void AltHashing::test_alt_hash() { - testMurmur3_32_ByteArray(); - testEquivalentHashes(); -} - -void AltHashing_test() { - AltHashing::test_alt_hash(); -} -#endif // PRODUCT diff --git a/hotspot/src/share/vm/classfile/altHashing.hpp b/hotspot/src/share/vm/classfile/altHashing.hpp index 2e04fd33a2d..43af02f39ce 100644 --- a/hotspot/src/share/vm/classfile/altHashing.hpp +++ b/hotspot/src/share/vm/classfile/altHashing.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -37,26 +37,18 @@ */ class AltHashing : AllStatic { + friend class AltHashingTest; // utility function copied from java/lang/Integer static juint Integer_rotateLeft(juint i, int distance) { - return (i << distance) | (i >> (32-distance)); + return (i << distance) | (i >> (32 - distance)); } static juint murmur3_32(const int* data, int len); static juint murmur3_32(juint seed, const int* data, int len); -#ifndef PRODUCT - // Hashing functions used for internal testing - static juint murmur3_32(const jbyte* data, int len); - static juint murmur3_32(const jchar* data, int len); - static void testMurmur3_32_ByteArray(); - static void testEquivalentHashes(); -#endif // PRODUCT - public: static juint compute_seed(); static juint murmur3_32(juint seed, const jbyte* data, int len); static juint murmur3_32(juint seed, const jchar* data, int len); - NOT_PRODUCT(static void test_alt_hash();) }; #endif // SHARE_VM_CLASSFILE_ALTHASHING_HPP diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp index c6543b71cab..70eece1f2d8 100644 --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp @@ -56,7 +56,6 @@ void InternalVMTests::run() { run_unit_test(CollectedHeap_test); run_unit_test(QuickSort_test); run_unit_test(GuardedMemory_test); - run_unit_test(AltHashing_test); run_unit_test(TestNewSize_test); run_unit_test(TestOldSize_test); run_unit_test(TestKlass_test); diff --git a/hotspot/test/native/classfile/test_AltHashing.cpp b/hotspot/test/native/classfile/test_AltHashing.cpp new file mode 100644 index 00000000000..4718bdd97b2 --- /dev/null +++ b/hotspot/test/native/classfile/test_AltHashing.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ +#include "precompiled.hpp" +#include "classfile/altHashing.hpp" +#include "unittest.hpp" + +// Internal test for alternate hashing. Translated from JDK version +// test/sun/misc/Hashing.java +static const jbyte ONE_BYTE[] = {(jbyte) 0x80}; +static const jbyte TWO_BYTE[] = {(jbyte) 0x80, (jbyte) 0x81}; +static const jchar ONE_CHAR[] = {(jchar) 0x8180}; +static const jbyte THREE_BYTE[] = {(jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82}; +static const jbyte FOUR_BYTE[] = {(jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83}; +static const jchar TWO_CHAR[] = {(jchar) 0x8180, (jchar) 0x8382}; +static const jint ONE_INT[] = {(jint) 0x83828180}; +static const jbyte SIX_BYTE[] = {(jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85}; +static const jchar THREE_CHAR[] = {(jchar) 0x8180, (jchar) 0x8382, (jchar) 0x8584}; +static const jbyte EIGHT_BYTE[] = { + (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, + (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85, + (jbyte) 0x86, (jbyte) 0x87 +}; +static const jchar FOUR_CHAR[] = { + (jchar) 0x8180, (jchar) 0x8382, + (jchar) 0x8584, (jchar) 0x8786 +}; + +static const jint TWO_INT[] = {(jint) 0x83828180, (jint) 0x87868584}; +static const juint MURMUR3_32_X86_CHECK_VALUE = 0xB0F57EE3; + +class AltHashingTest : public ::testing::Test { + public: + + static juint murmur3_32(const int* data, int len) { + return AltHashing::murmur3_32(data, len); + } +}; + +TEST_F(AltHashingTest, murmur3_32_byte_array_test) { + jbyte vector[256]; + jbyte hashes[4 * 256]; + + for (int i = 0; i < 256; i++) { + vector[i] = (jbyte) i; + } + + // Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255} + for (int i = 0; i < 256; i++) { + juint hash = AltHashing::murmur3_32(256 - i, vector, i); + hashes[i * 4] = (jbyte) hash; + hashes[i * 4 + 1] = (jbyte) (hash >> 8); + hashes[i * 4 + 2] = (jbyte) (hash >> 16); + hashes[i * 4 + 3] = (jbyte) (hash >> 24); + } + + // hash to get const result. + juint final_hash = AltHashing::murmur3_32(0, hashes, 4 * 256); + + ASSERT_EQ(MURMUR3_32_X86_CHECK_VALUE, final_hash) + << "Calculated hash result not as expected."; +} + +TEST_F(AltHashingTest, equivalent_hashes_test) { + juint jbytes, jchars, ints; + + jbytes = AltHashing::murmur3_32(0, TWO_BYTE, 2); + jchars = AltHashing::murmur3_32(0, ONE_CHAR, 1); + ASSERT_EQ(jbytes, jchars) << "Hashes did not match."; + + jbytes = AltHashing::murmur3_32(0, FOUR_BYTE, 4); + jchars = AltHashing::murmur3_32(0, TWO_CHAR, 2); + ints = AltHashingTest::murmur3_32(ONE_INT, 1); + + ASSERT_EQ(jbytes, jchars) << "Hashes did not match."; + ASSERT_EQ(jbytes, ints) << "Hashes did not match."; + + jbytes = AltHashing::murmur3_32(0, SIX_BYTE, 6); + jchars = AltHashing::murmur3_32(0, THREE_CHAR, 3); + ASSERT_EQ(jbytes, jchars) << "Hashes did not match."; + + jbytes = AltHashing::murmur3_32(0, EIGHT_BYTE, 8); + jchars = AltHashing::murmur3_32(0, FOUR_CHAR, 4); + ints = AltHashingTest::murmur3_32(TWO_INT, 2); + + ASSERT_EQ(jbytes, jchars) << "Hashes did not match."; + ASSERT_EQ(jbytes, ints) << "Hashes did not match."; +} From ad62406df7b039617f6aa6693e5dc8be14f3b082 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Wed, 24 Aug 2016 19:21:20 +0300 Subject: [PATCH 040/296] 8164743: Convert TestAsUtf8 to GTest Reviewed-by: dholmes, rprotacio --- .../share/vm/utilities/internalVMTests.cpp | 1 - hotspot/src/share/vm/utilities/utf8.cpp | 29 +---------- hotspot/test/native/utilities/test_utf8.cpp | 50 +++++++++++++++++++ 3 files changed, 51 insertions(+), 29 deletions(-) create mode 100644 hotspot/test/native/utilities/test_utf8.cpp diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp index 70eece1f2d8..bdeb84abedf 100644 --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp @@ -60,7 +60,6 @@ void InternalVMTests::run() { run_unit_test(TestOldSize_test); run_unit_test(TestKlass_test); run_unit_test(TestBitMap_test); - run_unit_test(TestAsUtf8); run_unit_test(TestResourcehash_test); run_unit_test(ObjectMonitor_test); run_unit_test(Test_linked_list); diff --git a/hotspot/src/share/vm/utilities/utf8.cpp b/hotspot/src/share/vm/utilities/utf8.cpp index 93ad3e23d89..0f479bad8dd 100644 --- a/hotspot/src/share/vm/utilities/utf8.cpp +++ b/hotspot/src/share/vm/utilities/utf8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -547,30 +547,3 @@ template int UNICODE::quoted_ascii_length(jbyte* base, int length); template int UNICODE::quoted_ascii_length(jchar* base, int length); template void UNICODE::as_quoted_ascii(const jbyte* base, int length, char* buf, int buflen); template void UNICODE::as_quoted_ascii(const jchar* base, int length, char* buf, int buflen); - - -#ifndef PRODUCT -void TestAsUtf8() { - char res[60]; - jchar str[20]; - - for (int i = 0; i < 20; i++) { - str[i] = 0x0800; // char that is 2B in UTF-16 but 3B in UTF-8 - } - str[19] = (jchar)'\0'; - - // The resulting string in UTF-8 is 3*19 bytes long, but should be truncated - UNICODE::as_utf8(str, 19, res, 10); - assert(strlen(res) == 9, "string should be truncated here"); - - UNICODE::as_utf8(str, 19, res, 18); - assert(strlen(res) == 15, "string should be truncated here"); - - UNICODE::as_utf8(str, 19, res, 20); - assert(strlen(res) == 18, "string should be truncated here"); - - // Test with an "unbounded" buffer - UNICODE::as_utf8(str, 19, res, INT_MAX); - assert(strlen(res) == 3*19, "string should end here"); -} -#endif diff --git a/hotspot/test/native/utilities/test_utf8.cpp b/hotspot/test/native/utilities/test_utf8.cpp new file mode 100644 index 00000000000..a36f016ecd0 --- /dev/null +++ b/hotspot/test/native/utilities/test_utf8.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +#include "precompiled.hpp" +#include "utilities/utf8.hpp" +#include "unittest.hpp" + +TEST(utf8, length) { + char res[60]; + jchar str[20]; + + for (int i = 0; i < 20; i++) { + str[i] = 0x0800; // char that is 2B in UTF-16 but 3B in UTF-8 + } + str[19] = (jchar) '\0'; + + // The resulting string in UTF-8 is 3*19 bytes long, but should be truncated + UNICODE::as_utf8(str, 19, res, 10); + ASSERT_EQ(strlen(res), (size_t) 9) << "string should be truncated here"; + + UNICODE::as_utf8(str, 19, res, 18); + ASSERT_EQ(strlen(res), (size_t) 15) << "string should be truncated here"; + + UNICODE::as_utf8(str, 19, res, 20); + ASSERT_EQ(strlen(res), (size_t) 18) << "string should be truncated here"; + + // Test with an "unbounded" buffer + UNICODE::as_utf8(str, 19, res, INT_MAX); + ASSERT_EQ(strlen(res), (size_t) 3 * 19) << "string should end here"; +} From dcb6b6c2e60358d36babc573a54d0a9ce99a1443 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Wed, 24 Aug 2016 20:38:22 +0200 Subject: [PATCH 041/296] =?UTF-8?q?8164208:=20Update=20tests=20with=20rede?= =?UTF-8?q?fine=20classes=20UL=20options=20and=20tags=E2=80=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: coleenp, gtriantafill --- .../java/lang/instrument/RedefineBigClass.sh | 2 +- .../RedefineSubclassWithTwoInterfaces.sh | 17 +---------------- .../java/lang/instrument/RetransformBigClass.sh | 2 +- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/jdk/test/java/lang/instrument/RedefineBigClass.sh b/jdk/test/java/lang/instrument/RedefineBigClass.sh index 60fb081055a..4f625a7501c 100644 --- a/jdk/test/java/lang/instrument/RedefineBigClass.sh +++ b/jdk/test/java/lang/instrument/RedefineBigClass.sh @@ -70,7 +70,7 @@ else fi "${JAVA}" ${TESTVMOPTS} \ - -XX:TraceRedefineClasses=3 ${NMT} \ + -Xlog:redefine+class+load=debug,redefine+class+load+exceptions=info ${NMT} \ -javaagent:RedefineBigClassAgent.jar=BigClass.class \ -classpath "${TESTCLASSES}" RedefineBigClassApp \ > output.log 2>&1 diff --git a/jdk/test/java/lang/instrument/RedefineSubclassWithTwoInterfaces.sh b/jdk/test/java/lang/instrument/RedefineSubclassWithTwoInterfaces.sh index 357e24417f9..e583c9df469 100644 --- a/jdk/test/java/lang/instrument/RedefineSubclassWithTwoInterfaces.sh +++ b/jdk/test/java/lang/instrument/RedefineSubclassWithTwoInterfaces.sh @@ -87,23 +87,8 @@ mv RedefineSubclassWithTwoInterfacesImpl.class \ echo "INFO: launching RedefineSubclassWithTwoInterfacesApp" -# TraceRedefineClasses options: -# -# 0x00000001 | 1 - name each target class before loading, after -# loading and after redefinition is completed -# 0x00000002 | 2 - print info if parsing, linking or -# verification throws an exception -# 0x00000004 | 4 - print timer info for the VM operation -# 0x00001000 | 4096 - detect calls to obsolete methods -# 0x00002000 | 8192 - fail a guarantee() in addition to detection -# 0x00004000 | 16384 - detect old/obsolete methods in metadata -# 0x00100000 | 1048576 - impl details: vtable updates -# 0x00200000 | 2097152 - impl details: itable updates -# -# 1+2+4+4096+8192+16384+1048576+2097152 == 3174407 - "${JAVA}" ${TESTVMOPTS} \ - -XX:TraceRedefineClasses=3174407 \ + -Xlog:redefine+class+load=trace,redefine+class+load+exceptions=trace,redefine+class+timer=trace,redefine+class+obsolete=trace,redefine+class+obsolete+metadata=trace,redefine+class+constantpool=trace \ -javaagent:RedefineSubclassWithTwoInterfacesAgent.jar \ -classpath "${TESTCLASSES}" \ RedefineSubclassWithTwoInterfacesApp > output.log 2>&1 diff --git a/jdk/test/java/lang/instrument/RetransformBigClass.sh b/jdk/test/java/lang/instrument/RetransformBigClass.sh index 7144689722b..455f42a3247 100644 --- a/jdk/test/java/lang/instrument/RetransformBigClass.sh +++ b/jdk/test/java/lang/instrument/RetransformBigClass.sh @@ -70,7 +70,7 @@ else fi "${JAVA}" ${TESTVMOPTS} \ - -XX:TraceRedefineClasses=3 ${NMT} \ + -Xlog:redefine+class+load=debug,redefine+class+load+exceptions=info ${NMT} \ -javaagent:RetransformBigClassAgent.jar=BigClass.class \ -classpath "${TESTCLASSES}" RetransformBigClassApp \ > output.log 2>&1 From 001e52768a43da068888f011a8e8dfc446aa0701 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Wed, 24 Aug 2016 20:51:37 +0200 Subject: [PATCH 042/296] 8158628: test/java/lang/instrument/NativeMethodPrefixAgent.java: Error occurred during initialization of VM: Failed to start tracing backend Reviewed-by: sla, gtriantafill --- jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java b/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java index 4522d8b1055..47090167051 100644 --- a/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java +++ b/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java @@ -24,6 +24,7 @@ /** * @test * @bug 6263319 + * @requires ((vm.opt.StartFlightRecording == null) | (vm.opt.StartFlightRecording == false)) & ((vm.opt.FlightRecorder == null) | (vm.opt.FlightRecorder == false)) * @summary test setNativeMethodPrefix * @author Robert Field, Sun Microsystems * From bc0cae288eb91cd8f5c86bf6b984b4fa66efec96 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Thu, 25 Aug 2016 12:24:16 +0900 Subject: [PATCH 043/296] 8163581: Heap Parameters in HSDB cannot handle G1CollectedHeap Reviewed-by: dholmes, sjohanss --- .../sun/tools/jhsdb/BasicLauncherTest.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java index 31384717ac9..f36be3a45f9 100644 --- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java +++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java @@ -35,6 +35,7 @@ import static jdk.testlibrary.Asserts.assertTrue; import java.io.BufferedReader; import java.io.IOException; +import java.io.OutputStream; import java.io.InputStreamReader; import java.io.File; import java.util.ArrayList; @@ -84,15 +85,24 @@ public class BasicLauncherTest { ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); Process toolProcess = processBuilder.start(); - toolProcess.getOutputStream().write("quit\n".getBytes()); - toolProcess.getOutputStream().close(); + + try (OutputStream out = toolProcess.getOutputStream()) { + out.write("universe\n".getBytes()); + out.write("quit\n".getBytes()); + } // By default child process output stream redirected to pipe, so we are reading it in foreground. - BufferedReader reader = new BufferedReader(new InputStreamReader(toolProcess.getInputStream())); + Exception unexpected = null; + try (BufferedReader reader = new BufferedReader(new InputStreamReader(toolProcess.getInputStream()))) { + String line; + while ((line = reader.readLine()) != null) { + line = line.trim(); + System.out.println(line); - String line; - while ((line = reader.readLine()) != null) { - System.out.println(line.trim()); + if (line.contains("unknown subtype of CollectedHeap")) { + unexpected = new RuntimeException("CollectedHeap type should be known."); + } + } } toolProcess.waitFor(); @@ -100,6 +110,10 @@ public class BasicLauncherTest { if (toolProcess.exitValue() != 0) { throw new RuntimeException("FAILED CLHSDB terminated with non-zero exit code " + toolProcess.exitValue()); } + + if (unexpected != null) { + throw unexpected; + } } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally { From 8214dd5bfcc7b5b2b48f59213d6cf99716f9565e Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Thu, 25 Aug 2016 08:39:06 -0400 Subject: [PATCH 044/296] 8164737: Remove Unsafe dependency from ProcessTools Reviewed-by: gtriantafill, dholmes --- test/lib/jdk/test/lib/Utils.java | 19 ------- .../lib/jdk/test/lib/unsafe/UnsafeHelper.java | 52 +++++++++++++++++++ 2 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 test/lib/jdk/test/lib/unsafe/UnsafeHelper.java diff --git a/test/lib/jdk/test/lib/Utils.java b/test/lib/jdk/test/lib/Utils.java index aececb0301f..66ad61e8981 100644 --- a/test/lib/jdk/test/lib/Utils.java +++ b/test/lib/jdk/test/lib/Utils.java @@ -25,7 +25,6 @@ package jdk.test.lib; import java.io.File; import java.io.IOException; -import java.lang.reflect.Field; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.ServerSocket; @@ -51,7 +50,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; -import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.assertTrue; import jdk.test.lib.process.ProcessTools; @@ -87,8 +85,6 @@ public final class Utils { */ public static final String TEST_SRC = System.getProperty("test.src", "").trim(); - private static Unsafe unsafe = null; - /** * Defines property name for seed value. */ @@ -373,21 +369,6 @@ public final class Utils { return new String(Files.readAllBytes(filePath)); } - /** - * @return Unsafe instance. - */ - public static synchronized Unsafe getUnsafe() { - if (unsafe == null) { - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe) f.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException("Unable to get Unsafe instance.", e); - } - } - return unsafe; - } private static final char[] hexArray = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; /** diff --git a/test/lib/jdk/test/lib/unsafe/UnsafeHelper.java b/test/lib/jdk/test/lib/unsafe/UnsafeHelper.java new file mode 100644 index 00000000000..4a6c92644a6 --- /dev/null +++ b/test/lib/jdk/test/lib/unsafe/UnsafeHelper.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.test.lib.unsafe; + +import jdk.internal.misc.Unsafe; +import java.lang.reflect.Field; + + +/** + * Helper class for accessing the jdk.internal.misc.Unsafe functionality + */ +public final class UnsafeHelper { + private static Unsafe unsafe = null; + + /** + * @return Unsafe instance. + */ + public static synchronized Unsafe getUnsafe() { + if (unsafe == null) { + try { + Field f = Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + unsafe = (Unsafe) f.get(null); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException("Unable to get Unsafe instance.", e); + } + } + return unsafe; + } +} + From d6ad2ec5c5db0bca45d5e2b67046522b621949a5 Mon Sep 17 00:00:00 2001 From: Sharath Ballal Date: Fri, 26 Aug 2016 13:11:39 +0300 Subject: [PATCH 045/296] 8163346: Update jmap-hashcode/Test8028623.java for better diagnostic of timeout Update jmap-hashcode/Test8028623.java to use LingeredApp and rename it to jhsdb/HeapDumpTest.java Reviewed-by: dsamersoff, dholmes --- jdk/test/ProblemList.txt | 2 + .../sun/tools/jhsdb/BasicLauncherTest.java | 20 --- jdk/test/sun/tools/jhsdb/HeapDumpTest.java | 131 ++++++++++++++++++ .../jhsdb/LingeredAppWithExtendedChars.java | 32 +++++ 4 files changed, 165 insertions(+), 20 deletions(-) create mode 100644 jdk/test/sun/tools/jhsdb/HeapDumpTest.java create mode 100644 jdk/test/sun/tools/jhsdb/LingeredAppWithExtendedChars.java diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 50eb6e6b321..560a463068f 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -367,6 +367,8 @@ sun/tools/jcmd/TestJcmdSanity.java 8031482 windows- sun/tools/jhsdb/BasicLauncherTest.java 8160376 macosx-all +sun/tools/jhsdb/HeapDumpTest.java 8160376 macosx-all + sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8160376 macosx-all sun/tools/jps/TestJpsJar.java 8160923 generic-all diff --git a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java index f36be3a45f9..57651e69c87 100644 --- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java +++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java @@ -31,13 +31,10 @@ * @run main BasicLauncherTest */ -import static jdk.testlibrary.Asserts.assertTrue; - import java.io.BufferedReader; import java.io.IOException; import java.io.OutputStream; import java.io.InputStreamReader; -import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Arrays; @@ -197,21 +194,6 @@ public class BasicLauncherTest { Arrays.asList(toolArgs)); } - public static void testHeapDump() throws IOException { - File dump = new File("jhsdb.jmap.dump." + - System.currentTimeMillis() + ".hprof"); - if (dump.exists()) { - dump.delete(); - } - dump.deleteOnExit(); - - launch("heap written to", null, "jmap", - "--binaryheap", "--dumpfile=" + dump.getAbsolutePath()); - - assertTrue(dump.exists() && dump.isFile(), - "Could not create dump file " + dump.getAbsolutePath()); - } - public static void main(String[] args) throws IOException { @@ -230,8 +212,6 @@ public class BasicLauncherTest { "System Properties info not available", "jinfo"); launch("java.threads", null, "jsnap"); - testHeapDump(); - // The test throws RuntimeException on error. // IOException is thrown if LingeredApp can't start because of some bad // environment condition diff --git a/jdk/test/sun/tools/jhsdb/HeapDumpTest.java b/jdk/test/sun/tools/jhsdb/HeapDumpTest.java new file mode 100644 index 00000000000..2c57252f76b --- /dev/null +++ b/jdk/test/sun/tools/jhsdb/HeapDumpTest.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8163346 + * @summary Test hashing of extended characters in Serviceability Agent. + * @library /test/lib/share/classes + * @library /lib/testlibrary + * @build jdk.testlibrary.* + * @build jdk.test.lib.apps.* + * @compile -encoding utf8 HeapDumpTest.java + * @run main/timeout=240 HeapDumpTest + */ + +import static jdk.testlibrary.Asserts.assertTrue; + +import java.io.IOException; +import java.io.File; +import java.util.List; +import java.util.Arrays; +import jdk.testlibrary.JDKToolLauncher; +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.ProcessTools; +import jdk.test.lib.apps.LingeredApp; +import jdk.testlibrary.Platform; + +public class HeapDumpTest { + + private static LingeredAppWithExtendedChars theApp = null; + + /** + * + * @param vmArgs - tool arguments to launch jhsdb + * @return exit code of tool + */ + public static void launch(String expectedMessage, List toolArgs) + throws IOException { + + System.out.println("Starting LingeredApp"); + try { + theApp = new LingeredAppWithExtendedChars(); + LingeredApp.startApp(Arrays.asList("-Xmx256m"), theApp); + + System.out.println(theApp.\u00CB); + System.out.println("Starting " + toolArgs.get(0) + " against " + theApp.getPid()); + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); + + for (String cmd : toolArgs) { + launcher.addToolArg(cmd); + } + + launcher.addToolArg("--pid=" + Long.toString(theApp.getPid())); + + ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); + processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); + OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); + System.out.println("stdout:"); + System.out.println(output.getStdout()); + System.out.println("stderr:"); + System.out.println(output.getStderr()); + output.shouldContain(expectedMessage); + output.shouldHaveExitValue(0); + + } catch (Exception ex) { + throw new RuntimeException("Test ERROR " + ex, ex); + } finally { + LingeredApp.stopApp(theApp); + } + } + + public static void launch(String expectedMessage, String... toolArgs) + throws IOException { + + launch(expectedMessage, Arrays.asList(toolArgs)); + } + + public static void testHeapDump() throws IOException { + File dump = new File("jhsdb.jmap.heap." + + System.currentTimeMillis() + ".hprof"); + if (dump.exists()) { + dump.delete(); + } + + launch("heap written to", "jmap", + "--binaryheap", "--dumpfile=" + dump.getAbsolutePath()); + + assertTrue(dump.exists() && dump.isFile(), + "Could not create dump file " + dump.getAbsolutePath()); + + dump.delete(); + } + + public static void main(String[] args) + throws IOException { + + if (!Platform.shouldSAAttach()) { + // Silently skip the test if we don't have enough permissions to attach + System.err.println("Error! Insufficient permissions to attach - test skipped."); + return; + } + + + testHeapDump(); + + // The test throws RuntimeException on error. + // IOException is thrown if LingeredApp can't start because of some bad + // environment condition + System.out.println("Test PASSED"); + } +} diff --git a/jdk/test/sun/tools/jhsdb/LingeredAppWithExtendedChars.java b/jdk/test/sun/tools/jhsdb/LingeredAppWithExtendedChars.java new file mode 100644 index 00000000000..90431d25ab9 --- /dev/null +++ b/jdk/test/sun/tools/jhsdb/LingeredAppWithExtendedChars.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ +import jdk.test.lib.apps.LingeredApp; + +public class LingeredAppWithExtendedChars extends LingeredApp { + + public static int \u00CB = 1; + + public static void main(String args[]) { + LingeredApp.main(args); + } + } From 10245a95e3e931bc8467246bb360c02a73cf04b9 Mon Sep 17 00:00:00 2001 From: Marcus Larsson Date: Fri, 26 Aug 2016 14:27:41 +0200 Subject: [PATCH 046/296] 8150823: UL disables log outputs incorrectly Reviewed-by: rehn, sla --- hotspot/src/share/vm/logging/logConfiguration.cpp | 7 ++++--- hotspot/test/native/logging/test_logConfiguration.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp index bdec5d689d4..0817a650e70 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.cpp +++ b/hotspot/src/share/vm/logging/logConfiguration.cpp @@ -243,6 +243,7 @@ void LogConfiguration::configure_output(size_t idx, const LogTagLevelExpression& } void LogConfiguration::disable_output(size_t idx) { + assert(idx < _n_outputs, "invalid index: " SIZE_FORMAT " (_n_outputs: " SIZE_FORMAT ")", idx, _n_outputs); LogOutput* out = _outputs[idx]; // Remove the output from all tagsets. @@ -253,7 +254,7 @@ void LogConfiguration::disable_output(size_t idx) { // Delete the output unless stdout/stderr if (out != LogOutput::Stderr && out != LogOutput::Stdout) { - delete_output(find_output(out->name())); + delete_output(idx); } else { out->set_config_string("all=off"); } @@ -261,8 +262,8 @@ void LogConfiguration::disable_output(size_t idx) { void LogConfiguration::disable_logging() { ConfigurationLock cl; - for (size_t i = 0; i < _n_outputs; i++) { - disable_output(i); + for (size_t i = _n_outputs; i > 0; i--) { + disable_output(i - 1); } notify_update_listeners(); } diff --git a/hotspot/test/native/logging/test_logConfiguration.cpp b/hotspot/test/native/logging/test_logConfiguration.cpp index 035909b5070..b07839ad04a 100644 --- a/hotspot/test/native/logging/test_logConfiguration.cpp +++ b/hotspot/test/native/logging/test_logConfiguration.cpp @@ -164,10 +164,17 @@ TEST_F(LogConfigurationTest, disable_logging) { // Add TestLogFileName as an output set_log_config(TestLogFileName, "logging=info"); + // Add a second file output + char other_file_name[2 * K]; + jio_snprintf(other_file_name, sizeof(other_file_name), "%s-other", TestLogFileName); + set_log_config(other_file_name, "logging=info"); + LogConfiguration::disable_logging(); - // Verify TestLogFileName was disabled + // Verify that both file outputs were disabled EXPECT_FALSE(is_described(TestLogFileName)); + EXPECT_FALSE(is_described(other_file_name)); + delete_file(other_file_name); // Verify that no tagset has logging enabled for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { From 7c219b82fc3eb28094d1c4b201e26cdec3ed35df Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Mon, 29 Aug 2016 11:59:52 +0300 Subject: [PATCH 047/296] 8160923: sun/tools/jps/TestJpsJar.java fails due to ClassNotFoundException: jdk.testlibrary.ProcessTools Cleanup build tag Reviewed-by: iklam, rehn, ctornqvi --- jdk/test/ProblemList.txt | 2 -- jdk/test/sun/tools/jps/TestJpsJar.java | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index eef70ab2612..b8d4831cd93 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -365,8 +365,6 @@ sun/tools/jhsdb/HeapDumpTest.java 8160376 macosx-a sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8160376 macosx-all -sun/tools/jps/TestJpsJar.java 8160923 generic-all - sun/tools/jps/TestJpsJarRelative.java 6456333 generic-all sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java 8057732 generic-all diff --git a/jdk/test/sun/tools/jps/TestJpsJar.java b/jdk/test/sun/tools/jps/TestJpsJar.java index 00cc5423018..97d744ec85f 100644 --- a/jdk/test/sun/tools/jps/TestJpsJar.java +++ b/jdk/test/sun/tools/jps/TestJpsJar.java @@ -38,7 +38,7 @@ import jdk.testlibrary.ProcessTools; * @library /lib/testlibrary * @modules jdk.jartool/sun.tools.jar * java.management - * @build jdk.testlibrary.* JpsHelper JpsBase + * @build JpsHelper JpsBase * @run main/othervm TestJpsJar */ public class TestJpsJar { From 99f0753054d6324a3203473e0e75a759522c1dca Mon Sep 17 00:00:00 2001 From: Marcus Larsson Date: Mon, 29 Aug 2016 14:11:22 +0200 Subject: [PATCH 048/296] 8157948: UL allows same log file with multiple file= Reviewed-by: dholmes, rehn --- hotspot/src/share/vm/logging/log.cpp | 2 +- .../src/share/vm/logging/logConfiguration.cpp | 117 ++++++++++++------ .../src/share/vm/logging/logConfiguration.hpp | 2 +- .../src/share/vm/logging/logFileOutput.cpp | 4 +- .../src/share/vm/logging/logFileOutput.hpp | 1 + .../native/logging/test_logConfiguration.cpp | 27 ++++ .../native/logging/test_logFileOutput.cpp | 2 +- 7 files changed, 111 insertions(+), 44 deletions(-) diff --git a/hotspot/src/share/vm/logging/log.cpp b/hotspot/src/share/vm/logging/log.cpp index 8796c1794e4..3f63d143f27 100644 --- a/hotspot/src/share/vm/logging/log.cpp +++ b/hotspot/src/share/vm/logging/log.cpp @@ -1161,7 +1161,7 @@ void Test_invalid_log_file() { // Attempt to log to a directory (existing log not a regular file) create_directory(target_name); - LogFileOutput bad_file("tmplogdir"); + LogFileOutput bad_file("file=tmplogdir"); assert(bad_file.initialize("", &ss) == false, "file was initialized " "when there was an existing directory with the same name"); assert(strstr(ss.as_string(), "tmplogdir is not a regular file") != NULL, diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp index 0817a650e70..29a65cd3a1f 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.cpp +++ b/hotspot/src/share/vm/logging/logConfiguration.cpp @@ -44,6 +44,9 @@ size_t LogConfiguration::_n_outputs = 0; LogConfiguration::UpdateListenerFunction* LogConfiguration::_listener_callbacks = NULL; size_t LogConfiguration::_n_listener_callbacks = 0; +// LogFileOutput is the default type of output, its type prefix should be used if no type was specified +static const char* implicit_output_prefix = LogFileOutput::Prefix; + // Stack object to take the lock for configuring the logging. // Should only be held during the critical parts of the configuration // (when calling configure_output or reading/modifying the outputs array). @@ -107,6 +110,55 @@ void LogConfiguration::finalize() { FREE_C_HEAP_ARRAY(LogOutput*, _outputs); } +// Normalizes the given LogOutput name to type=name form. +// For example, foo, "foo", file="foo", will all be normalized to file=foo (no quotes, prefixed). +static bool normalize_output_name(const char* full_name, char* buffer, size_t len, outputStream* errstream) { + const char* start_quote = strchr(full_name, '"'); + const char* equals = strchr(full_name, '='); + const bool quoted = start_quote != NULL; + const bool is_stdout_or_stderr = (strcmp(full_name, "stdout") == 0 || strcmp(full_name, "stderr") == 0); + + // ignore equals sign within quotes + if (quoted && equals > start_quote) { + equals = NULL; + } + + const char* prefix = ""; + size_t prefix_len = 0; + const char* name = full_name; + if (equals != NULL) { + // split on equals sign + name = equals + 1; + prefix = full_name; + prefix_len = equals - full_name + 1; + } else if (!is_stdout_or_stderr) { + prefix = implicit_output_prefix; + prefix_len = strlen(prefix); + } + size_t name_len = strlen(name); + + if (quoted) { + const char* end_quote = strchr(start_quote + 1, '"'); + if (end_quote == NULL) { + errstream->print_cr("Output name has opening quote but is missing a terminating quote."); + return false; + } + if (start_quote != name || end_quote[1] != '\0') { + errstream->print_cr("Output name can not be partially quoted." + " Either surround the whole name with quotation marks," + " or do not use quotation marks at all."); + return false; + } + // strip start and end quote + name++; + name_len -= 2; + } + + int ret = jio_snprintf(buffer, len, "%.*s%.*s", prefix_len, prefix, name_len, name); + assert(ret > 0, "buffer issue"); + return true; +} + size_t LogConfiguration::find_output(const char* name) { for (size_t i = 0; i < _n_outputs; i++) { if (strcmp(_outputs[i]->name(), name) == 0) { @@ -116,39 +168,14 @@ size_t LogConfiguration::find_output(const char* name) { return SIZE_MAX; } -LogOutput* LogConfiguration::new_output(char* name, const char* options, outputStream* errstream) { - const char* type; - char* equals_pos = strchr(name, '='); - if (equals_pos == NULL) { - type = "file"; - } else { - *equals_pos = '\0'; - type = name; - name = equals_pos + 1; - } - - // Check if name is quoted, and if so, strip the quotes - char* quote = strchr(name, '"'); - if (quote != NULL) { - char* end_quote = strchr(name + 1, '"'); - if (end_quote == NULL) { - errstream->print_cr("Output name has opening quote but is missing a terminating quote."); - return NULL; - } else if (quote != name || end_quote[1] != '\0') { - errstream->print_cr("Output name can not be partially quoted." - " Either surround the whole name with quotation marks," - " or do not use quotation marks at all."); - return NULL; - } - name++; - *end_quote = '\0'; - } - +LogOutput* LogConfiguration::new_output(const char* name, + const char* options, + outputStream* errstream) { LogOutput* output; - if (strcmp(type, "file") == 0) { + if (strncmp(name, LogFileOutput::Prefix, strlen(LogFileOutput::Prefix)) == 0) { output = new LogFileOutput(name); } else { - errstream->print_cr("Unsupported log output type."); + errstream->print_cr("Unsupported log output type: %s", name); return NULL; } @@ -374,25 +401,35 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr, ConfigurationLock cl; size_t idx; - if (outputstr[0] == '#') { - int ret = sscanf(outputstr+1, SIZE_FORMAT, &idx); + if (outputstr[0] == '#') { // Output specified using index + int ret = sscanf(outputstr + 1, SIZE_FORMAT, &idx); if (ret != 1 || idx >= _n_outputs) { errstream->print_cr("Invalid output index '%s'", outputstr); return false; } - } else { - idx = find_output(outputstr); + } else { // Output specified using name + // Normalize the name, stripping quotes and ensures it includes type prefix + size_t len = strlen(outputstr) + strlen(implicit_output_prefix) + 1; + char* normalized = NEW_C_HEAP_ARRAY(char, len, mtLogging); + if (!normalize_output_name(outputstr, normalized, len, errstream)) { + return false; + } + + idx = find_output(normalized); if (idx == SIZE_MAX) { - char* tmp = os::strdup_check_oom(outputstr, mtLogging); - LogOutput* output = new_output(tmp, output_options, errstream); - os::free(tmp); - if (output == NULL) { - return false; + // Attempt to create and add the output + LogOutput* output = new_output(normalized, output_options, errstream); + if (output != NULL) { + idx = add_output(output); } - idx = add_output(output); } else if (output_options != NULL && strlen(output_options) > 0) { errstream->print_cr("Output options for existing outputs are ignored."); } + + FREE_C_HEAP_ARRAY(char, normalized); + if (idx == SIZE_MAX) { + return false; + } } configure_output(idx, expr, decorators); notify_update_listeners(); diff --git a/hotspot/src/share/vm/logging/logConfiguration.hpp b/hotspot/src/share/vm/logging/logConfiguration.hpp index 9efbadddd02..344e66af5e2 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.hpp +++ b/hotspot/src/share/vm/logging/logConfiguration.hpp @@ -59,7 +59,7 @@ class LogConfiguration : public AllStatic { static size_t _n_listener_callbacks; // Create a new output. Returns NULL if failed. - static LogOutput* new_output(char* name, const char* options, outputStream* errstream); + static LogOutput* new_output(const char* name, const char* options, outputStream* errstream); // Add an output to the list of configured outputs. Returns the assigned index. static size_t add_output(LogOutput* out); diff --git a/hotspot/src/share/vm/logging/logFileOutput.cpp b/hotspot/src/share/vm/logging/logFileOutput.cpp index 77cad087a0c..3f431ef3e54 100644 --- a/hotspot/src/share/vm/logging/logFileOutput.cpp +++ b/hotspot/src/share/vm/logging/logFileOutput.cpp @@ -31,6 +31,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/defaultStream.hpp" +const char* LogFileOutput::Prefix = "file="; const char* LogFileOutput::FileOpenMode = "a"; const char* LogFileOutput::PidFilenamePlaceholder = "%p"; const char* LogFileOutput::TimestampFilenamePlaceholder = "%t"; @@ -45,7 +46,8 @@ LogFileOutput::LogFileOutput(const char* name) _file_name(NULL), _archive_name(NULL), _archive_name_len(0), _rotate_size(DefaultFileSize), _file_count(DefaultFileCount), _current_size(0), _current_file(0), _rotation_semaphore(1) { - _file_name = make_file_name(name, _pid_str, _vm_start_time_str); + assert(strstr(name, Prefix) == name, "invalid output name '%s': missing prefix: %s", name, Prefix); + _file_name = make_file_name(name + strlen(Prefix), _pid_str, _vm_start_time_str); } void LogFileOutput::set_file_name_parameters(jlong vm_start_time) { diff --git a/hotspot/src/share/vm/logging/logFileOutput.hpp b/hotspot/src/share/vm/logging/logFileOutput.hpp index 3ec3a771985..7808ab33f81 100644 --- a/hotspot/src/share/vm/logging/logFileOutput.hpp +++ b/hotspot/src/share/vm/logging/logFileOutput.hpp @@ -91,6 +91,7 @@ class LogFileOutput : public LogFileStreamOutput { return _name; } + static const char* Prefix; static void set_file_name_parameters(jlong start_time); }; diff --git a/hotspot/test/native/logging/test_logConfiguration.cpp b/hotspot/test/native/logging/test_logConfiguration.cpp index b07839ad04a..a5e52ca80ca 100644 --- a/hotspot/test/native/logging/test_logConfiguration.cpp +++ b/hotspot/test/native/logging/test_logConfiguration.cpp @@ -308,3 +308,30 @@ TEST_F(LogConfigurationTest, parse_invalid_tagset) { EXPECT_TRUE(string_contains_substring(msg, "No tag set matches selection(s):")); EXPECT_TRUE(string_contains_substring(msg, invalid_tagset)); } + +TEST_F(LogConfigurationTest, output_name_normalization) { + const char* patterns[] = { "%s", "file=%s", "\"%s\"", "file=\"%s\"" }; + char buf[1 * K]; + for (size_t i = 0; i < ARRAY_SIZE(patterns); i++) { + int ret = jio_snprintf(buf, sizeof(buf), patterns[i], TestLogFileName); + ASSERT_NE(-1, ret); + set_log_config(buf, "logging=trace"); + EXPECT_TRUE(is_described("#2: ")); + EXPECT_TRUE(is_described(TestLogFileName)); + EXPECT_FALSE(is_described("#3: ")) + << "duplicate file output due to incorrect normalization for pattern: " << patterns[i]; + } + + // Make sure prefixes are ignored when used within quotes + // (this should create a log with "file=" in its filename) + int ret = jio_snprintf(buf, sizeof(buf), "\"file=%s\"", TestLogFileName); + ASSERT_NE(-1, ret); + set_log_config(buf, "logging=trace"); + EXPECT_TRUE(is_described("#3: ")) << "prefix within quotes not ignored as it should be"; + set_log_config(buf, "all=off"); + + // Remove the extra log file created + ret = jio_snprintf(buf, sizeof(buf), "file=%s", TestLogFileName); + ASSERT_NE(-1, ret); + delete_file(buf); +} diff --git a/hotspot/test/native/logging/test_logFileOutput.cpp b/hotspot/test/native/logging/test_logFileOutput.cpp index da13e539412..b561048e7a5 100644 --- a/hotspot/test/native/logging/test_logFileOutput.cpp +++ b/hotspot/test/native/logging/test_logFileOutput.cpp @@ -29,7 +29,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/ostream.hpp" -static const char* name = "testlog.pid%p.%t.log"; +static const char* name = "file=testlog.pid%p.%t.log"; // Test parsing a bunch of valid file output options TEST(LogFileOutput, parse_valid) { From 6bcba7521ca56dd076a97caa49d914743897b648 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Mon, 29 Aug 2016 13:44:43 -0700 Subject: [PATCH 049/296] 8164837: fix jdeprscan TestLoad and TestScan failures on Windows Reviewed-by: darcy --- .../share/classes/com/sun/tools/jdeprscan/Main.java | 2 +- langtools/test/ProblemList.txt | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java index 28d4b33e886..a30add77b00 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java @@ -181,7 +181,7 @@ public class Main implements DiagnosticListener { .filter(name -> !name.endsWith("package-info.class")) .filter(name -> !name.endsWith("module-info.class")) .map(s -> s.replaceAll("\\.class$", "")) - .map(s -> s.replace('/', '.')) + .map(s -> s.replace(File.separatorChar, '.')) .collect(toList())); } diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt index a90395e8734..8ed5359b3be 100644 --- a/langtools/test/ProblemList.txt +++ b/langtools/test/ProblemList.txt @@ -77,10 +77,3 @@ tools/sjavac/ClasspathDependencies.java 8158002 generic-all Requires i ########################################################################### # # jdeps - -########################################################################### -# -# jdeprscan - -tools/jdeprscan/tests/jdk/jdeprscan/TestLoad.java 8164837 windows-all probably line breaks or encoding -tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java 8164837 windows-all probably line breaks or encoding From 8120ff31101ef5651b04a486933db7c27dc959aa Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 30 Aug 2016 17:47:46 -0700 Subject: [PATCH 050/296] 8160851: Remove old launcher module-related options Reviewed-by: jjg, alanb --- .../com/sun/tools/javac/comp/Modules.java | 6 +- .../com/sun/tools/javac/file/Locations.java | 2 +- .../com/sun/tools/javac/main/Option.java | 24 +++---- .../javac/platform/PlatformDescription.java | 2 +- .../javac/platform/PlatformProvider.java | 4 +- .../tools/javac/platform/package-info.java | 2 +- .../tools/javac/resources/compiler.properties | 14 ++-- .../tools/javac/resources/javac.properties | 4 +- .../com/sun/tools/sjavac/options/Option.java | 8 +-- .../sun/tools/javadoc/main/ToolOption.java | 70 ------------------ .../jdk/javadoc/internal/tool/ToolOption.java | 72 +------------------ .../classes/com/sun/tools/jdeprscan/Main.java | 10 +-- .../com/sun/tools/jdeps/DepsAnalyzer.java | 2 +- .../sun/tools/jdeps/JdepsConfiguration.java | 4 +- .../com/sun/tools/jdeps/JdepsTask.java | 2 +- 15 files changed, 40 insertions(+), 186 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java index d24b79529e8..8e464ef9fc6 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java @@ -1090,7 +1090,7 @@ public class Modules extends JCTree.Visitor { Set requiresPublic = requiresPublicCache.get(msym); if (requiresPublic == null) { - //the module graph may contain cycles involving automatic modules or -XaddReads edges + //the module graph may contain cycles involving automatic modules or --add-reads edges requiresPublic = new HashSet<>(); Set seen = new HashSet<>(); @@ -1192,7 +1192,7 @@ public class Modules extends JCTree.Visitor { } // Terminology comes from - // -XaddExports:module/package=target,... + // --add-exports module/package=target,... // Compare to // module module { exports package to target, ... } String moduleName = em.group(1); @@ -1245,7 +1245,7 @@ public class Modules extends JCTree.Visitor { } // Terminology comes from - // -XaddReads:target-module=source-module,... + // --add-reads target-module=source-module,... // Compare to // module target-module { requires source-module; ... } String targetName = rm.group(1); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java index ef7f1ce0236..422f72f13d8 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java @@ -810,7 +810,7 @@ public class Locations { * SYSTEM_MODULES and MODULE_PATH. * * The Location can be specified to accept overriding classes from the - * {@code -Xpatch:= } parameter. + * {@code --patch-module = } parameter. */ private class ModuleLocationHandler extends LocationHandler implements Location { protected final String name; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java index f20ff057191..6d39408b095 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java @@ -183,15 +183,15 @@ public enum Option { SOURCE_PATH("--source-path -sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER), - MODULE_SOURCE_PATH("--module-source-path -modulesourcepath", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER), + MODULE_SOURCE_PATH("--module-source-path", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER), - MODULE_PATH("--module-path -p -modulepath -mp", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER), + MODULE_PATH("--module-path -p", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER), - UPGRADE_MODULE_PATH("--upgrade-module-path -upgrademodulepath", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER), + UPGRADE_MODULE_PATH("--upgrade-module-path", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER), - SYSTEM("--system -system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER), + SYSTEM("--system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER), - PATCH_MODULE("--patch-module -Xpatch:", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) { + PATCH_MODULE("--patch-module", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) { // The deferred filemanager diagnostics mechanism assumes a single value per option, // but --patch-module can be used multiple times, once per module. Therefore we compose // a value for the option containing the last value specified for each module, and separate @@ -273,7 +273,7 @@ public enum Option { PROCESSOR_PATH("--processor-path -processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER), - PROCESSOR_MODULE_PATH("--processor-module-path -processormodulepath", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER), + PROCESSOR_MODULE_PATH("--processor-module-path", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER), PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC), @@ -311,7 +311,7 @@ public enum Option { } }, - RELEASE("--release -release", "opt.arg.release", "opt.release", STANDARD, BASIC) { + RELEASE("--release", "opt.arg.release", "opt.release", STANDARD, BASIC) { @Override protected void help(Log log) { Iterable providers = @@ -566,7 +566,7 @@ public enum Option { } }, - ADD_EXPORTS("--add-exports -XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) { + ADD_EXPORTS("--add-exports", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) { @Override public boolean process(OptionHelper helper, String option, String arg) { String prev = helper.get(ADD_EXPORTS); @@ -575,7 +575,7 @@ public enum Option { } }, - ADD_READS("--add-reads -XaddReads:", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) { + ADD_READS("--add-reads", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) { @Override public boolean process(OptionHelper helper, String option, String arg) { String prev = helper.get(ADD_READS); @@ -598,9 +598,9 @@ public enum Option { MODULE("--module -m", "opt.arg.m", "opt.m", STANDARD, BASIC), - ADD_MODULES("--add-modules -addmods", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC), + ADD_MODULES("--add-modules", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC), - LIMIT_MODULES("--limit-modules -limitmods", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC), + LIMIT_MODULES("--limit-modules", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC), // This option exists only for the purpose of documenting itself. // It's actually implemented by the CommandLine class. @@ -645,7 +645,7 @@ public enum Option { } }, - MULTIRELEASE("--multi-release -multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER), + MULTIRELEASE("--multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER), INHERIT_RUNTIME_ENVIRONMENT("--inherit-runtime-environment", "opt.inherit_runtime_environment", EXTENDED, BASIC) { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformDescription.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformDescription.java index fa1fab05401..4db3712b207 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformDescription.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformDescription.java @@ -36,7 +36,7 @@ import javax.annotation.processing.Processor; import com.sun.source.util.Plugin; -/**A description of settings needed for a particular {@code -release name} option. +/**A description of settings needed for a particular {@code --release name} option. * *

This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformProvider.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformProvider.java index db273a4cbc5..b552c6acf22 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformProvider.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformProvider.java @@ -25,7 +25,7 @@ package com.sun.tools.javac.platform; -/** A collection of platform descriptions that can be selected using {@code -release name} +/** A collection of platform descriptions that can be selected using {@code --release name} * command line option. * Register in {@code META-INF/services/com.sun.tools.javac.platform.PlatformProvider}. * @@ -36,7 +36,7 @@ package com.sun.tools.javac.platform; */ public interface PlatformProvider { - /**Names of platforms supported by this provider. Each returned name can be used as the key for -release. + /**Names of platforms supported by this provider. Each returned name can be used as the key for --release. * * @return the platform keys */ diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/package-info.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/package-info.java index f843a8adc52..d236ea181f4 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/package-info.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/package-info.java @@ -24,7 +24,7 @@ */ /** - * An internal API for plugging in -release implementations. + * An internal API for plugging in --release implementations. * *

This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index dcb7b2e7fee..f46d344ad18 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -2780,10 +2780,10 @@ compiler.err.module-info.with.xmodule.classpath=\ illegal combination of -Xmodule and module-info on classpath compiler.err.xmodule.no.module.sourcepath=\ - illegal combination of -Xmodule and -modulesourcepath + illegal combination of -Xmodule and --module-source-path compiler.err.processorpath.no.processormodulepath=\ - illegal combination of -processorpath and -processormodulepath + illegal combination of -processorpath and --processor-module-path # 0: symbol compiler.err.package.in.other.module=\ @@ -2817,22 +2817,22 @@ compiler.err.duplicate.module.on.path=\ # 0: string compiler.err.xaddexports.malformed.entry=\ - bad value for -XaddExports: {0} + bad value for --add-exports {0} # 0: string compiler.err.xaddexports.too.many=\ - multiple -XaddExports options for {0} + multiple --add-exports options for {0} # 0: string compiler.err.xaddreads.malformed.entry=\ - bad value for -XaddReads: {0} + bad value for --add-reads {0} # 0: string compiler.err.xaddreads.too.many=\ - multiple -XaddReads options for {0} + multiple --add-reads options for {0} compiler.err.addmods.all.module.path.invalid=\ - -addmods ALL-MODULE-PATH can only be used when compiling the unnamed module + --add-modules ALL-MODULE-PATH can only be used when compiling the unnamed module compiler.misc.locn.module_source_path=\ module source path diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties index 6d17bc7ef89..05874ad9087 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties @@ -390,10 +390,10 @@ javac.version={0} {1} javac.fullVersion={0} full version "{1}" javac.err.release.bootclasspath.conflict=\ - option {0} cannot be used together with -release + option {0} cannot be used together with --release javac.err.unsupported.release.version=\ release version {0} not supported javac.err.release.not.standard.file.manager=\ - -release option specified, but the provided JavaFileManager is not a StandardJavaFileManager. + --release option specified, but the provided JavaFileManager is not a StandardJavaFileManager. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java index fb07a4fdae0..13df6ef4d8e 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java @@ -85,13 +85,7 @@ public enum Option { helper.modulepath(paths); } }, - MODULEPATH("-modulepath", "An alias for -modulepath") { - @Override - protected void processMatching(ArgumentIterator iter, OptionHelper helper) { - MODULE_PATH.processMatching(iter, helper); - } - }, - P("-p", "An alias for -modulepath") { + P("-p", "An alias for --module-path") { @Override protected void processMatching(ArgumentIterator iter, OptionHelper helper) { MODULE_PATH.processMatching(iter, helper); diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java index 0838966e1c4..d3d7073f9f0 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java @@ -104,13 +104,6 @@ public enum ToolOption { } }, - MODULESOURCEPATH("-modulesourcepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg); - } - }, - MODULE_SOURCE_PATH("--module-source-path", true) { @Override public void process(Helper helper, String arg) { @@ -118,13 +111,6 @@ public enum ToolOption { } }, - UPGRADEMODULEPATH("-upgrademodulepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg); - } - }, - UPGRADE_MODULE_PATH("--upgrade-module-path", true) { @Override public void process(Helper helper, String arg) { @@ -132,13 +118,6 @@ public enum ToolOption { } }, - SYSTEM("-system", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.SYSTEM, arg); - } - }, - SYSTEM_("--system", true) { @Override public void process(Helper helper, String arg) { @@ -146,13 +125,6 @@ public enum ToolOption { } }, - MODULEPATH("-modulepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULE_PATH, arg); - } - }, - MODULE_PATH("--module-path", true) { @Override public void process(Helper helper, String arg) { @@ -167,13 +139,6 @@ public enum ToolOption { } }, - ADDMODS("-addmods", true) { - @Override - public void process(Helper helper, String arg) { - helper.setCompilerOpt(opt, arg); - } - }, - ADD_MODULES("--add-modules", true) { @Override public void process(Helper helper, String arg) { @@ -181,13 +146,6 @@ public enum ToolOption { } }, - LIMITMODS("-limitmods", true) { - @Override - public void process(Helper helper, String arg) { - helper.setCompilerOpt(opt, arg); - } - }, - LIMIT_MODULES("--limit-modules", true) { @Override public void process(Helper helper, String arg) { @@ -210,13 +168,6 @@ public enum ToolOption { } }, - RELEASE_OLD("-release", true) { - @Override - public void process(Helper helper, String arg) { - helper.setCompilerOpt("--release", arg); - } - }, - SOURCE("-source", true) { @Override public void process(Helper helper, String arg) { @@ -238,13 +189,6 @@ public enum ToolOption { } }, - XADDREADS("-XaddReads:", false) { - @Override - public void process(Helper helper, String arg) { - Option.ADD_READS.process(helper.getOptionHelper(), arg); - } - }, - ADD_READS("--add-reads", true) { @Override public void process(Helper helper, String arg) { @@ -252,13 +196,6 @@ public enum ToolOption { } }, - ADDEXPORTS("-XaddExports:", false) { - @Override - public void process(Helper helper, String arg) { - Option.ADD_EXPORTS.process(helper.getOptionHelper(), arg); - } - }, - ADD_EXPORTS("--add-exports", true) { @Override public void process(Helper helper, String arg) { @@ -273,13 +210,6 @@ public enum ToolOption { } }, - XPATCH("-Xpatch:", false) { - @Override - public void process(Helper helper, String arg) { - Option.XMODULE.process(helper.getOptionHelper(), arg); - } - }, - PATCH_MODULE("--patch-module", true) { @Override public void process(Helper helper, String arg) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java index fd07699fa83..0f5cf65cbe2 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java @@ -106,13 +106,6 @@ public enum ToolOption { } }, - MODULESOURCEPATH("-modulesourcepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg); - } - }, - MODULE_SOURCE_PATH("--module-source-path", true) { @Override public void process(Helper helper, String arg) { @@ -120,13 +113,6 @@ public enum ToolOption { } }, - UPGRADEMODULEPATH("-upgrademodulepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg); - } - }, - UPGRADE_MODULE_PATH("--upgrade-module-path", true) { @Override public void process(Helper helper, String arg) { @@ -134,27 +120,13 @@ public enum ToolOption { } }, - SYSTEM("-system", true) { + SYSTEM("--system", true) { @Override public void process(Helper helper, String arg) { helper.setFileManagerOpt(Option.SYSTEM, arg); } }, - SYSTEM_("--system", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.SYSTEM, arg); - } - }, - - MODULEPATH("-modulepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULE_PATH, arg); - } - }, - MODULE_PATH("--module-path", true) { @Override public void process(Helper helper, String arg) { @@ -169,13 +141,6 @@ public enum ToolOption { } }, - ADDMODS("-addmods", true) { - @Override - public void process(Helper helper, String arg) { - Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg); - } - }, - ADD_MODULES("--add-modules", true) { @Override public void process(Helper helper, String arg) { @@ -183,13 +148,6 @@ public enum ToolOption { } }, - LIMITMODS("-limitmods", true) { - @Override - public void process(Helper helper, String arg) { - Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg); - } - }, - LIMIT_MODULES("--limit-modules", true) { @Override public void process(Helper helper, String arg) { @@ -218,13 +176,6 @@ public enum ToolOption { } }, - RELEASE_OLD("-release", true) { - @Override - public void process(Helper helper, String arg) { - Option.RELEASE.process(helper.getOptionHelper(), opt, arg); - } - }, - SOURCE("-source", true) { @Override public void process(Helper helper, String arg) { @@ -246,13 +197,6 @@ public enum ToolOption { } }, - XADDREADS("-XaddReads:", false) { - @Override - public void process(Helper helper, String arg) { - Option.ADD_READS.process(helper.getOptionHelper(), arg); - } - }, - ADD_READS("--add-reads", true) { @Override public void process(Helper helper, String arg) { @@ -260,13 +204,6 @@ public enum ToolOption { } }, - ADDEXPORTS("-XaddExports:", false) { - @Override - public void process(Helper helper, String arg) { - Option.ADD_EXPORTS.process(helper.getOptionHelper(), arg); - } - }, - ADD_EXPORTS("--add-exports", true) { @Override public void process(Helper helper, String arg) { @@ -281,13 +218,6 @@ public enum ToolOption { } }, - XPATCH("-Xpatch:", false) { - @Override - public void process(Helper helper, String arg) { - Option.XMODULE.process(helper.getOptionHelper(), arg); - } - }, - PATCH_MODULE("--patch-module", true) { @Override public void process(Helper helper, String arg) { diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java index a30add77b00..3a024981393 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java @@ -81,7 +81,7 @@ import javax.lang.model.element.TypeElement; * - more rigorous GNU style option parsing; use joptsimple? * * FUTURES: - * - add module support: -addmods, -modulepath, module arg + * - add module support: --add-modules, --module-path, module arg * - load deprecation declarations from a designated class library instead * of the JDK * - load deprecation declarations from a module @@ -331,7 +331,7 @@ public class Main implements DiagnosticListener { * @throws IOException if an I/O error occurs */ boolean processSelf(Collection classes) throws IOException { - options.add("-addmods"); + options.add("--add-modules"); options.add("java.se.ee,jdk.xml.bind"); // TODO why jdk.xml.bind? if (classes.isEmpty()) { @@ -360,7 +360,7 @@ public class Main implements DiagnosticListener { * @return success value */ boolean processRelease(String release, Collection classes) throws IOException { - options.addAll(List.of("-release", release)); + options.addAll(List.of("--release", release)); if (release.equals("9")) { List rootMods = List.of("java.se", "java.se.ee"); @@ -368,7 +368,7 @@ public class Main implements DiagnosticListener { JavaCompiler.CompilationTask task = compiler.getTask(null, fm, this, // options - List.of("-addmods", String.join(",", rootMods)), + List.of("--add-modules", String.join(",", rootMods)), // classes List.of("java.lang.Object"), null); @@ -377,7 +377,7 @@ public class Main implements DiagnosticListener { return false; } Map> types = proc.getPublicTypes(); - options.add("-addmods"); + options.add("--add-modules"); options.add(String.join(",", rootMods)); return doClassNames( types.values().stream() diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java index 128e2ea7456..2975813c14f 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java @@ -56,7 +56,7 @@ import static java.util.stream.Collectors.*; * 1. archives specified in the command line arguments * 2. observable modules matching the source filter * 3. classpath archives matching the source filter or target filter - * 4. -addmods and -m root modules + * 4. --add-modules and -m root modules */ public class DepsAnalyzer { final JdepsConfiguration configuration; diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java index 2975651e373..3c4632a8078 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java @@ -127,7 +127,7 @@ public class JdepsConfiguration implements AutoCloseable { } } - // all roots specified in -addmods or -m are included + // all roots specified in --add-modules or -m are included // as the initial set for analysis. roots.stream() .map(nameToModule::get) @@ -342,7 +342,7 @@ public class JdepsConfiguration implements AutoCloseable { SystemModuleFinder(String javaHome) throws IOException { if (javaHome == null) { - // -system none + // --system none this.fileSystem = null; this.root = null; this.systemModules = Collections.emptyMap(); diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java index 2cdca8bb839..38e1d08c6ef 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java @@ -313,7 +313,7 @@ class JdepsTask { } }, - // Another alternative to list modules in -addmods option + // Another alternative to list modules in --add-modules option new HiddenOption(true, "--include-system-modules") { void process(JdepsTask task, String opt, String arg) throws BadArgs { task.options.includeSystemModulePattern = Pattern.compile(arg); From 2a62da3a6385a11353acf5f9fb87bf3e19471c8b Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 30 Aug 2016 20:49:41 -0700 Subject: [PATCH 051/296] 8165109: langtools/test switches to use new CLI options Reviewed-by: jjg, amlu --- .../test/jdk/javadoc/tool/ReleaseOption.java | 10 +++++----- .../T8139474/DashRelease7DashVerboseTest.java | 4 ++-- .../ProcessorPathNoProcessorModulePath.java | 2 +- .../MultiReleaseJarAwareSJFM.java | 2 +- .../MultiReleaseJar/MultiReleaseJarTest.java | 16 ++++++++-------- .../AnachronisticModuleInfoTest.java | 2 +- .../javac/modules/UpgradeModulePathTest.java | 2 +- .../javac/options/release/ReleaseOption.java | 4 ++-- .../options/release/ReleaseOptionClashes.java | 4 ++-- .../options/release/ReleaseOptionThroughAPI.java | 4 ++-- .../javac/platform/PlatformProviderTest.java | 4 ++-- .../tools/javac/sym/ElementStructureTest.java | 2 +- langtools/test/tools/javac/synthesize/Main.java | 2 +- langtools/test/tools/javadoc/ReleaseOption.java | 10 +++++----- .../test/tools/lib/toolbox/ModuleBuilder.java | 2 +- 15 files changed, 35 insertions(+), 35 deletions(-) diff --git a/langtools/test/jdk/javadoc/tool/ReleaseOption.java b/langtools/test/jdk/javadoc/tool/ReleaseOption.java index 9761af3f039..774b10ed658 100644 --- a/langtools/test/jdk/javadoc/tool/ReleaseOption.java +++ b/langtools/test/jdk/javadoc/tool/ReleaseOption.java @@ -33,7 +33,7 @@ import jdk.javadoc.internal.tool.Main; /** * @test * @bug 8086737 - * @summary Test -release option in javadoc + * @summary Test --release option in javadoc * @run main ReleaseOption * @modules jdk.javadoc/jdk.javadoc.internal.tool */ @@ -43,10 +43,10 @@ public class ReleaseOption { } void run() { - doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "-release", "7"); - doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "-release", "8"); - doRunTest(1, out -> true, "-release", "7", "-source", "7"); - doRunTest(1, out -> true, "-release", "7", "-bootclasspath", "any"); + doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7"); + doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8"); + doRunTest(1, out -> true, "--release", "7", "-source", "7"); + doRunTest(1, out -> true, "--release", "7", "-bootclasspath", "any"); } void doRunTest(int expectedResult, Predicate validate, String... args) { diff --git a/langtools/test/tools/javac/T8139474/DashRelease7DashVerboseTest.java b/langtools/test/tools/javac/T8139474/DashRelease7DashVerboseTest.java index 5e0c19cddb3..38f9f583884 100644 --- a/langtools/test/tools/javac/T8139474/DashRelease7DashVerboseTest.java +++ b/langtools/test/tools/javac/T8139474/DashRelease7DashVerboseTest.java @@ -24,8 +24,8 @@ /* * @test * bug 8139474 - * @summary -release 7 -verbose causes Javac exception - * @compile -release 7 -verbose DashRelease7DashVerboseTest.java + * @summary --release 7 -verbose causes Javac exception + * @compile --release 7 -verbose DashRelease7DashVerboseTest.java */ public class DashRelease7DashVerboseTest {} diff --git a/langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java b/langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java index 2e5d323df34..11c404cff50 100644 --- a/langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java +++ b/langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java @@ -22,6 +22,6 @@ */ // key: compiler.err.processorpath.no.processormodulepath -// options: -processormodulepath mods -processorpath mods +// options: --processor-module-path mods -processorpath mods class ProcessorPathNoProcessorModulePath {} diff --git a/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java index ae83a78ee7b..d89b16c577d 100644 --- a/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java +++ b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java @@ -174,7 +174,7 @@ public class MultiReleaseJarAwareSJFM { jfm.setLocation(jloc, List.of(new File("multi-release.jar"))); if (version.length() > 0) { - jfm.handleOption("-multi-release", List.of(version).iterator()); + jfm.handleOption("--multi-release", List.of(version).iterator()); } CustomClassLoader cldr = new CustomClassLoader(jfm); diff --git a/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java index 39e14ab1057..ce2ce4530f8 100644 --- a/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java +++ b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java @@ -135,12 +135,12 @@ public class MultiReleaseJarTest { } @Test(dataProvider="modes") - // javac -d classes -release 8 -cp multi-release.jar Main.java -> succeeds + // javac -d classes --release 8 -cp multi-release.jar Main.java -> succeeds public void main1Release8(Task.Mode mode) throws Exception { tb.writeFile("Main.java", main1); Task.Result result = new JavacTask(tb, mode) .outdir("classes") - .options("-release", "8") + .options("--release", "8") .classpath("multi-release.jar") .files("Main.java") .run(); @@ -149,12 +149,12 @@ public class MultiReleaseJarTest { } @Test(dataProvider="modes") - // javac -d classes -release 9 -cp multi-release.jar Main.java -> fails + // javac -d classes --release 9 -cp multi-release.jar Main.java -> fails public void main1Release9(Task.Mode mode) throws Exception { tb.writeFile("Main.java", main1); Task.Result result = new JavacTask(tb, mode) .outdir("classes") - .options("-release", "9") + .options("--release", "9") .classpath("multi-release.jar") .files("Main.java") .run(Task.Expect.FAIL, 1); @@ -177,12 +177,12 @@ public class MultiReleaseJarTest { } @Test(dataProvider="modes") - // javac -d classes -release 8 -cp multi-release.jar Main.java -> fails + // javac -d classes --release 8 -cp multi-release.jar Main.java -> fails public void main2Release8(Task.Mode mode) throws Exception { tb.writeFile("Main.java", main2); Task.Result result = new JavacTask(tb, mode) .outdir("classes") - .options("-release", "8") + .options("--release", "8") .classpath("multi-release.jar") .files("Main.java") .run(Task.Expect.FAIL, 1); @@ -191,12 +191,12 @@ public class MultiReleaseJarTest { } @Test(dataProvider="modes") - // javac -d classes -release 9 -cp multi-release.jar Main.java -> succeeds + // javac -d classes --release 9 -cp multi-release.jar Main.java -> succeeds public void main2Release9(Task.Mode mode) throws Exception { tb.writeFile("Main.java", main2); Task.Result result = new JavacTask(tb, mode) .outdir("classes") - .options("-release", "9") + .options("--release", "9") .classpath("multi-release.jar") .files("Main.java") .run(); diff --git a/langtools/test/tools/javac/modules/AnachronisticModuleInfo/AnachronisticModuleInfoTest.java b/langtools/test/tools/javac/modules/AnachronisticModuleInfo/AnachronisticModuleInfoTest.java index 0ac82ece5e0..5553983e709 100644 --- a/langtools/test/tools/javac/modules/AnachronisticModuleInfo/AnachronisticModuleInfoTest.java +++ b/langtools/test/tools/javac/modules/AnachronisticModuleInfo/AnachronisticModuleInfoTest.java @@ -78,7 +78,7 @@ public class AnachronisticModuleInfoTest extends TestRunner { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-upgrademodulepath", modulePath) + "--upgrade-module-path", modulePath) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() diff --git a/langtools/test/tools/javac/modules/UpgradeModulePathTest.java b/langtools/test/tools/javac/modules/UpgradeModulePathTest.java index cd83ef49734..1a923e940f8 100644 --- a/langtools/test/tools/javac/modules/UpgradeModulePathTest.java +++ b/langtools/test/tools/javac/modules/UpgradeModulePathTest.java @@ -23,7 +23,7 @@ /* * @test - * @summary tests for -upgrademodulepath + * @summary tests for --upgrade-module-path * @library /tools/lib * @modules * jdk.compiler/com.sun.tools.javac.api diff --git a/langtools/test/tools/javac/options/release/ReleaseOption.java b/langtools/test/tools/javac/options/release/ReleaseOption.java index 58f3a1d1cb1..2a7566aeb2e 100644 --- a/langtools/test/tools/javac/options/release/ReleaseOption.java +++ b/langtools/test/tools/javac/options/release/ReleaseOption.java @@ -1,9 +1,9 @@ /** * @test /nodynamiccopyright/ * @bug 8072480 - * @summary Verify that javac rejects Java 8 program with -release 7 + * @summary Verify that javac rejects Java 8 program with --release 7 * @compile ReleaseOption.java - * @compile/fail/ref=ReleaseOption-release7.out -XDrawDiagnostics -release 7 ReleaseOption.java + * @compile/fail/ref=ReleaseOption-release7.out -XDrawDiagnostics --release 7 ReleaseOption.java */ interface ReleaseOption extends java.util.stream.Stream { diff --git a/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java b/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java index f16e5081935..80c8f6c4d8d 100644 --- a/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java +++ b/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java @@ -24,7 +24,7 @@ /** * @test * @bug 8072480 - * @summary Verify option clash between -release and -source is reported correctly. + * @summary Verify option clash between --release and -source is reported correctly. * @modules jdk.compiler/com.sun.tools.javac.util */ @@ -62,7 +62,7 @@ public class ReleaseOptionClashes { useRawMessages.setBoolean(null, true); ByteArrayOutputStream out = new ByteArrayOutputStream(); List options = new ArrayList<>(); - options.addAll(Arrays.asList("-release", "7")); + options.addAll(Arrays.asList("--release", "7")); options.addAll(Arrays.asList(args)); options.add(System.getProperty("test.src") + File.separator + "ReleaseOptionClashes.java"); compiler.run(null, null, out, options.toArray(new String[0])); diff --git a/langtools/test/tools/javac/options/release/ReleaseOptionThroughAPI.java b/langtools/test/tools/javac/options/release/ReleaseOptionThroughAPI.java index 705b395e6f6..3196e8cbcbf 100644 --- a/langtools/test/tools/javac/options/release/ReleaseOptionThroughAPI.java +++ b/langtools/test/tools/javac/options/release/ReleaseOptionThroughAPI.java @@ -24,7 +24,7 @@ /** * @test * @bug 8072480 - * @summary Verify that javac can handle -release when invoked using the Compiler API + * @summary Verify that javac can handle --release when invoked using the Compiler API */ import java.io.IOException; @@ -50,7 +50,7 @@ public class ReleaseOptionThroughAPI { PrintWriter outWriter = new PrintWriter(out)) { Iterable input = fm.getJavaFileObjects(System.getProperty("test.src") + "/ReleaseOption.java"); - List options = Arrays.asList("-release", "7", "-XDrawDiagnostics"); + List options = Arrays.asList("--release", "7", "-XDrawDiagnostics"); compiler.getTask(outWriter, fm, null, options, null, input).call(); String expected = diff --git a/langtools/test/tools/javac/platform/PlatformProviderTest.java b/langtools/test/tools/javac/platform/PlatformProviderTest.java index 52cb7e3bb4d..2481d02d2dd 100644 --- a/langtools/test/tools/javac/platform/PlatformProviderTest.java +++ b/langtools/test/tools/javac/platform/PlatformProviderTest.java @@ -101,7 +101,7 @@ public class PlatformProviderTest implements PlatformProvider { "-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED", "-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-XDrawDiagnostics", - "-release", + "--release", platformSpec, System.getProperty("test.src") + "/PlatformProviderTestSource.java") .run(); @@ -135,7 +135,7 @@ public class PlatformProviderTest implements PlatformProvider { .options("-J--class-path=" + System.getProperty("test.classes"), "-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED", "-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", - "-release", + "--release", "fail", System.getProperty("test.src") + "/PlatformProviderTestSource.java") .run(Task.Expect.FAIL); diff --git a/langtools/test/tools/javac/sym/ElementStructureTest.java b/langtools/test/tools/javac/sym/ElementStructureTest.java index 55bc75d20e2..7a85c824be4 100644 --- a/langtools/test/tools/javac/sym/ElementStructureTest.java +++ b/langtools/test/tools/javac/sym/ElementStructureTest.java @@ -255,7 +255,7 @@ public class ElementStructureTest { } void run(Writer output, String version) throws Exception { - List options = Arrays.asList("-release", version, "-classpath", ""); + List options = Arrays.asList("--release", version, "-classpath", ""); List files = Arrays.asList(new ToolBox.JavaSource("Test", "")); JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, null, null, options, null, files); diff --git a/langtools/test/tools/javac/synthesize/Main.java b/langtools/test/tools/javac/synthesize/Main.java index 5817142cc41..d92cff2a96e 100644 --- a/langtools/test/tools/javac/synthesize/Main.java +++ b/langtools/test/tools/javac/synthesize/Main.java @@ -99,7 +99,7 @@ public class Main if (stdBootClassPath) { args.add("-Xmodule:java.base"); } else { - args.add("-system"); + args.add("--system"); args.add("none"); files.add("module-info.java"); } diff --git a/langtools/test/tools/javadoc/ReleaseOption.java b/langtools/test/tools/javadoc/ReleaseOption.java index d786e36e512..54e505c3bf1 100644 --- a/langtools/test/tools/javadoc/ReleaseOption.java +++ b/langtools/test/tools/javadoc/ReleaseOption.java @@ -34,7 +34,7 @@ import com.sun.tools.javadoc.Main; /** * @test * @bug 8086737 - * @summary Test -release option in javadoc + * @summary Test --release option in javadoc * @run main ReleaseOption */ public class ReleaseOption { @@ -43,10 +43,10 @@ public class ReleaseOption { } void run() { - doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "-release", "7"); - doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "-release", "8"); - doRunTest(1, out -> true, "-release", "7", "-source", "7"); - doRunTest(1, out -> true, "-release", "7", "-bootclasspath", "any"); + doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7"); + doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8"); + doRunTest(1, out -> true, "--release", "7", "-source", "7"); + doRunTest(1, out -> true, "--release", "7", "-bootclasspath", "any"); } void doRunTest(int expectedResult, Predicate validate, String... args) { diff --git a/langtools/test/tools/lib/toolbox/ModuleBuilder.java b/langtools/test/tools/lib/toolbox/ModuleBuilder.java index fc2b0440a57..8c7390261a2 100644 --- a/langtools/test/tools/lib/toolbox/ModuleBuilder.java +++ b/langtools/test/tools/lib/toolbox/ModuleBuilder.java @@ -205,7 +205,7 @@ public class ModuleBuilder { .collect(Collectors.joining(File.pathSeparator)); new JavacTask(tb) .outdir(Files.createDirectories(modules.resolve(name))) - .options("-mp", mp) + .options("--module-path", mp) .files(tb.findJavaFiles(moduleSrc)) .run() .writeAll(); From 7dceb3e785400ac7a2f7cc0c4694ccdc65470e2f Mon Sep 17 00:00:00 2001 From: Robert Field Date: Wed, 31 Aug 2016 10:35:51 -0700 Subject: [PATCH 052/296] 8164518: JShell: Add failover case of explicitly listening to "localhost" Reviewed-by: jlahoda --- .../share/classes/jdk/jshell/JShell.java | 5 +- .../execution/JDIDefaultExecutionControl.java | 17 +++++-- .../jdk/jshell/execution/JDIInitiator.java | 9 +++- .../JDILaunchingExecutionControlTest.java | 46 +++++++++++++++++++ .../JDIListeningExecutionControlTest.java | 4 +- ...isteningLocalhostExecutionControlTest.java | 46 +++++++++++++++++++ .../jdk/jshell/UserJDIUserRemoteTest.java | 2 +- 7 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 langtools/test/jdk/jshell/JDILaunchingExecutionControlTest.java create mode 100644 langtools/test/jdk/jshell/JDIListeningLocalhostExecutionControlTest.java diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java index a0ec79e9469..fd97832b676 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java @@ -51,8 +51,6 @@ import jdk.jshell.spi.ExecutionControl.EngineTerminationException; import jdk.jshell.spi.ExecutionControl.ExecutionControlException; import jdk.jshell.spi.ExecutionEnv; import static jdk.jshell.execution.Util.failOverExecutionControlGenerator; -import static java.util.stream.Collectors.collectingAndThen; -import static java.util.stream.Collectors.toList; import static jdk.jshell.Util.expunge; /** @@ -120,7 +118,8 @@ public class JShell implements AutoCloseable { this.executionControlGenerator = b.executionControlGenerator==null ? failOverExecutionControlGenerator( JDIDefaultExecutionControl.launch(), - JDIDefaultExecutionControl.listen()) + JDIDefaultExecutionControl.listen("localhost"), + JDIDefaultExecutionControl.listen(null)) : b.executionControlGenerator; this.maps = new SnippetMaps(this); diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java index 75f644efebd..bdf0873acab 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java @@ -77,17 +77,19 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl { * @return the generator */ public static ExecutionControl.Generator launch() { - return env -> create(env, true); + return env -> create(env, true, null); } /** * Creates an ExecutionControl instance based on a JDI * {@code ListeningConnector}. * + * @param host explicit hostname to use, if null use discovered + * hostname, applies to listening only (!isLaunch) * @return the generator */ - public static ExecutionControl.Generator listen() { - return env -> create(env, false); + public static ExecutionControl.Generator listen(String host) { + return env -> create(env, false, host); } /** @@ -100,10 +102,15 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl { * * @param env the context passed by * {@link jdk.jshell.spi.ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) } + * @param isLaunch does JDI do the launch? That is, LaunchingConnector, + * otherwise we start explicitly and use ListeningConnector + * @param host explicit hostname to use, if null use discovered + * hostname, applies to listening only (!isLaunch) * @return the channel * @throws IOException if there are errors in set-up */ - private static JDIDefaultExecutionControl create(ExecutionEnv env, boolean isLaunch) throws IOException { + private static JDIDefaultExecutionControl create(ExecutionEnv env, + boolean isLaunch, String host) throws IOException { try (final ServerSocket listener = new ServerSocket(0)) { // timeout after 60 seconds listener.setSoTimeout(60000); @@ -111,7 +118,7 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl { // Set-up the JDI connection JDIInitiator jdii = new JDIInitiator(port, - env.extraRemoteVMOptions(), REMOTE_AGENT, isLaunch); + env.extraRemoteVMOptions(), REMOTE_AGENT, isLaunch, host); VirtualMachine vm = jdii.vm(); Process process = jdii.process(); diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIInitiator.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIInitiator.java index 2c7b8d02a58..37d51db8c55 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIInitiator.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIInitiator.java @@ -56,9 +56,11 @@ public class JDIInitiator { * @param remoteAgent full class name of remote agent to launch * @param isLaunch does JDI do the launch? That is, LaunchingConnector, * otherwise we start explicitly and use ListeningConnector + * @param host explicit hostname to use, if null use discovered + * hostname, applies to listening only (!isLaunch) */ - public JDIInitiator(int port, List remoteVMOptions, - String remoteAgent, boolean isLaunch) { + public JDIInitiator(int port, List remoteVMOptions, String remoteAgent, + boolean isLaunch, String host) { this.remoteAgent = remoteAgent; String connectorName = isLaunch @@ -72,6 +74,9 @@ public class JDIInitiator { = isLaunch ? launchArgs(port, String.join(" ", remoteVMOptions)) : new HashMap<>(); + if (host != null && !isLaunch) { + argumentName2Value.put("localAddress", host); + } this.connectorArgs = mergeConnectorArgs(connector, argumentName2Value); this.vm = isLaunch ? launchTarget() diff --git a/langtools/test/jdk/jshell/JDILaunchingExecutionControlTest.java b/langtools/test/jdk/jshell/JDILaunchingExecutionControlTest.java new file mode 100644 index 00000000000..3baa5378d7b --- /dev/null +++ b/langtools/test/jdk/jshell/JDILaunchingExecutionControlTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8164518 + * @summary Tests for standard JDI connector (without failover) -- launching + * @modules jdk.jshell/jdk.jshell.execution + * @build KullaTesting ExecutionControlTestBase + * @run testng JDILaunchingExecutionControlTest + */ + + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; +import jdk.jshell.execution.JDIDefaultExecutionControl; + +@Test +public class JDILaunchingExecutionControlTest extends ExecutionControlTestBase { + + @BeforeMethod + @Override + public void setUp() { + setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.launch())); + } +} diff --git a/langtools/test/jdk/jshell/JDIListeningExecutionControlTest.java b/langtools/test/jdk/jshell/JDIListeningExecutionControlTest.java index dda377f6017..2540b90a1e3 100644 --- a/langtools/test/jdk/jshell/JDIListeningExecutionControlTest.java +++ b/langtools/test/jdk/jshell/JDIListeningExecutionControlTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8131029 8159935 8160127 + * @bug 8131029 8159935 8160127 8164518 * @summary Tests for alternate JDI connector -- listening * @modules jdk.jshell/jdk.jshell.execution * @build KullaTesting ExecutionControlTestBase @@ -41,6 +41,6 @@ public class JDIListeningExecutionControlTest extends ExecutionControlTestBase { @BeforeMethod @Override public void setUp() { - setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.listen())); + setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.listen(null))); } } diff --git a/langtools/test/jdk/jshell/JDIListeningLocalhostExecutionControlTest.java b/langtools/test/jdk/jshell/JDIListeningLocalhostExecutionControlTest.java new file mode 100644 index 00000000000..52a4487c674 --- /dev/null +++ b/langtools/test/jdk/jshell/JDIListeningLocalhostExecutionControlTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8164518 + * @summary Tests for alternate JDI connector -- listening to "localhost" + * @modules jdk.jshell/jdk.jshell.execution + * @build KullaTesting ExecutionControlTestBase + * @run testng JDIListeningLocalhostExecutionControlTest + */ + + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; +import jdk.jshell.execution.JDIDefaultExecutionControl; + +@Test +public class JDIListeningLocalhostExecutionControlTest extends ExecutionControlTestBase { + + @BeforeMethod + @Override + public void setUp() { + setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.listen("localhost"))); + } +} diff --git a/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java b/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java index e1e658ab44b..06cc2f9816a 100644 --- a/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java +++ b/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java @@ -159,7 +159,7 @@ class MyExecutionControl extends JDIExecutionControl { + System.getProperty("path.separator") + System.getProperty("user.dir")); JDIInitiator jdii = new JDIInitiator(port, - opts, REMOTE_AGENT, true); + opts, REMOTE_AGENT, true, null); VirtualMachine vm = jdii.vm(); Process process = jdii.process(); From 11de22e133261f420970aa61590de962b86f8a07 Mon Sep 17 00:00:00 2001 From: Shinya Yoshida Date: Thu, 1 Sep 2016 11:07:00 +0900 Subject: [PATCH 053/296] 8164825: jshell tool: Completion for subcommand Reviewed-by: jlahoda --- .../tool/ContinuousCompletionProvider.java | 97 ++++++++++++++++ .../jdk/internal/jshell/tool/Feedback.java | 16 +++ .../jdk/internal/jshell/tool/JShellTool.java | 104 ++++++++++++------ .../jdk/jshell/CommandCompletionTest.java | 77 ++++++++++++- 4 files changed, 262 insertions(+), 32 deletions(-) create mode 100644 langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ContinuousCompletionProvider.java diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ContinuousCompletionProvider.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ContinuousCompletionProvider.java new file mode 100644 index 00000000000..0fc6f6ca8a5 --- /dev/null +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ContinuousCompletionProvider.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.internal.jshell.tool; + +import java.util.List; +import static java.util.Comparator.comparing; +import java.util.Map; +import java.util.function.BiPredicate; +import java.util.function.Supplier; +import static java.util.stream.Collectors.toList; +import java.util.stream.Stream; +import jdk.internal.jshell.tool.JShellTool.CompletionProvider; +import jdk.jshell.SourceCodeAnalysis; +import jdk.jshell.SourceCodeAnalysis.Suggestion; + +class ContinuousCompletionProvider implements CompletionProvider { + + static final BiPredicate STARTSWITH_MATCHER = + (word, input) -> word.startsWith(input); + static final BiPredicate PERFECT_MATCHER = + (word, input) -> word.equals(input); + + private final Supplier> wordCompletionProviderSupplier; + private final BiPredicate matcher; + + ContinuousCompletionProvider( + Map wordCompletionProvider, + BiPredicate matcher) { + this(() -> wordCompletionProvider, matcher); + } + + ContinuousCompletionProvider( + Supplier> wordCompletionProviderSupplier, + BiPredicate matcher) { + this.wordCompletionProviderSupplier = wordCompletionProviderSupplier; + this.matcher = matcher; + } + + @Override + public List completionSuggestions(String input, int cursor, int[] anchor) { + String prefix = input.substring(0, cursor); + int space = prefix.indexOf(' '); + + Stream result; + + Map wordCompletionProvider = wordCompletionProviderSupplier.get(); + + if (space == (-1)) { + result = wordCompletionProvider.keySet().stream() + .distinct() + .filter(key -> key.startsWith(prefix)) + .map(key -> new JShellTool.ArgSuggestion(key + " ")); + anchor[0] = 0; + } else { + String rest = prefix.substring(space + 1); + String word = prefix.substring(0, space); + + List candidates = wordCompletionProvider.entrySet().stream() + .filter(e -> matcher.test(e.getKey(), word)) + .map(Map.Entry::getValue) + .collect(toList()); + if (candidates.size() == 1) { + result = candidates.get(0).completionSuggestions(rest, cursor - space - 1, anchor).stream(); + } else { + result = Stream.empty(); + } + anchor[0] += space + 1; + } + + return result.sorted(comparing(Suggestion::continuation)) + .collect(toList()); + } + +} diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java index 7f78c2f9962..b6d97b30215 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java @@ -35,9 +35,14 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toMap; +import static jdk.internal.jshell.tool.ContinuousCompletionProvider.PERFECT_MATCHER; +import jdk.internal.jshell.tool.JShellTool.CompletionProvider; +import static jdk.internal.jshell.tool.JShellTool.EMPTY_COMPLETION_PROVIDER; /** * Feedback customization support @@ -146,6 +151,17 @@ class Feedback { .forEach(m -> m.readOnly = true); } + JShellTool.CompletionProvider modeCompletions() { + return modeCompletions(EMPTY_COMPLETION_PROVIDER); + } + + JShellTool.CompletionProvider modeCompletions(CompletionProvider successor) { + return new ContinuousCompletionProvider( + () -> modeMap.keySet().stream() + .collect(toMap(Function.identity(), m -> successor)), + PERFECT_MATCHER); + } + { for (FormatCase e : FormatCase.all) selectorMap.put(e.name().toLowerCase(Locale.US), e); diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index fa83c0fd40e..da8d4b0de7e 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -112,6 +112,7 @@ import static jdk.internal.jshell.debug.InternalDebugControl.DBG_DEP; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_EVNT; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_FMGR; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN; +import static jdk.internal.jshell.tool.ContinuousCompletionProvider.STARTSWITH_MATCHER; /** * Command line REPL tool for Java using the JShell API. @@ -909,6 +910,7 @@ public class JShellTool implements MessageHandler { interface CompletionProvider { List completionSuggestions(String input, int cursor, int[] anchor); + } enum CommandKind { @@ -953,14 +955,31 @@ public class JShellTool implements MessageHandler { } - private static final CompletionProvider EMPTY_COMPLETION_PROVIDER = new FixedCompletionProvider(); + static final CompletionProvider EMPTY_COMPLETION_PROVIDER = new FixedCompletionProvider(); private static final CompletionProvider KEYWORD_COMPLETION_PROVIDER = new FixedCompletionProvider("-all ", "-start ", "-history "); private static final CompletionProvider RELOAD_OPTIONS_COMPLETION_PROVIDER = new FixedCompletionProvider("-restore", "-quiet"); + private static final CompletionProvider SET_MODE_OPTIONS_COMPLETION_PROVIDER = new FixedCompletionProvider("-command", "-quiet", "-delete"); private static final CompletionProvider FILE_COMPLETION_PROVIDER = fileCompletions(p -> true); private final Map commands = new LinkedHashMap<>(); private void registerCommand(Command cmd) { commands.put(cmd.command, cmd); } + + private static CompletionProvider skipWordThenCompletion(CompletionProvider completionProvider) { + return (input, cursor, anchor) -> { + List result = Collections.emptyList(); + + int space = input.indexOf(' '); + if (space != -1) { + String rest = input.substring(space + 1); + result = completionProvider.completionSuggestions(rest, cursor - space - 1, anchor); + anchor[0] += space + 1; + } + + return result; + }; + } + private static CompletionProvider fileCompletions(Predicate accept) { return (code, cursor, anchor) -> { int lastSlash = code.lastIndexOf('/'); @@ -1037,6 +1056,31 @@ public class JShellTool implements MessageHandler { }; } + private static CompletionProvider orMostSpecificCompletion( + CompletionProvider left, CompletionProvider right) { + return (code, cursor, anchor) -> { + int[] leftAnchor = {-1}; + int[] rightAnchor = {-1}; + + List leftSuggestions = left.completionSuggestions(code, cursor, leftAnchor); + List rightSuggestions = right.completionSuggestions(code, cursor, rightAnchor); + + List suggestions = new ArrayList<>(); + + if (leftAnchor[0] >= rightAnchor[0]) { + anchor[0] = leftAnchor[0]; + suggestions.addAll(leftSuggestions); + } + + if (leftAnchor[0] <= rightAnchor[0]) { + anchor[0] = rightAnchor[0]; + suggestions.addAll(rightSuggestions); + } + + return suggestions; + }; + } + // Snippet lists Stream allSnippets() { @@ -1123,10 +1167,26 @@ public class JShellTool implements MessageHandler { EMPTY_COMPLETION_PROVIDER)); registerCommand(new Command("/set", arg -> cmdSet(arg), - new FixedCompletionProvider(SET_SUBCOMMANDS))); + new ContinuousCompletionProvider(Map.of( + // need more completion for format for usability + "format", feedback.modeCompletions(), + "truncation", feedback.modeCompletions(), + "feedback", feedback.modeCompletions(), + "mode", skipWordThenCompletion(orMostSpecificCompletion( + feedback.modeCompletions(SET_MODE_OPTIONS_COMPLETION_PROVIDER), + SET_MODE_OPTIONS_COMPLETION_PROVIDER)), + "prompt", feedback.modeCompletions(), + "editor", fileCompletions(Files::isExecutable), + "start", FILE_COMPLETION_PROVIDER), + STARTSWITH_MATCHER))); registerCommand(new Command("/retain", arg -> cmdRetain(arg), - new FixedCompletionProvider(RETAIN_SUBCOMMANDS))); + new ContinuousCompletionProvider(Map.of( + "feedback", feedback.modeCompletions(), + "mode", feedback.modeCompletions(), + "editor", fileCompletions(Files::isExecutable), + "start", FILE_COMPLETION_PROVIDER), + STARTSWITH_MATCHER))); registerCommand(new Command("/?", "help.quest", arg -> cmdHelp(arg), @@ -1151,36 +1211,18 @@ public class JShellTool implements MessageHandler { registerCommand(new Command("shortcuts", "help.shortcuts", CommandKind.HELP_SUBJECT)); + + commandCompletions = new ContinuousCompletionProvider( + commands.values().stream() + .filter(c -> c.kind.shouldSuggestCompletions) + .collect(toMap(c -> c.command, c -> c.completions)), + STARTSWITH_MATCHER); } + private ContinuousCompletionProvider commandCompletions; + public List commandCompletionSuggestions(String code, int cursor, int[] anchor) { - String prefix = code.substring(0, cursor); - int space = prefix.indexOf(' '); - Stream result; - - if (space == (-1)) { - result = commands.values() - .stream() - .distinct() - .filter(cmd -> cmd.kind.shouldSuggestCompletions) - .map(cmd -> cmd.command) - .filter(key -> key.startsWith(prefix)) - .map(key -> new ArgSuggestion(key + " ")); - anchor[0] = 0; - } else { - String arg = prefix.substring(space + 1); - String cmd = prefix.substring(0, space); - Command[] candidates = findCommand(cmd, c -> true); - if (candidates.length == 1) { - result = candidates[0].completions.completionSuggestions(arg, cursor - space, anchor).stream(); - anchor[0] += space + 1; - } else { - result = Stream.empty(); - } - } - - return result.sorted((s1, s2) -> s1.continuation().compareTo(s2.continuation())) - .collect(Collectors.toList()); + return commandCompletions.completionSuggestions(code, cursor, anchor); } public String commandDocumentation(String code, int cursor) { @@ -2484,7 +2526,7 @@ public class JShellTool implements MessageHandler { } } - private static class ArgSuggestion implements Suggestion { + static class ArgSuggestion implements Suggestion { private final String continuation; diff --git a/langtools/test/jdk/jshell/CommandCompletionTest.java b/langtools/test/jdk/jshell/CommandCompletionTest.java index 6544084a133..ad01de44959 100644 --- a/langtools/test/jdk/jshell/CommandCompletionTest.java +++ b/langtools/test/jdk/jshell/CommandCompletionTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8144095 + * @bug 8144095 8164825 * @summary Test Command Completion * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -40,6 +40,7 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.function.Predicate; @@ -148,6 +149,80 @@ public class CommandCompletionTest extends ReplToolTesting { assertCompletion("/classpath ~/|", false, completions.toArray(new String[completions.size()])); } + public void testSet() throws IOException { + List p1 = listFiles(Paths.get("")); + FileSystems.getDefault().getRootDirectories().forEach(s -> p1.add(s.toString())); + Collections.sort(p1); + + String[] modes = {"concise ", "normal ", "silent ", "verbose "}; + String[] options = {"-command", "-delete", "-quiet"}; + String[] modesWithOptions = Stream.concat(Arrays.stream(options), Arrays.stream(modes)).sorted().toArray(String[]::new); + test(false, new String[] {"--no-startup"}, + a -> assertCompletion(a, "/se|", false, "/set "), + a -> assertCompletion(a, "/set |", false, "editor ", "feedback ", "format ", "mode ", "prompt ", "start ", "truncation "), + + // /set editor + a -> assertCompletion(a, "/set e|", false, "editor "), + a -> assertCompletion(a, "/set editor |", false, p1.toArray(new String[p1.size()])), + + // /set feedback + a -> assertCompletion(a, "/set fe|", false, "feedback "), + a -> assertCompletion(a, "/set fe |", false, modes), + + // /set format + a -> assertCompletion(a, "/set fo|", false, "format "), + a -> assertCompletion(a, "/set fo |", false, modes), + + // /set mode + a -> assertCompletion(a, "/set mo|", false, "mode "), + a -> assertCompletion(a, "/set mo |", false), + a -> assertCompletion(a, "/set mo newmode |", false, modesWithOptions), + a -> assertCompletion(a, "/set mo newmode -|", false, options), + a -> assertCompletion(a, "/set mo newmode -command |", false), + a -> assertCompletion(a, "/set mo newmode normal |", false, options), + + // /set prompt + a -> assertCompletion(a, "/set pro|", false, "prompt "), + a -> assertCompletion(a, "/set pro |", false, modes), + + // /set start + a -> assertCompletion(a, "/set st|", false, "start "), + a -> assertCompletion(a, "/set st |", false, p1.toArray(new String[p1.size()])), + + // /set truncation + a -> assertCompletion(a, "/set tr|", false, "truncation "), + a -> assertCompletion(a, "/set tr |", false, modes) + ); + } + + public void testRetain() throws IOException { + List p1 = listFiles(Paths.get("")); + FileSystems.getDefault().getRootDirectories().forEach(s -> p1.add(s.toString())); + Collections.sort(p1); + + String[] modes = {"concise ", "normal ", "silent ", "verbose "}; + test(false, new String[] {"--no-startup"}, + a -> assertCompletion(a, "/ret|", false, "/retain "), + a -> assertCompletion(a, "/retain |", false, "editor ", "feedback ", "mode ", "start "), + + // /retain editor + a -> assertCompletion(a, "/retain e|", false, "editor "), + a -> assertCompletion(a, "/retain editor |", false, p1.toArray(new String[p1.size()])), + + // /retain feedback + a -> assertCompletion(a, "/retain fe|", false, "feedback "), + a -> assertCompletion(a, "/retain fe |", false, modes), + + // /retain mode + a -> assertCompletion(a, "/retain mo|", false, "mode "), + a -> assertCompletion(a, "/retain mo |", false, modes), + + // /retain start + a -> assertCompletion(a, "/retain st|", false, "start "), + a -> assertCompletion(a, "/retain st |", false, p1.toArray(new String[p1.size()])) + ); + } + private void createIfNeeded(Path file) throws IOException { if (!Files.exists(file)) Files.createFile(file); From 9f1556675ecc9af52c915842b5f6c42df0c1ec92 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Thu, 1 Sep 2016 13:18:42 +0800 Subject: [PATCH 054/296] 8165193: Workaround intermittent failures of JavacTreeScannerTest and SourceTreeScannerTest due to C2 memory usage Reviewed-by: darcy --- langtools/test/tools/javac/tree/JavacTreeScannerTest.java | 4 ++-- langtools/test/tools/javac/tree/SourceTreeScannerTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/langtools/test/tools/javac/tree/JavacTreeScannerTest.java b/langtools/test/tools/javac/tree/JavacTreeScannerTest.java index e2b7676add3..24519b4cd83 100644 --- a/langtools/test/tools/javac/tree/JavacTreeScannerTest.java +++ b/langtools/test/tools/javac/tree/JavacTreeScannerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -41,7 +41,7 @@ * jdk.compiler/com.sun.tools.javac.tree * jdk.compiler/com.sun.tools.javac.util * @build AbstractTreeScannerTest JavacTreeScannerTest - * @run main JavacTreeScannerTest -q -r . + * @run main/othervm JavacTreeScannerTest -q -r . */ import java.io.*; diff --git a/langtools/test/tools/javac/tree/SourceTreeScannerTest.java b/langtools/test/tools/javac/tree/SourceTreeScannerTest.java index 5882037e1f6..1d1bc2cc0df 100644 --- a/langtools/test/tools/javac/tree/SourceTreeScannerTest.java +++ b/langtools/test/tools/javac/tree/SourceTreeScannerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -41,7 +41,7 @@ * jdk.compiler/com.sun.tools.javac.tree * jdk.compiler/com.sun.tools.javac.util * @build AbstractTreeScannerTest SourceTreeScannerTest - * @run main SourceTreeScannerTest -q -r . + * @run main/othervm SourceTreeScannerTest -q -r . */ import java.io.*; From 74e01787b3dd7329cc7e395156d3c0a54540d421 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 1 Sep 2016 10:30:50 +0200 Subject: [PATCH 055/296] 8131023: JShell: System.in does not work Pass user input to snippets/remote agent Reviewed-by: rfield --- .../jshell/tool/ConsoleIOContext.java | 36 ++++++ .../jdk/internal/jshell/tool/IOContext.java | 2 + .../jdk/internal/jshell/tool/JShellTool.java | 41 ++++++- .../jshell/execution/DemultiplexInput.java | 29 +++-- .../execution/JDIDefaultExecutionControl.java | 23 ++-- .../execution/MultiplexingOutputStream.java | 18 ++- .../jdk/jshell/execution/PipeInputStream.java | 29 ++++- .../execution/RemoteExecutionControl.java | 10 +- .../classes/jdk/jshell/execution/Util.java | 109 ++++++++++-------- .../test/jdk/jshell/ReplToolTesting.java | 3 +- .../test/jdk/jshell/StartOptionTest.java | 1 - langtools/test/jdk/jshell/UserInputTest.java | 44 +++++++ .../jdk/jshell/UserJDIUserRemoteTest.java | 32 ++--- 13 files changed, 265 insertions(+), 112 deletions(-) create mode 100644 langtools/test/jdk/jshell/UserInputTest.java diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java index ca475115c10..b4df8efbe54 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java @@ -57,6 +57,8 @@ import jdk.internal.jline.console.ConsoleReader; import jdk.internal.jline.console.KeyMap; import jdk.internal.jline.console.UserInterruptException; import jdk.internal.jline.console.completer.Completer; +import jdk.internal.jline.console.history.History; +import jdk.internal.jline.console.history.MemoryHistory; import jdk.internal.jline.extra.EditingHistory; import jdk.internal.jshell.tool.StopDetectingInputStream.State; @@ -68,6 +70,7 @@ class ConsoleIOContext extends IOContext { final StopDetectingInputStream input; final ConsoleReader in; final EditingHistory history; + final MemoryHistory userInputHistory = new MemoryHistory(); String prefix = ""; @@ -299,6 +302,9 @@ class ConsoleIOContext extends IOContext { } public void beforeUserCode() { + synchronized (this) { + inputBytes = null; + } input.setState(State.BUFFER); } @@ -380,6 +386,36 @@ class ConsoleIOContext extends IOContext { } } + private byte[] inputBytes; + private int inputBytesPointer; + + @Override + public synchronized int readUserInput() { + while (inputBytes == null || inputBytes.length <= inputBytesPointer) { + boolean prevHandleUserInterrupt = in.getHandleUserInterrupt(); + History prevHistory = in.getHistory(); + + try { + input.setState(State.WAIT); + in.setHandleUserInterrupt(true); + in.setHistory(userInputHistory); + inputBytes = (in.readLine("") + System.getProperty("line.separator")).getBytes(); + inputBytesPointer = 0; + } catch (IOException ex) { + ex.printStackTrace(); + return -1; + } catch (UserInterruptException ex) { + repl.state.stop(); + return -1; + } finally { + in.setHistory(prevHistory); + in.setHandleUserInterrupt(prevHandleUserInterrupt); + input.setState(State.BUFFER); + } + } + return inputBytes[inputBytesPointer++]; + } + /** * A possible action which the user can choose to perform. */ diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/IOContext.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/IOContext.java index 8f8606fed05..4f4a51a44b0 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/IOContext.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/IOContext.java @@ -54,6 +54,8 @@ abstract class IOContext implements AutoCloseable { public abstract void replaceLastHistoryEntry(String source); + public abstract int readUserInput(); + class InputInterruptedException extends Exception { private static final long serialVersionUID = 1L; } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index da8d4b0de7e..203132444f2 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -26,7 +26,6 @@ package jdk.internal.jshell.tool; import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; @@ -139,6 +138,25 @@ public class JShellTool implements MessageHandler { final Feedback feedback = new Feedback(); + /** + * The constructor for the tool (used by tool launch via main and by test + * harnesses to capture ins and outs. + * @param in command line input -- snippets, commands and user input + * @param cmdout command line output, feedback including errors + * @param cmderr start-up errors and debugging info + * @param console console control interaction + * @param userout code execution output -- System.out.printf("hi") + * @param usererr code execution error stream -- System.err.printf("Oops") + * @param prefs preferences to use + * @param locale locale to use + */ + public JShellTool(InputStream in, PrintStream cmdout, PrintStream cmderr, + PrintStream console, + PrintStream userout, PrintStream usererr, + Preferences prefs, Locale locale) { + this(in, cmdout, cmderr, console, null, userout, usererr, prefs, locale); + } + /** * The constructor for the tool (used by tool launch via main and by test * harnesses to capture ins and outs. @@ -146,7 +164,7 @@ public class JShellTool implements MessageHandler { * @param cmdout command line output, feedback including errors * @param cmderr start-up errors and debugging info * @param console console control interaction - * @param userin code execution input (not yet functional) + * @param userin code execution input, or null to use IOContext * @param userout code execution output -- System.out.printf("hi") * @param usererr code execution error stream -- System.err.printf("Oops") * @param prefs preferences to use @@ -160,7 +178,12 @@ public class JShellTool implements MessageHandler { this.cmdout = cmdout; this.cmderr = cmderr; this.console = console; - this.userin = userin; + this.userin = userin != null ? userin : new InputStream() { + @Override + public int read() throws IOException { + return input.readUserInput(); + } + }; this.userout = userout; this.usererr = usererr; this.prefs = prefs; @@ -452,7 +475,7 @@ public class JShellTool implements MessageHandler { */ public static void main(String[] args) throws Exception { new JShellTool(System.in, System.out, System.err, System.out, - new ByteArrayInputStream(new byte[0]), System.out, System.err, + System.out, System.err, Preferences.userRoot().node("tool/JShell"), Locale.getDefault()) .start(args); @@ -2621,6 +2644,11 @@ class ScannerIOContext extends NonInteractiveIOContext { public void close() { scannerIn.close(); } + + @Override + public int readUserInput() { + return -1; + } } class FileScannerIOContext extends ScannerIOContext { @@ -2659,4 +2687,9 @@ class ReloadIOContext extends NonInteractiveIOContext { @Override public void close() { } + + @Override + public int readUserInput() { + return -1; + } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DemultiplexInput.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DemultiplexInput.java index ca400d536d0..09912801f7b 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DemultiplexInput.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DemultiplexInput.java @@ -40,15 +40,14 @@ import java.util.Map; class DemultiplexInput extends Thread { private final DataInputStream delegate; - private final PipeInputStream command; private final Map io; + private final Iterable closeList; - DemultiplexInput(InputStream input, PipeInputStream command, - Map io) { + DemultiplexInput(InputStream input, Map io, Iterable closeList) { super("output reader"); this.delegate = new DataInputStream(input); - this.command = command; this.io = io; + this.closeList = closeList; } @Override @@ -65,23 +64,23 @@ class DemultiplexInput extends Thread { byte[] data = new byte[dataLen]; DemultiplexInput.this.delegate.readFully(data); String chan = new String(name, "UTF-8"); - if (chan.equals("command")) { - for (byte b : data) { - command.write(Byte.toUnsignedInt(b)); - } + OutputStream out = io.get(chan); + if (out == null) { + debug("Unexpected channel name: %s", chan); } else { - OutputStream out = io.get(chan); - if (out == null) { - debug("Unexpected channel name: %s", chan); - } else { - out.write(data); - } + out.write(data); } } } catch (IOException ex) { debug(ex, "Failed reading output"); } finally { - command.close(); + for (OutputStream out : closeList) { + try { + out.close(); + } catch (IOException ex) { + debug(ex, "Failed reading output"); + } + } } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java index bdf0873acab..18f8282f93b 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java @@ -25,9 +25,9 @@ package jdk.jshell.execution; import java.io.IOException; +import java.io.InputStream; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.io.ObjectOutputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; @@ -48,7 +48,7 @@ import com.sun.jdi.VMDisconnectedException; import com.sun.jdi.VirtualMachine; import jdk.jshell.spi.ExecutionControl; import jdk.jshell.spi.ExecutionEnv; -import static jdk.jshell.execution.Util.remoteInput; +import static jdk.jshell.execution.Util.remoteInputOutput; /** * The implementation of {@link jdk.jshell.spi.ExecutionControl} that the @@ -109,7 +109,7 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl { * @return the channel * @throws IOException if there are errors in set-up */ - private static JDIDefaultExecutionControl create(ExecutionEnv env, + private static ExecutionControl create(ExecutionEnv env, boolean isLaunch, String host) throws IOException { try (final ServerSocket listener = new ServerSocket(0)) { // timeout after 60 seconds @@ -122,10 +122,6 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl { VirtualMachine vm = jdii.vm(); Process process = jdii.process(); - // Forward input to the remote agent - Util.forwardInputToRemote(env.userIn(), process.getOutputStream(), - ex -> debug(ex, "input forwarding failure")); - List> deathListeners = new ArrayList<>(); deathListeners.add(s -> env.closeDown()); Util.detectJDIExitEvent(vm, s -> { @@ -138,12 +134,13 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl { // output. Socket socket = listener.accept(); // out before in -- match remote creation so we don't hang - ObjectOutput cmdout = new ObjectOutputStream(socket.getOutputStream()); - Map io = new HashMap<>(); - io.put("out", env.userOut()); - io.put("err", env.userErr()); - ObjectInput cmdin = remoteInput(socket.getInputStream(), io); - return new JDIDefaultExecutionControl(cmdout, cmdin, vm, process, deathListeners); + OutputStream out = socket.getOutputStream(); + Map outputs = new HashMap<>(); + outputs.put("out", env.userOut()); + outputs.put("err", env.userErr()); + Map input = new HashMap<>(); + input.put("in", env.userIn()); + return remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new JDIDefaultExecutionControl(objOut, objIn, vm, process, deathListeners)); } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/MultiplexingOutputStream.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/MultiplexingOutputStream.java index 43e3bc52287..4cc13d8673a 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/MultiplexingOutputStream.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/MultiplexingOutputStream.java @@ -50,13 +50,7 @@ class MultiplexingOutputStream extends OutputStream { @Override public void write(int b) throws IOException { - synchronized (delegate) { - delegate.write(name.length); //assuming the len is small enough to fit into byte - delegate.write(name); - delegate.write(1); - delegate.write(b); - delegate.flush(); - } + write(new byte[] {(byte) b}); } @Override @@ -65,10 +59,12 @@ class MultiplexingOutputStream extends OutputStream { int i = 0; while (len > 0) { int size = Math.min(PACKET_SIZE, len); - delegate.write(name.length); //assuming the len is small enough to fit into byte - delegate.write(name); - delegate.write(size); - delegate.write(b, off + i, size); + byte[] data = new byte[name.length + 1 + size + 1]; + data[0] = (byte) name.length; //assuming the len is small enough to fit into byte + System.arraycopy(name, 0, data, 1, name.length); + data[name.length + 1] = (byte) size; + System.arraycopy(b, off + i, data, name.length + 2, size); + delegate.write(data); i += size; len -= size; } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/PipeInputStream.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/PipeInputStream.java index 1470827ff29..1b582fa9b10 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/PipeInputStream.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/PipeInputStream.java @@ -24,7 +24,9 @@ */ package jdk.jshell.execution; +import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; /** * @@ -39,7 +41,10 @@ class PipeInputStream extends InputStream { private boolean closed; @Override - public synchronized int read() { + public synchronized int read() throws IOException { + if (start == end) { + inputNeeded(); + } while (start == end) { if (closed) { return -1; @@ -57,7 +62,9 @@ class PipeInputStream extends InputStream { } } - public synchronized void write(int b) { + protected void inputNeeded() throws IOException {} + + private synchronized void write(int b) { if (closed) { throw new IllegalStateException("Already closed."); } @@ -85,4 +92,22 @@ class PipeInputStream extends InputStream { notifyAll(); } + public OutputStream createOutput() { + return new OutputStream() { + @Override public void write(int b) throws IOException { + PipeInputStream.this.write(b); + } + @Override + public void write(byte[] b, int off, int len) throws IOException { + for (int i = 0 ; i < len ; i++) { + write(Byte.toUnsignedInt(b[off + i])); + } + } + @Override + public void close() throws IOException { + PipeInputStream.this.close(); + } + }; + } + } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java index 9ea549c5fdb..8a131422b5a 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java @@ -61,10 +61,12 @@ public class RemoteExecutionControl extends DirectExecutionControl implements Ex Socket socket = new Socket(loopBack, Integer.parseInt(args[0])); InputStream inStream = socket.getInputStream(); OutputStream outStream = socket.getOutputStream(); - Map> chans = new HashMap<>(); - chans.put("out", st -> System.setOut(new PrintStream(st, true))); - chans.put("err", st -> System.setErr(new PrintStream(st, true))); - forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, chans); + Map> outputs = new HashMap<>(); + outputs.put("out", st -> System.setOut(new PrintStream(st, true))); + outputs.put("err", st -> System.setErr(new PrintStream(st, true))); + Map> input = new HashMap<>(); + input.put("in", st -> System.setIn(st)); + forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, outputs, input); } // These three variables are used by the main JShell process in interrupting diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java index 9f1521572ff..da8decab065 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java @@ -25,6 +25,7 @@ package jdk.jshell.execution; import jdk.jshell.spi.ExecutionEnv; + import java.io.IOException; import java.io.InputStream; import java.io.ObjectInput; @@ -32,9 +33,13 @@ import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.io.OutputStream; +import java.util.Arrays; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.function.BiFunction; import java.util.function.Consumer; + import com.sun.jdi.VirtualMachine; import jdk.jshell.spi.ExecutionControl; @@ -99,21 +104,40 @@ public class Util { * instance, then responses back on the output. * @param ec the direct instance of {@link ExecutionControl} to process commands * @param inStream the stream from which to create the command input - * @param outStream the stream that will carry {@code System.out}, - * {@code System.err}, any specified auxiliary channels, and the - * command response output. - * @param streamMap a map between names of additional streams to carry and setters - * for the stream + * @param outStream the stream that will carry any specified auxiliary channels (like + * {@code System.out} and {@code System.err}), and the command response output. + * @param outputStreamMap a map between names of additional streams to carry and setters + * for the stream. Names starting with '$' are reserved for internal use. + * @param inputStreamMap a map between names of additional streams to carry and setters + * for the stream. Names starting with '$' are reserved for internal use. * @throws IOException if there are errors using the passed streams */ public static void forwardExecutionControlAndIO(ExecutionControl ec, InputStream inStream, OutputStream outStream, - Map> streamMap) throws IOException { - ObjectInputStream cmdIn = new ObjectInputStream(inStream); - for (Entry> e : streamMap.entrySet()) { + Map> outputStreamMap, + Map> inputStreamMap) throws IOException { + for (Entry> e : outputStreamMap.entrySet()) { e.getValue().accept(multiplexingOutputStream(e.getKey(), outStream)); } - ObjectOutputStream cmdOut = new ObjectOutputStream(multiplexingOutputStream("command", outStream)); + + ObjectOutputStream cmdOut = new ObjectOutputStream(multiplexingOutputStream("$command", outStream)); + PipeInputStream cmdInPipe = new PipeInputStream(); + Map inputs = new HashMap<>(); + inputs.put("$command", cmdInPipe.createOutput()); + for (Entry> e : inputStreamMap.entrySet()) { + OutputStream inputSignal = multiplexingOutputStream("$" + e.getKey() + "-input-requested", outStream); + PipeInputStream inputPipe = new PipeInputStream() { + @Override protected void inputNeeded() throws IOException { + inputSignal.write('1'); + inputSignal.flush(); + } + }; + inputs.put(e.getKey(), inputPipe.createOutput()); + e.getValue().accept(inputPipe); + } + new DemultiplexInput(inStream, inputs, inputs.values()).start(); + ObjectInputStream cmdIn = new ObjectInputStream(cmdInPipe); + forwardExecutionControl(ec, cmdIn, cmdOut); } @@ -122,18 +146,41 @@ public class Util { } /** - * Reads from an InputStream which has been packetized and write its contents - * to the out and err OutputStreams; Copies the command stream. + * Creates an ExecutionControl for given packetized input and output. The given InputStream + * is de-packetized, and content forwarded to ObjectInput and given OutputStreams. The ObjectOutput + * and values read from the given InputStream are packetized and sent to the given OutputStream. + * * @param input the packetized input stream - * @param streamMap a map between stream names and the output streams to forward - * @return the command stream + * @param output the packetized output stream + * @param outputStreamMap a map between stream names and the output streams to forward. + * Names starting with '$' are reserved for internal use. + * @param inputStreamMap a map between stream names and the input streams to forward. + * Names starting with '$' are reserved for internal use. + * @param factory to create the ExecutionControl from ObjectInput and ObjectOutput. + * @return the created ExecutionControl * @throws IOException if setting up the streams raised an exception */ - public static ObjectInput remoteInput(InputStream input, - Map streamMap) throws IOException { + public static ExecutionControl remoteInputOutput(InputStream input, OutputStream output, + Map outputStreamMap, Map inputStreamMap, + BiFunction factory) throws IOException { + Map augmentedStreamMap = new HashMap<>(outputStreamMap); + ObjectOutput commandOut = new ObjectOutputStream(Util.multiplexingOutputStream("$command", output)); + for (Entry e : inputStreamMap.entrySet()) { + InputStream in = e.getValue(); + OutputStream inTarget = Util.multiplexingOutputStream(e.getKey(), output); + augmentedStreamMap.put("$" + e.getKey() + "-input-requested", new OutputStream() { + @Override + public void write(int b) throws IOException { + //value ignored, just a trigger to read from the input + inTarget.write(in.read()); + } + }); + } PipeInputStream commandIn = new PipeInputStream(); - new DemultiplexInput(input, commandIn, streamMap).start(); - return new ObjectInputStream(commandIn); + OutputStream commandInTarget = commandIn.createOutput(); + augmentedStreamMap.put("$command", commandInTarget); + new DemultiplexInput(input, augmentedStreamMap, Arrays.asList(commandInTarget)).start(); + return factory.apply(new ObjectInputStream(commandIn), commandOut); } /** @@ -151,32 +198,4 @@ public class Util { } } - /** - * Creates a Thread that will ship all input to the remote agent. - * - * @param inputStream the user input - * @param outStream the input to the remote agent - * @param handler a failure handler - */ - public static void forwardInputToRemote(final InputStream inputStream, - final OutputStream outStream, final Consumer handler) { - Thread thr = new Thread("input reader") { - @Override - public void run() { - try { - byte[] buf = new byte[256]; - int cnt; - while ((cnt = inputStream.read(buf)) != -1) { - outStream.write(buf, 0, cnt); - outStream.flush(); - } - } catch (Exception ex) { - handler.accept(ex); - } - } - }; - thr.setPriority(Thread.MAX_PRIORITY - 1); - thr.start(); - } - } diff --git a/langtools/test/jdk/jshell/ReplToolTesting.java b/langtools/test/jdk/jshell/ReplToolTesting.java index a2e80a78260..23c70af0690 100644 --- a/langtools/test/jdk/jshell/ReplToolTesting.java +++ b/langtools/test/jdk/jshell/ReplToolTesting.java @@ -247,7 +247,6 @@ public class ReplToolTesting { new PrintStream(cmdout), new PrintStream(cmderr), new PrintStream(console), - userin, new PrintStream(userout), new PrintStream(usererr), prefs, @@ -463,7 +462,7 @@ public class ReplToolTesting { private List computeCompletions(String code, boolean isSmart) { JShellTool js = this.repl != null ? this.repl - : new JShellTool(null, null, null, null, null, null, null, prefs, Locale.ROOT); + : new JShellTool(null, null, null, null, null, null, prefs, Locale.ROOT); int cursor = code.indexOf('|'); code = code.replace("|", ""); assertTrue(cursor > -1, "'|' not found: " + code); diff --git a/langtools/test/jdk/jshell/StartOptionTest.java b/langtools/test/jdk/jshell/StartOptionTest.java index 5ca48854341..dbbbf0943f6 100644 --- a/langtools/test/jdk/jshell/StartOptionTest.java +++ b/langtools/test/jdk/jshell/StartOptionTest.java @@ -63,7 +63,6 @@ public class StartOptionTest { new PrintStream(cmdout), new PrintStream(cmderr), new PrintStream(console), - new TestingInputStream(), new PrintStream(userout), new PrintStream(usererr), new ReplToolTesting.MemoryPreferences(), diff --git a/langtools/test/jdk/jshell/UserInputTest.java b/langtools/test/jdk/jshell/UserInputTest.java new file mode 100644 index 00000000000..5289ab7c56b --- /dev/null +++ b/langtools/test/jdk/jshell/UserInputTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8131023 + * @summary Verify that the user's code can read System.in + * @build KullaTesting TestingInputStream + * @run testng UserInputTest + */ + +import org.testng.annotations.Test; + +@Test +public class UserInputTest extends KullaTesting { + + public void testReadInput() { + setInput("AB\n"); + assertEval("System.in.read()", "65"); + setInput("BC\n"); + assertEval("System.in.read()", "66"); + } + +} diff --git a/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java b/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java index 06cc2f9816a..bfd04a1289c 100644 --- a/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java +++ b/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java @@ -37,7 +37,6 @@ import static jdk.jshell.Snippet.Status.VALID; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.io.ObjectOutputStream; import java.net.ServerSocket; import java.util.ArrayList; import java.util.List; @@ -62,7 +61,7 @@ import jdk.jshell.spi.ExecutionEnv; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; import static jdk.jshell.execution.Util.forwardExecutionControlAndIO; -import static jdk.jshell.execution.Util.remoteInput; +import static jdk.jshell.execution.Util.remoteInputOutput; @Test public class UserJDIUserRemoteTest extends ExecutionControlTestBase { @@ -146,7 +145,7 @@ class MyExecutionControl extends JDIExecutionControl { * @return the channel * @throws IOException if there are errors in set-up */ - static MyExecutionControl make(ExecutionEnv env, UserJDIUserRemoteTest test) throws IOException { + static ExecutionControl make(ExecutionEnv env, UserJDIUserRemoteTest test) throws IOException { try (final ServerSocket listener = new ServerSocket(0)) { // timeout after 60 seconds listener.setSoTimeout(60000); @@ -175,13 +174,14 @@ class MyExecutionControl extends JDIExecutionControl { // output. Socket socket = listener.accept(); // out before in -- match remote creation so we don't hang - ObjectOutput cmdout = new ObjectOutputStream(socket.getOutputStream()); - Map io = new HashMap<>(); - io.put("out", env.userOut()); - io.put("err", env.userErr()); - io.put("aux", test.auxStream); - ObjectInput cmdin = remoteInput(socket.getInputStream(), io); - MyExecutionControl myec = new MyExecutionControl(cmdout, cmdin, vm, process, deathListeners); + OutputStream out = socket.getOutputStream(); + Map outputs = new HashMap<>(); + outputs.put("out", env.userOut()); + outputs.put("err", env.userErr()); + outputs.put("aux", test.auxStream); + Map input = new HashMap<>(); + input.put("in", env.userIn()); + ExecutionControl myec = remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new MyExecutionControl(objOut, objIn, vm, process, deathListeners)); test.currentEC = myec; return myec; } @@ -255,11 +255,13 @@ class MyRemoteExecutionControl extends DirectExecutionControl implements Executi Socket socket = new Socket(loopBack, Integer.parseInt(args[0])); InputStream inStream = socket.getInputStream(); OutputStream outStream = socket.getOutputStream(); - Map> chans = new HashMap<>(); - chans.put("out", st -> System.setOut(new PrintStream(st, true))); - chans.put("err", st -> System.setErr(new PrintStream(st, true))); - chans.put("aux", st -> { auxPrint = new PrintStream(st, true); }); - forwardExecutionControlAndIO(new MyRemoteExecutionControl(), inStream, outStream, chans); + Map> outputs = new HashMap<>(); + outputs.put("out", st -> System.setOut(new PrintStream(st, true))); + outputs.put("err", st -> System.setErr(new PrintStream(st, true))); + outputs.put("aux", st -> { auxPrint = new PrintStream(st, true); }); + Map> input = new HashMap<>(); + input.put("in", st -> System.setIn(st)); + forwardExecutionControlAndIO(new MyRemoteExecutionControl(), inStream, outStream, outputs, input); } catch (Throwable ex) { throw ex; } From 161e3c650ab658a745bb1bfa0113105bc20e194a Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 29 Aug 2016 15:53:03 +0200 Subject: [PATCH 056/296] 8165008: javac -Xmodule compiles the module in a way that reads the unnamed module Ensuring proper separation between named modules and the unnamed module when using -Xmodule Reviewed-by: jjg --- .../com/sun/tools/javac/code/ClassFinder.java | 35 +---- .../com/sun/tools/javac/comp/Modules.java | 5 +- .../test/tools/javac/modules/XModuleTest.java | 132 +++++++++++++++++- 3 files changed, 134 insertions(+), 38 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java index d928ee13f3a..7cccabeb5bd 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java @@ -119,10 +119,6 @@ public class ClassFinder { */ final Name completionFailureName; - /** Module specified with -Xmodule: - */ - final Name moduleOverride; - /** Access to files */ private final JavaFileManager fileManager; @@ -210,9 +206,6 @@ public class ClassFinder { ? names.fromString(options.get("failcomplete")) : null; - moduleOverride = options.isSet(Option.XMODULE) ? names.fromString(options.get(Option.XMODULE)) - : null; - // Temporary, until more info is available from the module system. boolean useCtProps; JavaFileManager fm = context.get(JavaFileManager.class); @@ -527,16 +520,15 @@ public class ClassFinder { if (msym == syms.noModule) { preferCurrent = false; if (userPathsFirst) { - scanUserPaths(p); + scanUserPaths(p, true); preferCurrent = true; scanPlatformPath(p); } else { scanPlatformPath(p); - scanUserPaths(p); + scanUserPaths(p, true); } } else if (msym.classLocation == StandardLocation.CLASS_PATH) { - // assert p.modle.sourceLocation == StandardLocation.SOURCE_PATH); - scanUserPaths(p); + scanUserPaths(p, msym.sourceLocation == StandardLocation.SOURCE_PATH); } else { scanModulePaths(p, msym); } @@ -561,23 +553,6 @@ public class ClassFinder { String packageName = p.fullname.toString(); - if (msym.name == moduleOverride) { - if (wantClassFiles) { - fillIn(p, CLASS_PATH, - fileManager.list(CLASS_PATH, - packageName, - classKinds, - false)); - } - if (wantSourceFiles && fileManager.hasLocation(SOURCE_PATH)) { - fillIn(p, SOURCE_PATH, - fileManager.list(SOURCE_PATH, - packageName, - sourceKinds, - false)); - } - } - Location classLocn = msym.classLocation; Location sourceLocn = msym.sourceLocation; @@ -600,7 +575,7 @@ public class ClassFinder { /** * Scans class path and source path for files in given package. */ - private void scanUserPaths(PackageSymbol p) throws IOException { + private void scanUserPaths(PackageSymbol p, boolean includeSourcePath) throws IOException { Set kinds = getPackageFileKinds(); Set classKinds = EnumSet.copyOf(kinds); @@ -611,7 +586,7 @@ public class ClassFinder { sourceKinds.remove(JavaFileObject.Kind.CLASS); boolean wantSourceFiles = !sourceKinds.isEmpty(); - boolean haveSourcePath = fileManager.hasLocation(SOURCE_PATH); + boolean haveSourcePath = includeSourcePath && fileManager.hasLocation(SOURCE_PATH); if (verbose && verbosePath) { if (fileManager instanceof StandardJavaFileManager) { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java index 8e464ef9fc6..8b8a0379546 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java @@ -392,6 +392,7 @@ public class Modules extends JCTree.Visitor { if (moduleOverride != null) { checkNoAllModulePath(); defaultModule = moduleFinder.findModule(names.fromString(moduleOverride)); + defaultModule.sourceLocation = StandardLocation.SOURCE_PATH; } else { // Question: why not do findAllModules and initVisiblePackages here? // i.e. body of unnamedModuleCompleter @@ -432,7 +433,9 @@ public class Modules extends JCTree.Visitor { if (defaultModule != syms.unnamedModule) { syms.unnamedModule.completer = getUnnamedModuleCompleter(); - syms.unnamedModule.sourceLocation = StandardLocation.SOURCE_PATH; + if (moduleOverride == null) { + syms.unnamedModule.sourceLocation = StandardLocation.SOURCE_PATH; + } syms.unnamedModule.classLocation = StandardLocation.CLASS_PATH; } diff --git a/langtools/test/tools/javac/modules/XModuleTest.java b/langtools/test/tools/javac/modules/XModuleTest.java index b4f49f64d3d..5dc5d8f35dd 100644 --- a/langtools/test/tools/javac/modules/XModuleTest.java +++ b/langtools/test/tools/javac/modules/XModuleTest.java @@ -27,7 +27,9 @@ * @library /tools/lib * @modules * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.code * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.processing * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase * @run main XModuleTest */ @@ -35,12 +37,22 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.List; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.ModuleElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.util.Elements; + +import com.sun.tools.javac.code.Symtab; +import com.sun.tools.javac.processing.JavacProcessingEnvironment; import toolbox.JavacTask; import toolbox.ModuleBuilder; import toolbox.Task; -import toolbox.TestRunner; -import toolbox.ToolBox; +import toolbox.Task.Expect; public class XModuleTest extends ModuleTestBase { @@ -111,15 +123,22 @@ public class XModuleTest extends ModuleTestBase { Path classes = base.resolve("classes"); tb.createDirectories(classes); - String log = new JavacTask(tb) - .options("-Xmodule:java.compiler", "--class-path", cpClasses.toString()) + List log = new JavacTask(tb) + .options("-Xmodule:java.compiler", + "--class-path", cpClasses.toString(), + "-XDrawDiagnostics") .outdir(classes) .files(src.resolve("javax/lang/model/element/Extra.java")) - .run() + .run(Expect.FAIL) .writeAll() - .getOutput(Task.OutputKind.DIRECT); + .getOutputLines(Task.OutputKind.DIRECT); - if (!log.isEmpty()) + List expectedOut = Arrays.asList( + "Extra.java:1:76: compiler.err.doesnt.exist: p", + "1 error" + ); + + if (!expectedOut.equals(log)) throw new Exception("expected output not found: " + log); } @@ -302,4 +321,103 @@ public class XModuleTest extends ModuleTestBase { .run() .writeAll(); } + + @Test + public void testUnnamedIsolation(Path base) throws Exception { + //note: avoiding use of java.base, as that gets special handling on some places: + Path sourcePath = base.resolve("source-path"); + tb.writeJavaFiles(sourcePath, "package src; public class Src {}"); + + Path classPathSrc = base.resolve("class-path-src"); + tb.writeJavaFiles(classPathSrc, "package cp; public class CP { }"); + Path classPath = base.resolve("classPath"); + tb.createDirectories(classPath); + + String cpLog = new JavacTask(tb) + .outdir(classPath) + .files(findJavaFiles(classPathSrc)) + .run() + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + + if (!cpLog.isEmpty()) + throw new Exception("expected output not found: " + cpLog); + + Path modulePathSrc = base.resolve("module-path-src"); + tb.writeJavaFiles(modulePathSrc, + "module m {}", + "package m; public class M {}"); + Path modulePath = base.resolve("modulePath"); + tb.createDirectories(modulePath.resolve("m")); + + String modLog = new JavacTask(tb) + .outdir(modulePath.resolve("m")) + .files(findJavaFiles(modulePathSrc)) + .run() + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + + if (!modLog.isEmpty()) + throw new Exception("expected output not found: " + modLog); + + Path src = base.resolve("src"); + tb.writeJavaFiles(src, "package m; public class Extra { }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + String log = new JavacTask(tb) + .options("-Xmodule:m", + "--class-path", classPath.toString(), + "--source-path", sourcePath.toString(), + "--module-path", modulePath.toString(), + "--processor-path", System.getProperty("test.classes"), + "-XDaccessInternalAPI=true", + "-processor", CheckModuleContentProcessing.class.getName()) + .outdir(classes) + .files(findJavaFiles(sourcePath)) + .run() + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + + if (!log.isEmpty()) + throw new Exception("expected output not found: " + log); + } + + @SupportedAnnotationTypes("*") + public static final class CheckModuleContentProcessing extends AbstractProcessor { + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + Symtab syms = Symtab.instance(((JavacProcessingEnvironment) processingEnv).getContext()); + Elements elements = processingEnv.getElementUtils(); + ModuleElement unnamedModule = syms.unnamedModule; + ModuleElement mModule = elements.getModuleElement("m"); + + assertNonNull("mModule found", mModule); + assertNonNull("src.Src from m", elements.getTypeElement(mModule, "src.Src")); + assertNull("cp.CP not from m", elements.getTypeElement(mModule, "cp.CP")); + assertNull("src.Src not from unnamed", elements.getTypeElement(unnamedModule, "src.Src")); + assertNonNull("cp.CP from unnamed", elements.getTypeElement(unnamedModule, "cp.CP")); + + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + private static void assertNonNull(String msg, Object val) { + if (val == null) { + throw new AssertionError(msg); + } + } + + private static void assertNull(String msg, Object val) { + if (val != null) { + throw new AssertionError(msg); + } + } + } + } From d871b35f4074415a12cc8ca88284617a0254ba42 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Mon, 29 Aug 2016 20:15:12 +0300 Subject: [PATCH 057/296] 8164230: Convert TestCodeCacheRemSet_test to GTest Reviewed-by: mgerdin, dfazunen --- .../src/share/vm/gc/g1/g1CodeCacheRemSet.cpp | 160 +++--------------- .../src/share/vm/gc/g1/g1CodeCacheRemSet.hpp | 8 +- .../src/share/vm/gc/g1/g1CodeRootSetTable.hpp | 76 +++++++++ .../share/vm/utilities/internalVMTests.cpp | 1 - .../native/gc/g1/test_g1CodeCacheRemSet.cpp | 94 ++++++++++ 5 files changed, 200 insertions(+), 139 deletions(-) create mode 100644 hotspot/src/share/vm/gc/g1/g1CodeRootSetTable.hpp create mode 100644 hotspot/test/native/gc/g1/test_g1CodeCacheRemSet.cpp diff --git a/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.cpp b/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.cpp index afbe72c8c6a..88611f472ca 100644 --- a/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "code/codeCache.hpp" #include "code/nmethod.hpp" +#include "gc/g1/g1CodeRootSetTable.hpp" #include "gc/g1/g1CodeCacheRemSet.hpp" #include "gc/g1/heapRegion.hpp" #include "memory/heap.hpp" @@ -33,58 +34,13 @@ #include "utilities/hashtable.inline.hpp" #include "utilities/stack.inline.hpp" -class CodeRootSetTable : public Hashtable { - friend class G1CodeRootSetTest; - typedef HashtableEntry Entry; +G1CodeRootSetTable* volatile G1CodeRootSetTable::_purge_list = NULL; - static CodeRootSetTable* volatile _purge_list; - - CodeRootSetTable* _purge_next; - - unsigned int compute_hash(nmethod* nm) { - uintptr_t hash = (uintptr_t)nm; - return hash ^ (hash >> 7); // code heap blocks are 128byte aligned - } - - void remove_entry(Entry* e, Entry* previous); - Entry* new_entry(nmethod* nm); - - public: - CodeRootSetTable(int size) : Hashtable(size, sizeof(Entry)), _purge_next(NULL) {} - ~CodeRootSetTable(); - - // Needs to be protected locks - bool add(nmethod* nm); - bool remove(nmethod* nm); - - // Can be called without locking - bool contains(nmethod* nm); - - int entry_size() const { return BasicHashtable::entry_size(); } - - void copy_to(CodeRootSetTable* new_table); - void nmethods_do(CodeBlobClosure* blk); - - template - int remove_if(CB& should_remove); - - static void purge_list_append(CodeRootSetTable* tbl); - static void purge(); - - static size_t static_mem_size() { - return sizeof(_purge_list); - } - - size_t mem_size(); -}; - -CodeRootSetTable* volatile CodeRootSetTable::_purge_list = NULL; - -size_t CodeRootSetTable::mem_size() { - return sizeof(CodeRootSetTable) + (entry_size() * number_of_entries()) + (sizeof(HashtableBucket) * table_size()); +size_t G1CodeRootSetTable::mem_size() { + return sizeof(G1CodeRootSetTable) + (entry_size() * number_of_entries()) + (sizeof(HashtableBucket) * table_size()); } -CodeRootSetTable::Entry* CodeRootSetTable::new_entry(nmethod* nm) { +G1CodeRootSetTable::Entry* G1CodeRootSetTable::new_entry(nmethod* nm) { unsigned int hash = compute_hash(nm); Entry* entry = (Entry*) new_entry_free_list(); if (entry == NULL) { @@ -96,7 +52,7 @@ CodeRootSetTable::Entry* CodeRootSetTable::new_entry(nmethod* nm) { return entry; } -void CodeRootSetTable::remove_entry(Entry* e, Entry* previous) { +void G1CodeRootSetTable::remove_entry(Entry* e, Entry* previous) { int index = hash_to_index(e->hash()); assert((e == bucket(index)) == (previous == NULL), "if e is the first entry then previous should be null"); @@ -108,7 +64,7 @@ void CodeRootSetTable::remove_entry(Entry* e, Entry* previous) { free_entry(e); } -CodeRootSetTable::~CodeRootSetTable() { +G1CodeRootSetTable::~G1CodeRootSetTable() { for (int index = 0; index < table_size(); ++index) { for (Entry* e = bucket(index); e != NULL; ) { Entry* to_remove = e; @@ -125,7 +81,7 @@ CodeRootSetTable::~CodeRootSetTable() { } } -bool CodeRootSetTable::add(nmethod* nm) { +bool G1CodeRootSetTable::add(nmethod* nm) { if (!contains(nm)) { Entry* e = new_entry(nm); int index = hash_to_index(e->hash()); @@ -135,7 +91,7 @@ bool CodeRootSetTable::add(nmethod* nm) { return false; } -bool CodeRootSetTable::contains(nmethod* nm) { +bool G1CodeRootSetTable::contains(nmethod* nm) { int index = hash_to_index(compute_hash(nm)); for (Entry* e = bucket(index); e != NULL; e = e->next()) { if (e->literal() == nm) { @@ -145,7 +101,7 @@ bool CodeRootSetTable::contains(nmethod* nm) { return false; } -bool CodeRootSetTable::remove(nmethod* nm) { +bool G1CodeRootSetTable::remove(nmethod* nm) { int index = hash_to_index(compute_hash(nm)); Entry* previous = NULL; for (Entry* e = bucket(index); e != NULL; previous = e, e = e->next()) { @@ -157,7 +113,7 @@ bool CodeRootSetTable::remove(nmethod* nm) { return false; } -void CodeRootSetTable::copy_to(CodeRootSetTable* new_table) { +void G1CodeRootSetTable::copy_to(G1CodeRootSetTable* new_table) { for (int index = 0; index < table_size(); ++index) { for (Entry* e = bucket(index); e != NULL; e = e->next()) { new_table->add(e->literal()); @@ -166,7 +122,7 @@ void CodeRootSetTable::copy_to(CodeRootSetTable* new_table) { new_table->copy_freelist(this); } -void CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) { +void G1CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) { for (int index = 0; index < table_size(); ++index) { for (Entry* e = bucket(index); e != NULL; e = e->next()) { blk->do_code_blob(e->literal()); @@ -175,7 +131,7 @@ void CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) { } template -int CodeRootSetTable::remove_if(CB& should_remove) { +int G1CodeRootSetTable::remove_if(CB& should_remove) { int num_removed = 0; for (int index = 0; index < table_size(); ++index) { Entry* previous = NULL; @@ -198,52 +154,52 @@ G1CodeRootSet::~G1CodeRootSet() { delete _table; } -CodeRootSetTable* G1CodeRootSet::load_acquire_table() { - return (CodeRootSetTable*) OrderAccess::load_ptr_acquire(&_table); +G1CodeRootSetTable* G1CodeRootSet::load_acquire_table() { + return (G1CodeRootSetTable*) OrderAccess::load_ptr_acquire(&_table); } void G1CodeRootSet::allocate_small_table() { - CodeRootSetTable* temp = new CodeRootSetTable(SmallSize); + G1CodeRootSetTable* temp = new G1CodeRootSetTable(SmallSize); OrderAccess::release_store_ptr(&_table, temp); } -void CodeRootSetTable::purge_list_append(CodeRootSetTable* table) { +void G1CodeRootSetTable::purge_list_append(G1CodeRootSetTable* table) { for (;;) { table->_purge_next = _purge_list; - CodeRootSetTable* old = (CodeRootSetTable*) Atomic::cmpxchg_ptr(table, &_purge_list, table->_purge_next); + G1CodeRootSetTable* old = (G1CodeRootSetTable*) Atomic::cmpxchg_ptr(table, &_purge_list, table->_purge_next); if (old == table->_purge_next) { break; } } } -void CodeRootSetTable::purge() { - CodeRootSetTable* table = _purge_list; +void G1CodeRootSetTable::purge() { + G1CodeRootSetTable* table = _purge_list; _purge_list = NULL; while (table != NULL) { - CodeRootSetTable* to_purge = table; + G1CodeRootSetTable* to_purge = table; table = table->_purge_next; delete to_purge; } } void G1CodeRootSet::move_to_large() { - CodeRootSetTable* temp = new CodeRootSetTable(LargeSize); + G1CodeRootSetTable* temp = new G1CodeRootSetTable(LargeSize); _table->copy_to(temp); - CodeRootSetTable::purge_list_append(_table); + G1CodeRootSetTable::purge_list_append(_table); OrderAccess::release_store_ptr(&_table, temp); } void G1CodeRootSet::purge() { - CodeRootSetTable::purge(); + G1CodeRootSetTable::purge(); } size_t G1CodeRootSet::static_mem_size() { - return CodeRootSetTable::static_mem_size(); + return G1CodeRootSetTable::static_mem_size(); } void G1CodeRootSet::add(nmethod* method) { @@ -278,7 +234,7 @@ bool G1CodeRootSet::remove(nmethod* method) { } bool G1CodeRootSet::contains(nmethod* method) { - CodeRootSetTable* table = load_acquire_table(); // contains() may be called outside of lock, so ensure mem sync. + G1CodeRootSetTable* table = load_acquire_table(); // contains() may be called outside of lock, so ensure mem sync. if (table != NULL) { return table->contains(method); } @@ -348,67 +304,3 @@ void G1CodeRootSet::clean(HeapRegion* owner) { clear(); } } - -#ifndef PRODUCT - -class G1CodeRootSetTest { - public: - static void test() { - { - G1CodeRootSet set1; - assert(set1.is_empty(), "Code root set must be initially empty but is not."); - - assert(G1CodeRootSet::static_mem_size() == sizeof(void*), - "The code root set's static memory usage is incorrect, " SIZE_FORMAT " bytes", G1CodeRootSet::static_mem_size()); - - set1.add((nmethod*)1); - assert(set1.length() == 1, "Added exactly one element, but set contains " - SIZE_FORMAT " elements", set1.length()); - - const size_t num_to_add = (size_t)G1CodeRootSet::Threshold + 1; - - for (size_t i = 1; i <= num_to_add; i++) { - set1.add((nmethod*)1); - } - assert(set1.length() == 1, - "Duplicate detection should not have increased the set size but " - "is " SIZE_FORMAT, set1.length()); - - for (size_t i = 2; i <= num_to_add; i++) { - set1.add((nmethod*)(uintptr_t)(i)); - } - assert(set1.length() == num_to_add, - "After adding in total " SIZE_FORMAT " distinct code roots, they " - "need to be in the set, but there are only " SIZE_FORMAT, - num_to_add, set1.length()); - - assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable"); - - size_t num_popped = 0; - for (size_t i = 1; i <= num_to_add; i++) { - bool removed = set1.remove((nmethod*)i); - if (removed) { - num_popped += 1; - } else { - break; - } - } - assert(num_popped == num_to_add, - "Managed to pop " SIZE_FORMAT " code roots, but only " SIZE_FORMAT " " - "were added", num_popped, num_to_add); - assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable"); - - G1CodeRootSet::purge(); - - assert(CodeRootSetTable::_purge_list == NULL, "should have purged old small tables"); - - } - - } -}; - -void TestCodeCacheRemSet_test() { - G1CodeRootSetTest::test(); -} - -#endif diff --git a/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.hpp b/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.hpp index fcd82187909..3c7ed50d81c 100644 --- a/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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,7 +28,7 @@ #include "memory/allocation.hpp" class CodeBlobClosure; -class CodeRootSetTable; +class G1CodeRootSetTable; class HeapRegion; class nmethod; @@ -42,8 +42,8 @@ class G1CodeRootSet VALUE_OBJ_CLASS_SPEC { const static size_t Threshold = 24; const static size_t LargeSize = 512; - CodeRootSetTable* _table; - CodeRootSetTable* load_acquire_table(); + G1CodeRootSetTable* _table; + G1CodeRootSetTable* load_acquire_table(); size_t _length; diff --git a/hotspot/src/share/vm/gc/g1/g1CodeRootSetTable.hpp b/hotspot/src/share/vm/gc/g1/g1CodeRootSetTable.hpp new file mode 100644 index 00000000000..4a3b6bbc25b --- /dev/null +++ b/hotspot/src/share/vm/gc/g1/g1CodeRootSetTable.hpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +#ifndef SHARE_VM_GC_G1_G1CODEROOTSETTABLE_HPP +#define SHARE_VM_GC_G1_G1CODEROOTSETTABLE_HPP + +#include "utilities/hashtable.hpp" + +class nmethod; + +class G1CodeRootSetTable : public Hashtable { + friend class G1CodeRootSetTest; + typedef HashtableEntry Entry; + + static G1CodeRootSetTable* volatile _purge_list; + + G1CodeRootSetTable* _purge_next; + + unsigned int compute_hash(nmethod* nm) { + uintptr_t hash = (uintptr_t)nm; + return hash ^ (hash >> 7); // code heap blocks are 128byte aligned + } + + void remove_entry(Entry* e, Entry* previous); + Entry* new_entry(nmethod* nm); + + public: + G1CodeRootSetTable(int size) : Hashtable(size, sizeof(Entry)), _purge_next(NULL) {} + ~G1CodeRootSetTable(); + + // Needs to be protected by locks + bool add(nmethod* nm); + bool remove(nmethod* nm); + + // Can be called without locking + bool contains(nmethod* nm); + + int entry_size() const { return BasicHashtable::entry_size(); } + + void copy_to(G1CodeRootSetTable* new_table); + void nmethods_do(CodeBlobClosure* blk); + + template + int remove_if(CB& should_remove); + + static void purge_list_append(G1CodeRootSetTable* tbl); + static void purge(); + + static size_t static_mem_size() { + return sizeof(_purge_list); + } + + size_t mem_size(); +}; + +#endif /* SHARE_VM_GC_G1_G1CODEROOTSETTABLE_HPP */ diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp index 03737b6a213..6e7ad0bdf6a 100644 --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp @@ -89,7 +89,6 @@ void InternalVMTests::run() { #if INCLUDE_ALL_GCS run_unit_test(TestG1BiasedArray_test); run_unit_test(TestBufferingOopClosure_test); - run_unit_test(TestCodeCacheRemSet_test); if (UseG1GC) { run_unit_test(FreeRegionList_test); run_unit_test(IHOP_test); diff --git a/hotspot/test/native/gc/g1/test_g1CodeCacheRemSet.cpp b/hotspot/test/native/gc/g1/test_g1CodeCacheRemSet.cpp new file mode 100644 index 00000000000..4365e9929a8 --- /dev/null +++ b/hotspot/test/native/gc/g1/test_g1CodeCacheRemSet.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2014, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +#include "precompiled.hpp" +#include "gc/g1/g1CodeRootSetTable.hpp" +#include "gc/g1/g1CodeCacheRemSet.hpp" +#include "unittest.hpp" + +class G1CodeRootSetTest : public ::testing::Test { + public: + + size_t threshold() { + return G1CodeRootSet::Threshold; + } + + G1CodeRootSetTable* purge_list() { + return G1CodeRootSetTable::_purge_list; + } +}; + +TEST_VM_F(G1CodeRootSetTest, g1_code_cache_rem_set) { + G1CodeRootSet root_set; + + ASSERT_TRUE(root_set.is_empty()) << "Code root set must be initially empty " + "but is not."; + + ASSERT_EQ(G1CodeRootSet::static_mem_size(), sizeof (void*)) << + "The code root set's static memory usage is incorrect, " + << G1CodeRootSet::static_mem_size() << " bytes"; + + root_set.add((nmethod*) 1); + ASSERT_EQ(root_set.length(), (size_t) 1) << "Added exactly one element, but" + " set contains " << root_set.length() << " elements"; + + const size_t num_to_add = (size_t) threshold() + 1; + + for (size_t i = 1; i <= num_to_add; i++) { + root_set.add((nmethod*) 1); + } + ASSERT_EQ(root_set.length(), (size_t) 1) + << "Duplicate detection should not have increased the set size but " + << "is " << root_set.length(); + + for (size_t i = 2; i <= num_to_add; i++) { + root_set.add((nmethod*) (uintptr_t) (i)); + } + + ASSERT_EQ(root_set.length(), num_to_add) + << "After adding in total " << num_to_add << " distinct code roots, " + "they need to be in the set, but there are only " << root_set.length(); + + ASSERT_NE(purge_list(), (G1CodeRootSetTable*) NULL) + << "should have grown to large hashtable"; + + size_t num_popped = 0; + for (size_t i = 1; i <= num_to_add; i++) { + bool removed = root_set.remove((nmethod*) i); + if (removed) { + num_popped += 1; + } else { + break; + } + } + ASSERT_EQ(num_popped, num_to_add) + << "Managed to pop " << num_popped << " code roots, but only " + << num_to_add << " were added"; + ASSERT_NE(purge_list(), (G1CodeRootSetTable*) NULL) + << "should have grown to large hashtable"; + + G1CodeRootSet::purge(); + + ASSERT_EQ(purge_list(), (G1CodeRootSetTable*) NULL) + << "should have purged old small tables"; +} From 56ff858c45bbc4c584271f33a2e0c51d2405252e Mon Sep 17 00:00:00 2001 From: Dmitry Fazunenko Date: Mon, 29 Aug 2016 23:04:48 +0400 Subject: [PATCH 058/296] 8164660: MinimalVM is not tested with GC tests Reviewed-by: jmasa, tschatzl --- hotspot/test/gc/TestCardTablePageCommits.java | 1 - hotspot/test/gc/TestObjectAlignment.java | 1 - hotspot/test/gc/TestSmallHeap.java | 1 - hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java | 1 - hotspot/test/gc/TestVerifyDuringStartup.java | 1 - hotspot/test/gc/TestVerifySilently.java | 1 - hotspot/test/gc/TestVerifySubSet.java | 1 - hotspot/test/gc/g1/TestEagerReclaimHumongousRegions.java | 1 + .../gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java | 1 + .../test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java | 1 + hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java | 1 + hotspot/test/gc/g1/TestGCLogMessages.java | 1 + hotspot/test/gc/g1/TestHumongousAllocInitialMark.java | 1 + hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java | 1 + hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java | 1 + hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java | 1 + hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java | 1 + hotspot/test/gc/g1/TestStringDeduplicationFullGC.java | 1 + hotspot/test/gc/g1/TestStringDeduplicationInterned.java | 1 + hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java | 1 + hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java | 1 + hotspot/test/gc/g1/TestStringDeduplicationTableResize.java | 1 + hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java | 1 + hotspot/test/gc/g1/TestStringSymbolTableStats.java | 1 + hotspot/test/gc/serial/HeapChangeLogging.java | 2 +- 25 files changed, 18 insertions(+), 8 deletions(-) diff --git a/hotspot/test/gc/TestCardTablePageCommits.java b/hotspot/test/gc/TestCardTablePageCommits.java index fe50587d95a..e3d70b38533 100644 --- a/hotspot/test/gc/TestCardTablePageCommits.java +++ b/hotspot/test/gc/TestCardTablePageCommits.java @@ -34,7 +34,6 @@ import jdk.test.lib.Platform; * @requires vm.gc.Parallel * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management * @run driver TestCardTablePageCommits */ public class TestCardTablePageCommits { diff --git a/hotspot/test/gc/TestObjectAlignment.java b/hotspot/test/gc/TestObjectAlignment.java index 9c6be10bd3f..ac4c1e267e7 100644 --- a/hotspot/test/gc/TestObjectAlignment.java +++ b/hotspot/test/gc/TestObjectAlignment.java @@ -28,7 +28,6 @@ * @summary G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=8 * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=16 * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 diff --git a/hotspot/test/gc/TestSmallHeap.java b/hotspot/test/gc/TestSmallHeap.java index f604a4c5a06..9fb8f36a851 100644 --- a/hotspot/test/gc/TestSmallHeap.java +++ b/hotspot/test/gc/TestSmallHeap.java @@ -28,7 +28,6 @@ * @summary Verify that starting the VM with a small heap works * @library /test/lib * @modules java.base/jdk.internal.misc - * @modules java.management/sun.management * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestSmallHeap diff --git a/hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java b/hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java index 6ea205757e7..79afdfb6bff 100644 --- a/hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java +++ b/hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java @@ -27,7 +27,6 @@ * @summary Tests that all SoftReferences has been cleared at time of OOM. * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management * @run main/othervm -Xmx128m TestSoftReferencesBehaviorOnOOME 512 2k * @run main/othervm -Xmx128m TestSoftReferencesBehaviorOnOOME 128k 256k * @run main/othervm -Xmx128m TestSoftReferencesBehaviorOnOOME 2k 32k diff --git a/hotspot/test/gc/TestVerifyDuringStartup.java b/hotspot/test/gc/TestVerifyDuringStartup.java index 7439e40c04e..744b52be360 100644 --- a/hotspot/test/gc/TestVerifyDuringStartup.java +++ b/hotspot/test/gc/TestVerifyDuringStartup.java @@ -27,7 +27,6 @@ * @summary Simple test run with -XX:+VerifyDuringStartup -XX:-UseTLAB to verify 8010463 * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management */ import jdk.test.lib.JDKToolFinder; diff --git a/hotspot/test/gc/TestVerifySilently.java b/hotspot/test/gc/TestVerifySilently.java index 7d11c44c7c3..5b811cfdc6d 100644 --- a/hotspot/test/gc/TestVerifySilently.java +++ b/hotspot/test/gc/TestVerifySilently.java @@ -27,7 +27,6 @@ * @summary Test silent verification. * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management */ import jdk.test.lib.process.ProcessTools; diff --git a/hotspot/test/gc/TestVerifySubSet.java b/hotspot/test/gc/TestVerifySubSet.java index c43079475bc..b8ac248541d 100644 --- a/hotspot/test/gc/TestVerifySubSet.java +++ b/hotspot/test/gc/TestVerifySubSet.java @@ -27,7 +27,6 @@ * @summary Test VerifySubSet option * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management */ import jdk.test.lib.process.ProcessTools; diff --git a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions.java b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions.java index 71ec43de6ff..1a7945b4791 100644 --- a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions.java +++ b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions.java @@ -27,6 +27,7 @@ * @summary Test to make sure that eager reclaim of humongous objects work. We simply try to fill * up the heap with humongous objects that should be eagerly reclaimable to avoid Full GC. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java index a516e02185a..d36782936d5 100644 --- a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java +++ b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java @@ -27,6 +27,7 @@ * @summary Test to make sure that eager reclaim of humongous objects correctly clears * mark bitmaps at reclaim. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java index 6bfa89b00bf..8643564236a 100644 --- a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java +++ b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java @@ -30,6 +30,7 @@ * referencing that we know is in the old gen. After changing this reference, the object * should still be eagerly reclaimable to avoid Full GC. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java b/hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java index 2c27eb276ab..aafc5aa3dfb 100644 --- a/hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java +++ b/hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java @@ -27,6 +27,7 @@ * @summary Ensure that the output for a G1TraceEagerReclaimHumongousObjects * includes the expected necessary messages. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestGCLogMessages.java b/hotspot/test/gc/g1/TestGCLogMessages.java index 776ef7d826a..6b2ac94d699 100644 --- a/hotspot/test/gc/g1/TestGCLogMessages.java +++ b/hotspot/test/gc/g1/TestGCLogMessages.java @@ -27,6 +27,7 @@ * @summary Ensure the output for a minor GC with G1 * includes the expected necessary messages. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java b/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java index c760c36db48..01fe107c725 100644 --- a/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java +++ b/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java @@ -25,6 +25,7 @@ * @test TestHumongousAllocInitialMark * @bug 7168848 * @summary G1: humongous object allocations should initiate marking cycles when necessary + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java b/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java index 7c0d7a170c3..ce01acd68a3 100644 --- a/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java +++ b/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java @@ -26,6 +26,7 @@ * @bug 8143587 * @summary G1: humongous object allocations should work even when there is * not enough space in the heapRegion to fit a filler object. + * @requires vm.gc.G1 * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver TestHumongousAllocNearlyFullRegion diff --git a/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java b/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java index 955474c99e6..8acd37ca497 100644 --- a/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java +++ b/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java @@ -26,6 +26,7 @@ * @key regression * @key gc * @bug 8027756 + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java b/hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java index 79b797b4286..873851c3805 100644 --- a/hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java +++ b/hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java @@ -26,6 +26,7 @@ * @key gc * @bug 8014240 * @summary Test output of G1PrintRegionRememberedSetInfo + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java b/hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java index 25e6a12ff5e..aa5192d843e 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java @@ -26,6 +26,7 @@ * @summary Test string deduplication age threshold * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationFullGC.java b/hotspot/test/gc/g1/TestStringDeduplicationFullGC.java index 1c2ab7389c4..be88c99cdd1 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationFullGC.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationFullGC.java @@ -26,6 +26,7 @@ * @summary Test string deduplication during full GC * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationInterned.java b/hotspot/test/gc/g1/TestStringDeduplicationInterned.java index 766c9f821b0..48f4b598d31 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationInterned.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationInterned.java @@ -26,6 +26,7 @@ * @summary Test string deduplication of interned strings * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java b/hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java index 43940962f9b..bb47eb52c7f 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java @@ -26,6 +26,7 @@ * @summary Test string deduplication print options * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java b/hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java index 5f466f3681d..7c52c36612c 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java @@ -26,6 +26,7 @@ * @summary Test string deduplication table rehash * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationTableResize.java b/hotspot/test/gc/g1/TestStringDeduplicationTableResize.java index 1259869e4e5..2a72f4042e2 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationTableResize.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationTableResize.java @@ -26,6 +26,7 @@ * @summary Test string deduplication table resize * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java b/hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java index a65e4ab3ce2..4cbc744a6f6 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java @@ -26,6 +26,7 @@ * @summary Test string deduplication during young GC * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringSymbolTableStats.java b/hotspot/test/gc/g1/TestStringSymbolTableStats.java index 62994fa2d55..d0c3d312e91 100644 --- a/hotspot/test/gc/g1/TestStringSymbolTableStats.java +++ b/hotspot/test/gc/g1/TestStringSymbolTableStats.java @@ -26,6 +26,7 @@ * @bug 8027476 8027455 * @summary Ensure that the G1TraceStringSymbolTableScrubbing prints the expected message. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/serial/HeapChangeLogging.java b/hotspot/test/gc/serial/HeapChangeLogging.java index a8ef6f64464..ffc646d5d46 100644 --- a/hotspot/test/gc/serial/HeapChangeLogging.java +++ b/hotspot/test/gc/serial/HeapChangeLogging.java @@ -24,9 +24,9 @@ /* * @test HeapChangeLogging.java * @bug 8027440 + * @requires vm.gc.Serial * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management * @summary Allocate to get a promotion failure and verify that that heap change logging is present. * @run main HeapChangeLogging */ From 6db26ca5bfbe97e9ae948da1e8fa201e07dec14e Mon Sep 17 00:00:00 2001 From: David Holmes Date: Mon, 29 Aug 2016 20:13:45 -0400 Subject: [PATCH 059/296] 8158854: Ensure release_store is paired with load_acquire in lock-free code Reviewed-by: shade, dcubed, zgu --- .../src/share/vm/classfile/classLoader.hpp | 8 ++-- hotspot/src/share/vm/classfile/verifier.cpp | 4 +- hotspot/src/share/vm/oops/arrayKlass.hpp | 2 + .../src/share/vm/oops/arrayKlass.inline.hpp | 39 +++++++++++++++++++ hotspot/src/share/vm/oops/instanceKlass.cpp | 6 ++- hotspot/src/share/vm/oops/instanceKlass.hpp | 12 +++--- .../share/vm/oops/instanceKlass.inline.hpp | 17 ++++++++ hotspot/src/share/vm/oops/objArrayKlass.cpp | 9 +++-- hotspot/src/share/vm/oops/typeArrayKlass.cpp | 9 +++-- hotspot/src/share/vm/runtime/vmStructs.cpp | 4 +- 10 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 hotspot/src/share/vm/oops/arrayKlass.inline.hpp diff --git a/hotspot/src/share/vm/classfile/classLoader.hpp b/hotspot/src/share/vm/classfile/classLoader.hpp index e0d56862b95..35c000a6be1 100644 --- a/hotspot/src/share/vm/classfile/classLoader.hpp +++ b/hotspot/src/share/vm/classfile/classLoader.hpp @@ -50,12 +50,14 @@ class ClassFileStream; class ClassPathEntry : public CHeapObj { private: - ClassPathEntry* _next; + ClassPathEntry* volatile _next; public: // Next entry in class path - ClassPathEntry* next() const { return _next; } + ClassPathEntry* next() const { + return (ClassPathEntry*) OrderAccess::load_ptr_acquire(&_next); + } void set_next(ClassPathEntry* next) { - // may have unlocked readers, so write atomically. + // may have unlocked readers, so ensure visibility. OrderAccess::release_store_ptr(&_next, next); } virtual bool is_jrt() = 0; diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp index 2194859c30c..440257b9e79 100644 --- a/hotspot/src/share/vm/classfile/verifier.cpp +++ b/hotspot/src/share/vm/classfile/verifier.cpp @@ -67,12 +67,12 @@ static void* volatile _verify_byte_codes_fn = NULL; static volatile jint _is_new_verify_byte_codes_fn = (jint) true; static void* verify_byte_codes_fn() { - if (_verify_byte_codes_fn == NULL) { + if (OrderAccess::load_ptr_acquire(&_verify_byte_codes_fn) == NULL) { void *lib_handle = os::native_java_library(); void *func = os::dll_lookup(lib_handle, "VerifyClassCodesForMajorVersion"); OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); if (func == NULL) { - OrderAccess::release_store(&_is_new_verify_byte_codes_fn, false); + _is_new_verify_byte_codes_fn = false; func = os::dll_lookup(lib_handle, "VerifyClassCodes"); OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); } diff --git a/hotspot/src/share/vm/oops/arrayKlass.hpp b/hotspot/src/share/vm/oops/arrayKlass.hpp index 3761229a1ce..c7dcd1f8657 100644 --- a/hotspot/src/share/vm/oops/arrayKlass.hpp +++ b/hotspot/src/share/vm/oops/arrayKlass.hpp @@ -56,7 +56,9 @@ class ArrayKlass: public Klass { void set_dimension(int dimension) { _dimension = dimension; } Klass* higher_dimension() const { return _higher_dimension; } + inline Klass* higher_dimension_acquire() const; // load with acquire semantics void set_higher_dimension(Klass* k) { _higher_dimension = k; } + inline void release_set_higher_dimension(Klass* k); // store with release semantics Klass** adr_higher_dimension() { return (Klass**)&this->_higher_dimension;} Klass* lower_dimension() const { return _lower_dimension; } diff --git a/hotspot/src/share/vm/oops/arrayKlass.inline.hpp b/hotspot/src/share/vm/oops/arrayKlass.inline.hpp new file mode 100644 index 00000000000..43f62915f34 --- /dev/null +++ b/hotspot/src/share/vm/oops/arrayKlass.inline.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + * + */ + +#ifndef SHARE_VM_OOPS_ARRAYKLASS_INLINE_HPP +#define SHARE_VM_OOPS_ARRAYKLASS_INLINE_HPP + +#include "runtime/orderAccess.inline.hpp" +#include "oops/arrayKlass.hpp" + +inline Klass* ArrayKlass::higher_dimension_acquire() const { + return (Klass*) OrderAccess::load_ptr_acquire(&_higher_dimension); +} + +inline void ArrayKlass::release_set_higher_dimension(Klass* k) { + OrderAccess::release_store_ptr(&_higher_dimension, k); +} + +#endif // SHARE_VM_OOPS_ARRAYKLASS_INLINE_HPP diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index d6b2323af28..1385affc5df 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -1041,7 +1041,8 @@ Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) { } Klass* InstanceKlass::array_klass_impl(instanceKlassHandle this_k, bool or_null, int n, TRAPS) { - if (this_k->array_klasses() == NULL) { + // Need load-acquire for lock-free read + if (this_k->array_klasses_acquire() == NULL) { if (or_null) return NULL; ResourceMark rm; @@ -1054,7 +1055,8 @@ Klass* InstanceKlass::array_klass_impl(instanceKlassHandle this_k, bool or_null, // Check if update has already taken place if (this_k->array_klasses() == NULL) { Klass* k = ObjArrayKlass::allocate_objArray_klass(this_k->class_loader_data(), 1, this_k, CHECK_NULL); - this_k->set_array_klasses(k); + // use 'release' to pair with lock-free load + this_k->release_set_array_klasses(k); } } } diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 24da1868237..da36a1422b4 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -148,7 +148,7 @@ class InstanceKlass: public Klass { // Package this class is defined in PackageEntry* _package_entry; // Array classes holding elements of this class. - Klass* _array_klasses; + Klass* volatile _array_klasses; // Constant pool for this class. ConstantPool* _constants; // The InnerClasses attribute and EnclosingMethod attribute. The @@ -230,7 +230,7 @@ class InstanceKlass: public Klass { OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily) MemberNameTable* _member_names; // Member names JNIid* _jni_ids; // First JNI identifier for static fields in this class - jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none + jmethodID* volatile _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none intptr_t _dep_context; // packed DependencyContext structure nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class #if INCLUDE_JVMTI @@ -368,7 +368,9 @@ class InstanceKlass: public Klass { // array klasses Klass* array_klasses() const { return _array_klasses; } + inline Klass* array_klasses_acquire() const; // load with acquire semantics void set_array_klasses(Klass* k) { _array_klasses = k; } + inline void release_set_array_klasses(Klass* k); // store with release semantics // methods Array* methods() const { return _methods; } @@ -1238,10 +1240,8 @@ private: // cache management logic if the caches can grow instead of just // going from NULL to non-NULL. bool idnum_can_increment() const { return has_been_redefined(); } - jmethodID* methods_jmethod_ids_acquire() const - { return (jmethodID*)OrderAccess::load_ptr_acquire(&_methods_jmethod_ids); } - void release_set_methods_jmethod_ids(jmethodID* jmeths) - { OrderAccess::release_store_ptr(&_methods_jmethod_ids, jmeths); } + inline jmethodID* methods_jmethod_ids_acquire() const; + inline void release_set_methods_jmethod_ids(jmethodID* jmeths); // Lock during initialization public: diff --git a/hotspot/src/share/vm/oops/instanceKlass.inline.hpp b/hotspot/src/share/vm/oops/instanceKlass.inline.hpp index 3fe04808df4..a213272a9e5 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.inline.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.inline.hpp @@ -29,10 +29,27 @@ #include "oops/instanceKlass.hpp" #include "oops/klass.hpp" #include "oops/oop.inline.hpp" +#include "runtime/orderAccess.inline.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" +inline Klass* InstanceKlass::array_klasses_acquire() const { + return (Klass*) OrderAccess::load_ptr_acquire(&_array_klasses); +} + +inline void InstanceKlass::release_set_array_klasses(Klass* k) { + OrderAccess::release_store_ptr(&_array_klasses, k); +} + +inline jmethodID* InstanceKlass::methods_jmethod_ids_acquire() const { + return (jmethodID*)OrderAccess::load_ptr_acquire(&_methods_jmethod_ids); +} + +inline void InstanceKlass::release_set_methods_jmethod_ids(jmethodID* jmeths) { + OrderAccess::release_store_ptr(&_methods_jmethod_ids, jmeths); +} + // The iteration over the oops in objects is a hot path in the GC code. // By force inlining the following functions, we get similar GC performance // as the previous macro based implementation. diff --git a/hotspot/src/share/vm/oops/objArrayKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlass.cpp index 1abcc152fc6..bf2672daa78 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp @@ -34,6 +34,7 @@ #include "memory/metadataFactory.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.inline.hpp" +#include "oops/arrayKlass.inline.hpp" #include "oops/instanceKlass.hpp" #include "oops/klass.inline.hpp" #include "oops/objArrayKlass.inline.hpp" @@ -42,7 +43,6 @@ #include "oops/symbol.hpp" #include "runtime/handles.inline.hpp" #include "runtime/mutexLocker.hpp" -#include "runtime/orderAccess.inline.hpp" #include "utilities/copy.hpp" #include "utilities/macros.hpp" @@ -321,7 +321,8 @@ Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { int dim = dimension(); if (dim == n) return this; - if (higher_dimension() == NULL) { + // lock-free read needs acquire semantics + if (higher_dimension_acquire() == NULL) { if (or_null) return NULL; ResourceMark rm; @@ -339,8 +340,8 @@ Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { ObjArrayKlass::allocate_objArray_klass(class_loader_data(), dim + 1, this, CHECK_NULL); ObjArrayKlass* ak = ObjArrayKlass::cast(k); ak->set_lower_dimension(this); - OrderAccess::storestore(); - set_higher_dimension(ak); + // use 'release' to pair with lock-free load + release_set_higher_dimension(ak); assert(ak->is_objArray_klass(), "incorrect initialization of ObjArrayKlass"); } } diff --git a/hotspot/src/share/vm/oops/typeArrayKlass.cpp b/hotspot/src/share/vm/oops/typeArrayKlass.cpp index 76b2bb8e6b9..580c4694512 100644 --- a/hotspot/src/share/vm/oops/typeArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/typeArrayKlass.cpp @@ -34,6 +34,7 @@ #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "memory/universe.inline.hpp" +#include "oops/arrayKlass.inline.hpp" #include "oops/instanceKlass.hpp" #include "oops/klass.inline.hpp" #include "oops/objArrayKlass.hpp" @@ -41,7 +42,6 @@ #include "oops/typeArrayKlass.inline.hpp" #include "oops/typeArrayOop.inline.hpp" #include "runtime/handles.inline.hpp" -#include "runtime/orderAccess.inline.hpp" #include "utilities/macros.hpp" bool TypeArrayKlass::compute_is_subtype_of(Klass* k) { @@ -166,7 +166,8 @@ Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { if (dim == n) return this; - if (higher_dimension() == NULL) { + // lock-free read needs acquire semantics + if (higher_dimension_acquire() == NULL) { if (or_null) return NULL; ResourceMark rm; @@ -181,8 +182,8 @@ Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { class_loader_data(), dim + 1, this, CHECK_NULL); ObjArrayKlass* h_ak = ObjArrayKlass::cast(oak); h_ak->set_lower_dimension(this); - OrderAccess::storestore(); - set_higher_dimension(h_ak); + // use 'release' to pair with lock-free load + release_set_higher_dimension(h_ak); assert(h_ak->is_objArray_klass(), "incorrect initialization of ObjArrayKlass"); } } diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 34b48c3cf80..81994ce96f1 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -242,7 +242,7 @@ typedef CompactHashtable SymbolCompactHashTable; nonstatic_field(ConstantPool, _reference_map, Array*) \ nonstatic_field(ConstantPoolCache, _length, int) \ nonstatic_field(ConstantPoolCache, _constant_pool, ConstantPool*) \ - nonstatic_field(InstanceKlass, _array_klasses, Klass*) \ + volatile_nonstatic_field(InstanceKlass, _array_klasses, Klass*) \ nonstatic_field(InstanceKlass, _methods, Array*) \ nonstatic_field(InstanceKlass, _default_methods, Array*) \ nonstatic_field(InstanceKlass, _local_interfaces, Array*) \ @@ -271,7 +271,7 @@ typedef CompactHashtable SymbolCompactHashTable; nonstatic_field(InstanceKlass, _osr_nmethods_head, nmethod*) \ JVMTI_ONLY(nonstatic_field(InstanceKlass, _breakpoints, BreakpointInfo*)) \ nonstatic_field(InstanceKlass, _generic_signature_index, u2) \ - nonstatic_field(InstanceKlass, _methods_jmethod_ids, jmethodID*) \ + volatile_nonstatic_field(InstanceKlass, _methods_jmethod_ids, jmethodID*) \ volatile_nonstatic_field(InstanceKlass, _idnum_allocated_count, u2) \ nonstatic_field(InstanceKlass, _annotations, Annotations*) \ nonstatic_field(InstanceKlass, _method_ordering, Array*) \ From 5c73d79296adf88187d3eafe1e63d7f9e29d48f1 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Tue, 30 Aug 2016 09:31:28 +0800 Subject: [PATCH 060/296] 8163934: Remove intermittent key from java/lang/ProcessBuilder/Zombies.java Reviewed-by: darcy --- jdk/test/java/lang/ProcessBuilder/Zombies.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/test/java/lang/ProcessBuilder/Zombies.java b/jdk/test/java/lang/ProcessBuilder/Zombies.java index 30f296cc513..10c804ee1d4 100644 --- a/jdk/test/java/lang/ProcessBuilder/Zombies.java +++ b/jdk/test/java/lang/ProcessBuilder/Zombies.java @@ -25,7 +25,6 @@ * @test * @run main/othervm Zombies * @bug 6474073 6180151 - * @key intermittent * @summary Make sure zombies don't get created on Unix * @author Martin Buchholz */ From 5ee89f9f22340c5d6577b42e02133537e8ad3c46 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Tue, 30 Aug 2016 09:36:23 +0800 Subject: [PATCH 061/296] 8164545: Mark java/net/URLPermission/nstest/lookup.sh as intermittently failing Reviewed-by: dfuchs --- jdk/test/java/net/URLPermission/nstest/lookup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/java/net/URLPermission/nstest/lookup.sh b/jdk/test/java/net/URLPermission/nstest/lookup.sh index 89798669f53..798e1c168f6 100644 --- a/jdk/test/java/net/URLPermission/nstest/lookup.sh +++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh @@ -27,6 +27,7 @@ # @build jdk.testlibrary.* # @compile -XDignore.symbol.file=true LookupTest.java # @run shell/timeout=50 lookup.sh +# @key intermittent # OS=`uname -s` From 5f5e297c52ca415f68e0c37cf9eb9e112e158c2f Mon Sep 17 00:00:00 2001 From: Masayoshi Okutsu Date: Tue, 30 Aug 2016 14:16:16 +0900 Subject: [PATCH 062/296] 8157792: After Integrating tzdata2016d the test/sun/util/calendar/zi/TestZoneInfo310.java fails for "Asia/Oral" and "Asia/Qyzylorda" Timezones Reviewed-by: peytoia --- .../sun/util/calendar/zi/TestZoneInfo310.java | 16 ++++++++-------- jdk/test/sun/util/calendar/zi/Zoneinfo.java | 13 +++++++++++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java index 9d124ffb21d..0c1d7650c48 100644 --- a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java +++ b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java @@ -22,11 +22,15 @@ */ /* - *@test - *@bug 8007572 8008161 - *@summary Test whether the TimeZone generated from JSR310 tzdb is the same - *as the one from the tz data from javazic + * @test + * @bug 8007572 8008161 8157792 + * @summary Test whether the TimeZone generated from JSR310 tzdb is the same + * as the one from the tz data from javazic * @modules java.base/sun.util.calendar + * @build BackEnd Checksum DayOfWeek Gen GenDoc Main Mappings Month + * Rule RuleDay RuleRec Simple TestZoneInfo310 Time Timezone + * TzIDOldMapping Zone ZoneInfoFile ZoneInfoOld ZoneRec Zoneinfo + * @run main TestZoneInfo310 */ import java.io.File; @@ -164,10 +168,6 @@ public class TestZoneInfo310 { } for (String zid : zids_new) { - if (zid.equals("Asia/Oral") || zid.equals("Asia/Qyzylorda")) { - // JDK-8157792 tracking this issue - continue; - } ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid)); ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid); if (! zi.equalsTo(ziOLD)) { diff --git a/jdk/test/sun/util/calendar/zi/Zoneinfo.java b/jdk/test/sun/util/calendar/zi/Zoneinfo.java index 9e48655181f..e58fd188a30 100644 --- a/jdk/test/sun/util/calendar/zi/Zoneinfo.java +++ b/jdk/test/sun/util/calendar/zi/Zoneinfo.java @@ -373,6 +373,7 @@ class Zoneinfo { tz.getOffsetIndex(zrec.getGmtOffset()); int lastGmtOffsetValue = -1; + ZoneRec prevzrec = null; int currentSave = 0; boolean usedZone; for (int zindex = 0; zindex < zone.size(); zindex++) { @@ -441,6 +442,15 @@ class Zoneinfo { currentSave); if (zrec.hasUntil()) { if (transition >= zrec.getUntilTime(currentSave)) { + // If the GMT offset changed from the previous one, + // record fromTime as a transition. + if (!fromTimeUsed && prevzrec != null + && gmtOffset != prevzrec.getGmtOffset()) { + tz.addTransition(fromTime, + tz.getOffsetIndex(gmtOffset+currentSave), + tz.getDstOffsetIndex(currentSave)); + fromTimeUsed = true; // for consistency + } break year_loop; } } @@ -452,8 +462,6 @@ class Zoneinfo { if (fromTime != minTime) { int prevsave; - ZoneRec prevzrec = zone.get(zindex - 1); - // See if until time in the previous // ZoneRec is the same thing as the // local time in the next rule. @@ -555,6 +563,7 @@ class Zoneinfo { fromYear = zrec.getUntilYear(); year = zrec.getUntilYear(); } + prevzrec = zrec; } if (tz.getDSTType() == Timezone.UNDEF_DST) { From dba7bcf4f801aafac793b70aec1116bdd99acebe Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 30 Aug 2016 11:07:58 +0530 Subject: [PATCH 063/296] 6357887: selected printertray is ignored under linux Reviewed-by: prr, vadim --- .../share/classes/sun/print/PSPrinterJob.java | 31 +-- .../unix/classes/sun/print/UnixPrintJob.java | 14 +- .../PrinterJob/TestMediaTraySelection.java | 185 ++++++++++++++++++ 3 files changed, 212 insertions(+), 18 deletions(-) create mode 100644 jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java diff --git a/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java b/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java index abe8bd9ab7a..f80e10c9778 100644 --- a/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java +++ b/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java @@ -33,11 +33,8 @@ import java.awt.GraphicsEnvironment; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.HeadlessException; -import java.awt.Rectangle; import java.awt.Shape; -import java.awt.image.BufferedImage; - import java.awt.font.FontRenderContext; import java.awt.geom.AffineTransform; @@ -46,7 +43,6 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; -import java.awt.peer.FontPeer; import java.awt.print.Pageable; import java.awt.print.PageFormat; import java.awt.print.Paper; @@ -55,14 +51,12 @@ import java.awt.print.PrinterException; import java.awt.print.PrinterIOException; import java.awt.print.PrinterJob; -import javax.print.DocFlavor; import javax.print.PrintService; import javax.print.StreamPrintService; import javax.print.attribute.HashPrintRequestAttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.PrintServiceAttributeSet; import javax.print.attribute.standard.PrinterName; -import javax.print.attribute.standard.Chromaticity; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.DialogTypeSelection; @@ -72,7 +66,6 @@ import javax.print.attribute.standard.Sides; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; -import java.io.CharConversionException; import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; @@ -85,17 +78,14 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Locale; import java.util.Properties; import sun.awt.CharsetString; import sun.awt.FontConfiguration; -import sun.awt.FontDescriptor; import sun.awt.PlatformFont; import sun.awt.SunToolkit; import sun.font.FontAccess; -import sun.font.FontManagerFactory; import sun.font.FontUtilities; import java.nio.charset.*; @@ -105,7 +95,9 @@ import java.nio.file.Files; //REMIND: Remove use of this class when IPPPrintService is moved to share directory. import java.lang.reflect.Method; +import javax.print.attribute.Attribute; import javax.print.attribute.standard.JobSheets; +import javax.print.attribute.standard.Media; /** * A class which initiates and executes a PostScript printer job. @@ -489,6 +481,23 @@ public class PSPrinterJob extends RasterPrinterJob { return doPrint; } + @Override + protected void setAttributes(PrintRequestAttributeSet attributes) + throws PrinterException { + super.setAttributes(attributes); + if (attributes == null) { + return; // now always use attributes, so this shouldn't happen. + } + Attribute attr = attributes.get(Media.class); + if (attr instanceof CustomMediaTray) { + CustomMediaTray customTray = (CustomMediaTray)attr; + String choice = customTray.getChoiceName(); + if (choice != null) { + mOptions = " InputSlot="+ choice; + } + } + } + /** * Invoked by the RasterPrinterJob super class * this method is called to mark the start of a @@ -1629,7 +1638,7 @@ public class PSPrinterJob extends RasterPrinterJob { execCmd[n++] = "-o job-sheets=standard"; } if ((pFlags & OPTIONS) != 0) { - execCmd[n++] = new String(options); + execCmd[n++] = "-o" + options; } } else { ncomps+=1; //add 1 arg for lp diff --git a/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java b/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java index 7d79243d393..06b086e59a2 100644 --- a/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java +++ b/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java @@ -41,14 +41,12 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.Reader; import java.io.StringWriter; -import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.util.Vector; import javax.print.CancelablePrintJob; import javax.print.Doc; import javax.print.DocFlavor; -import javax.print.DocPrintJob; import javax.print.PrintService; import javax.print.PrintException; import javax.print.event.PrintJobEvent; @@ -56,7 +54,6 @@ import javax.print.event.PrintJobListener; import javax.print.event.PrintJobAttributeListener; import javax.print.attribute.Attribute; -import javax.print.attribute.AttributeSet; import javax.print.attribute.AttributeSetUtilities; import javax.print.attribute.DocAttributeSet; import javax.print.attribute.HashPrintJobAttributeSet; @@ -65,7 +62,6 @@ import javax.print.attribute.PrintJobAttribute; import javax.print.attribute.PrintJobAttributeSet; import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintRequestAttributeSet; -import javax.print.attribute.PrintServiceAttributeSet; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.DocumentName; @@ -77,13 +73,17 @@ import javax.print.attribute.standard.Media; import javax.print.attribute.standard.MediaSize; import javax.print.attribute.standard.MediaSizeName; import javax.print.attribute.standard.OrientationRequested; -import javax.print.attribute.standard.PrinterName; import javax.print.attribute.standard.RequestingUserName; import javax.print.attribute.standard.NumberUp; import javax.print.attribute.standard.Sides; import javax.print.attribute.standard.PrinterIsAcceptingJobs; -import java.awt.print.*; +import java.awt.print.PageFormat; +import java.awt.print.PrinterJob; +import java.awt.print.Pageable; +import java.awt.print.Paper; +import java.awt.print.Printable; +import java.awt.print.PrinterException; @@ -370,7 +370,7 @@ public class UnixPrintJob implements CancelablePrintJob { customTray instanceof CustomMediaTray) { String choice = customTray.getChoiceName(); if (choice != null) { - mOptions += " media="+choice; + mOptions += " InputSlot="+choice; } } diff --git a/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java b/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java new file mode 100644 index 00000000000..374928a56c5 --- /dev/null +++ b/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ +/* + * @test + * @bug 6357887 + * @summary Verifies if selected printertray is used + * @requires (os.family == "linux" | os.family == "solaris") + * @run main/manual TestMediaTraySelection + */ + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import javax.print.DocFlavor; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.Media; +import javax.print.attribute.standard.MediaTray; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class TestMediaTraySelection implements Printable { + + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static PrintService prservices; + + public static void main(String[] args) throws Exception { + prservices = PrintServiceLookup.lookupDefaultPrintService(); + if (prservices == null) { + System.out.println("No print service found"); + return; + } + System.out.println(" Print service " + prservices); + SwingUtilities.invokeAndWait(() -> { + doTest(TestMediaTraySelection::printTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(90000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Banner page did not print"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void printTest() { + + MediaTray tray = null; + //tray = getMediaTray( prservices, "Bypass Tray" ); + tray = getMediaTray( prservices, "Tray 4" ); + PrintRequestAttributeSet atrset = new HashPrintRequestAttributeSet(); + //atrset.add( MediaSizeName.ISO_A4 ); + atrset.add(tray); + PrinterJob pjob = PrinterJob.getPrinterJob(); + pjob.setPrintable(new TestMediaTraySelection()); + try { + pjob.print(atrset); + } catch (PrinterException e) { + e.printStackTrace(); + fail(); + } + } + + static MediaTray getMediaTray( PrintService ps, String name) { + Media[] media = (Media[])ps.getSupportedAttributeValues( Media.class, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, null); + + for (Media m : media) { + if ( m instanceof MediaTray) { + System.out.println("MediaTray=" + m.toString() ); + if ( m.toString().trim().indexOf( name ) > -1 ) { + return (MediaTray)m; + } + } + } + return null; + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " Please verify the \"Tray 4\" of printer is used for printout\n" + + " and not standard/auto tray. If yes, press PASS else press FAIL"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printBannerTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); + } + + @Override + public int print(Graphics g, PageFormat pf, int pi) { + System.out.println("pi = " + pi); + if (pi > 0) { + return NO_SUCH_PAGE; + } + g.drawString("Testing : " , 200, 200); + return PAGE_EXISTS; + } +} From 5258f6573c1e6a02e9d14ba98b53fdc08edde799 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 30 Aug 2016 09:17:49 +0200 Subject: [PATCH 064/296] 8155917: Memory access in free regions during G1 full gc causes regressions in SPECjvm2008 scimark.fft,lu,sor,sparse with 9+116 on Linux-x64 Do not unnecessarily touch the memory of free regions during the compaction phase in G1 full gc causing some OSes to allocate physical memory for them, decreasing performance in some situations. Reviewed-by: mgerdin, jmasa --- hotspot/src/share/vm/gc/shared/space.inline.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/gc/shared/space.inline.hpp b/hotspot/src/share/vm/gc/shared/space.inline.hpp index 3943a6da5dc..77b6f4ceb5a 100644 --- a/hotspot/src/share/vm/gc/shared/space.inline.hpp +++ b/hotspot/src/share/vm/gc/shared/space.inline.hpp @@ -293,10 +293,11 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) { verify_up_to_first_dead(space); + HeapWord* const bottom = space->bottom(); HeapWord* const end_of_live = space->_end_of_live; assert(space->_first_dead <= end_of_live, "Invariant. _first_dead: " PTR_FORMAT " <= end_of_live: " PTR_FORMAT, p2i(space->_first_dead), p2i(end_of_live)); - if (space->_first_dead == end_of_live && !oop(space->bottom())->is_gc_marked()) { + if (space->_first_dead == end_of_live && (bottom == end_of_live || !oop(bottom)->is_gc_marked())) { // Nothing to compact. The space is either empty or all live object should be left in place. clear_empty_region(space); return; @@ -305,8 +306,8 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) { const intx scan_interval = PrefetchScanIntervalInBytes; const intx copy_interval = PrefetchCopyIntervalInBytes; - assert(space->bottom() < end_of_live, "bottom: " PTR_FORMAT " should be < end_of_live: " PTR_FORMAT, p2i(space->bottom()), p2i(end_of_live)); - HeapWord* cur_obj = space->bottom(); + assert(bottom < end_of_live, "bottom: " PTR_FORMAT " should be < end_of_live: " PTR_FORMAT, p2i(bottom), p2i(end_of_live)); + HeapWord* cur_obj = bottom; if (space->_first_dead > cur_obj && !oop(cur_obj)->is_gc_marked()) { // All object before _first_dead can be skipped. They should not be moved. // A pointer to the first live object is stored at the memory location for _first_dead. From 8445923b1ce3b6bcbf5a7ea2221f6013398c2902 Mon Sep 17 00:00:00 2001 From: Jini George Date: Tue, 30 Aug 2016 11:06:25 +0300 Subject: [PATCH 065/296] 8164562: serviceability/sa/TestInstanceKlassSizeForInterface.java: fails with NPE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addition of –XX:+UnlockDiagnosticVMOptions for the test invocation for jcmd and modularization related cleanup Reviewed-by: dholmes, mchung --- .../sa/TestInstanceKlassSize.java | 33 ++++++++++++------- .../sa/TestInstanceKlassSizeForInterface.java | 29 ++++++++++------ 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/hotspot/test/serviceability/sa/TestInstanceKlassSize.java b/hotspot/test/serviceability/sa/TestInstanceKlassSize.java index db1ed0f180f..dd8deda1612 100644 --- a/hotspot/test/serviceability/sa/TestInstanceKlassSize.java +++ b/hotspot/test/serviceability/sa/TestInstanceKlassSize.java @@ -23,6 +23,7 @@ import sun.jvm.hotspot.HotSpotAgent; import sun.jvm.hotspot.utilities.SystemDictionaryHelper; +import sun.jvm.hotspot.oops.InstanceKlass; import sun.jvm.hotspot.debugger.*; import java.util.ArrayList; @@ -44,15 +45,19 @@ import java.util.*; * @test * @library /test/lib * @modules java.base/jdk.internal.misc - * @modules jdk.hotspot.agent - * @modules jdk.hotspot.agent/sun.jvm.hotspot - * @modules jdk.hotspot.agent/sun.jvm.hotspot.utilities - * @modules jdk.hotspot.agent/sun.jvm.hotspot.oops - * @compile -XDignore.symbol.file=true -Xmodule:jdk.hotspot.agent - * -XaddExports:java.base/jdk.internal.misc=jdk.hotspot.agent - * -XaddExports:java.management/java.lang.management=jdk.hotspot.agent + * @compile -XDignore.symbol.file=true + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED * TestInstanceKlassSize.java - * @run main/othervm TestInstanceKlassSize + * @run main/othervm + * --add-modules=jdk.hotspot.agent + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED + * TestInstanceKlassSize */ public class TestInstanceKlassSize { @@ -112,11 +117,11 @@ public class TestInstanceKlassSize { " java.lang.Byte", }; String[] toolArgs = { - "-XX:+UnlockDiagnosticVMOptions", "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED", "TestInstanceKlassSize", Long.toString(app.getPid()) }; @@ -136,6 +141,8 @@ public class TestInstanceKlassSize { String jcmdInstanceKlassSize = getJcmdInstanceKlassSize( jcmdOutput, instanceKlassName); + Asserts.assertNotNull(jcmdInstanceKlassSize, + "Could not get the instance klass size from the jcmd output"); for (String s : output.asLines()) { if (s.contains(instanceKlassName)) { Asserts.assertTrue( @@ -165,10 +172,12 @@ public class TestInstanceKlassSize { } for (String SAInstanceKlassName : SAInstanceKlassNames) { - Long size = SystemDictionaryHelper.findInstanceKlass( - SAInstanceKlassName).getSize(); + InstanceKlass ik = SystemDictionaryHelper.findInstanceKlass( + SAInstanceKlassName); + Asserts.assertNotNull(ik, + String.format("Unable to find instance klass for %s", ik)); System.out.println("SA: The size of " + SAInstanceKlassName + - " is " + size); + " is " + ik.getSize()); } agent.detach(); } diff --git a/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java b/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java index 0c23373e6e3..0bd8bc38b23 100644 --- a/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java +++ b/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java @@ -38,15 +38,20 @@ import jdk.test.lib.Asserts; * @test * @library /test/lib * @modules java.base/jdk.internal.misc - * @modules jdk.hotspot.agent - * @modules jdk.hotspot.agent/sun.jvm.hotspot - * @modules jdk.hotspot.agent/sun.jvm.hotspot.utilities - * @modules jdk.hotspot.agent/sun.jvm.hotspot.oops - * @compile -XDignore.symbol.file=true -Xmodule:jdk.hotspot.agent - * -XaddExports:java.base/jdk.internal.misc=jdk.hotspot.agent - * -XaddExports:java.management/java.lang.management=jdk.hotspot.agent + * @compile -XDignore.symbol.file=true + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED * TestInstanceKlassSizeForInterface.java - * @run main/othervm TestInstanceKlassSizeForInterface + * @run main/othervm + * -XX:+UnlockDiagnosticVMOptions + * --add-modules=jdk.hotspot.agent + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED + * TestInstanceKlassSizeForInterface */ interface Language { @@ -80,6 +85,8 @@ public class TestInstanceKlassSizeForInterface { for (String instanceKlassName : instanceKlassNames) { InstanceKlass iKlass = SystemDictionaryHelper.findInstanceKlass( instanceKlassName); + Asserts.assertNotNull(iKlass, + String.format("Unable to find instance klass for %s", instanceKlassName)); System.out.println("SA: The size of " + instanceKlassName + " is " + iKlass.getSize()); } @@ -106,11 +113,11 @@ public class TestInstanceKlassSizeForInterface { // Grab the pid from the current java process and pass it String[] toolArgs = { - "-XX:+UnlockDiagnosticVMOptions", "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED", "TestInstanceKlassSizeForInterface", Long.toString(ProcessTools.getProcessId()) }; @@ -138,6 +145,8 @@ public class TestInstanceKlassSizeForInterface { String jcmdInstanceKlassSize = getJcmdInstanceKlassSize( jcmdOutput, instanceKlassName); + Asserts.assertNotNull(jcmdInstanceKlassSize, + "Could not get the instance klass size from the jcmd output"); for (String s : SAOutput.asLines()) { if (s.contains(instanceKlassName)) { Asserts.assertTrue( @@ -162,7 +171,7 @@ public class TestInstanceKlassSizeForInterface { return; } - if ( args == null || args.length == 0 ) { + if (args == null || args.length == 0) { ParselTongue lang = new ParselTongue(); Language ventro = new Language() { From 4f55b6c7e03687e9b799456d6e4d0b82027566ec Mon Sep 17 00:00:00 2001 From: Alexander Kulyakhtin Date: Tue, 30 Aug 2016 12:48:03 +0300 Subject: [PATCH 066/296] 8148103: add more tests for task "Update JDI and JDWP for modules" A new JDWP test Reviewed-by: sspitsyn --- .../jdwp/AllModulesCommandTest.java | 149 ++++++++++++++++ .../jdwp/AllModulesCommandTestDebuggee.java | 55 ++++++ .../serviceability/jdwp/DebuggeeLauncher.java | 166 ++++++++++++++++++ .../jdwp/JdwpAllModulesCmd.java | 32 ++++ .../jdwp/JdwpAllModulesReply.java | 61 +++++++ .../serviceability/jdwp/JdwpCanReadCmd.java | 35 ++++ .../serviceability/jdwp/JdwpCanReadReply.java | 41 +++++ .../test/serviceability/jdwp/JdwpChannel.java | 71 ++++++++ .../jdwp/JdwpClassLoaderCmd.java | 34 ++++ .../jdwp/JdwpClassLoaderReply.java | 42 +++++ hotspot/test/serviceability/jdwp/JdwpCmd.java | 93 ++++++++++ .../test/serviceability/jdwp/JdwpExitCmd.java | 34 ++++ .../serviceability/jdwp/JdwpModNameCmd.java | 34 ++++ .../serviceability/jdwp/JdwpModNameReply.java | 42 +++++ .../test/serviceability/jdwp/JdwpReply.java | 75 ++++++++ .../serviceability/jdwp/StreamHandler.java | 81 +++++++++ 16 files changed, 1045 insertions(+) create mode 100644 hotspot/test/serviceability/jdwp/AllModulesCommandTest.java create mode 100644 hotspot/test/serviceability/jdwp/AllModulesCommandTestDebuggee.java create mode 100644 hotspot/test/serviceability/jdwp/DebuggeeLauncher.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpAllModulesCmd.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpAllModulesReply.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpCanReadCmd.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpCanReadReply.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpChannel.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpClassLoaderCmd.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpClassLoaderReply.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpCmd.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpExitCmd.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpModNameCmd.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpModNameReply.java create mode 100644 hotspot/test/serviceability/jdwp/JdwpReply.java create mode 100644 hotspot/test/serviceability/jdwp/StreamHandler.java diff --git a/hotspot/test/serviceability/jdwp/AllModulesCommandTest.java b/hotspot/test/serviceability/jdwp/AllModulesCommandTest.java new file mode 100644 index 00000000000..33bb583c59d --- /dev/null +++ b/hotspot/test/serviceability/jdwp/AllModulesCommandTest.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.IOException; +import java.util.Arrays; +import java.util.concurrent.CountDownLatch; +import java.util.Set; +import java.util.HashSet; +import static jdk.test.lib.Asserts.assertTrue; + +/** + * @test + * @summary Tests AllModules JDWP command + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @compile AllModulesCommandTestDebuggee.java + * @run main/othervm AllModulesCommandTest + */ +public class AllModulesCommandTest implements DebuggeeLauncher.Listener { + + private DebuggeeLauncher launcher; + private JdwpChannel channel; + private CountDownLatch jdwpLatch = new CountDownLatch(1); + private Set jdwpModuleNames = new HashSet<>(); + private Set javaModuleNames = new HashSet<>(); + + public static void main(String[] args) throws Throwable { + new AllModulesCommandTest().doTest(); + } + + private void doTest() throws Throwable { + launcher = new DebuggeeLauncher(this); + launcher.launchDebuggee(); + // Await till the debuggee sends all the necessary modules info to check against + // then start the JDWP session + jdwpLatch.await(); + doJdwp(); + } + + @Override + public void onDebuggeeModuleInfo(String modName) { + // The debuggee has sent out info about a loaded module + javaModuleNames.add(modName); + } + + @Override + public void onDebuggeeSendingCompleted() { + // The debuggee has completed sending all the info + // We can start the JDWP session + jdwpLatch.countDown(); + } + + @Override + public void onDebuggeeError(String message) { + System.err.println("Debuggee error: '" + message + "'"); + System.exit(1); + } + + private void doJdwp() throws Exception { + try { + // Establish JDWP socket connection + channel = new JdwpChannel(); + channel.connect(); + // Send out ALLMODULES JDWP command + // and verify the reply + JdwpAllModulesReply reply = new JdwpAllModulesCmd().send(channel); + assertReply(reply); + for (int i = 0; i < reply.getModulesCount(); ++i) { + long modId = reply.getModuleId(i); + // For each module reported by JDWP get its name using the JDWP NAME command + getModuleName(modId); + // Assert the JDWP CANREAD and CLASSLOADER commands + assertCanRead(modId); + assertClassLoader(modId); + } + + System.out.println("Module names reported by JDWP: " + Arrays.toString(jdwpModuleNames.toArray())); + System.out.println("Module names reported by Java: " + Arrays.toString(javaModuleNames.toArray())); + + // Modules reported by the JDWP should be the same as reported by the Java API + if (!jdwpModuleNames.equals(javaModuleNames)) { + throw new RuntimeException("Modules info reported by Java API differs from that reported by JDWP."); + } else { + System.out.println("Test passed!"); + } + + } finally { + launcher.terminateDebuggee(); + try { + new JdwpExitCmd(0).send(channel); + channel.disconnect(); + } catch (Exception x) { + } + } + } + + private void getModuleName(long modId) throws IOException { + // Send out the JDWP NAME command and store the reply + JdwpModNameReply reply = new JdwpModNameCmd(modId).send(channel); + assertReply(reply); + String modName = reply.getModuleName(); + if (modName != null) { // JDWP reports unnamed modules, ignore them + jdwpModuleNames.add(modName); + } + } + + private void assertReply(JdwpReply reply) { + // Simple assert for any JDWP reply + if (reply.getErrorCode() != 0) { + throw new RuntimeException("Unexpected reply error code " + reply.getErrorCode() + " for reply " + reply); + } + } + + private void assertCanRead(long modId) throws IOException { + // Simple assert for the CANREAD command + JdwpCanReadReply reply = new JdwpCanReadCmd(modId, modId).send(channel); + assertReply(reply); + assertTrue(reply.canRead(), "canRead() reports false for reading from the same module"); + } + + private void assertClassLoader(long modId) throws IOException { + // Simple assert for the CLASSLOADER command + JdwpClassLoaderReply reply = new JdwpClassLoaderCmd(modId).send(channel); + assertReply(reply); + long clId = reply.getClassLoaderId(); + assertTrue(clId >= 0, "bad classloader refId " + clId + " for module id " + modId); + } + +} diff --git a/hotspot/test/serviceability/jdwp/AllModulesCommandTestDebuggee.java b/hotspot/test/serviceability/jdwp/AllModulesCommandTestDebuggee.java new file mode 100644 index 00000000000..1b686ec9ae4 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/AllModulesCommandTestDebuggee.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.lang.reflect.Module; +import java.lang.reflect.Layer; +import java.util.Set; +import java.util.HashSet; + +/** + * The debuggee to be launched by the test + * Sends out the info about the loaded modules + * then stays to respond to the JDWP commands + */ +public class AllModulesCommandTestDebuggee { + + public static void main(String[] args) throws InterruptedException { + + int modCount = Layer.boot().modules().size(); + + // Send all modules names via the process output + for (Module mod : Layer.boot().modules()) { + String info = String.format("module %s", mod.getName()); + write(info); + } + // Signal that the sending is done + write("ready"); + Thread.sleep(Long.MAX_VALUE); + } + + private static void write(String s) { + System.out.println(s); + System.out.flush(); + } + +} diff --git a/hotspot/test/serviceability/jdwp/DebuggeeLauncher.java b/hotspot/test/serviceability/jdwp/DebuggeeLauncher.java new file mode 100644 index 00000000000..259c9ac0f6c --- /dev/null +++ b/hotspot/test/serviceability/jdwp/DebuggeeLauncher.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.StringTokenizer; +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Utils; +import static jdk.test.lib.Asserts.assertFalse; + +/** + * Launches the debuggee with the necessary JDWP options and handles the output + */ +public class DebuggeeLauncher implements StreamHandler.Listener { + + public interface Listener { + + /** + * Callback to use when a module name is received from the debuggee + * + * @param modName module name reported by the debuggee + */ + void onDebuggeeModuleInfo(String modName); + + /** + * Callback to use when the debuggee completes sending out the info + */ + void onDebuggeeSendingCompleted(); + + /** + * Callback to handle any debuggee error + * + * @param line line from the debuggee's stderr + */ + void onDebuggeeError(String line); + } + + private static int jdwpPort = -1; + private static final String CLS_DIR = System.getProperty("test.classes", "").trim(); + private static final String DEBUGGEE = "AllModulesCommandTestDebuggee"; + private Process p; + private final Listener listener; + private StreamHandler inputHandler; + private StreamHandler errorHandler; + + /** + * @param listener the listener we report the debuggee events to + */ + public DebuggeeLauncher(Listener listener) { + this.listener = listener; + } + + /** + * Starts the debuggee with the necessary JDWP options and handles the + * debuggee's stdout and stderr outputs + * + * @throws Throwable + */ + public void launchDebuggee() throws Throwable { + + ProcessBuilder pb = new ProcessBuilder(getCommand()); + p = pb.start(); + inputHandler = new StreamHandler(p.getInputStream(), this); + errorHandler = new StreamHandler(p.getErrorStream(), this); + inputHandler.start(); + errorHandler.start(); + } + + /** + * Command to start the debuggee with the JDWP options and using the JDK + * under test + * + * @return the command + */ + private String[] getCommand() { + return new String[]{ + JDKToolFinder.getTestJDKTool("java"), + getJdwpOptions(), + "-cp", + CLS_DIR, + DEBUGGEE + }; + } + + /** + * Terminates the debuggee + */ + public void terminateDebuggee() { + if (p.isAlive()) { + p.destroyForcibly(); + } + } + + /** + * Debuggee JDWP options + * + * @return the JDWP options to start the debuggee with + */ + private static String getJdwpOptions() { + return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + getJdwpPort(); + } + + /** + * Find an available port for the JDWP session + * + * @return JDWP port + */ + public static int getJdwpPort() { + if (jdwpPort == -1) { + jdwpPort = findFreePort(); + assertFalse(jdwpPort == -1, "Can not find vailbale port for JDWP"); + } + return jdwpPort; + } + + private static int findFreePort() { + try (ServerSocket socket = new ServerSocket(0)) { + return socket.getLocalPort(); + } catch (IOException e) { + } + return -1; + } + + @Override + public void onStringRead(StreamHandler handler, String line) { + if (handler.equals(errorHandler)) { + terminateDebuggee(); + listener.onDebuggeeError(line); + } else { + processDebuggeeOutput(line); + } + } + + private void processDebuggeeOutput(String line) { + StringTokenizer st = new StringTokenizer(line); + String token = st.nextToken(); + switch (token) { + case "module": + listener.onDebuggeeModuleInfo(st.nextToken()); + break; + case "ready": + listener.onDebuggeeSendingCompleted(); + break; + } + } +} diff --git a/hotspot/test/serviceability/jdwp/JdwpAllModulesCmd.java b/hotspot/test/serviceability/jdwp/JdwpAllModulesCmd.java new file mode 100644 index 00000000000..020b95f9962 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpAllModulesCmd.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/** + * The JDWP ALLMODULES command + */ +public class JdwpAllModulesCmd extends JdwpCmd { + + public JdwpAllModulesCmd() { + super(22, 1, JdwpAllModulesReply.class, 0); + } +} diff --git a/hotspot/test/serviceability/jdwp/JdwpAllModulesReply.java b/hotspot/test/serviceability/jdwp/JdwpAllModulesReply.java new file mode 100644 index 00000000000..53d3de1f11f --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpAllModulesReply.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.DataInputStream; +import java.io.IOException; + +/** + * The JDWP reply to the ALLMODULES command + */ +public class JdwpAllModulesReply extends JdwpReply { + + private int modulesCount; + private long[] modulesId; + + protected void parseData(DataInputStream ds) throws IOException { + modulesCount = ds.readInt(); + modulesId = new long[modulesCount]; + for (int nmod = 0; nmod < modulesCount; ++nmod) { + modulesId[nmod] = readRefId(ds); + } + } + + /** + * Number of modules reported + * + * @return modules count + */ + public int getModulesCount() { + return modulesCount; + } + + /** + * The id of a module reported + * + * @param ndx module index in the array of the reported ids + * @return module id + */ + public long getModuleId(int ndx) { + return modulesId[ndx]; + } +} diff --git a/hotspot/test/serviceability/jdwp/JdwpCanReadCmd.java b/hotspot/test/serviceability/jdwp/JdwpCanReadCmd.java new file mode 100644 index 00000000000..81cb5a9983c --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpCanReadCmd.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/** + * The JDWP CANREAD command + */ +public class JdwpCanReadCmd extends JdwpCmd { + + public JdwpCanReadCmd(long modId, long srcModId) { + super(3, 18, JdwpCanReadReply.class, 2 * refLen()); + putRefId(modId); + putRefId(srcModId); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpCanReadReply.java b/hotspot/test/serviceability/jdwp/JdwpCanReadReply.java new file mode 100644 index 00000000000..f838baf89b6 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpCanReadReply.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ +import java.io.DataInputStream; +import java.io.IOException; + +/** + * The reply to the JDWP CANREAD command + */ +public class JdwpCanReadReply extends JdwpReply { + + private boolean canRead; + + protected void parseData(DataInputStream ds) throws IOException { + canRead = ds.read() == 1; + } + + public boolean canRead() { + return canRead; + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpChannel.java b/hotspot/test/serviceability/jdwp/JdwpChannel.java new file mode 100644 index 00000000000..d2e780c802f --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpChannel.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.net.Socket; +import java.util.Arrays; + +/** + * JDWP socket transport + */ +public class JdwpChannel { + + private Socket sock; + + public void connect() throws IOException { + sock = new Socket("localhost", DebuggeeLauncher.getJdwpPort()); + handshake(); + } + + /** + * Sends JDWP handshake and verifies the reply + * @throws IOException + */ + private void handshake() throws IOException { + final byte[] HANDSHAKE = "JDWP-Handshake".getBytes(); + sock.getOutputStream().write(HANDSHAKE, 0, HANDSHAKE.length); + + byte[] reply = new byte[14]; + sock.getInputStream().read(reply, 0, 14); + if (!Arrays.equals(HANDSHAKE, reply)) { + throw new RuntimeException("Error during handshake. Reply was: " + new String(reply) + " expected " + new String(HANDSHAKE)); + } + } + + public void disconnect() { + try { + sock.close(); + } catch (IOException x) { + } + } + + public void write(byte[] data, int length) throws IOException { + sock.getOutputStream().write(data, 0, length); + } + + public InputStream getInputStream() throws IOException { + return sock.getInputStream(); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpClassLoaderCmd.java b/hotspot/test/serviceability/jdwp/JdwpClassLoaderCmd.java new file mode 100644 index 00000000000..14ffb615f73 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpClassLoaderCmd.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/** + * The JDWP CLASSLOADER command + */ +public class JdwpClassLoaderCmd extends JdwpCmd { + + public JdwpClassLoaderCmd(long modId) { + super(2, 18, JdwpClassLoaderReply.class, refLen()); + putRefId(modId); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpClassLoaderReply.java b/hotspot/test/serviceability/jdwp/JdwpClassLoaderReply.java new file mode 100644 index 00000000000..bb1cbcd6ace --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpClassLoaderReply.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.DataInputStream; +import java.io.IOException; + +/** + * The JDWP CLASSLOADER reply + */ +public class JdwpClassLoaderReply extends JdwpReply { + + private long refId; + + protected void parseData(DataInputStream ds) throws IOException { + refId = readRefId(ds); + } + + public long getClassLoaderId() { + return refId; + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpCmd.java b/hotspot/test/serviceability/jdwp/JdwpCmd.java new file mode 100644 index 00000000000..fe7f28707a8 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpCmd.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.IOException; +import java.nio.ByteBuffer; + +/** + * Generic JDWP command + * @param the corresponding JDWP reply class, to construct a reply object + */ +public abstract class JdwpCmd { + + private ByteBuffer data; + private static int id = 1; + private final byte FLAGS = 0; + private T reply; + private final int dataLen; + private final int HEADER_LEN = 11; + + /** + * JDWWp command + * @param cmd command code + * @param cmdSet command set + * @param replyClz command reply class + * @param dataLen length of additional data for the command + */ + JdwpCmd(int cmd, int cmdSet, Class replyClz, int dataLen) { + this.dataLen = dataLen; + data = ByteBuffer.allocate(HEADER_LEN + dataLen); + data.putInt(HEADER_LEN + dataLen); + data.putInt(id++); + data.put(FLAGS); + data.put((byte) cmdSet); + data.put((byte) cmd); + if (replyClz != null) { + try { + reply = replyClz.newInstance(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + JdwpCmd(int cmd, int cmdSet, Class replyClz) { + this(cmd, cmdSet, replyClz, 0); + } + + int getDataLength() { + return dataLen; + } + + public final T send(JdwpChannel channel) throws IOException { + System.err.println("Sending command: " + this); + channel.write(data.array(), HEADER_LEN + getDataLength()); + if (reply != null) { + reply.initFromStream(channel.getInputStream()); + } + return (T) reply; + } + + protected void putRefId(long refId) { + data.putLong(refId); + } + + protected void putInt(int val) { + data.putInt(val); + } + + protected static int refLen() { + return 8; + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpExitCmd.java b/hotspot/test/serviceability/jdwp/JdwpExitCmd.java new file mode 100644 index 00000000000..e63031a57ca --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpExitCmd.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/** + * The JDWP EXIT command to terminate the debuggee + */ +public class JdwpExitCmd extends JdwpCmd { + + public JdwpExitCmd(int exitCode) { + super(10, 1, null, 4); + putInt(exitCode); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpModNameCmd.java b/hotspot/test/serviceability/jdwp/JdwpModNameCmd.java new file mode 100644 index 00000000000..2fe4b12aec2 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpModNameCmd.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/** + * The JDWP NAME command + */ +public class JdwpModNameCmd extends JdwpCmd { + + public JdwpModNameCmd(long modId) { + super(1, 18, JdwpModNameReply.class, refLen()); + putRefId(modId); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpModNameReply.java b/hotspot/test/serviceability/jdwp/JdwpModNameReply.java new file mode 100644 index 00000000000..c6db98e6614 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpModNameReply.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.DataInputStream; +import java.io.IOException; + +/** + * JDWP reply to the NAME command + */ +public class JdwpModNameReply extends JdwpReply { + + private byte[] name; + + protected void parseData(DataInputStream ds) throws IOException { + name = readJdwpString(ds); + } + + public String getModuleName() { + return name == null ? null : new String(name); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpReply.java b/hotspot/test/serviceability/jdwp/JdwpReply.java new file mode 100644 index 00000000000..a3f95a5d509 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpReply.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * Generic JDWP reply + */ +public abstract class JdwpReply { + + protected final static int HEADER_LEN = 11; + private byte[] errCode = new byte[2]; + private byte[] data; + + public final void initFromStream(InputStream is) throws IOException { + DataInputStream ds = new DataInputStream(is); + + int length = ds.readInt(); + int id = ds.readInt(); + byte flags = (byte) ds.read(); + + ds.read(errCode, 0, 2); + + int dataLength = length - HEADER_LEN; + if (dataLength > 0) { + data = new byte[dataLength]; + ds.read(data, 0, dataLength); + parseData(new DataInputStream(new ByteArrayInputStream(data))); + } + } + + protected void parseData(DataInputStream ds) throws IOException { + } + + protected byte[] readJdwpString(DataInputStream ds) throws IOException { + byte[] str = null; + int len = ds.readInt(); + if (len > 0) { + str = new byte[len]; + ds.read(str, 0, len); + } + return str; + } + + protected long readRefId(DataInputStream ds) throws IOException { + return ds.readLong(); + } + + public int getErrorCode() { + return (((errCode[0] & 0xFF) << 8) | (errCode[1] & 0xFF)); + } +} diff --git a/hotspot/test/serviceability/jdwp/StreamHandler.java b/hotspot/test/serviceability/jdwp/StreamHandler.java new file mode 100644 index 00000000000..257f66a66a9 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/StreamHandler.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * Handles the process output (either stdin or stdout) + * passing the lines to a listener + */ +public class StreamHandler implements Runnable { + + public interface Listener { + /** + * Called when a line has been read from the process output stream + * @param handler this StreamHandler + * @param s the line + */ + void onStringRead(StreamHandler handler, String s); + } + + private final ExecutorService executor; + private final InputStream is; + private final Listener listener; + + /** + * @param is input stream to read from + * @param listener listener to pass the read lines to + * @throws IOException + */ + public StreamHandler(InputStream is, Listener listener) throws IOException { + this.is = is; + this.listener = listener; + executor = Executors.newSingleThreadExecutor(); + } + + /** + * Starts asynchronous reading + */ + public void start() { + executor.submit(this); + } + + @Override + public void run() { + try { + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String line; + while ((line = br.readLine()) != null) { + listener.onStringRead(this, line); + } + } catch (Exception x) { + throw new RuntimeException(x); + } + } + +} From 3ab913d3984b8e549bdfd7cd41100405a51bee77 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Tue, 30 Aug 2016 15:31:46 +0300 Subject: [PATCH 067/296] 6474807: (smartcardio) CardTerminal.connect() throws CardException instead of CardNotPresentException Reviewed-by: valeriep --- .../classes/sun/security/smartcardio/TerminalImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java b/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java index de1410f3ef1..604fac30cc4 100644 --- a/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java +++ b/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -75,10 +75,10 @@ final class TerminalImpl extends CardTerminal { } } try { - card = new CardImpl(this, protocol); + card = new CardImpl(this, protocol); return card; } catch (PCSCException e) { - if (e.code == SCARD_W_REMOVED_CARD) { + if (e.code == SCARD_W_REMOVED_CARD || e.code == SCARD_E_NO_SMARTCARD) { throw new CardNotPresentException("No card present", e); } else { throw new CardException("connect() failed", e); From 010d9bf7dfb16272f83ad91093e6c529fd1ddbd9 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 30 Aug 2016 16:08:52 +0200 Subject: [PATCH 068/296] 8165315: [ppc] Port "8133749: NMT detail stack trace cleanup" Also add methods to check for slow/fastdebug to Platform.java. Reviewed-by: simonis, cjplummer, dholmes --- hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp | 6 ++++-- hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp | 6 ++++-- .../share/vm/utilities/globalDefinitions_xlc.hpp | 2 +- .../NMT/CheckForProperDetailStackTrace.java | 14 +++++--------- .../TestMutuallyExclusivePlatformPredicates.java | 5 +++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp index 7a40c0df126..1e440ca8579 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp @@ -192,8 +192,10 @@ frame os::current_frame() { intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer()); // hack. frame topframe(csp, (address)0x8); - // return sender of current topframe which hopefully has pc != NULL. - return os::get_sender_for_C_frame(&topframe); + // Return sender of sender of current topframe which hopefully + // both have pc != NULL. + frame tmp = os::get_sender_for_C_frame(&topframe); + return os::get_sender_for_C_frame(&tmp); } // Utility functions diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp index 3dce4275405..c0aeb994f41 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp @@ -205,8 +205,10 @@ frame os::current_frame() { intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer()); // hack. frame topframe(csp, (address)0x8); - // return sender of current topframe which hopefully has pc != NULL. - return os::get_sender_for_C_frame(&topframe); + // Return sender of sender of current topframe which hopefully + // both have pc != NULL. + frame tmp = os::get_sender_for_C_frame(&topframe); + return os::get_sender_for_C_frame(&tmp); } // Utility functions diff --git a/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp b/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp index 68e204d45f0..ff97f116a77 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp @@ -186,6 +186,6 @@ inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } // Inlining support #define NOINLINE -#define ALWAYSINLINE __attribute__((always_inline)) +#define ALWAYSINLINE inline __attribute__((always_inline)) #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP diff --git a/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java b/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java index c053f660e9e..8caa81686f8 100644 --- a/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java +++ b/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java @@ -57,11 +57,6 @@ public class CheckForProperDetailStackTrace { private static String expectedSymbol = "locked_create_entry_or_null"; - private static final String jdkDebug = System.getProperty("jdk.debug"); - private static boolean isSlowDebugBuild() { - return (jdkDebug.toLowerCase().equals("slowdebug")); - } - public static void main(String args[]) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", @@ -76,11 +71,12 @@ public class CheckForProperDetailStackTrace { output.shouldNotContain("NativeCallStack::NativeCallStack"); output.shouldNotContain("os::get_native_stack"); - // AllocateHeap shouldn't be in the output because it is suppose to always be inlined. - // We check for that here, but allow it for Windows and Solaris slowdebug builds because - // the compiler ends up not inlining AllocateHeap. + // AllocateHeap shouldn't be in the output because it is supposed to always be inlined. + // We check for that here, but allow it for Aix, Solaris and Windows slowdebug builds + // because the compiler ends up not inlining AllocateHeap. Boolean okToHaveAllocateHeap = - isSlowDebugBuild() && (Platform.isSolaris() || Platform.isWindows()); + Platform.isSlowDebugBuild() && + (Platform.isAix() || Platform.isSolaris() || Platform.isWindows()); if (!okToHaveAllocateHeap) { output.shouldNotContain("AllocateHeap"); } diff --git a/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java b/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java index 399535944f6..0d38e160684 100644 --- a/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java +++ b/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java @@ -50,8 +50,9 @@ public class TestMutuallyExclusivePlatformPredicates { OS("isAix", "isLinux", "isOSX", "isSolaris", "isWindows"), VM_TYPE("isClient", "isServer", "isGraal", "isMinimal", "isZero", "isEmbedded"), MODE("isInt", "isMixed", "isComp"), - IGNORED("isDebugBuild", "shouldSAAttach", - "canPtraceAttachLinux", "canAttachOSX", "isTieredSupported"); + IGNORED("isDebugBuild", "isFastDebugBuild", "isSlowDebugBuild", + "shouldSAAttach", "canPtraceAttachLinux", "canAttachOSX", + "isTieredSupported"); public final List methodNames; From 87d30c0c7d328e5bd92f19488786e22f1c571ef3 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Thu, 1 Sep 2016 20:46:40 +0300 Subject: [PATCH 069/296] 8164039: Convert test_memset_with_concurrent_readers to GTest Reviewed-by: iignatyev, kbarrett --- .../share/vm/utilities/internalVMTests.cpp | 1 - .../test_memset_with_concurrent_readers.cpp} | 53 +++++++++---------- 2 files changed, 24 insertions(+), 30 deletions(-) rename hotspot/{src/share/vm/gc/shared/memset_with_concurrent_readers.cpp => test/native/gc/shared/test_memset_with_concurrent_readers.cpp} (69%) diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp index 6e7ad0bdf6a..76087d52bfe 100644 --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp @@ -93,7 +93,6 @@ void InternalVMTests::run() { run_unit_test(FreeRegionList_test); run_unit_test(IHOP_test); } - run_unit_test(test_memset_with_concurrent_readers); run_unit_test(WorkerDataArray_test); run_unit_test(ParallelCompact_test); #endif diff --git a/hotspot/src/share/vm/gc/shared/memset_with_concurrent_readers.cpp b/hotspot/test/native/gc/shared/test_memset_with_concurrent_readers.cpp similarity index 69% rename from hotspot/src/share/vm/gc/shared/memset_with_concurrent_readers.cpp rename to hotspot/test/native/gc/shared/test_memset_with_concurrent_readers.cpp index 27625a30dfd..7af5b232ad6 100644 --- a/hotspot/src/share/vm/gc/shared/memset_with_concurrent_readers.cpp +++ b/hotspot/test/native/gc/shared/test_memset_with_concurrent_readers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -19,30 +19,22 @@ * 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. - * */ #include "precompiled.hpp" - #include -#include "gc/shared/memset_with_concurrent_readers.hpp" -#include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" -#include "utilities/macros.hpp" -#include "utilities/ostream.hpp" +#include +#include "gc/shared/memset_with_concurrent_readers.hpp" +#include "unittest.hpp" #if INCLUDE_ALL_GCS -// Unit test -#ifndef PRODUCT - static unsigned line_byte(const char* line, size_t i) { return unsigned(line[i]) & 0xFF; } -// Verify memset_with_concurrent_readers mimics memset. -// We don't attempt to verify the concurrent reader case. -void test_memset_with_concurrent_readers() { +TEST(gc, memset_with_concurrent_readers) { const size_t chunk_size = 8 * BytesPerWord; const unsigned chunk_count = 4; const size_t block_size = (chunk_count + 4) * chunk_size; @@ -76,29 +68,32 @@ void test_memset_with_concurrent_readers() { bool middle_set = !memcmp(set_block, block + set_start, set_size); bool tail_clear = !memcmp(clear_block, block + set_end, block_size - set_end); if (!(head_clear && middle_set && tail_clear)) { - tty->print_cr("*** memset_with_concurrent_readers failed: " - "set start " SIZE_FORMAT ", set end " SIZE_FORMAT, - set_start, set_end); + std::ostringstream err_stream; + err_stream << "*** memset_with_concurrent_readers failed: set start " + << set_start << ", set end " << set_end << std::endl; for (unsigned chunk = 0; chunk < (block_size / chunk_size); ++chunk) { for (unsigned line = 0; line < (chunk_size / BytesPerWord); ++line) { + const char* lp = &block[chunk * chunk_size + line * BytesPerWord]; - tty->print_cr("%d,%d: %2x %2x %2x %2x %2x %2x %2x %2x", - chunk, line, - line_byte(lp, 0), line_byte(lp, 1), - line_byte(lp, 2), line_byte(lp, 3), - line_byte(lp, 4), line_byte(lp, 5), - line_byte(lp, 6), line_byte(lp, 7)); + + err_stream << std::dec << chunk << "," << line << ": " << std::hex + << std::setw(2) << line_byte(lp, 0) << " " + << std::setw(2) << line_byte(lp, 1) << " " + << std::setw(2) << line_byte(lp, 2) << " " + << std::setw(2) << line_byte(lp, 3) << " " + << std::setw(2) << line_byte(lp, 4) << " " + << std::setw(2) << line_byte(lp, 5) << " " + << std::setw(2) << line_byte(lp, 6) << " " + << std::setw(2) << line_byte(lp, 7) << std::endl; } } - assert(head_clear, "leading byte not clear"); - assert(middle_set, "memset byte not set"); - assert(tail_clear, "trailing bye not clear"); + EXPECT_TRUE(head_clear) << "leading byte not clear"; + EXPECT_TRUE(middle_set) << "memset byte not set"; + EXPECT_TRUE(tail_clear) << "trailing bye not clear"; + ASSERT_TRUE(head_clear && middle_set && tail_clear) << err_stream.str(); } } } } } - -#endif // end unit test - -#endif // INCLUDE_ALL_GCS +#endif From f03ab592ccc80856e340bc9524e40f827b09d913 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Thu, 1 Sep 2016 18:02:13 -0400 Subject: [PATCH 070/296] 8165268: [BACKOUT] InstanceKlass::_previous_version_count goes negative Reviewed-by: dcubed --- .../share/vm/classfile/classLoaderData.cpp | 2 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 19 ++----- hotspot/src/share/vm/oops/instanceKlass.hpp | 5 +- .../runtime/RedefineTests/RedefineCount.java | 56 ------------------- 4 files changed, 8 insertions(+), 74 deletions(-) delete mode 100644 hotspot/test/runtime/RedefineTests/RedefineCount.java diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index f7711449312..ba1191614b1 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -962,7 +962,7 @@ bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, // Mark metadata seen on the stack only so we can delete unneeded entries. // Only walk all metadata, including the expensive code cache walk, for Full GC - // and only if class redefinition occurred and if there are previous versions of + // and only if class redefinition and if there's previous versions of // Klasses to delete. bool walk_all_metadata = clean_previous_versions && JvmtiExport::has_redefined_a_class() && diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 2b34d9ae8c2..1385affc5df 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -3370,7 +3370,6 @@ int InstanceKlass::_previous_version_count = 0; // Purge previous versions before adding new previous versions of the class. void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { - assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); if (ik->previous_versions() != NULL) { // This klass has previous versions so see what we can cleanup // while it is safe to do so. @@ -3399,12 +3398,7 @@ void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { // are executing. Unlink this previous_version. // The previous version InstanceKlass is on the ClassLoaderData deallocate list // so will be deallocated during the next phase of class unloading. - // - // Update count for class unloading. - _previous_version_count--; - log_trace(redefine, class, iklass, purge) - ("previous version " INTPTR_FORMAT " is dead. previous_version_count = %d", - p2i(pv_node), _previous_version_count); + log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is dead", p2i(pv_node)); // For debugging purposes. pv_node->set_is_scratch_class(); pv_node->class_loader_data()->add_to_deallocate_list(pv_node); @@ -3519,7 +3513,6 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, int emcp_method_count) { assert(Thread::current()->is_VM_thread(), "only VMThread can add previous versions"); - assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); ResourceMark rm; log_trace(redefine, class, iklass, add) @@ -3543,6 +3536,8 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, // For debugging purposes. scratch_class->set_is_scratch_class(); scratch_class->class_loader_data()->add_to_deallocate_list(scratch_class()); + // Update count for class unloading. + _previous_version_count--; return; } @@ -3570,14 +3565,12 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, } // Add previous version if any methods are still running. - // Update count for class unloading. - _previous_version_count++; - log_trace(redefine, class, iklass, add) - ("scratch class added; one of its methods is on_stack. previous_version_count = %d", - _previous_version_count); + log_trace(redefine, class, iklass, add)("scratch class added; one of its methods is on_stack"); assert(scratch_class->previous_versions() == NULL, "shouldn't have a previous version"); scratch_class->link_previous_versions(previous_versions()); link_previous_versions(scratch_class()); + // Update count for class unloading. + _previous_version_count++; } // end add_previous_version() #endif // INCLUDE_JVMTI diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index c9cc2cfb64f..da36a1422b4 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -771,10 +771,7 @@ public: static int _previous_version_count; public: static void purge_previous_versions(InstanceKlass* ik); - static bool has_previous_versions() { - assert(_previous_version_count >= 0, "count should never be negative"); - return _previous_version_count > 0; - } + static bool has_previous_versions() { return _previous_version_count > 0; } // JVMTI: Support for caching a class file before it is modified by an agent that can do retransformation void set_cached_class_file(JvmtiCachedClassFileData *data) { diff --git a/hotspot/test/runtime/RedefineTests/RedefineCount.java b/hotspot/test/runtime/RedefineTests/RedefineCount.java deleted file mode 100644 index ce8d40d0902..00000000000 --- a/hotspot/test/runtime/RedefineTests/RedefineCount.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2016, 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * 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. - */ - -/* - * @test - * @bug 8164692 - * @summary Redefine previous_versions count goes negative - * @library /test/lib - * @modules java.base/jdk.internal.misc - * @modules java.compiler - * java.instrument - * jdk.jartool/sun.tools.jar - * @run main RedefineClassHelper - * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+iklass+add=trace,redefine+class+iklass+purge=trace RedefineCount - */ -public class RedefineCount { - - public static String newB = - "class RedefineCount$B {" + - "}"; - - static class B { } - - public static void main(String[] args) throws Exception { - - // Redefine a class and create some garbage - // Since there are no methods running, the previous version is never added to the - // previous_version_list and the count should stay zero and not go negative - RedefineClassHelper.redefineClass(B.class, newB); - - for (int i = 0; i < 20 ; i++) { - String s = new String("some garbage"); - System.gc(); - } - } -} From 3e07dc6611689d1307ad6f1ecefcc7fcdb48bf75 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Fri, 2 Sep 2016 08:51:26 +0200 Subject: [PATCH 071/296] 8165215: Setting same UL tag multiple times matches wrong tagset Reviewed-by: mlarsson, rprotacio --- hotspot/src/share/vm/logging/logTagLevelExpression.cpp | 9 ++++++++- hotspot/src/share/vm/logging/logTagLevelExpression.hpp | 8 +++++++- .../test/native/logging/test_logTagLevelExpression.cpp | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/logging/logTagLevelExpression.cpp b/hotspot/src/share/vm/logging/logTagLevelExpression.cpp index 6520c62d962..6b53ab563a9 100644 --- a/hotspot/src/share/vm/logging/logTagLevelExpression.cpp +++ b/hotspot/src/share/vm/logging/logTagLevelExpression.cpp @@ -164,7 +164,14 @@ bool LogTagLevelExpression::parse(const char* str, outputStream* errstream) { success = false; break; } - add_tag(tag); + if (!add_tag(tag)) { + if (errstream != NULL) { + errstream->print_cr("Tag combination have duplicate tag '%s' in what-expression.", + cur_tag); + } + success = false; + break; + } cur_tag = plus_pos + 1; } while (plus_pos != NULL); diff --git a/hotspot/src/share/vm/logging/logTagLevelExpression.hpp b/hotspot/src/share/vm/logging/logTagLevelExpression.hpp index e1f4cb2e94a..278f265a0d0 100644 --- a/hotspot/src/share/vm/logging/logTagLevelExpression.hpp +++ b/hotspot/src/share/vm/logging/logTagLevelExpression.hpp @@ -59,9 +59,15 @@ class LogTagLevelExpression : public StackObj { _ntags = 0; } - void add_tag(LogTagType tag) { + bool add_tag(LogTagType tag) { assert(_ntags < LogTag::MaxTags, "Can't have more tags than MaxTags!"); + for (size_t i = 0; i < _ntags; i++) { + if (_tags[_ncombinations][i] == tag) { + return false; + } + } _tags[_ncombinations][_ntags++] = tag; + return true; } void set_level(LogLevelType level) { diff --git a/hotspot/test/native/logging/test_logTagLevelExpression.cpp b/hotspot/test/native/logging/test_logTagLevelExpression.cpp index 72bd244a5ca..870c6af42db 100644 --- a/hotspot/test/native/logging/test_logTagLevelExpression.cpp +++ b/hotspot/test/native/logging/test_logTagLevelExpression.cpp @@ -33,7 +33,7 @@ TEST(LogTagLevelExpression, parse) { const char* invalid_substr[] = { "=", "+", " ", "+=", "+=*", "*+", " +", "**", "++", ".", ",", ",," ",+", " *", "all+", "all*", "+all", "+all=Warning", "==Info", "=InfoWarning", - "BadTag+", "logging++", "logging*+", ",=", "gc+gc+gc+gc+gc+gc" + "BadTag+", "logging++", "logging*+", ",=", "gc+gc+" }; const char* valid_expression[] = { "all", "gc", "gc,logging", "gc+logging", "logging+gc", "logging+gc,gc", "logging+gc*", "gc=trace", From e4f4b40488a329dba5e19c8c57317673b6632d85 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Fri, 2 Sep 2016 09:49:10 +0200 Subject: [PATCH 072/296] 8164936: G1 age table printout contains contents from previous GC Split tenuring threshold update and printing into two separate parts so that they can be used independently. Reviewed-by: jmasa, sangheki --- .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 1 + .../src/share/vm/gc/g1/g1DefaultPolicy.cpp | 16 ++- .../src/share/vm/gc/g1/g1DefaultPolicy.hpp | 4 + hotspot/src/share/vm/gc/g1/g1Policy.hpp | 3 + .../share/vm/gc/serial/defNewGeneration.cpp | 15 ++- hotspot/src/share/vm/gc/shared/ageTable.cpp | 27 +++-- hotspot/src/share/vm/gc/shared/ageTable.hpp | 8 +- hotspot/test/gc/TestAgeOutput.java | 103 ++++++++++++++++++ 8 files changed, 154 insertions(+), 23 deletions(-) create mode 100644 hotspot/test/gc/TestAgeOutput.java diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index e1462e9343c..7b6974c4f58 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -4513,6 +4513,7 @@ void G1CollectedHeap::post_evacuate_collection_set(EvacuationInfo& evacuation_in #if defined(COMPILER2) || INCLUDE_JVMCI DerivedPointerTable::update_pointers(); #endif + g1_policy()->print_age_table(); } void G1CollectedHeap::record_obj_copy_mem_stats() { diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index 454f73bc0c6..803c1b62d79 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -885,6 +885,15 @@ bool G1DefaultPolicy::adaptive_young_list_length() const { return _young_gen_sizer.adaptive_young_list_length(); } +size_t G1DefaultPolicy::desired_survivor_size() const { + size_t const survivor_capacity = HeapRegion::GrainWords * _max_survivor_regions; + return (size_t)((((double)survivor_capacity) * TargetSurvivorRatio) / 100); +} + +void G1DefaultPolicy::print_age_table() { + _survivors_age_table.print_age_table(_tenuring_threshold); +} + void G1DefaultPolicy::update_max_gc_locker_expansion() { uint expansion_region_num = 0; if (GCLockerEdenExpansionPercent > 0) { @@ -908,8 +917,11 @@ void G1DefaultPolicy::update_survivors_policy() { // smaller than 1.0) we'll get 1. _max_survivor_regions = (uint) ceil(max_survivor_regions_d); - _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold( - HeapRegion::GrainWords * _max_survivor_regions, _policy_counters); + _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold(desired_survivor_size()); + if (UsePerfData) { + _policy_counters->tenuring_threshold()->set_value(_tenuring_threshold); + _policy_counters->desired_survivor_size()->set_value(desired_survivor_size() * oopSize); + } } bool G1DefaultPolicy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp index 21ab55a4ab4..6eba7e76e20 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp @@ -360,6 +360,8 @@ private: AgeTable _survivors_age_table; +protected: + size_t desired_survivor_size() const; public: uint tenuring_threshold() const { return _tenuring_threshold; } @@ -379,6 +381,8 @@ public: _survivors_age_table.merge(age_table); } + void print_age_table(); + void update_max_gc_locker_expansion(); void update_survivors_policy(); diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp index 78240032d2d..92aa6050e70 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -181,6 +181,9 @@ public: virtual void note_stop_adding_survivor_regions() = 0; virtual void record_age_table(AgeTable* age_table) = 0; + virtual void print_age_table() = 0; +protected: + virtual size_t desired_survivor_size() const = 0; }; #endif // SHARE_VM_GC_G1_G1POLICY_HPP diff --git a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp index 147bc06d305..e7f96a22228 100644 --- a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp +++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp @@ -564,9 +564,18 @@ HeapWord* DefNewGeneration::expand_and_allocate(size_t size, void DefNewGeneration::adjust_desired_tenuring_threshold() { // Set the desired survivor size to half the real survivor space - GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->gen_policy()->counters(); - _tenuring_threshold = - age_table()->compute_tenuring_threshold(to()->capacity()/HeapWordSize, gc_counters); + size_t const survivor_capacity = to()->capacity() / HeapWordSize; + size_t const desired_survivor_size = (size_t)((((double)survivor_capacity) * TargetSurvivorRatio) / 100); + + _tenuring_threshold = age_table()->compute_tenuring_threshold(desired_survivor_size); + + if (UsePerfData) { + GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->gen_policy()->counters(); + gc_counters->tenuring_threshold()->set_value(_tenuring_threshold); + gc_counters->desired_survivor_size()->set_value(desired_survivor_size * oopSize); + } + + age_table()->print_age_table(_tenuring_threshold); } void DefNewGeneration::collect(bool full, diff --git a/hotspot/src/share/vm/gc/shared/ageTable.cpp b/hotspot/src/share/vm/gc/shared/ageTable.cpp index 48ddfa1e492..d2a76cff1d0 100644 --- a/hotspot/src/share/vm/gc/shared/ageTable.cpp +++ b/hotspot/src/share/vm/gc/shared/ageTable.cpp @@ -27,7 +27,6 @@ #include "gc/shared/ageTableTracer.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/collectorPolicy.hpp" -#include "gc/shared/gcPolicyCounters.hpp" #include "memory/resourceArea.hpp" #include "logging/log.hpp" #include "oops/oop.inline.hpp" @@ -75,8 +74,7 @@ void AgeTable::merge(AgeTable* subTable) { } } -uint AgeTable::compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCounters* gc_counters) { - size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100); +uint AgeTable::compute_tenuring_threshold(size_t desired_survivor_size) { uint result; if (AlwaysTenure || NeverTenure) { @@ -99,9 +97,16 @@ uint AgeTable::compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCoun log_debug(gc, age)("Desired survivor size " SIZE_FORMAT " bytes, new threshold " UINTX_FORMAT " (max threshold " UINTX_FORMAT ")", - desired_survivor_size*oopSize, (uintx) result, MaxTenuringThreshold); + desired_survivor_size * oopSize, (uintx) result, MaxTenuringThreshold); + return result; +} + +void AgeTable::print_age_table(uint tenuring_threshold) { if (log_is_enabled(Trace, gc, age) || UsePerfData || AgeTableTracer::is_tenuring_distribution_event_enabled()) { + log_trace(gc, age)("Age table with threshold %u (max threshold " UINTX_FORMAT ")", + tenuring_threshold, MaxTenuringThreshold); + size_t total = 0; uint age = 1; while (age < table_size) { @@ -109,20 +114,14 @@ uint AgeTable::compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCoun total += wordSize; if (wordSize > 0) { log_trace(gc, age)("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total", - age, wordSize*oopSize, total*oopSize); + age, wordSize * oopSize, total * oopSize); } - AgeTableTracer::send_tenuring_distribution_event(age, wordSize*oopSize); + AgeTableTracer::send_tenuring_distribution_event(age, wordSize * oopSize); if (UsePerfData) { - _perf_sizes[age]->set_value(wordSize*oopSize); + _perf_sizes[age]->set_value(wordSize * oopSize); } age++; } - if (UsePerfData) { - gc_counters->tenuring_threshold()->set_value(result); - gc_counters->desired_survivor_size()->set_value( - desired_survivor_size*oopSize); - } } - - return result; } + diff --git a/hotspot/src/share/vm/gc/shared/ageTable.hpp b/hotspot/src/share/vm/gc/shared/ageTable.hpp index 4af836f8acd..858ae0ae5dd 100644 --- a/hotspot/src/share/vm/gc/shared/ageTable.hpp +++ b/hotspot/src/share/vm/gc/shared/ageTable.hpp @@ -29,8 +29,6 @@ #include "oops/oop.hpp" #include "runtime/perfData.hpp" -class GCPolicyCounters; - /* Copyright (c) 1992, 2016, Oracle and/or its affiliates, and Stanford University. See the LICENSE file for license information. */ @@ -67,10 +65,12 @@ class AgeTable VALUE_OBJ_CLASS_SPEC { // for parallel young generation gc. void merge(AgeTable* subTable); - // calculate new tenuring threshold based on age information - uint compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCounters* gc_counters); + // Calculate new tenuring threshold based on age information. + uint compute_tenuring_threshold(size_t desired_survivor_size); + void print_age_table(uint tenuring_threshold); private: + PerfVariable* _perf_sizes[table_size]; }; diff --git a/hotspot/test/gc/TestAgeOutput.java b/hotspot/test/gc/TestAgeOutput.java new file mode 100644 index 00000000000..6be8c14e0e0 --- /dev/null +++ b/hotspot/test/gc/TestAgeOutput.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test TestAgeOutput + * @bug 8164936 + * @summary Check that collectors using age table based aging print an age table even for the first garbage collection + * @key gc + * @requires vm.gc=="null" + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -XX:+UseSerialGC TestAgeOutput UseSerialGC + * @run main/othervm -XX:+UseConcMarkSweepGC TestAgeOutput UseConcMarkSweepGC + * @run main/othervm -XX:+UseG1GC TestAgeOutput UseG1GC + */ + +import sun.hotspot.WhiteBox; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jdk.test.lib.Platform; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import static jdk.test.lib.Asserts.*; + +public class TestAgeOutput { + + public static void checkPattern(String pattern, String what) throws Exception { + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(what); + + if (!m.find()) { + throw new RuntimeException("Could not find pattern " + pattern + " in output"); + } + } + + public static void runTest(String gcArg) throws Exception { + final String[] arguments = { + "-Xbootclasspath/a:.", + "-XX:+UnlockExperimentalVMOptions", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:+" + gcArg, + "-Xmx10M", + "-Xlog:gc+age=trace", + GCTest.class.getName() + }; + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + output.shouldHaveExitValue(0); + + System.out.println(output.getStdout()); + + String stdout = output.getStdout(); + + checkPattern(".*GC\\(0\\) .*Desired survivor size.*", stdout); + checkPattern(".*GC\\(0\\) .*Age table with threshold.*", stdout); + checkPattern(".*GC\\(0\\) .*- age 1:.*", stdout); + } + + public static void main(String[] args) throws Exception { + runTest(args[0]); + } + + static class GCTest { + private static final WhiteBox WB = WhiteBox.getWhiteBox(); + + public static Object holder; + + public static void main(String [] args) { + holder = new byte[100]; + WB.youngGC(); + System.out.println(holder); + } + } +} + From 8a4ddec87486c8b743cd04e4e995e8b5b353f4ed Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Tue, 30 Aug 2016 21:35:56 +0300 Subject: [PATCH 073/296] 8157468: gc/testlibrary contains a lot of duplicated code Reviewed-by: dfazunen, iignatyev --- hotspot/test/gc/testlibrary/Helpers.java | 67 ++++-------------------- 1 file changed, 9 insertions(+), 58 deletions(-) diff --git a/hotspot/test/gc/testlibrary/Helpers.java b/hotspot/test/gc/testlibrary/Helpers.java index e97d4a03ea9..e326308e5d1 100644 --- a/hotspot/test/gc/testlibrary/Helpers.java +++ b/hotspot/test/gc/testlibrary/Helpers.java @@ -32,7 +32,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; public class Helpers { @@ -124,20 +123,13 @@ public class Helpers { */ public static String generate(String className, String superClass, String constructor, long fieldCount) { - StringBuilder builder = new StringBuilder(); - builder.append(String.format("public class %s%s {\n", className, superClass == null ? "" - : " extends " + superClass)); - - if (constructor != null) { - builder.append(constructor); - } - - for (int i = 0; i < fieldCount; ++i) { - builder.append(String.format("long f%d;\n", i)); - } - - builder.append("}\n"); - return builder.toString(); + return new StringBuilder() + .append(String.format("public class %s%s {\n", className, superClass == null ? "" + : " extends " + superClass)) + .append(constructor == null ? "" : constructor) + .append(fieldsGenerator(fieldCount)) + .append("}\n") + .toString(); } /** @@ -212,50 +204,9 @@ public class Helpers { Path workDir, String prefix) throws IOException, ClassNotFoundException { - if (instanceSize % SIZE_OF_LONG != 0L) { - throw new Error(String.format("Test bug: only sizes aligned by 8 bytes are supported and %d was specified", - instanceSize)); - } + generateByTemplateAndCompile(className, null, "public class ${ClassName} extends ${BaseClass} {\n${Fields}}\n", + "", instanceSize, workDir, prefix); - long instanceSizeWithoutObjectHeader = instanceSize - WhiteBox.getWhiteBox().getObjectSize(new Object()); - - int generatedClassesCount; - int fieldsInLastClassCount; - - int sizeOfLastFile = (int) (instanceSizeWithoutObjectHeader - % (MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS * SIZE_OF_LONG)); - - if (sizeOfLastFile != 0) { - generatedClassesCount = (int) instanceSizeWithoutObjectHeader - / (MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS * SIZE_OF_LONG) + 1; - fieldsInLastClassCount = sizeOfLastFile / SIZE_OF_LONG; - } else { - generatedClassesCount = (int) instanceSizeWithoutObjectHeader - / (MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS * SIZE_OF_LONG); - fieldsInLastClassCount = MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS; - } - - for (int i = 0; i < generatedClassesCount; i++) { - // for the last generated class we use specified class name - String clsName = (i == generatedClassesCount - 1) ? className : prefix + i; - - // If we already have a file with the same name we do not create it again - if (Files.notExists(Paths.get(clsName + ".java"))) { - Helpers.compileClass(clsName, workDir, - Helpers.generate( - clsName, - // for first generated class we don't have 'extends' - (i == 0 ? null : prefix + (i - 1)), - null, - // for the last generated class we use different field count - (i == generatedClassesCount - 1) ? fieldsInLastClassCount - : MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS)); - } else { - System.out.println("Class " + clsName + - ".java already exists, skipping class' generation and compilation"); - } - - } return classLoader.loadClass(className); } From 0b55f8862f9e9b7a114ad1d5c23b55143f376a6a Mon Sep 17 00:00:00 2001 From: Alexandre Iline Date: Tue, 30 Aug 2016 14:30:32 -0700 Subject: [PATCH 074/296] 8164859: Fix module dependences in java/text tests Reviewed-by: naoto --- jdk/test/java/text/Bidi/BidiConformance.java | 3 ++- jdk/test/java/text/Bidi/BidiEmbeddingTest.java | 3 ++- jdk/test/java/text/Bidi/Bug7042148.java | 3 ++- jdk/test/java/text/Bidi/Bug7051769.java | 3 ++- jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java | 7 ++++--- jdk/test/java/text/Collator/APITest.java | 1 + jdk/test/java/text/Collator/CollationKeyTest.java | 1 + jdk/test/java/text/Collator/DanishTest.java | 1 + jdk/test/java/text/Collator/FinnishTest.java | 1 + jdk/test/java/text/Collator/FrenchTest.java | 1 + jdk/test/java/text/Collator/G7Test.java | 1 + jdk/test/java/text/Collator/JapaneseTest.java | 1 + jdk/test/java/text/Collator/KoreanTest.java | 1 + jdk/test/java/text/Collator/Regression.java | 1 + jdk/test/java/text/Collator/ThaiTest.java | 1 + jdk/test/java/text/Collator/TurkishTest.java | 1 + jdk/test/java/text/Collator/VietnameseTest.java | 1 + jdk/test/java/text/Format/DateFormat/Bug4823811.java | 3 ++- jdk/test/java/text/Format/DateFormat/Bug6683975.java | 3 ++- jdk/test/java/text/Format/DateFormat/Bug8139572.java | 3 ++- .../java/text/Format/DateFormat/ContextMonthNamesTest.java | 3 ++- jdk/test/java/text/Format/DateFormat/DateFormatTest.java | 1 + .../java/text/Format/DateFormat/LocaleDateFormats.java | 3 ++- .../text/Format/DateFormat/NonGregorianFormatTest.java | 1 + jdk/test/java/text/Format/DateFormat/bug4117335.java | 1 + .../java/text/Format/MessageFormat/LargeMessageFormat.java | 1 + jdk/test/java/text/Format/NumberFormat/Bug8132125.java | 3 ++- jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java | 1 + .../text/Format/NumberFormat/IntlTestNumberFormatAPI.java | 1 + .../java/text/Format/NumberFormat/NumberRegression.java | 1 + jdk/test/java/text/Format/NumberFormat/NumberTest.java | 1 + 31 files changed, 44 insertions(+), 13 deletions(-) diff --git a/jdk/test/java/text/Bidi/BidiConformance.java b/jdk/test/java/text/Bidi/BidiConformance.java index 73689659cc3..45e49cb632f 100644 --- a/jdk/test/java/text/Bidi/BidiConformance.java +++ b/jdk/test/java/text/Bidi/BidiConformance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, 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,6 +25,7 @@ * @test * @bug 6850113 8032446 * @summary confirm the behavior of new Bidi implementation. (Backward compatibility) + * @modules java.desktop */ import java.awt.font.NumericShaper; diff --git a/jdk/test/java/text/Bidi/BidiEmbeddingTest.java b/jdk/test/java/text/Bidi/BidiEmbeddingTest.java index 86578f4f1be..fb4d5f7418c 100644 --- a/jdk/test/java/text/Bidi/BidiEmbeddingTest.java +++ b/jdk/test/java/text/Bidi/BidiEmbeddingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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,6 +28,7 @@ * indicate overrides, rather than using bit 7. Also tests Bidi without loading awt classes to * confirm that Bidi can be used without awt. Verify that embedding level 0 is properly mapped * to the base embedding level. + * @modules java.desktop */ import java.awt.Color; diff --git a/jdk/test/java/text/Bidi/Bug7042148.java b/jdk/test/java/text/Bidi/Bug7042148.java index 92c3001dde9..d905a49b746 100644 --- a/jdk/test/java/text/Bidi/Bug7042148.java +++ b/jdk/test/java/text/Bidi/Bug7042148.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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,6 +25,7 @@ * @test * @bug 7042148 * @summary verify that Bidi.baseIsLeftToRight() returns the correct value even if an incorrect position is set in the given AttributedCharacterIterator. + * @modules java.desktop */ import java.awt.font.*; import java.text.*; diff --git a/jdk/test/java/text/Bidi/Bug7051769.java b/jdk/test/java/text/Bidi/Bug7051769.java index 9b1326021b5..a0737ec0afc 100644 --- a/jdk/test/java/text/Bidi/Bug7051769.java +++ b/jdk/test/java/text/Bidi/Bug7051769.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -26,6 +26,7 @@ * @bug 7051769 8038092 * @summary verify that Bidi.toString() returns the corect result. * The second run is intended to test lazy SharedSectets init for 8038092 + * @modules java.desktop * @run main Bug7051769 * @run main/othervm -DpreloadBidi=true Bug7051769 */ diff --git a/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java b/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java index 467cbc574c3..4e114d75bf3 100644 --- a/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java +++ b/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java @@ -22,9 +22,10 @@ */ /* - @test - @summary test Comparison of New Collators against Old Collators in the en_US locale -*/ + * @test + * @summary test Comparison of New Collators against Old Collators in the en_US locale + * @modules jdk.localedata + */ import java.io.*; import java.util.Enumeration; diff --git a/jdk/test/java/text/Collator/APITest.java b/jdk/test/java/text/Collator/APITest.java index f2b0a019a29..43782c5ad90 100644 --- a/jdk/test/java/text/Collator/APITest.java +++ b/jdk/test/java/text/Collator/APITest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Collation API + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/CollationKeyTest.java b/jdk/test/java/text/Collator/CollationKeyTest.java index 9146bf97e9a..901a6347a57 100644 --- a/jdk/test/java/text/Collator/CollationKeyTest.java +++ b/jdk/test/java/text/Collator/CollationKeyTest.java @@ -29,6 +29,7 @@ * RuleBasedCollationKey. This test basically tests on the two features: * 1. Existing code using CollationKey works (backward compatiblility) * 2. CollationKey can be extended by its subclass. + * @modules jdk.localedata */ diff --git a/jdk/test/java/text/Collator/DanishTest.java b/jdk/test/java/text/Collator/DanishTest.java index b5194a83c2a..0c35d22e488 100644 --- a/jdk/test/java/text/Collator/DanishTest.java +++ b/jdk/test/java/text/Collator/DanishTest.java @@ -26,6 +26,7 @@ * @bug 4930708 4174436 5008498 * @library /java/text/testlib * @summary test Danish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/FinnishTest.java b/jdk/test/java/text/Collator/FinnishTest.java index 6df18ef0146..9efc3cd861d 100644 --- a/jdk/test/java/text/Collator/FinnishTest.java +++ b/jdk/test/java/text/Collator/FinnishTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Finnish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/FrenchTest.java b/jdk/test/java/text/Collator/FrenchTest.java index 939ef322253..38492db023c 100644 --- a/jdk/test/java/text/Collator/FrenchTest.java +++ b/jdk/test/java/text/Collator/FrenchTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test French Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/G7Test.java b/jdk/test/java/text/Collator/G7Test.java index 0b41566bd2e..f7bdfa4f868 100644 --- a/jdk/test/java/text/Collator/G7Test.java +++ b/jdk/test/java/text/Collator/G7Test.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test G7 Collation + * @modules jdk.localedata */ /* * diff --git a/jdk/test/java/text/Collator/JapaneseTest.java b/jdk/test/java/text/Collator/JapaneseTest.java index 2bd5f6d0179..7333da34b12 100644 --- a/jdk/test/java/text/Collator/JapaneseTest.java +++ b/jdk/test/java/text/Collator/JapaneseTest.java @@ -25,6 +25,7 @@ * @test 1.1 02/09/11 * @bug 4176141 4655819 * @summary Regression tests for Japanese Collation + * @modules jdk.localedata */ import java.text.*; diff --git a/jdk/test/java/text/Collator/KoreanTest.java b/jdk/test/java/text/Collator/KoreanTest.java index fd314ee13ed..fb3c5eae941 100644 --- a/jdk/test/java/text/Collator/KoreanTest.java +++ b/jdk/test/java/text/Collator/KoreanTest.java @@ -25,6 +25,7 @@ * @test 1.1 02/09/12 * @bug 4176141 4655819 * @summary Regression tests for Korean Collation + * @modules jdk.localedata */ import java.text.*; diff --git a/jdk/test/java/text/Collator/Regression.java b/jdk/test/java/text/Collator/Regression.java index 958ce29c524..212ab39d557 100644 --- a/jdk/test/java/text/Collator/Regression.java +++ b/jdk/test/java/text/Collator/Regression.java @@ -29,6 +29,7 @@ * 4133509 4139572 4141640 4179126 4179686 4244884 4663220 * @library /java/text/testlib * @summary Regression tests for Collation and associated classes + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/ThaiTest.java b/jdk/test/java/text/Collator/ThaiTest.java index 7d643446434..7a961ed5968 100644 --- a/jdk/test/java/text/Collator/ThaiTest.java +++ b/jdk/test/java/text/Collator/ThaiTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Thai Collation + * @modules jdk.localedata */ /* * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. diff --git a/jdk/test/java/text/Collator/TurkishTest.java b/jdk/test/java/text/Collator/TurkishTest.java index f83ef228e06..d8c078abb4d 100644 --- a/jdk/test/java/text/Collator/TurkishTest.java +++ b/jdk/test/java/text/Collator/TurkishTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Turkish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/VietnameseTest.java b/jdk/test/java/text/Collator/VietnameseTest.java index faa4921073c..6708622d096 100644 --- a/jdk/test/java/text/Collator/VietnameseTest.java +++ b/jdk/test/java/text/Collator/VietnameseTest.java @@ -26,6 +26,7 @@ * @bug 4932968 5015215 * @library /java/text/testlib * @summary test Vietnamese Collation + * @modules jdk.localedata */ /* diff --git a/jdk/test/java/text/Format/DateFormat/Bug4823811.java b/jdk/test/java/text/Format/DateFormat/Bug4823811.java index 524f790e1fb..c2d35e9f64f 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug4823811.java +++ b/jdk/test/java/text/Format/DateFormat/Bug4823811.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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,6 +25,7 @@ * @test * @bug 4823811 8008577 * @summary Confirm that text which includes numbers with a trailing minus sign is parsed correctly. + * @modules jdk.localedata * @run main/othervm -Duser.timezone=GMT+09:00 -Djava.locale.providers=JRE,SPI Bug4823811 */ diff --git a/jdk/test/java/text/Format/DateFormat/Bug6683975.java b/jdk/test/java/text/Format/DateFormat/Bug6683975.java index e0c8cd75f15..1f401058e5a 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug6683975.java +++ b/jdk/test/java/text/Format/DateFormat/Bug6683975.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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,6 +25,7 @@ * @test * @bug 6683975 8008577 * @summary Make sure that date is formatted correctlyin th locale. + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=JRE,SPI Bug6683975 */ import java.text.*; diff --git a/jdk/test/java/text/Format/DateFormat/Bug8139572.java b/jdk/test/java/text/Format/DateFormat/Bug8139572.java index d55196b3a23..13154c836c5 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug8139572.java +++ b/jdk/test/java/text/Format/DateFormat/Bug8139572.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -26,6 +26,7 @@ * @bug 8139572 * @summary SimpleDateFormat parse month stand-alone format bug * @compile -encoding utf-8 Bug8139572.java + * @modules jdk.localedata * @run main Bug8139572 */ import java.text.ParseException; diff --git a/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java b/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java index 6f38bfb15c1..60632b0fcce 100644 --- a/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java +++ b/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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,6 +25,7 @@ * @test * @bug 7079560 8008577 * @summary Unit test for context-sensitive month names + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=JRE,SPI ContextMonthNamesTest */ diff --git a/jdk/test/java/text/Format/DateFormat/DateFormatTest.java b/jdk/test/java/text/Format/DateFormat/DateFormatTest.java index c4f148f3d77..7384a82af0c 100644 --- a/jdk/test/java/text/Format/DateFormat/DateFormatTest.java +++ b/jdk/test/java/text/Format/DateFormat/DateFormatTest.java @@ -26,6 +26,7 @@ * @bug 4052223 4089987 4469904 4326988 4486735 8008577 8045998 8140571 * @summary test DateFormat and SimpleDateFormat. * @library /java/text/testlib + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=COMPAT,SPI DateFormatTest */ diff --git a/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java b/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java index bff177ff7e4..9241e59c3bd 100644 --- a/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java +++ b/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,6 +24,7 @@ /** * @test * @bug 8080774 + * @modules jdk.localedata * @run testng/othervm -Djava.locale.providers=JRE,CLDR LocaleDateFormats * @summary This file contains tests for JRE locales date formats */ diff --git a/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java b/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java index 69808d47645..b811900901d 100644 --- a/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java +++ b/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java @@ -25,6 +25,7 @@ * @test * @bug 4833268 6253991 8008577 * @summary Test formatting and parsing with non-Gregorian calendars + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=COMPAT,SPI NonGregorianFormatTest */ diff --git a/jdk/test/java/text/Format/DateFormat/bug4117335.java b/jdk/test/java/text/Format/DateFormat/bug4117335.java index 6c9af2a4716..d9b59eda005 100644 --- a/jdk/test/java/text/Format/DateFormat/bug4117335.java +++ b/jdk/test/java/text/Format/DateFormat/bug4117335.java @@ -25,6 +25,7 @@ * @test * * @bug 4117335 4432617 + * @modules jdk.localedata */ import java.text.DateFormatSymbols ; diff --git a/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java b/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java index 1a4ca1d092d..55c9869c373 100644 --- a/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java +++ b/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java @@ -25,6 +25,7 @@ * @test * @bug 4112090 8008577 * @summary verify that MessageFormat can handle large numbers of arguments + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=COMPAT,SPI LargeMessageFormat */ diff --git a/jdk/test/java/text/Format/NumberFormat/Bug8132125.java b/jdk/test/java/text/Format/NumberFormat/Bug8132125.java index e19b2cd17eb..9f713324a21 100644 --- a/jdk/test/java/text/Format/NumberFormat/Bug8132125.java +++ b/jdk/test/java/text/Format/NumberFormat/Bug8132125.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,6 +25,7 @@ * @test * @bug 8132125 * @summary Checks Swiss' number elements + * @modules jdk.localedata */ import java.text.*; diff --git a/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java b/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java index 96fa3976701..44b53d25ec1 100644 --- a/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java +++ b/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java @@ -25,6 +25,7 @@ * @test * @bug 4290801 4942982 5102005 8008577 8021121 * @summary Basic tests for currency formatting. + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=JRE,SPI CurrencyFormat */ diff --git a/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java b/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java index ab1069bdfc2..011db2bdea3 100644 --- a/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java +++ b/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test International Number Format API + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved diff --git a/jdk/test/java/text/Format/NumberFormat/NumberRegression.java b/jdk/test/java/text/Format/NumberFormat/NumberRegression.java index 0edaa11ccf5..b194d270a5c 100644 --- a/jdk/test/java/text/Format/NumberFormat/NumberRegression.java +++ b/jdk/test/java/text/Format/NumberFormat/NumberRegression.java @@ -34,6 +34,7 @@ * @library /java/text/testlib * @build IntlTest HexDumpReader TestUtils * @modules java.base/sun.util.resources + * jdk.localedata * @compile -XDignore.symbol.file NumberRegression.java * @run main/othervm -Djava.locale.providers=COMPAT,SPI NumberRegression */ diff --git a/jdk/test/java/text/Format/NumberFormat/NumberTest.java b/jdk/test/java/text/Format/NumberFormat/NumberTest.java index ca519bb6dab..cf64a431a55 100644 --- a/jdk/test/java/text/Format/NumberFormat/NumberTest.java +++ b/jdk/test/java/text/Format/NumberFormat/NumberTest.java @@ -27,6 +27,7 @@ * @summary test NumberFormat * @library /java/text/testlib * @modules java.base/sun.util.resources + * jdk.localedata * @compile -XDignore.symbol.file NumberTest.java * @run main/othervm -Djava.locale.providers=COMPAT,SPI NumberTest */ From 3f2262b34783eef1a3a42c250dfa4c70dae1628c Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 30 Aug 2016 17:48:07 -0700 Subject: [PATCH 075/296] 8160851: Remove old launcher module-related options Reviewed-by: jjg, alanb --- jdk/src/java.base/share/native/libjli/java.c | 53 +------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c index 12ca2b2c656..4b869ceb56f 100644 --- a/jdk/src/java.base/share/native/libjli/java.c +++ b/jdk/src/java.base/share/native/libjli/java.c @@ -556,20 +556,6 @@ IsLauncherOption(const char* name) { JLI_StrCmp(name, "--list-modules") == 0; } -#ifndef OLD_MODULE_OPTIONS -/* - * Old module options for transition - */ -static jboolean -IsOldModuleOption(const char* name) { - return JLI_StrCmp(name, "-modulepath") == 0 || - JLI_StrCmp(name, "-mp") == 0 || - JLI_StrCmp(name, "-upgrademodulepath") == 0 || - JLI_StrCmp(name, "-addmods") == 0 || - JLI_StrCmp(name, "-limitmods") == 0; -} -#endif - /* * Test if the given name is a module-system white-space option that * will be passed to the VM with its corresponding long-form option @@ -584,8 +570,7 @@ IsModuleOption(const char* name) { JLI_StrCmp(name, "--limit-modules") == 0 || JLI_StrCmp(name, "--add-exports") == 0 || JLI_StrCmp(name, "--add-reads") == 0 || - JLI_StrCmp(name, "--patch-module") == 0 || - IsOldModuleOption(name); + JLI_StrCmp(name, "--patch-module") == 0; } /* @@ -1224,32 +1209,6 @@ GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue) { } } -#ifndef OLD_MODULE_OPTIONS - // for transition to support both old and new syntax - if (JLI_StrCmp(arg, "-modulepath") == 0 || - JLI_StrCmp(arg, "-mp") == 0) { - option = "--module-path"; - } else if (JLI_StrCmp(arg, "-upgrademodulepath") == 0) { - option = "--upgrade-module-path"; - } else if (JLI_StrCmp(arg, "-addmods") == 0) { - option = "--add-modules"; - } else if (JLI_StrCmp(arg, "-limitmods") == 0) { - option = "--limit-modules"; - } else if (JLI_StrCCmp(arg, "-XaddExports:") == 0) { - option = "--add-exports"; - value = arg + 13; - kind = VM_LONG_OPTION_WITH_ARGUMENT; - } else if (JLI_StrCCmp(arg, "-XaddReads:") == 0) { - option = "--add-reads"; - value = arg + 11; - kind = VM_LONG_OPTION_WITH_ARGUMENT; - } else if (JLI_StrCCmp(arg, "-Xpatch:") == 0) { - option = "--patch-module"; - value = arg + 8; - kind = VM_LONG_OPTION_WITH_ARGUMENT; - } -#endif - *pargc = argc; *pargv = argv; *poption = option; @@ -1340,16 +1299,6 @@ ParseArguments(int *pargc, char ***pargv, JLI_StrCmp(arg, "--patch-module") == 0) { REPORT_ERROR (has_arg, ARG_ERROR6, arg); } -#ifndef OLD_MODULE_OPTIONS - else if (JLI_StrCmp(arg, "-modulepath") == 0 || - JLI_StrCmp(arg, "-mp") == 0 || - JLI_StrCmp(arg, "-upgrademodulepath") == 0) { - REPORT_ERROR (has_arg, ARG_ERROR4, arg); - } else if (JLI_StrCmp(arg, "-addmods") == 0 || - JLI_StrCmp(arg, "-limitmods") == 0) { - REPORT_ERROR (has_arg, ARG_ERROR6, arg); - } -#endif /* * The following cases will cause the argument parsing to stop */ From d2d5a91ec405507a2c0d628de445f8fd1380917d Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 30 Aug 2016 17:48:27 -0700 Subject: [PATCH 076/296] 8160851: Remove old launcher module-related options Reviewed-by: alanb --- hotspot/test/runtime/Unsafe/NestedUnsafe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/runtime/Unsafe/NestedUnsafe.java b/hotspot/test/runtime/Unsafe/NestedUnsafe.java index f009d6dddd4..9bda7eac304 100644 --- a/hotspot/test/runtime/Unsafe/NestedUnsafe.java +++ b/hotspot/test/runtime/Unsafe/NestedUnsafe.java @@ -79,7 +79,7 @@ public class NestedUnsafe { " throw new RuntimeException(\"Exception: \" + ex.toString()); " + " } " + "} } ", - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED"); + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED"); Class klass2 = unsafe.defineAnonymousClass(NestedUnsafe.class, klassbuf2, new Object[0]); try { klass2.getMethod("doit").invoke(null); From ab956e880ea5a3f4d5081e61b80b9b091375e98f Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 30 Aug 2016 17:49:43 -0700 Subject: [PATCH 077/296] 8160851: Remove old launcher module-related options Reviewed-by: jjg, alanb --- .../module/ServiceProviderTest/BasicModularXMLParserTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java index c2bf928ba1f..72fd20c1d74 100644 --- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java +++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java @@ -93,7 +93,7 @@ public class BasicModularXMLParserTest { */ public void testWithOneProvider() throws Exception { int exitValue - = executeTestJava("-mp", MOD_DIR1.toString(), + = executeTestJava("--module-path", MOD_DIR1.toString(), "-cp", CLASSES_DIR.toString(), "Main", "xmlprovider1") .outputTo(System.out) @@ -108,7 +108,7 @@ public class BasicModularXMLParserTest { */ public void testWithTwoProvider() throws Exception { int exitValue - = executeTestJava("-mp", MOD_DIR1.toString() + File.pathSeparator + MOD_DIR2.toString(), + = executeTestJava("--module-path", MOD_DIR1.toString() + File.pathSeparator + MOD_DIR2.toString(), "-cp", CLASSES_DIR.toString(), "Main", "xmlprovider1", "xmlprovider2") .outputTo(System.out) From 2416447009af96d2f3d65ec9c2d35fe5d3cabb5d Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 30 Aug 2016 17:49:50 -0700 Subject: [PATCH 078/296] 8160851: Remove old launcher module-related options Reviewed-by: jjg, alanb --- make/CompileJavaModules.gmk | 2 +- make/common/SetupJavaCompilers.gmk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 65e43933dec..9023aba0acc 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -504,7 +504,7 @@ $(eval $(call SetupJavaCompilation, $(MODULE), \ $($(MODULE)_ADD_JAVAC_FLAGS) \ --module-source-path $(MODULESOURCEPATH) \ --module-path $(MODULEPATH) \ - -system none, \ + --system none, \ )) TARGETS += $($(MODULE)) $($(MODULE)_COPY_EXTRA) diff --git a/make/common/SetupJavaCompilers.gmk b/make/common/SetupJavaCompilers.gmk index 52b2cc337fe..65fc170404d 100644 --- a/make/common/SetupJavaCompilers.gmk +++ b/make/common/SetupJavaCompilers.gmk @@ -88,7 +88,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \ $(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE, \ JVM := $(JAVA_SMALL), \ JAVAC := $(NEW_JAVAC), \ - FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules -system none $(DISABLE_WARNINGS), \ + FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none $(DISABLE_WARNINGS), \ SERVER_DIR := $(SJAVAC_SERVER_DIR), \ SERVER_JVM := $(SJAVAC_SERVER_JAVA))) From 7bddef3ed08e9353f6a2aafaa9c43cabd7d5b68a Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Tue, 30 Aug 2016 23:46:02 -0400 Subject: [PATCH 079/296] 8156500: Move Reference pending list into VM to prevent deadlocks Move reference pending list and locking into VM Co-authored-by: Per Liden Reviewed-by: coleenp, dholmes, dcubed, mchung, plevart --- jdk/make/mapfiles/libjava/mapfile-vers | 3 + .../classes/java/lang/ref/Reference.java | 151 +++++++++--------- .../share/classes/java/nio/Bits.java | 53 +++--- .../jdk/internal/misc/JavaLangRefAccess.java | 14 +- jdk/src/java.base/share/native/include/jvm.h | 12 ++ .../share/native/libjava/Reference.c | 45 ++++++ .../FileInputStreamPoolTest.java | 23 +-- 7 files changed, 185 insertions(+), 116 deletions(-) create mode 100644 jdk/src/java.base/share/native/libjava/Reference.c diff --git a/jdk/make/mapfiles/libjava/mapfile-vers b/jdk/make/mapfiles/libjava/mapfile-vers index c34ba2f709d..20ea7c916b8 100644 --- a/jdk/make/mapfiles/libjava/mapfile-vers +++ b/jdk/make/mapfiles/libjava/mapfile-vers @@ -176,6 +176,9 @@ SUNWprivate_1.1 { Java_java_lang_ProcessHandleImpl_00024Info_info0; Java_java_lang_ProcessImpl_init; Java_java_lang_ProcessImpl_forkAndExec; + Java_java_lang_ref_Reference_getAndClearReferencePendingList; + Java_java_lang_ref_Reference_hasReferencePendingList; + Java_java_lang_ref_Reference_waitForReferencePendingList; Java_java_lang_reflect_Array_get; Java_java_lang_reflect_Array_getBoolean; Java_java_lang_reflect_Array_getByte; diff --git a/jdk/src/java.base/share/classes/java/lang/ref/Reference.java b/jdk/src/java.base/share/classes/java/lang/ref/Reference.java index 0a6728d007e..cd4bd8065bc 100644 --- a/jdk/src/java.base/share/classes/java/lang/ref/Reference.java +++ b/jdk/src/java.base/share/classes/java/lang/ref/Reference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -110,22 +110,6 @@ public abstract class Reference { private transient Reference discovered; /* used by VM */ - /* Object used to synchronize with the garbage collector. The collector - * must acquire this lock at the beginning of each collection cycle. It is - * therefore critical that any code holding this lock complete as quickly - * as possible, allocate no new objects, and avoid calling user code. - */ - private static class Lock { } - private static Lock lock = new Lock(); - - - /* List of References waiting to be enqueued. The collector adds - * References to this list, while the Reference-handler thread removes - * them. This list is protected by the above lock object. The - * list uses the discovered field to link its elements. - */ - private static Reference pending = null; - /* High-priority thread to enqueue pending References */ private static class ReferenceHandler extends Thread { @@ -139,10 +123,9 @@ public abstract class Reference { } static { - // pre-load and initialize InterruptedException and Cleaner classes - // so that we don't get into trouble later in the run loop if there's - // memory shortage while loading/initializing them lazily. - ensureClassInitialized(InterruptedException.class); + // pre-load and initialize Cleaner class so that we don't + // get into trouble later in the run loop if there's + // memory shortage while loading/initializing it lazily. ensureClassInitialized(Cleaner.class); } @@ -152,72 +135,80 @@ public abstract class Reference { public void run() { while (true) { - tryHandlePending(true); + processPendingReferences(); } } } - /** - * Try handle pending {@link Reference} if there is one.

- * Return {@code true} as a hint that there might be another - * {@link Reference} pending or {@code false} when there are no more pending - * {@link Reference}s at the moment and the program can do some other - * useful work instead of looping. - * - * @param waitForNotify if {@code true} and there was no pending - * {@link Reference}, wait until notified from VM - * or interrupted; if {@code false}, return immediately - * when there is no pending {@link Reference}. - * @return {@code true} if there was a {@link Reference} pending and it - * was processed, or we waited for notification and either got it - * or thread was interrupted before being notified; - * {@code false} otherwise. + /* Atomically get and clear (set to null) the VM's pending list. */ - static boolean tryHandlePending(boolean waitForNotify) { - Reference r; - Cleaner c; - try { - synchronized (lock) { - if (pending != null) { - r = pending; - // 'instanceof' might throw OutOfMemoryError sometimes - // so do this before un-linking 'r' from the 'pending' chain... - c = r instanceof Cleaner ? (Cleaner) r : null; - // unlink 'r' from 'pending' chain - pending = r.discovered; - r.discovered = null; - } else { - // The waiting on the lock may cause an OutOfMemoryError - // because it may try to allocate exception objects. - if (waitForNotify) { - lock.wait(); - } - // retry if waited - return waitForNotify; + private static native Reference getAndClearReferencePendingList(); + + /* Test whether the VM's pending list contains any entries. + */ + private static native boolean hasReferencePendingList(); + + /* Wait until the VM's pending list may be non-null. + */ + private static native void waitForReferencePendingList(); + + private static final Object processPendingLock = new Object(); + private static boolean processPendingActive = false; + + private static void processPendingReferences() { + // Only the singleton reference processing thread calls + // waitForReferencePendingList() and getAndClearReferencePendingList(). + // These are separate operations to avoid a race with other threads + // that are calling waitForReferenceProcessing(). + waitForReferencePendingList(); + Reference pendingList; + synchronized (processPendingLock) { + pendingList = getAndClearReferencePendingList(); + processPendingActive = true; + } + while (pendingList != null) { + Reference ref = pendingList; + pendingList = ref.discovered; + ref.discovered = null; + + if (ref instanceof Cleaner) { + ((Cleaner)ref).clean(); + // Notify any waiters that progress has been made. + // This improves latency for nio.Bits waiters, which + // are the only important ones. + synchronized (processPendingLock) { + processPendingLock.notifyAll(); } + } else { + ReferenceQueue q = ref.queue; + if (q != ReferenceQueue.NULL) q.enqueue(ref); } - } catch (OutOfMemoryError x) { - // Give other threads CPU time so they hopefully drop some live references - // and GC reclaims some space. - // Also prevent CPU intensive spinning in case 'r instanceof Cleaner' above - // persistently throws OOME for some time... - Thread.yield(); - // retry - return true; - } catch (InterruptedException x) { - // retry - return true; } - - // Fast path for cleaners - if (c != null) { - c.clean(); - return true; + // Notify any waiters of completion of current round. + synchronized (processPendingLock) { + processPendingActive = false; + processPendingLock.notifyAll(); } + } - ReferenceQueue q = r.queue; - if (q != ReferenceQueue.NULL) q.enqueue(r); - return true; + // Wait for progress in reference processing. + // + // Returns true after waiting (for notification from the reference + // processing thread) if either (1) the VM has any pending + // references, or (2) the reference processing thread is + // processing references. Otherwise, returns false immediately. + private static boolean waitForReferenceProcessing() + throws InterruptedException + { + synchronized (processPendingLock) { + if (processPendingActive || hasReferencePendingList()) { + // Wait for progress, not necessarily completion. + processPendingLock.wait(); + return true; + } else { + return false; + } + } } static { @@ -236,8 +227,10 @@ public abstract class Reference { // provide access in SharedSecrets SharedSecrets.setJavaLangRefAccess(new JavaLangRefAccess() { @Override - public boolean tryHandlePendingReference() { - return tryHandlePending(false); + public boolean waitForReferenceProcessing() + throws InterruptedException + { + return Reference.waitForReferenceProcessing(); } }); } diff --git a/jdk/src/java.base/share/classes/java/nio/Bits.java b/jdk/src/java.base/share/classes/java/nio/Bits.java index 8a7dcf77253..dfe6a8f13a7 100644 --- a/jdk/src/java.base/share/classes/java/nio/Bits.java +++ b/jdk/src/java.base/share/classes/java/nio/Bits.java @@ -131,23 +131,38 @@ class Bits { // package-private } final JavaLangRefAccess jlra = SharedSecrets.getJavaLangRefAccess(); - - // retry while helping enqueue pending Reference objects - // which includes executing pending Cleaner(s) which includes - // Cleaner(s) that free direct buffer memory - while (jlra.tryHandlePendingReference()) { - if (tryReserveMemory(size, cap)) { - return; - } - } - - // trigger VM's Reference processing - System.gc(); - - // a retry loop with exponential back-off delays - // (this gives VM some time to do it's job) boolean interrupted = false; try { + + // Retry allocation until success or there are no more + // references (including Cleaners that might free direct + // buffer memory) to process and allocation still fails. + boolean refprocActive; + do { + try { + refprocActive = jlra.waitForReferenceProcessing(); + } catch (InterruptedException e) { + // Defer interrupts and keep trying. + interrupted = true; + refprocActive = true; + } + if (tryReserveMemory(size, cap)) { + return; + } + } while (refprocActive); + + // trigger VM's Reference processing + System.gc(); + + // A retry loop with exponential back-off delays. + // Sometimes it would suffice to give up once reference + // processing is complete. But if there are many threads + // competing for memory, this gives more opportunities for + // any given thread to make progress. In particular, this + // seems to be enough for a stress test like + // DirectBufferAllocTest to (usually) succeed, while + // without it that test likely fails. Since failure here + // ends in OOME, there's no need to hurry. long sleepTime = 1; int sleeps = 0; while (true) { @@ -157,14 +172,14 @@ class Bits { // package-private if (sleeps >= MAX_SLEEPS) { break; } - if (!jlra.tryHandlePendingReference()) { - try { + try { + if (!jlra.waitForReferenceProcessing()) { Thread.sleep(sleepTime); sleepTime <<= 1; sleeps++; - } catch (InterruptedException e) { - interrupted = true; } + } catch (InterruptedException e) { + interrupted = true; } } diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangRefAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangRefAccess.java index 374ca55c847..81c72bcbe91 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangRefAccess.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangRefAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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,12 +28,12 @@ package jdk.internal.misc; public interface JavaLangRefAccess { /** - * Help ReferenceHandler thread process next pending - * {@link java.lang.ref.Reference} + * Wait for progress in {@link java.lang.ref.Reference} + * processing. If there aren't any pending {@link + * java.lang.ref.Reference}s, return immediately. * - * @return {@code true} if there was a pending reference and it - * was enqueue-ed or {@code false} if there was no - * pending reference + * @return {@code true} if there were any pending + * {@link java.lang.ref.Reference}s, {@code false} otherwise. */ - boolean tryHandlePendingReference(); + boolean waitForReferenceProcessing() throws InterruptedException; } diff --git a/jdk/src/java.base/share/native/include/jvm.h b/jdk/src/java.base/share/native/include/jvm.h index 2011e58352a..bf60a857beb 100644 --- a/jdk/src/java.base/share/native/include/jvm.h +++ b/jdk/src/java.base/share/native/include/jvm.h @@ -281,6 +281,18 @@ JVM_GetSystemPackage(JNIEnv *env, jstring name); JNIEXPORT jobjectArray JNICALL JVM_GetSystemPackages(JNIEnv *env); +/* + * java.lang.ref.Reference + */ +JNIEXPORT jobject JNICALL +JVM_GetAndClearReferencePendingList(JNIEnv *env); + +JNIEXPORT jboolean JNICALL +JVM_HasReferencePendingList(JNIEnv *env); + +JNIEXPORT void JNICALL +JVM_WaitForReferencePendingList(JNIEnv *env); + /* * java.io.ObjectInputStream */ diff --git a/jdk/src/java.base/share/native/libjava/Reference.c b/jdk/src/java.base/share/native/libjava/Reference.c new file mode 100644 index 00000000000..92c518c5d90 --- /dev/null +++ b/jdk/src/java.base/share/native/libjava/Reference.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +#include "jvm.h" +#include "java_lang_ref_Reference.h" + +JNIEXPORT jobject JNICALL +Java_java_lang_ref_Reference_getAndClearReferencePendingList(JNIEnv *env, jclass ignore) +{ + return JVM_GetAndClearReferencePendingList(env); +} + +JNIEXPORT jboolean JNICALL +Java_java_lang_ref_Reference_hasReferencePendingList(JNIEnv *env, jclass ignore) +{ + return JVM_HasReferencePendingList(env); +} + +JNIEXPORT void JNICALL +Java_java_lang_ref_Reference_waitForReferencePendingList(JNIEnv *env, jclass ignore) +{ + JVM_WaitForReferencePendingList(env); +} diff --git a/jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java b/jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java index 63d5fce25ba..55811ddaf53 100644 --- a/jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java +++ b/jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -69,7 +69,7 @@ public class FileInputStreamPoolTest { // make JVM process References System.gc(); // help ReferenceHandler thread enqueue References - while (TestProxy.Reference_tryHandlePending(false)) {} + while (TestProxy.Reference_waitForReferenceProcessing()) { } // help run Finalizers System.runFinalization(); } @@ -103,11 +103,11 @@ public class FileInputStreamPoolTest { /** * A proxy for (package)private static methods: * sun.security.provider.FileInputStreamPool.getInputStream - * java.lang.ref.Reference.tryHandlePending + * java.lang.ref.Reference.waitForReferenceProcessing */ static class TestProxy { private static final Method getInputStreamMethod; - private static final Method tryHandlePendingMethod; + private static final Method waitForReferenceProcessingMethod; static { try { @@ -118,9 +118,9 @@ public class FileInputStreamPoolTest { "getInputStream", File.class); getInputStreamMethod.setAccessible(true); - tryHandlePendingMethod = Reference.class.getDeclaredMethod( - "tryHandlePending", boolean.class); - tryHandlePendingMethod.setAccessible(true); + waitForReferenceProcessingMethod = + Reference.class.getDeclaredMethod("waitForReferenceProcessing"); + waitForReferenceProcessingMethod.setAccessible(true); } catch (Exception e) { throw new Error(e); } @@ -146,13 +146,14 @@ public class FileInputStreamPoolTest { } } - static boolean Reference_tryHandlePending(boolean waitForNotify) { + static boolean Reference_waitForReferenceProcessing() { try { - return (boolean) tryHandlePendingMethod - .invoke(null, waitForNotify); + return (boolean) waitForReferenceProcessingMethod.invoke(null); } catch (InvocationTargetException e) { Throwable te = e.getTargetException(); - if (te instanceof RuntimeException) { + if (te instanceof InterruptedException) { + return true; + } else if (te instanceof RuntimeException) { throw (RuntimeException) te; } else if (te instanceof Error) { throw (Error) te; From 66706edf1561310326bb5f61837d179e25e351cb Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Tue, 30 Aug 2016 23:48:16 -0400 Subject: [PATCH 080/296] 8156500: Move Reference pending list into VM to prevent deadlocks Move reference pending list and locking into VM Co-authored-by: Per Liden Reviewed-by: coleenp, dholmes, dcubed, mchung, plevart --- hotspot/make/symbols/symbols-unix | 3 + .../sun/jvm/hotspot/runtime/Threads.java | 4 +- .../sun/jvm/hotspot/utilities/soql/sa.js | 1 - hotspot/src/share/vm/ci/ciReplay.cpp | 5 +- .../src/share/vm/classfile/javaClasses.cpp | 41 ---- .../src/share/vm/classfile/javaClasses.hpp | 13 - .../src/share/vm/compiler/compileBroker.cpp | 10 - .../vm/gc/cms/concurrentMarkSweepThread.cpp | 18 -- .../src/share/vm/gc/cms/vmCMSOperations.cpp | 28 +-- .../src/share/vm/gc/cms/vmCMSOperations.hpp | 8 - .../share/vm/gc/g1/concurrentMarkThread.cpp | 4 +- .../src/share/vm/gc/g1/g1CollectedHeap.hpp | 6 - .../src/share/vm/gc/g1/vm_operations_g1.cpp | 21 +- .../src/share/vm/gc/g1/vm_operations_g1.hpp | 18 +- .../src/share/vm/gc/shared/collectedHeap.hpp | 6 - .../share/vm/gc/shared/genCollectedHeap.hpp | 4 - .../gc/shared/referencePendingListLocker.cpp | 222 ------------------ .../gc/shared/referencePendingListLocker.hpp | 95 -------- .../share/vm/gc/shared/referenceProcessor.cpp | 53 +---- .../share/vm/gc/shared/referenceProcessor.hpp | 9 +- .../src/share/vm/gc/shared/vmGCOperations.cpp | 16 +- .../src/share/vm/gc/shared/vmGCOperations.hpp | 8 - hotspot/src/share/vm/memory/universe.cpp | 43 +++- hotspot/src/share/vm/memory/universe.hpp | 14 ++ hotspot/src/share/vm/oops/method.cpp | 7 - hotspot/src/share/vm/prims/jvm.cpp | 29 +++ hotspot/src/share/vm/prims/jvm.h | 12 + hotspot/src/share/vm/runtime/thread.cpp | 9 - hotspot/src/share/vm/runtime/vmStructs.cpp | 2 - 29 files changed, 133 insertions(+), 576 deletions(-) delete mode 100644 hotspot/src/share/vm/gc/shared/referencePendingListLocker.cpp delete mode 100644 hotspot/src/share/vm/gc/shared/referencePendingListLocker.hpp diff --git a/hotspot/make/symbols/symbols-unix b/hotspot/make/symbols/symbols-unix index 406d6f99db3..04dd4aeff53 100644 --- a/hotspot/make/symbols/symbols-unix +++ b/hotspot/make/symbols/symbols-unix @@ -67,6 +67,7 @@ JVM_FindSignal JVM_FreeMemory JVM_GC JVM_GetAllThreads +JVM_GetAndClearReferencePendingList JVM_GetArrayElement JVM_GetArrayLength JVM_GetCallerClass @@ -130,6 +131,7 @@ JVM_GetSystemPackages JVM_GetTemporaryDirectory JVM_GetVmArguments JVM_Halt +JVM_HasReferencePendingList JVM_HoldsLock JVM_IHashCode JVM_InitProperties @@ -179,6 +181,7 @@ JVM_SuspendThread JVM_ToStackTraceElement JVM_TotalMemory JVM_UnloadLibrary +JVM_WaitForReferencePendingList JVM_Yield # Module related API's diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index cfcab6b8413..1e471412d58 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -129,8 +129,6 @@ public class Threads { virtualConstructor.addMapping("CompilerThread", CompilerThread.class); virtualConstructor.addMapping("CodeCacheSweeperThread", CodeCacheSweeperThread.class); } - // for now, use JavaThread itself. fix it later with appropriate class if needed - virtualConstructor.addMapping("ReferencePendingListLockerThread", JavaThread.class); virtualConstructor.addMapping("JvmtiAgentThread", JvmtiAgentThread.class); virtualConstructor.addMapping("ServiceThread", ServiceThread.class); } @@ -172,7 +170,7 @@ public class Threads { return thread; } catch (Exception e) { throw new RuntimeException("Unable to deduce type of thread from address " + threadAddr + - " (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread, ReferencePendingListLockerThread, or CodeCacheSweeperThread)", e); + " (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread or CodeCacheSweeperThread)", e); } } diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/sa.js b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/sa.js index 7a7f4501493..2bd5c556d0d 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/sa.js +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/sa.js @@ -837,7 +837,6 @@ vmType2Class["InterpreterCodelet"] = sapkg.interpreter.InterpreterCodelet; vmType2Class["JavaThread"] = sapkg.runtime.JavaThread; vmType2Class["CompilerThread"] = sapkg.runtime.CompilerThread; vmType2Class["CodeCacheSweeperThread"] = sapkg.runtime.CodeCacheSweeperThread; -vmType2Class["ReferencePendingListLockerThread"] = sapkg.runtime.JavaThread; vmType2Class["DebuggerThread"] = sapkg.runtime.DebuggerThread; // gc diff --git a/hotspot/src/share/vm/ci/ciReplay.cpp b/hotspot/src/share/vm/ci/ciReplay.cpp index ec788919c32..50a1dd37c3b 100644 --- a/hotspot/src/share/vm/ci/ciReplay.cpp +++ b/hotspot/src/share/vm/ci/ciReplay.cpp @@ -29,7 +29,6 @@ #include "ci/ciKlass.hpp" #include "ci/ciUtilities.hpp" #include "compiler/compileBroker.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "memory/allocation.inline.hpp" #include "memory/oopFactory.hpp" #include "memory/resourceArea.hpp" @@ -577,9 +576,7 @@ class CompileReplay : public StackObj { Method* method = parse_method(CHECK); if (had_error()) return; /* just copied from Method, to build interpret data*/ - if (ReferencePendingListLocker::is_locked_by_self()) { - return; - } + // To be properly initialized, some profiling in the MDO needs the // method to be rewritten (number of arguments at a call for // instance) diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 6df74ae4244..b3a6564d92e 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -3015,41 +3015,6 @@ void java_lang_boxing_object::print(BasicType type, jvalue* value, outputStream* } } - -// Support for java_lang_ref_Reference -HeapWord *java_lang_ref_Reference::pending_list_lock_addr() { - InstanceKlass* ik = SystemDictionary::Reference_klass(); - address addr = ik->static_field_addr(static_lock_offset); - return (HeapWord*) addr; -} - -oop java_lang_ref_Reference::pending_list_lock() { - InstanceKlass* ik = SystemDictionary::Reference_klass(); - address addr = ik->static_field_addr(static_lock_offset); - if (UseCompressedOops) { - return oopDesc::load_decode_heap_oop((narrowOop *)addr); - } else { - return oopDesc::load_decode_heap_oop((oop*)addr); - } -} - -HeapWord *java_lang_ref_Reference::pending_list_addr() { - InstanceKlass* ik = SystemDictionary::Reference_klass(); - address addr = ik->static_field_addr(static_pending_offset); - // XXX This might not be HeapWord aligned, almost rather be char *. - return (HeapWord*)addr; -} - -oop java_lang_ref_Reference::pending_list() { - char *addr = (char *)pending_list_addr(); - if (UseCompressedOops) { - return oopDesc::load_decode_heap_oop((narrowOop *)addr); - } else { - return oopDesc::load_decode_heap_oop((oop*)addr); - } -} - - // Support for java_lang_ref_SoftReference jlong java_lang_ref_SoftReference::timestamp(oop ref) { @@ -3616,8 +3581,6 @@ int java_lang_ref_Reference::referent_offset; int java_lang_ref_Reference::queue_offset; int java_lang_ref_Reference::next_offset; int java_lang_ref_Reference::discovered_offset; -int java_lang_ref_Reference::static_lock_offset; -int java_lang_ref_Reference::static_pending_offset; int java_lang_ref_Reference::number_of_fake_oop_fields; int java_lang_ref_SoftReference::timestamp_offset; int java_lang_ref_SoftReference::static_clock_offset; @@ -3772,8 +3735,6 @@ void JavaClasses::compute_hard_coded_offsets() { java_lang_ref_Reference::queue_offset = java_lang_ref_Reference::hc_queue_offset * x + header; java_lang_ref_Reference::next_offset = java_lang_ref_Reference::hc_next_offset * x + header; java_lang_ref_Reference::discovered_offset = java_lang_ref_Reference::hc_discovered_offset * x + header; - java_lang_ref_Reference::static_lock_offset = java_lang_ref_Reference::hc_static_lock_offset * x; - java_lang_ref_Reference::static_pending_offset = java_lang_ref_Reference::hc_static_pending_offset * x; // Artificial fields for java_lang_ref_Reference // The first field is for the discovered field added in 1.4 java_lang_ref_Reference::number_of_fake_oop_fields = 1; @@ -4006,8 +3967,6 @@ void JavaClasses::check_offsets() { CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, next, "Ljava/lang/ref/Reference;"); // Fake field //CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, discovered, "Ljava/lang/ref/Reference;"); - CHECK_STATIC_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, lock, "Ljava/lang/ref/Reference$Lock;"); - CHECK_STATIC_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, pending, "Ljava/lang/ref/Reference;"); // java.lang.ref.SoftReference diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 7d101b88ea6..307cd65d5f8 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -886,17 +886,11 @@ class java_lang_ref_Reference: AllStatic { hc_next_offset = 2, hc_discovered_offset = 3 // Is not last, see SoftRefs. }; - enum { - hc_static_lock_offset = 0, - hc_static_pending_offset = 1 - }; static int referent_offset; static int queue_offset; static int next_offset; static int discovered_offset; - static int static_lock_offset; - static int static_pending_offset; static int number_of_fake_oop_fields; // Accessors @@ -912,13 +906,6 @@ class java_lang_ref_Reference: AllStatic { static inline void set_discovered(oop ref, oop value); static inline void set_discovered_raw(oop ref, oop value); static inline HeapWord* discovered_addr(oop ref); - - // Accessors for statics - static oop pending_list_lock(); - static oop pending_list(); - - static HeapWord* pending_list_lock_addr(); - static HeapWord* pending_list_addr(); }; diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index b3bc80c6a51..62433c1c088 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -32,7 +32,6 @@ #include "compiler/compileLog.hpp" #include "compiler/compilerOracle.hpp" #include "compiler/directivesParser.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "interpreter/linkResolver.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" @@ -893,15 +892,6 @@ void CompileBroker::compile_method_base(const methodHandle& method, return; } - // If the requesting thread is holding the pending list lock - // then we just return. We can't risk blocking while holding - // the pending list lock or a 3-way deadlock may occur - // between the reference handler thread, a GC (instigated - // by a compiler thread), and compiled method registration. - if (ReferencePendingListLocker::is_locked_by_self()) { - return; - } - if (TieredCompilation) { // Tiered policy requires MethodCounters to exist before adding a method to // the queue. Create if we don't have them yet. diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepThread.cpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepThread.cpp index 3ea77838462..43a32e913e8 100644 --- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepThread.cpp +++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepThread.cpp @@ -28,7 +28,6 @@ #include "gc/cms/concurrentMarkSweepThread.hpp" #include "gc/shared/gcId.hpp" #include "gc/shared/genCollectedHeap.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "oops/oop.inline.hpp" #include "runtime/init.hpp" #include "runtime/interfaceSupport.hpp" @@ -77,23 +76,6 @@ void ConcurrentMarkSweepThread::run_service() { log_warning(gc)("Couldn't bind CMS thread to processor " UINTX_FORMAT, CPUForCMSThread); } - { - MutexLockerEx x(CGC_lock, true); - set_CMS_flag(CMS_cms_wants_token); - assert(is_init_completed() && Universe::is_fully_initialized(), "ConcurrentGCThread::run() should have waited for this."); - - // Wait until the surrogate locker thread that will do - // pending list locking on our behalf has been created. - // We cannot start the SLT thread ourselves since we need - // to be a JavaThread to do so. - CMSLoopCountWarn loopY("CMS::run", "waiting for SLT installation", 2); - while (!ReferencePendingListLocker::is_initialized() && !should_terminate()) { - CGC_lock->wait(true, 200); - loopY.tick(); - } - clear_CMS_flag(CMS_cms_wants_token); - } - while (!should_terminate()) { sleepBeforeNextCycle(); if (should_terminate()) break; diff --git a/hotspot/src/share/vm/gc/cms/vmCMSOperations.cpp b/hotspot/src/share/vm/gc/cms/vmCMSOperations.cpp index 73f205485db..3aa8a0ccd6b 100644 --- a/hotspot/src/share/vm/gc/cms/vmCMSOperations.cpp +++ b/hotspot/src/share/vm/gc/cms/vmCMSOperations.cpp @@ -37,14 +37,6 @@ ////////////////////////////////////////////////////////// // Methods in abstract class VM_CMS_Operation ////////////////////////////////////////////////////////// -void VM_CMS_Operation::acquire_pending_list_lock() { - _pending_list_locker.lock(); -} - -void VM_CMS_Operation::release_and_notify_pending_list_lock() { - _pending_list_locker.unlock(); -} - void VM_CMS_Operation::verify_before_gc() { if (VerifyBeforeGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { @@ -85,17 +77,10 @@ bool VM_CMS_Operation::doit_prologue() { assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(), "Possible deadlock"); - if (needs_pending_list_lock()) { - acquire_pending_list_lock(); - } - // Get the Heap_lock after the pending_list_lock. Heap_lock->lock(); if (lost_race()) { assert(_prologue_succeeded == false, "Initialized in c'tor"); Heap_lock->unlock(); - if (needs_pending_list_lock()) { - release_and_notify_pending_list_lock(); - } } else { _prologue_succeeded = true; } @@ -108,11 +93,10 @@ void VM_CMS_Operation::doit_epilogue() { assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(), "Possible deadlock"); - // Release the Heap_lock first. - Heap_lock->unlock(); - if (needs_pending_list_lock()) { - release_and_notify_pending_list_lock(); + if (Universe::has_reference_pending_list()) { + Heap_lock->notify_all(); } + Heap_lock->unlock(); } ////////////////////////////////////////////////////////// @@ -230,9 +214,11 @@ void VM_GenCollectFullConcurrent::doit_epilogue() { Thread* thr = Thread::current(); assert(thr->is_Java_thread(), "just checking"); JavaThread* jt = (JavaThread*)thr; - // Release the Heap_lock first. + + if (Universe::has_reference_pending_list()) { + Heap_lock->notify_all(); + } Heap_lock->unlock(); - release_and_notify_pending_list_lock(); // It is fine to test whether completed collections has // exceeded our request count without locking because diff --git a/hotspot/src/share/vm/gc/cms/vmCMSOperations.hpp b/hotspot/src/share/vm/gc/cms/vmCMSOperations.hpp index e6fe2c2ac25..fd39fe479d9 100644 --- a/hotspot/src/share/vm/gc/cms/vmCMSOperations.hpp +++ b/hotspot/src/share/vm/gc/cms/vmCMSOperations.hpp @@ -28,7 +28,6 @@ #include "gc/cms/concurrentMarkSweepGeneration.hpp" #include "gc/shared/gcCause.hpp" #include "gc/shared/gcId.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "gc/shared/vmGCOperations.hpp" #include "runtime/vm_operations.hpp" @@ -52,9 +51,6 @@ class CMSCollector; class VM_CMS_Operation: public VM_Operation { - private: - ReferencePendingListLocker _pending_list_locker; - protected: CMSCollector* _collector; // associated collector bool _prologue_succeeded; // whether doit_prologue succeeded @@ -62,10 +58,6 @@ class VM_CMS_Operation: public VM_Operation { bool lost_race() const; - // java.lang.ref.Reference support - void acquire_pending_list_lock(); - void release_and_notify_pending_list_lock(); - public: VM_CMS_Operation(CMSCollector* collector): _collector(collector), diff --git a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp index 469412245bf..9c94863a43b 100644 --- a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp +++ b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp @@ -175,7 +175,7 @@ void ConcurrentMarkThread::run_service() { TimeHelper::counter_to_millis(mark_end - mark_start)); CMCheckpointRootsFinalClosure final_cl(_cm); - VM_CGC_Operation op(&final_cl, "Pause Remark", true /* needs_pll */); + VM_CGC_Operation op(&final_cl, "Pause Remark"); VMThread::execute(&op); } if (cm()->restart_for_overflow()) { @@ -199,7 +199,7 @@ void ConcurrentMarkThread::run_service() { delay_to_keep_mmu(g1_policy, false /* cleanup */); CMCleanUp cl_cl(_cm); - VM_CGC_Operation op(&cl_cl, "Pause Cleanup", false /* needs_pll */); + VM_CGC_Operation op(&cl_cl, "Pause Cleanup"); VMThread::execute(&op); } else { // We don't want to update the marking status if a GC pause diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp index b47778324b4..4aadccbe916 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp @@ -1273,12 +1273,6 @@ public: return true; } - // The reference pending list lock is acquired from from the - // ConcurrentMarkThread. - virtual bool needs_reference_pending_list_locker_thread() const { - return true; - } - inline bool is_in_young(const oop obj); virtual bool is_scavengable(const void* addr); diff --git a/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp b/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp index 333499a0a97..148fe80e3ef 100644 --- a/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp +++ b/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp @@ -204,14 +204,6 @@ void VM_G1IncCollectionPause::doit_epilogue() { } } -void VM_CGC_Operation::acquire_pending_list_lock() { - _pending_list_locker.lock(); -} - -void VM_CGC_Operation::release_and_notify_pending_list_lock() { - _pending_list_locker.unlock(); -} - void VM_CGC_Operation::doit() { GCIdMark gc_id_mark(_gc_id); GCTraceCPUTime tcpu; @@ -222,20 +214,13 @@ void VM_CGC_Operation::doit() { } bool VM_CGC_Operation::doit_prologue() { - // Note the relative order of the locks must match that in - // VM_GC_Operation::doit_prologue() or deadlocks can occur - if (_needs_pending_list_lock) { - acquire_pending_list_lock(); - } Heap_lock->lock(); return true; } void VM_CGC_Operation::doit_epilogue() { - // Note the relative order of the unlocks must match that in - // VM_GC_Operation::doit_epilogue() - Heap_lock->unlock(); - if (_needs_pending_list_lock) { - release_and_notify_pending_list_lock(); + if (Universe::has_reference_pending_list()) { + Heap_lock->notify_all(); } + Heap_lock->unlock(); } diff --git a/hotspot/src/share/vm/gc/g1/vm_operations_g1.hpp b/hotspot/src/share/vm/gc/g1/vm_operations_g1.hpp index 5aab7096586..94844f72881 100644 --- a/hotspot/src/share/vm/gc/g1/vm_operations_g1.hpp +++ b/hotspot/src/share/vm/gc/g1/vm_operations_g1.hpp @@ -27,7 +27,6 @@ #include "gc/g1/g1AllocationContext.hpp" #include "gc/shared/gcId.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "gc/shared/vmGCOperations.hpp" // VM_operations for the G1 collector. @@ -103,20 +102,13 @@ public: // Concurrent GC stop-the-world operations such as remark and cleanup; // consider sharing these with CMS's counterparts. class VM_CGC_Operation: public VM_Operation { - VoidClosure* _cl; - const char* _printGCMessage; - bool _needs_pending_list_lock; - ReferencePendingListLocker _pending_list_locker; - uint _gc_id; - -protected: - // java.lang.ref.Reference support - void acquire_pending_list_lock(); - void release_and_notify_pending_list_lock(); + VoidClosure* _cl; + const char* _printGCMessage; + uint _gc_id; public: - VM_CGC_Operation(VoidClosure* cl, const char *printGCMsg, bool needs_pending_list_lock) - : _cl(cl), _printGCMessage(printGCMsg), _needs_pending_list_lock(needs_pending_list_lock), _gc_id(GCId::current()) {} + VM_CGC_Operation(VoidClosure* cl, const char *printGCMsg) + : _cl(cl), _printGCMessage(printGCMsg), _gc_id(GCId::current()) {} virtual VMOp_Type type() const { return VMOp_CGC_Operation; } virtual void doit(); virtual bool doit_prologue(); diff --git a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp index 303252369e4..af26fc892e9 100644 --- a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp +++ b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp @@ -441,12 +441,6 @@ class CollectedHeap : public CHeapObj { // remembered set. virtual void flush_deferred_store_barrier(JavaThread* thread); - // Should return true if the reference pending list lock is - // acquired from non-Java threads, such as a concurrent GC thread. - virtual bool needs_reference_pending_list_locker_thread() const { - return false; - } - // Perform a collection of the heap; intended for use in implementing // "System.gc". This probably implies as full a collection as the // "CollectedHeap" supports. diff --git a/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp b/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp index f4a7e252942..9a469d14f7d 100644 --- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp @@ -281,10 +281,6 @@ public: return UseConcMarkSweepGC; } - virtual bool needs_reference_pending_list_locker_thread() const { - return UseConcMarkSweepGC; - } - // We don't need barriers for stores to objects in the // young gen and, a fortiori, for initializing stores to // objects therein. This applies to DefNew+Tenured and ParNew+CMS diff --git a/hotspot/src/share/vm/gc/shared/referencePendingListLocker.cpp b/hotspot/src/share/vm/gc/shared/referencePendingListLocker.cpp deleted file mode 100644 index 0c35d65aeee..00000000000 --- a/hotspot/src/share/vm/gc/shared/referencePendingListLocker.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2016, 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * 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. - * - */ - -#include "precompiled.hpp" -#include "classfile/javaClasses.hpp" -#include "classfile/systemDictionary.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "gc/shared/referencePendingListLocker.hpp" -#include "memory/universe.hpp" -#include "runtime/javaCalls.hpp" -#include "utilities/preserveException.hpp" - -ReferencePendingListLockerThread::ReferencePendingListLockerThread() : - JavaThread(&start), - _monitor(Monitor::nonleaf, "ReferencePendingListLocker", false, Monitor::_safepoint_check_sometimes), - _message(NONE) {} - -ReferencePendingListLockerThread* ReferencePendingListLockerThread::create(TRAPS) { - // Create Java thread objects - instanceKlassHandle thread_klass = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK_NULL); - instanceHandle thread_object = thread_klass->allocate_instance_handle(CHECK_NULL); - Handle thread_name = java_lang_String::create_from_str("Reference Pending List Locker", CHECK_NULL); - Handle thread_group = Universe::system_thread_group(); - JavaValue result(T_VOID); - JavaCalls::call_special(&result, - thread_object, - thread_klass, - vmSymbols::object_initializer_name(), - vmSymbols::threadgroup_string_void_signature(), - thread_group, - thread_name, - CHECK_NULL); - - { - MutexLocker ml(Threads_lock); - - // Allocate thread - ReferencePendingListLockerThread* thread = new ReferencePendingListLockerThread(); - if (thread == NULL || thread->osthread() == NULL) { - vm_exit_during_initialization("java.lang.OutOfMemoryError", - os::native_thread_creation_failed_msg()); - } - - // Initialize thread - java_lang_Thread::set_thread(thread_object(), thread); - java_lang_Thread::set_priority(thread_object(), NearMaxPriority); - java_lang_Thread::set_daemon(thread_object()); - thread->set_threadObj(thread_object()); - - // Start thread - Threads::add(thread); - Thread::start(thread); - - return thread; - } -} - -void ReferencePendingListLockerThread::start(JavaThread* thread, TRAPS) { - ReferencePendingListLockerThread* locker_thread = static_cast(thread); - locker_thread->receive_and_handle_messages(); -} - -bool ReferencePendingListLockerThread::is_hidden_from_external_view() const { - return true; -} - -void ReferencePendingListLockerThread::send_message(Message message) { - assert(message != NONE, "Should not be none"); - MonitorLockerEx ml(&_monitor, Monitor::_no_safepoint_check_flag); - - // Wait for completion of current message - while (_message != NONE) { - ml.wait(Monitor::_no_safepoint_check_flag); - } - - // Send new message - _message = message; - ml.notify_all(); - - // Wait for completion of new message - while (_message != NONE) { - ml.wait(Monitor::_no_safepoint_check_flag); - } -} - -void ReferencePendingListLockerThread::receive_and_handle_messages() { - ReferencePendingListLocker pending_list_locker; - MonitorLockerEx ml(&_monitor); - - // Main loop, never terminates - for (;;) { - // Wait for message - while (_message == NONE) { - ml.wait(); - } - - // Handle message - if (_message == LOCK) { - pending_list_locker.lock(); - } else if (_message == UNLOCK) { - pending_list_locker.unlock(); - } else { - ShouldNotReachHere(); - } - - // Clear message - _message = NONE; - ml.notify_all(); - } -} - -void ReferencePendingListLockerThread::lock() { - send_message(LOCK); -} - -void ReferencePendingListLockerThread::unlock() { - send_message(UNLOCK); -} - -bool ReferencePendingListLocker::_is_initialized = false; -ReferencePendingListLockerThread* ReferencePendingListLocker::_locker_thread = NULL; - -void ReferencePendingListLocker::initialize(bool needs_locker_thread, TRAPS) { - if (needs_locker_thread) { - _locker_thread = ReferencePendingListLockerThread::create(CHECK); - } - - _is_initialized = true; -} - -bool ReferencePendingListLocker::is_initialized() { - return _is_initialized; -} - -bool ReferencePendingListLocker::is_locked_by_self() { - oop pending_list_lock = java_lang_ref_Reference::pending_list_lock(); - if (pending_list_lock == NULL) { - return false; - } - - JavaThread* thread = JavaThread::current(); - Handle handle(thread, pending_list_lock); - return ObjectSynchronizer::current_thread_holds_lock(thread, handle); -} - -void ReferencePendingListLocker::lock() { - assert(!Heap_lock->owned_by_self(), "Heap_lock must not be owned by requesting thread"); - - if (Thread::current()->is_Java_thread()) { - assert(java_lang_ref_Reference::pending_list_lock() != NULL, "Not initialized"); - - // We may enter this with a pending exception - PRESERVE_EXCEPTION_MARK; - - HandleMark hm; - Handle handle(THREAD, java_lang_ref_Reference::pending_list_lock()); - - // Lock - ObjectSynchronizer::fast_enter(handle, &_basic_lock, false, THREAD); - - assert(is_locked_by_self(), "Locking failed"); - - if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; - } - } else { - // Delegate operation to locker thread - assert(_locker_thread != NULL, "Locker thread not created"); - _locker_thread->lock(); - } -} - -void ReferencePendingListLocker::unlock() { - if (Thread::current()->is_Java_thread()) { - assert(java_lang_ref_Reference::pending_list_lock() != NULL, "Not initialized"); - - // We may enter this with a pending exception - PRESERVE_EXCEPTION_MARK; - - HandleMark hm; - Handle handle(THREAD, java_lang_ref_Reference::pending_list_lock()); - - assert(is_locked_by_self(), "Should be locked by self"); - - // Notify waiters if the pending list is non-empty - if (java_lang_ref_Reference::pending_list() != NULL) { - ObjectSynchronizer::notifyall(handle, THREAD); - } - - // Unlock - ObjectSynchronizer::fast_exit(handle(), &_basic_lock, THREAD); - - if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; - } - } else { - // Delegate operation to locker thread - assert(_locker_thread != NULL, "Locker thread not created"); - _locker_thread->unlock(); - } -} diff --git a/hotspot/src/share/vm/gc/shared/referencePendingListLocker.hpp b/hotspot/src/share/vm/gc/shared/referencePendingListLocker.hpp deleted file mode 100644 index 62cf7eed995..00000000000 --- a/hotspot/src/share/vm/gc/shared/referencePendingListLocker.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2016, 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * 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. - * - */ - -#ifndef SHARE_VM_GC_SHARED_REFERENCEPENDINGLISTLOCKER_HPP -#define SHARE_VM_GC_SHARED_REFERENCEPENDINGLISTLOCKER_HPP - -#include "memory/allocation.hpp" -#include "runtime/basicLock.hpp" -#include "runtime/mutex.hpp" -#include "runtime/thread.hpp" -#include "utilities/exceptions.hpp" - -// -// The ReferencePendingListLockerThread locks and unlocks the reference -// pending list lock on behalf a non-Java thread, typically a concurrent -// GC thread. This interface should not be directly accessed. All uses -// should instead go through the ReferencePendingListLocker, which calls -// this thread if needed. -// -class ReferencePendingListLockerThread : public JavaThread { -private: - enum Message { - NONE, - LOCK, - UNLOCK - }; - - Monitor _monitor; - Message _message; - - ReferencePendingListLockerThread(); - - static void start(JavaThread* thread, TRAPS); - - void send_message(Message message); - void receive_and_handle_messages(); - -public: - static ReferencePendingListLockerThread* create(TRAPS); - - virtual bool is_hidden_from_external_view() const; - - void lock(); - void unlock(); -}; - -// -// The ReferencePendingListLocker is the main interface for locking and -// unlocking the reference pending list lock, which needs to be held by -// the GC when adding references to the pending list. Since this is a -// Java-level monitor it can only be locked/unlocked by a Java thread. -// For this reason there is an option to spawn a helper thread, the -// ReferencePendingListLockerThread, during initialization. If a helper -// thread is spawned all lock operations from non-Java threads will be -// delegated to the helper thread. The helper thread is typically needed -// by concurrent GCs. -// -class ReferencePendingListLocker VALUE_OBJ_CLASS_SPEC { -private: - static bool _is_initialized; - static ReferencePendingListLockerThread* _locker_thread; - BasicLock _basic_lock; - -public: - static void initialize(bool needs_locker_thread, TRAPS); - static bool is_initialized(); - - static bool is_locked_by_self(); - - void lock(); - void unlock(); -}; - -#endif // SHARE_VM_GC_SHARED_REFERENCEPENDINGLISTLOCKER_HPP diff --git a/hotspot/src/share/vm/gc/shared/referenceProcessor.cpp b/hotspot/src/share/vm/gc/shared/referenceProcessor.cpp index 2200e7620a4..38df96ddd4c 100644 --- a/hotspot/src/share/vm/gc/shared/referenceProcessor.cpp +++ b/hotspot/src/share/vm/gc/shared/referenceProcessor.cpp @@ -289,39 +289,16 @@ void ReferenceProcessor::process_phaseJNI(BoolObjectClosure* is_alive, complete_gc->do_void(); } - -template -bool enqueue_discovered_ref_helper(ReferenceProcessor* ref, - AbstractRefProcTaskExecutor* task_executor) { - - // Remember old value of pending references list - T* pending_list_addr = (T*)java_lang_ref_Reference::pending_list_addr(); - T old_pending_list_value = *pending_list_addr; - +void ReferenceProcessor::enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor) { // Enqueue references that are not made active again, and // clear the decks for the next collection (cycle). - ref->enqueue_discovered_reflists((HeapWord*)pending_list_addr, task_executor); - // Do the post-barrier on pending_list_addr missed in - // enqueue_discovered_reflist. - oopDesc::bs()->write_ref_field(pending_list_addr, oopDesc::load_decode_heap_oop(pending_list_addr)); + enqueue_discovered_reflists(task_executor); // Stop treating discovered references specially. - ref->disable_discovery(); - - // Return true if new pending references were added - return old_pending_list_value != *pending_list_addr; + disable_discovery(); } -bool ReferenceProcessor::enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor) { - if (UseCompressedOops) { - return enqueue_discovered_ref_helper(this, task_executor); - } else { - return enqueue_discovered_ref_helper(this, task_executor); - } -} - -void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list, - HeapWord* pending_list_addr) { +void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list) { // Given a list of refs linked through the "discovered" field // (java.lang.ref.Reference.discovered), self-loop their "next" field // thus distinguishing them from active References, then @@ -354,10 +331,9 @@ void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list, oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(obj), next_d); } else { // This is the last object. - // Swap refs_list into pending_list_addr and - // set obj's discovered to what we read from pending_list_addr. - oop old = oopDesc::atomic_exchange_oop(refs_list.head(), pending_list_addr); - // Need post-barrier on pending_list_addr. See enqueue_discovered_ref_helper() above. + // Swap refs_list into pending list and set obj's + // discovered to what we read from the pending list. + oop old = Universe::swap_reference_pending_list(refs_list.head()); java_lang_ref_Reference::set_discovered_raw(obj, old); // old may be NULL oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(obj), old); } @@ -369,10 +345,8 @@ class RefProcEnqueueTask: public AbstractRefProcTaskExecutor::EnqueueTask { public: RefProcEnqueueTask(ReferenceProcessor& ref_processor, DiscoveredList discovered_refs[], - HeapWord* pending_list_addr, int n_queues) - : EnqueueTask(ref_processor, discovered_refs, - pending_list_addr, n_queues) + : EnqueueTask(ref_processor, discovered_refs, n_queues) { } virtual void work(unsigned int work_id) { @@ -387,8 +361,7 @@ public: for (int j = 0; j < ReferenceProcessor::number_of_subclasses_of_ref(); j++, index += _n_queues) { - _ref_processor.enqueue_discovered_reflist( - _refs_lists[index], _pending_list_addr); + _ref_processor.enqueue_discovered_reflist(_refs_lists[index]); _refs_lists[index].set_head(NULL); _refs_lists[index].set_length(0); } @@ -396,17 +369,15 @@ public: }; // Enqueue references that are not made active again -void ReferenceProcessor::enqueue_discovered_reflists(HeapWord* pending_list_addr, - AbstractRefProcTaskExecutor* task_executor) { +void ReferenceProcessor::enqueue_discovered_reflists(AbstractRefProcTaskExecutor* task_executor) { if (_processing_is_mt && task_executor != NULL) { // Parallel code - RefProcEnqueueTask tsk(*this, _discovered_refs, - pending_list_addr, _max_num_q); + RefProcEnqueueTask tsk(*this, _discovered_refs, _max_num_q); task_executor->execute(tsk); } else { // Serial code: call the parent class's implementation for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { - enqueue_discovered_reflist(_discovered_refs[i], pending_list_addr); + enqueue_discovered_reflist(_discovered_refs[i]); _discovered_refs[i].set_head(NULL); _discovered_refs[i].set_length(0); } diff --git a/hotspot/src/share/vm/gc/shared/referenceProcessor.hpp b/hotspot/src/share/vm/gc/shared/referenceProcessor.hpp index c5d0f5f8321..393029642b4 100644 --- a/hotspot/src/share/vm/gc/shared/referenceProcessor.hpp +++ b/hotspot/src/share/vm/gc/shared/referenceProcessor.hpp @@ -290,7 +290,7 @@ class ReferenceProcessor : public CHeapObj { VoidClosure* complete_gc); // Enqueue references with a certain reachability level - void enqueue_discovered_reflist(DiscoveredList& refs_list, HeapWord* pending_list_addr); + void enqueue_discovered_reflist(DiscoveredList& refs_list); // "Preclean" all the discovered reference lists // by removing references with strongly reachable referents. @@ -311,7 +311,7 @@ class ReferenceProcessor : public CHeapObj { // occupying the i / _num_q slot. const char* list_name(uint i); - void enqueue_discovered_reflists(HeapWord* pending_list_addr, AbstractRefProcTaskExecutor* task_executor); + void enqueue_discovered_reflists(AbstractRefProcTaskExecutor* task_executor); protected: // "Preclean" the given discovered reference list @@ -424,7 +424,7 @@ class ReferenceProcessor : public CHeapObj { GCTimer *gc_timer); // Enqueue references at end of GC (called by the garbage collector) - bool enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor = NULL); + void enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor = NULL); // If a discovery is in process that is being superceded, abandon it: all // the discovered lists will be empty, and all the objects on them will @@ -613,11 +613,9 @@ class AbstractRefProcTaskExecutor::EnqueueTask { protected: EnqueueTask(ReferenceProcessor& ref_processor, DiscoveredList refs_lists[], - HeapWord* pending_list_addr, int n_queues) : _ref_processor(ref_processor), _refs_lists(refs_lists), - _pending_list_addr(pending_list_addr), _n_queues(n_queues) { } @@ -627,7 +625,6 @@ public: protected: ReferenceProcessor& _ref_processor; DiscoveredList* _refs_lists; - HeapWord* _pending_list_addr; int _n_queues; }; diff --git a/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp b/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp index 9ac7d42e0a0..ce73880ba2a 100644 --- a/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp +++ b/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp @@ -62,14 +62,6 @@ void VM_GC_Operation::notify_gc_end() { HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); } -void VM_GC_Operation::acquire_pending_list_lock() { - _pending_list_locker.lock(); -} - -void VM_GC_Operation::release_and_notify_pending_list_lock() { - _pending_list_locker.unlock(); -} - // Allocations may fail in several threads at about the same time, // resulting in multiple gc requests. We only want to do one of them. // In case a GC locker is active and the need for a GC is already signaled, @@ -102,16 +94,13 @@ bool VM_GC_Operation::doit_prologue() { proper_unit_for_byte_size(NewSize))); } - acquire_pending_list_lock(); // If the GC count has changed someone beat us to the collection - // Get the Heap_lock after the pending_list_lock. Heap_lock->lock(); // Check invocations if (skip_operation()) { // skip collection Heap_lock->unlock(); - release_and_notify_pending_list_lock(); _prologue_succeeded = false; } else { _prologue_succeeded = true; @@ -122,9 +111,10 @@ bool VM_GC_Operation::doit_prologue() { void VM_GC_Operation::doit_epilogue() { assert(Thread::current()->is_Java_thread(), "just checking"); - // Release the Heap_lock first. + if (Universe::has_reference_pending_list()) { + Heap_lock->notify_all(); + } Heap_lock->unlock(); - release_and_notify_pending_list_lock(); } bool VM_GC_HeapInspection::skip_operation() const { diff --git a/hotspot/src/share/vm/gc/shared/vmGCOperations.hpp b/hotspot/src/share/vm/gc/shared/vmGCOperations.hpp index fe742964b56..80e652e1029 100644 --- a/hotspot/src/share/vm/gc/shared/vmGCOperations.hpp +++ b/hotspot/src/share/vm/gc/shared/vmGCOperations.hpp @@ -27,7 +27,6 @@ #include "gc/shared/collectedHeap.hpp" #include "gc/shared/genCollectedHeap.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "memory/heapInspection.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/handles.hpp" @@ -70,9 +69,6 @@ // class VM_GC_Operation: public VM_Operation { - private: - ReferencePendingListLocker _pending_list_locker; - protected: uint _gc_count_before; // gc count before acquiring PLL uint _full_gc_count_before; // full gc count before acquiring PLL @@ -83,10 +79,6 @@ class VM_GC_Operation: public VM_Operation { virtual bool skip_operation() const; - // java.lang.ref.Reference support - void acquire_pending_list_lock(); - void release_and_notify_pending_list_lock(); - public: VM_GC_Operation(uint gc_count_before, GCCause::Cause _cause, diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 1e434d1b79a..97cd396b340 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -135,6 +135,7 @@ oop Universe::_arithmetic_exception_instance = NULL; oop Universe::_virtual_machine_error_instance = NULL; oop Universe::_vm_exception = NULL; oop Universe::_allocation_context_notification_obj = NULL; +oop Universe::_reference_pending_list = NULL; Array* Universe::_the_empty_int_array = NULL; Array* Universe::_the_empty_short_array = NULL; @@ -212,6 +213,7 @@ void Universe::oops_do(OopClosure* f, bool do_all) { f->do_oop((oop*)&_system_thread_group); f->do_oop((oop*)&_vm_exception); f->do_oop((oop*)&_allocation_context_notification_obj); + f->do_oop((oop*)&_reference_pending_list); debug_only(f->do_oop((oop*)&_fullgc_alot_dummy_array);) } @@ -488,6 +490,35 @@ void Universe::fixup_mirrors(TRAPS) { java_lang_Class::set_fixup_mirror_list(NULL); } +#define assert_pll_locked(test) \ + assert(Heap_lock->test(), "Reference pending list access requires lock") + +#define assert_pll_ownership() assert_pll_locked(owned_by_self) + +oop Universe::reference_pending_list() { + assert_pll_ownership(); + return _reference_pending_list; +} + +void Universe::set_reference_pending_list(oop list) { + assert_pll_ownership(); + _reference_pending_list = list; +} + +bool Universe::has_reference_pending_list() { + assert_pll_ownership(); + return _reference_pending_list != NULL; +} + +oop Universe::swap_reference_pending_list(oop list) { + assert_pll_locked(is_locked); + return (oop)Atomic::xchg_ptr(list, &_reference_pending_list); +} + +#undef assert_pll_locked +#undef assert_pll_ownership + + static bool has_run_finalizers_on_exit = false; void Universe::run_finalizers_on_exit() { @@ -565,12 +596,14 @@ bool Universe::should_fill_in_stack_trace(Handle throwable) { oop Universe::gen_out_of_memory_error(oop default_err) { // generate an out of memory error: - // - if there is a preallocated error with backtrace available then return it wth - // a filled in stack trace. - // - if there are no preallocated errors with backtrace available then return - // an error without backtrace. + // - if there is a preallocated error and stack traces are available + // (j.l.Throwable is initialized), then return the preallocated + // error with a filled in stack trace, and with the message + // provided by the default error. + // - otherwise, return the default error, without a stack trace. int next; - if (_preallocated_out_of_memory_error_avail_count > 0) { + if ((_preallocated_out_of_memory_error_avail_count > 0) && + SystemDictionary::Throwable_klass()->is_initialized()) { next = (int)Atomic::add(-1, &_preallocated_out_of_memory_error_avail_count); assert(next < (int)PreallocatedOutOfMemoryErrorCount, "avail count is corrupt"); } else { diff --git a/hotspot/src/share/vm/memory/universe.hpp b/hotspot/src/share/vm/memory/universe.hpp index 054b11aa873..2ded08fc801 100644 --- a/hotspot/src/share/vm/memory/universe.hpp +++ b/hotspot/src/share/vm/memory/universe.hpp @@ -185,6 +185,9 @@ class Universe: AllStatic { static oop _allocation_context_notification_obj; + // References waiting to be transferred to the ReferenceHandler + static oop _reference_pending_list; + // The particular choice of collected heap. static CollectedHeap* _collectedHeap; @@ -334,6 +337,17 @@ class Universe: AllStatic { static inline oop allocation_context_notification_obj(); static inline void set_allocation_context_notification_obj(oop obj); + // Reference pending list manipulation. Access is protected by + // Heap_lock. The getter, setter and predicate require the caller + // owns the lock. Swap is used by parallel non-concurrent reference + // processing threads, where some higher level controller owns + // Heap_lock, so requires the lock is locked, but not necessarily by + // the current thread. + static oop reference_pending_list(); + static void set_reference_pending_list(oop list); + static bool has_reference_pending_list(); + static oop swap_reference_pending_list(oop list); + static Array* the_empty_int_array() { return _the_empty_int_array; } static Array* the_empty_short_array() { return _the_empty_short_array; } static Array* the_empty_method_array() { return _the_empty_method_array; } diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index f890d1d1e9b..95e38717dc5 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -30,7 +30,6 @@ #include "gc/shared/collectedHeap.inline.hpp" #include "gc/shared/gcLocker.hpp" #include "gc/shared/generation.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "interpreter/bytecodeStream.hpp" #include "interpreter/bytecodeTracer.hpp" #include "interpreter/bytecodes.hpp" @@ -400,12 +399,6 @@ void Method::build_interpreter_method_data(const methodHandle& method, TRAPS) { return; } - // Do not profile method if current thread holds the pending list lock, - // which avoids deadlock for acquiring the MethodData_lock. - if (ReferencePendingListLocker::is_locked_by_self()) { - return; - } - // Grab a lock here to prevent multiple // MethodData*s from being created. MutexLocker ml(MethodData_lock, THREAD); diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index b66c22bf74e..549e9f47109 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -3352,6 +3352,35 @@ JVM_ENTRY(jobjectArray, JVM_GetSystemPackages(JNIEnv *env)) JVM_END +// java.lang.ref.Reference /////////////////////////////////////////////////////////////// + + +JVM_ENTRY(jobject, JVM_GetAndClearReferencePendingList(JNIEnv* env)) + JVMWrapper("JVM_GetAndClearReferencePendingList"); + + MonitorLockerEx ml(Heap_lock); + oop ref = Universe::reference_pending_list(); + if (ref != NULL) { + Universe::set_reference_pending_list(NULL); + } + return JNIHandles::make_local(env, ref); +JVM_END + +JVM_ENTRY(jboolean, JVM_HasReferencePendingList(JNIEnv* env)) + JVMWrapper("JVM_HasReferencePendingList"); + MonitorLockerEx ml(Heap_lock); + return Universe::has_reference_pending_list(); +JVM_END + +JVM_ENTRY(void, JVM_WaitForReferencePendingList(JNIEnv* env)) + JVMWrapper("JVM_WaitForReferencePendingList"); + MonitorLockerEx ml(Heap_lock); + while (!Universe::has_reference_pending_list()) { + ml.wait(); + } +JVM_END + + // ObjectInputStream /////////////////////////////////////////////////////////////// bool force_verify_field_access(Klass* current_class, Klass* field_class, AccessFlags access, bool classloader_only) { diff --git a/hotspot/src/share/vm/prims/jvm.h b/hotspot/src/share/vm/prims/jvm.h index 58a8fbfeb75..7a0da904bd1 100644 --- a/hotspot/src/share/vm/prims/jvm.h +++ b/hotspot/src/share/vm/prims/jvm.h @@ -296,6 +296,18 @@ JVM_GetSystemPackage(JNIEnv *env, jstring name); JNIEXPORT jobjectArray JNICALL JVM_GetSystemPackages(JNIEnv *env); +/* + * java.lang.ref.Reference + */ +JNIEXPORT jobject JNICALL +JVM_GetAndClearReferencePendingList(JNIEnv *env); + +JNIEXPORT jboolean JNICALL +JVM_HasReferencePendingList(JNIEnv *env); + +JNIEXPORT void JNICALL +JVM_WaitForReferencePendingList(JNIEnv *env); + /* * java.io.ObjectInputStream */ diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index f3481dad820..aa17ff69641 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -35,7 +35,6 @@ #include "compiler/compileTask.hpp" #include "gc/shared/gcId.hpp" #include "gc/shared/gcLocker.inline.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "gc/shared/workgroup.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/linkResolver.hpp" @@ -3718,14 +3717,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { Management::record_vm_init_completed(); #endif // INCLUDE_MANAGEMENT - // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and - // set_init_completed has just been called, causing exceptions not to be shortcut - // anymore. We call vm_exit_during_initialization directly instead. - - // Initialize reference pending list locker - bool needs_locker_thread = Universe::heap()->needs_reference_pending_list_locker_thread(); - ReferencePendingListLocker::initialize(needs_locker_thread, CHECK_JNI_ERR); - // Signal Dispatcher needs to be started before VMInit event is posted os::signal_init(); diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 81994ce96f1..26147144526 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -54,7 +54,6 @@ #include "gc/shared/genCollectedHeap.hpp" #include "gc/shared/generation.hpp" #include "gc/shared/generationSpec.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "gc/shared/space.hpp" #include "interpreter/bytecodeInterpreter.hpp" #include "interpreter/bytecodes.hpp" @@ -1637,7 +1636,6 @@ typedef CompactHashtable SymbolCompactHashTable; declare_type(JavaThread, Thread) \ declare_type(JvmtiAgentThread, JavaThread) \ declare_type(ServiceThread, JavaThread) \ - declare_type(ReferencePendingListLockerThread, JavaThread) \ declare_type(CompilerThread, JavaThread) \ declare_type(CodeCacheSweeperThread, JavaThread) \ declare_toplevel_type(OSThread) \ From 23ceda31a0994e3ae21dfda2bd78d33854d14631 Mon Sep 17 00:00:00 2001 From: Marcus Larsson Date: Wed, 31 Aug 2016 09:38:46 +0200 Subject: [PATCH 081/296] 8164939: GTest LogDecorations.iso8601_time_test fails on macOS Reviewed-by: sla, dsamersoff --- hotspot/test/native/logging/test_logDecorations.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/native/logging/test_logDecorations.cpp b/hotspot/test/native/logging/test_logDecorations.cpp index 324792b24b8..c23fb1b8227 100644 --- a/hotspot/test/native/logging/test_logDecorations.cpp +++ b/hotspot/test/native/logging/test_logDecorations.cpp @@ -144,7 +144,7 @@ TEST(LogDecorations, iso8601_time) { reported_time.tm_hour = h; reported_time.tm_min = m; reported_time.tm_sec = s; - reported_time.tm_isdst = daylight; + reported_time.tm_isdst = -1; // let mktime deduce DST settings time_t reported_ts = mktime(&reported_time); expected_ts = mktime(localtime(&expected_ts)); time_t diff = reported_ts - expected_ts; From 6449bab3d190709a932ed8c8b0c983335c8dce9c Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Wed, 31 Aug 2016 11:13:53 +0300 Subject: [PATCH 082/296] 8163193: Metal L&F gradient is lighter on HiDPI display after the fix JDK-8143064 Reviewed-by: serb, ssadetsky --- .../classes/sun/swing/CachedPainter.java | 18 ++- .../8163193/ButtonGradientTest.java | 134 ++++++++++++++++++ 2 files changed, 146 insertions(+), 6 deletions(-) create mode 100644 jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java diff --git a/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java b/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java index 818e20dbdd3..92c0e3bad8e 100644 --- a/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java +++ b/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java @@ -107,13 +107,16 @@ public abstract class CachedPainter { ImageCache cache = getCache(key); Image image = cache.getImage(key, config, w, h, args); int attempts = 0; + VolatileImage volatileImage = (image instanceof VolatileImage) + ? (VolatileImage) image + : null; do { boolean draw = false; - if (image instanceof VolatileImage) { + if (volatileImage != null) { // See if we need to recreate the image - switch (((VolatileImage)image).validate(config)) { + switch (volatileImage.validate(config)) { case VolatileImage.IMAGE_INCOMPATIBLE: - ((VolatileImage)image).flush(); + volatileImage.flush(); image = null; break; case VolatileImage.IMAGE_RESTORED: @@ -126,11 +129,14 @@ public abstract class CachedPainter { image = createImage(c, w, h, config, args); cache.setImage(key, config, w, h, args, image); draw = true; + volatileImage = (image instanceof VolatileImage) + ? (VolatileImage) image + : null; } if (draw) { // Render to the Image Graphics2D g2 = (Graphics2D) image.getGraphics(); - if (w != baseWidth || h != baseHeight) { + if (volatileImage == null && (w != baseWidth || h != baseHeight)) { g2.scale((double) w / baseWidth, (double) h / baseHeight); } paintToImage(c, image, g2, baseWidth, baseHeight, args); @@ -140,8 +146,8 @@ public abstract class CachedPainter { // If we did this 3 times and the contents are still lost // assume we're painting to a VolatileImage that is bogus and // give up. Presumably we'll be called again to paint. - } while ((image instanceof VolatileImage) && - ((VolatileImage)image).contentsLost() && ++attempts < 3); + } while ((volatileImage != null) && + volatileImage.contentsLost() && ++attempts < 3); return image; } diff --git a/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java b/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java new file mode 100644 index 00000000000..8860d768a0d --- /dev/null +++ b/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.util.List; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.plaf.metal.MetalLookAndFeel; + +/* + * @test + * @bug 8163193 + * @key headful + * @summary Metal L&F gradient is lighter on HiDPI display + * @run main/othervm -Dsun.java2d.uiScale=2 ButtonGradientTest + */ +public class ButtonGradientTest { + + private static JFrame frame; + private static JButton button; + + public static void main(String[] args) throws Exception { + try { + testGradient(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void testGradient() throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(ButtonGradientTest::createAndShowGUI); + robot.waitForIdle(); + + Rectangle rect = getButtonBounds(); + List gradient = (List) UIManager.get("Button.gradient"); + float ratio = ((Number) gradient.get(0)).floatValue(); + Color c1 = (Color) gradient.get(2); + Color c2 = (Color) gradient.get(3); + int mid = (int) (ratio * rect.height); + + Color gradientColor = getGradientColor(rect.width, mid, c1, c2); + int x = rect.x + rect.width / 2; + int y = rect.y + mid / 2; + Color buttonColor = robot.getPixelColor(x, y); + + if (!similarColors(buttonColor, gradientColor)) { + throw new RuntimeException("Button gradient is changed!"); + } + } + + private static void createAndShowGUI() { + + try { + UIManager.setLookAndFeel(new MetalLookAndFeel()); + } catch (Exception e) { + throw new RuntimeException(e); + } + + frame = new JFrame(); + frame.setSize(300, 300); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JPanel panel = new JPanel(new BorderLayout()); + button = new JButton(""); + panel.add(button); + frame.getContentPane().add(panel); + frame.setVisible(true); + } + + private static Rectangle getButtonBounds() throws Exception { + Rectangle[] rectangles = new Rectangle[1]; + SwingUtilities.invokeAndWait(() -> { + rectangles[0] = button.getBounds(); + rectangles[0].setLocation(button.getLocationOnScreen()); + }); + return rectangles[0]; + } + + private static Color getGradientColor(int w, int h, Color c1, Color c2) { + GradientPaint gradient = new GradientPaint(0, 0, c1, 0, h, c2, true); + BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics2D g = img.createGraphics(); + g.setPaint(gradient); + g.fillRect(0, 0, w, h); + g.dispose(); + return new Color(img.getRGB(w / 2, h / 2)); + } + + private static boolean similarColors(Color c1, Color c2) { + return similar(c1.getRed(), c2.getRed()) + && similar(c1.getGreen(), c2.getGreen()) + && similar(c1.getBlue(), c2.getBlue()); + } + + private static boolean similar(int i1, int i2) { + return Math.abs(i2 - i1) < 7; + } +} From c7a2c07ca83fd20eb692efaee7a3612fe7a106d9 Mon Sep 17 00:00:00 2001 From: Jini George Date: Wed, 31 Aug 2016 11:46:59 +0300 Subject: [PATCH 083/296] 8163150: SA: CLHSDB printmdo throws an exception with "java.lang.InternalError: missing reason for 22" Accounted for the new JVMCI related Deoptimization Reasons. Reviewed-by: dsamersoff, sla --- .../sun/tools/jhsdb/BasicLauncherTest.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java index 57651e69c87..7c9cc31da5a 100644 --- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java +++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java @@ -85,20 +85,52 @@ public class BasicLauncherTest { try (OutputStream out = toolProcess.getOutputStream()) { out.write("universe\n".getBytes()); + out.write("printmdo -a\n".getBytes()); out.write("quit\n".getBytes()); } // By default child process output stream redirected to pipe, so we are reading it in foreground. Exception unexpected = null; - try (BufferedReader reader = new BufferedReader(new InputStreamReader(toolProcess.getInputStream()))) { + try (BufferedReader reader = + new BufferedReader(new InputStreamReader(toolProcess.getInputStream()))) { String line; + String unexpectedMsg = + "One or more of 'VirtualCallData', 'CounterData', " + + "'ReceiverTypeData', 'bci', 'MethodData' " + + "or 'java/lang/Object' not found"; + boolean knownClassFound = false; + boolean knownProfileDataTypeFound = false; + boolean knownTokensFound = false; + while ((line = reader.readLine()) != null) { line = line.trim(); System.out.println(line); if (line.contains("unknown subtype of CollectedHeap")) { unexpected = new RuntimeException("CollectedHeap type should be known."); + break; } + else if (line.contains("missing reason for ")) { + unexpected = new RuntimeException("missing reason for "); + break; + } + if (line.contains("VirtualCallData") || + line.contains("CounterData") || + line.contains("ReceiverTypeData")) { + knownProfileDataTypeFound = true; + } + if (line.contains("bci") || + line.contains("MethodData")) { + knownTokensFound = true; + } + if (line.contains("java/lang/Object")) { + knownClassFound = true; + } + } + if ((knownClassFound == false) || + (knownTokensFound == false) || + (knownProfileDataTypeFound == false)) { + unexpected = new RuntimeException(unexpectedMsg); } } From ab538ab5ed85aeff06fdcba603ff1d50e5131c12 Mon Sep 17 00:00:00 2001 From: Jini George Date: Wed, 31 Aug 2016 11:47:14 +0300 Subject: [PATCH 084/296] 8163150: SA: CLHSDB printmdo throws an exception with "java.lang.InternalError: missing reason for 22" Accounted for the new JVMCI related Deoptimization Reasons. Reviewed-by: dsamersoff, sla --- .../sun/jvm/hotspot/oops/MethodData.java | 7 +++-- .../jvm/hotspot/oops/ReceiverTypeData.java | 26 +++++++++++++++---- .../sun/jvm/hotspot/oops/VirtualCallData.java | 8 ++++-- hotspot/src/share/vm/runtime/vmStructs.cpp | 13 +++++++++- 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java index 1549538a10e..f01bb5e6ce5 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java @@ -36,6 +36,7 @@ import sun.jvm.hotspot.utilities.*; public class MethodData extends Metadata implements MethodDataInterface { static int TypeProfileWidth = 2; static int BciProfileWidth = 2; + static int MethodProfileWidth = 0; static int CompileThreshold; static int Reason_many; // indicates presence of several reasons @@ -142,6 +143,8 @@ public class MethodData extends Metadata implements MethodDataInterface parametersTypeData() { int di = (int)parametersTypeDataDi.getValue(getAddress()); - if (di == -1) { + if (di == -1 || di == -2) { return null; } DataLayout dataLayout = new DataLayout(this, di + (int)data.getOffset()); diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java index 7ac053fe0c5..ed2a120ca61 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -38,9 +38,21 @@ import sun.jvm.hotspot.utilities.*; // that the check is reached, and a series of (Klass, count) pairs // which are used to store a type profile for the receiver of the check. public class ReceiverTypeData extends CounterData { - static final int receiver0Offset = counterCellCount; - static final int count0Offset = receiver0Offset + 1; - static final int receiverTypeRowCellCount = (count0Offset + 1) - receiver0Offset; + static final int INCLUDE_JVMCI; + static final int nonProfiledCountOffset = counterCellCount; + static final int receiver0Offset; + static final int count0Offset; + static final int receiverTypeRowCellCount; + static { + INCLUDE_JVMCI = VM.getVM().getTypeDataBase().lookupIntConstant("INCLUDE_JVMCI"); + if (INCLUDE_JVMCI == 1) { + receiver0Offset = nonProfiledCountOffset + 1; + } else { + receiver0Offset = counterCellCount; + } + count0Offset = receiver0Offset + 1; + receiverTypeRowCellCount = (count0Offset + 1) - receiver0Offset; + } final MethodDataInterface methodData; public ReceiverTypeData(MethodDataInterface methodData, DataLayout layout) { @@ -53,7 +65,11 @@ public class ReceiverTypeData extends CounterData { boolean isReceivertypedata() { return true; } static int staticCellCount() { - return counterCellCount + MethodData.TypeProfileWidth * receiverTypeRowCellCount; + int cellCount = counterCellCount + MethodData.TypeProfileWidth * receiverTypeRowCellCount; + if (INCLUDE_JVMCI == 1) { + cellCount += 1; + } + return cellCount; } public int cellCount() { diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java index eec5000a6a4..fe7183822a1 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -44,7 +44,11 @@ public class VirtualCallData extends ReceiverTypeData { static int staticCellCount() { // At this point we could add more profile state, e.g., for arguments. // But for now it's the same size as the base record type. - return ReceiverTypeData.staticCellCount(); + int cellCount = ReceiverTypeData.staticCellCount(); + if (INCLUDE_JVMCI == 1) { + cellCount += MethodData.MethodProfileWidth * receiverTypeRowCellCount; + } + return cellCount; } public int cellCount() { diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 26147144526..84eb6fa7d86 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -2626,6 +2626,11 @@ typedef CompactHashtable SymbolCompactHashTable; declare_constant(Deoptimization::Reason_rtm_state_change) \ declare_constant(Deoptimization::Reason_unstable_if) \ declare_constant(Deoptimization::Reason_unstable_fused_if) \ + NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_aliasing))) \ + NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_transfer_to_interpreter))) \ + NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_not_compiled_exception_handler))) \ + NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_unresolved))) \ + NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_jsr_mismatch))) \ declare_constant(Deoptimization::Reason_tenured) \ declare_constant(Deoptimization::Reason_LIMIT) \ declare_constant(Deoptimization::Reason_RECORDED_LIMIT) \ @@ -2750,7 +2755,13 @@ typedef CompactHashtable SymbolCompactHashTable; declare_constant(ConcreteRegisterImpl::number_of_registers) \ declare_preprocessor_constant("REG_COUNT", REG_COUNT) \ declare_c2_preprocessor_constant("SAVED_ON_ENTRY_REG_COUNT", SAVED_ON_ENTRY_REG_COUNT) \ - declare_c2_preprocessor_constant("C_SAVED_ON_ENTRY_REG_COUNT", C_SAVED_ON_ENTRY_REG_COUNT) + declare_c2_preprocessor_constant("C_SAVED_ON_ENTRY_REG_COUNT", C_SAVED_ON_ENTRY_REG_COUNT) \ + \ + /****************/ \ + /* JVMCI */ \ + /****************/ \ + \ + declare_preprocessor_constant("INCLUDE_JVMCI", INCLUDE_JVMCI) //-------------------------------------------------------------------------------- From 5f8a441f1a19d11ffb96d19b50195cf5717c7dc1 Mon Sep 17 00:00:00 2001 From: Amit Sapre Date: Wed, 31 Aug 2016 12:10:00 +0300 Subject: [PATCH 085/296] 8066635: Fix deprecation warnings in java.management module Fixed deprecation warnings in java.management module Reviewed-by: dholmes --- .../DefaultMBeanServerInterceptor.java | 21 +------------- .../interceptor/MBeanServerInterceptor.java | 28 +------------------ .../classes/javax/management/MBeanServer.java | 21 ++++++++------ 3 files changed, 15 insertions(+), 55 deletions(-) diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java index a0589f72b05..350eb0218a0 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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 @@ -1707,25 +1707,6 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { throw new UnsupportedOperationException("Not supported yet."); } - @SuppressWarnings("deprecation") - public ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException, - OperationsException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("deprecation") - public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, - ReflectionException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("deprecation") - public ObjectInputStream deserialize(String className, ObjectName loaderName, - byte[] data) throws InstanceNotFoundException, OperationsException, - ReflectionException { - throw new UnsupportedOperationException("Not supported yet."); - } - public ClassLoaderRepository getClassLoaderRepository() { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java index 8f0f9b66a5a..bbb1340d141 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -94,32 +94,6 @@ public interface MBeanServerInterceptor extends MBeanServer { throws ReflectionException, MBeanException, InstanceNotFoundException; - /** - * This method should never be called. - * Usually throws UnsupportedOperationException. - */ - @Deprecated - public ObjectInputStream deserialize(ObjectName name, byte[] data) - throws InstanceNotFoundException, OperationsException; - - /** - * This method should never be called. - * Usually throws UnsupportedOperationException. - */ - @Deprecated - public ObjectInputStream deserialize(String className, byte[] data) - throws OperationsException, ReflectionException; - - /** - * This method should never be called. - * Usually hrows UnsupportedOperationException. - */ - @Deprecated - public ObjectInputStream deserialize(String className, - ObjectName loaderName, byte[] data) - throws InstanceNotFoundException, OperationsException, - ReflectionException; - /** * This method should never be called. * Usually throws UnsupportedOperationException. diff --git a/jdk/src/java.management/share/classes/javax/management/MBeanServer.java b/jdk/src/java.management/share/classes/javax/management/MBeanServer.java index 1526d818013..b093b204fe3 100644 --- a/jdk/src/java.management/share/classes/javax/management/MBeanServer.java +++ b/jdk/src/java.management/share/classes/javax/management/MBeanServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -666,9 +666,10 @@ public interface MBeanServer extends MBeanServerConnection { * obtain the appropriate class loader for deserialization. */ @Deprecated - public ObjectInputStream deserialize(ObjectName name, byte[] data) - throws InstanceNotFoundException, OperationsException; - + default public ObjectInputStream deserialize(ObjectName name, byte[] data) + throws InstanceNotFoundException, OperationsException { + throw new UnsupportedOperationException("Not supported."); + } /** *

De-serializes a byte array in the context of a given MBean @@ -693,8 +694,10 @@ public interface MBeanServer extends MBeanServerConnection { * class loader repository and use it to deserialize. */ @Deprecated - public ObjectInputStream deserialize(String className, byte[] data) - throws OperationsException, ReflectionException; + default public ObjectInputStream deserialize(String className, byte[] data) + throws OperationsException, ReflectionException { + throw new UnsupportedOperationException("Not supported."); + } /** @@ -724,11 +727,13 @@ public interface MBeanServer extends MBeanServerConnection { * the class loader for deserialization. */ @Deprecated - public ObjectInputStream deserialize(String className, + default public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data) throws InstanceNotFoundException, OperationsException, - ReflectionException; + ReflectionException { + throw new UnsupportedOperationException("Not supported."); + } /** *

Return the {@link java.lang.ClassLoader} that was used for From b7149b5cc75b35754275e0634f962d409cb8339b Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Wed, 31 Aug 2016 12:49:03 +0300 Subject: [PATCH 086/296] 8153287: [PIT] [hidpi] java/awt/image/multiresolution/MultiresolutionIconTest failed (GTK+ and Nimbus L&F) Reviewed-by: serb, ssadetsky --- .../javax/swing/plaf/synth/SynthButtonUI.java | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java index 379bcd9a10a..07ee542ac16 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java @@ -391,21 +391,8 @@ public class SynthButtonUI extends BasicButtonUI implements } private Icon getRolloverIcon(AbstractButton b, Icon defaultIcon) { - ButtonModel model = b.getModel(); - Icon icon = null; - if (model.isSelected()) { - icon = getIcon(b, b.getRolloverSelectedIcon(), null, - SynthConstants.MOUSE_OVER | SynthConstants.SELECTED); - if (icon == null) { - icon = getIcon(b, b.getSelectedIcon(), null, - SynthConstants.SELECTED); - } - } - if (icon == null) { - icon = getIcon(b, b.getRolloverIcon(), defaultIcon, - SynthConstants.MOUSE_OVER); - } - return icon; + return getSpecificIcon(b, b.getRolloverSelectedIcon(), b.getRolloverIcon(), + defaultIcon, SynthConstants.MOUSE_OVER); } private Icon getPressedIcon(AbstractButton b, Icon defaultIcon) { @@ -414,21 +401,44 @@ public class SynthButtonUI extends BasicButtonUI implements } private Icon getSynthDisabledIcon(AbstractButton b, Icon defaultIcon) { - ButtonModel model = b.getModel(); + return getSpecificIcon(b, b.getDisabledSelectedIcon(), b.getDisabledIcon(), + defaultIcon, SynthConstants.DISABLED); + } + + private Icon getSpecificIcon(AbstractButton b, Icon specificSelectedIcon, + Icon specificIcon, Icon defaultIcon, + int state) { + boolean selected = b.getModel().isSelected(); Icon icon = null; - if (model.isSelected()) { - icon = getIcon(b, b.getDisabledSelectedIcon(), null, - SynthConstants.DISABLED | SynthConstants.SELECTED); + + if (selected) { + icon = specificSelectedIcon; if (icon == null) { - icon = getIcon(b, b.getSelectedIcon(), null, - SynthConstants.SELECTED); + icon = b.getSelectedIcon(); } } + if (icon == null) { - icon = getIcon(b, b.getDisabledIcon(), defaultIcon, - SynthConstants.DISABLED); + icon = specificIcon; } - return icon; + + if (icon != null) { + return icon; + } + + if (defaultIcon == null || defaultIcon instanceof UIResource) { + if (selected) { + icon = getSynthIcon(b, state | SynthConstants.SELECTED); + if (icon == null) { + icon = getSynthIcon(b, SynthConstants.SELECTED); + } + } + if (icon == null) { + icon = getSynthIcon(b, state); + } + } + + return icon != null ? icon : defaultIcon; } /** From 31d8fcc4f9a43440d6e7d8d3585cc24b28846fbb Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 31 Aug 2016 06:35:19 -0400 Subject: [PATCH 087/296] 8164692: InstanceKlass::_previous_version_count goes negative Decrement previous_version_count when it's removed from the list. Reviewed-by: dcubed, dlong, sspitsyn --- .../share/vm/classfile/classLoaderData.cpp | 2 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 19 +++++-- hotspot/src/share/vm/oops/instanceKlass.hpp | 5 +- .../runtime/RedefineTests/RedefineCount.java | 56 +++++++++++++++++++ 4 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 hotspot/test/runtime/RedefineTests/RedefineCount.java diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index ba1191614b1..f7711449312 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -962,7 +962,7 @@ bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, // Mark metadata seen on the stack only so we can delete unneeded entries. // Only walk all metadata, including the expensive code cache walk, for Full GC - // and only if class redefinition and if there's previous versions of + // and only if class redefinition occurred and if there are previous versions of // Klasses to delete. bool walk_all_metadata = clean_previous_versions && JvmtiExport::has_redefined_a_class() && diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 1385affc5df..2b34d9ae8c2 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -3370,6 +3370,7 @@ int InstanceKlass::_previous_version_count = 0; // Purge previous versions before adding new previous versions of the class. void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { + assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); if (ik->previous_versions() != NULL) { // This klass has previous versions so see what we can cleanup // while it is safe to do so. @@ -3398,7 +3399,12 @@ void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { // are executing. Unlink this previous_version. // The previous version InstanceKlass is on the ClassLoaderData deallocate list // so will be deallocated during the next phase of class unloading. - log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is dead", p2i(pv_node)); + // + // Update count for class unloading. + _previous_version_count--; + log_trace(redefine, class, iklass, purge) + ("previous version " INTPTR_FORMAT " is dead. previous_version_count = %d", + p2i(pv_node), _previous_version_count); // For debugging purposes. pv_node->set_is_scratch_class(); pv_node->class_loader_data()->add_to_deallocate_list(pv_node); @@ -3513,6 +3519,7 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, int emcp_method_count) { assert(Thread::current()->is_VM_thread(), "only VMThread can add previous versions"); + assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); ResourceMark rm; log_trace(redefine, class, iklass, add) @@ -3536,8 +3543,6 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, // For debugging purposes. scratch_class->set_is_scratch_class(); scratch_class->class_loader_data()->add_to_deallocate_list(scratch_class()); - // Update count for class unloading. - _previous_version_count--; return; } @@ -3565,12 +3570,14 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, } // Add previous version if any methods are still running. - log_trace(redefine, class, iklass, add)("scratch class added; one of its methods is on_stack"); + // Update count for class unloading. + _previous_version_count++; + log_trace(redefine, class, iklass, add) + ("scratch class added; one of its methods is on_stack. previous_version_count = %d", + _previous_version_count); assert(scratch_class->previous_versions() == NULL, "shouldn't have a previous version"); scratch_class->link_previous_versions(previous_versions()); link_previous_versions(scratch_class()); - // Update count for class unloading. - _previous_version_count++; } // end add_previous_version() #endif // INCLUDE_JVMTI diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index da36a1422b4..c9cc2cfb64f 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -771,7 +771,10 @@ public: static int _previous_version_count; public: static void purge_previous_versions(InstanceKlass* ik); - static bool has_previous_versions() { return _previous_version_count > 0; } + static bool has_previous_versions() { + assert(_previous_version_count >= 0, "count should never be negative"); + return _previous_version_count > 0; + } // JVMTI: Support for caching a class file before it is modified by an agent that can do retransformation void set_cached_class_file(JvmtiCachedClassFileData *data) { diff --git a/hotspot/test/runtime/RedefineTests/RedefineCount.java b/hotspot/test/runtime/RedefineTests/RedefineCount.java new file mode 100644 index 00000000000..ce8d40d0902 --- /dev/null +++ b/hotspot/test/runtime/RedefineTests/RedefineCount.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8164692 + * @summary Redefine previous_versions count goes negative + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @modules java.compiler + * java.instrument + * jdk.jartool/sun.tools.jar + * @run main RedefineClassHelper + * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+iklass+add=trace,redefine+class+iklass+purge=trace RedefineCount + */ +public class RedefineCount { + + public static String newB = + "class RedefineCount$B {" + + "}"; + + static class B { } + + public static void main(String[] args) throws Exception { + + // Redefine a class and create some garbage + // Since there are no methods running, the previous version is never added to the + // previous_version_list and the count should stay zero and not go negative + RedefineClassHelper.redefineClass(B.class, newB); + + for (int i = 0; i < 20 ; i++) { + String s = new String("some garbage"); + System.gc(); + } + } +} From 74e4516b0503dea8819ddfcb55c532ea5158c464 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Wed, 31 Aug 2016 14:20:00 +0200 Subject: [PATCH 088/296] 8164858: Enable build-time use of java.lang.invoke resolve tracing Reviewed-by: erikj, vlivanov --- make/Images.gmk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/make/Images.gmk b/make/Images.gmk index c7df894ceaf..75a8cb5e04b 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -116,8 +116,10 @@ JMODS := $(wildcard $(IMAGES_OUTPUTDIR)/jmods/*.jmod) JIMAGE_TARGET_FILE := bin/java$(EXE_SUFFIX) JLINK_ORDER_RESOURCES := **module-info.class +JLINK_JLI_CLASSES := ifeq ($(ENABLE_GENERATE_CLASSLIST), true) JLINK_ORDER_RESOURCES += @$(SUPPORT_OUTPUTDIR)/classlist/classlist + JLINK_JLI_CLASSES := --generate-jli-classes=@$(SUPPORT_OUTPUTDIR)/classlist/jli_trace.out endif JLINK_ORDER_RESOURCES += \ /java.base/java/** \ @@ -131,6 +133,7 @@ JLINK_TOOL := $(JLINK) --module-path $(IMAGES_OUTPUTDIR)/jmods \ --endian $(OPENJDK_BUILD_CPU_ENDIAN) \ --release-info $(BASE_RELEASE_FILE) \ --order-resources=$(call CommaList, $(JLINK_ORDER_RESOURCES)) \ + $(JLINK_JLI_CLASSES) \ # ifeq ($(JLINK_KEEP_PACKAGED_MODULES), true) From 5afec5d3d638d65d0a0311d708ee3ed5570182a9 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Wed, 31 Aug 2016 14:20:02 +0200 Subject: [PATCH 089/296] 8164858: Enable build-time use of java.lang.invoke resolve tracing Reviewed-by: erikj, vlivanov --- jdk/make/GenerateClasslist.gmk | 12 +- .../plugins/GenerateJLIClassesPlugin.java | 103 +++++++++++------- .../tools/jlink/resources/plugins.properties | 6 +- .../plugins/GenerateJLIClassesPluginTest.java | 3 +- 4 files changed, 73 insertions(+), 51 deletions(-) diff --git a/jdk/make/GenerateClasslist.gmk b/jdk/make/GenerateClasslist.gmk index 279cf9da012..3863a57d670 100644 --- a/jdk/make/GenerateClasslist.gmk +++ b/jdk/make/GenerateClasslist.gmk @@ -50,6 +50,8 @@ TARGETS += $(CLASSLIST_JAR) CLASSLIST_FILE := $(SUPPORT_OUTPUTDIR)/classlist/classlist +JLI_TRACE_FILE := $(SUPPORT_OUTPUTDIR)/classlist/jli_trace.out + # If an external buildjdk has been supplied, we don't build a separate interim # image, so just use the external build jdk instead. ifeq ($(EXTERNAL_BUILDJDK), true) @@ -59,13 +61,11 @@ endif $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR) $(call MakeDir, $(@D)) $(call LogInfo, Generating lib/classlist) - $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@.tmp \ - -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \ - build.tools.classlist.HelloClasslist $(LOG_DEBUG) 2>&1 - # Filter out generated classes, remove after JDK-8149977 $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@ \ - -Xshare:dump -XX:SharedClassListFile=$@.tmp $(LOG_DEBUG) 2>&1 - $(RM) $@.tmp + -Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \ + -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \ + build.tools.classlist.HelloClasslist \ + $(LOG_DEBUG) 2>&1 > $(JLI_TRACE_FILE) TARGETS += $(CLASSLIST_FILE) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index a60a1e934b5..115020953f3 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -29,12 +29,12 @@ import java.io.IOException; import java.lang.invoke.MethodType; import java.nio.file.Files; import java.util.ArrayList; -import java.util.Arrays; import java.util.EnumSet; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.internal.misc.SharedSecrets; @@ -69,11 +69,11 @@ public final class GenerateJLIClassesPlugin implements Plugin { private static final JavaLangInvokeAccess JLIA = SharedSecrets.getJavaLangInvokeAccess(); - List speciesTypes; + Set speciesTypes; - List invokerTypes; + Set invokerTypes; - Map> dmhMethods; + Map> dmhMethods; public GenerateJLIClassesPlugin() { } @@ -110,8 +110,8 @@ public final class GenerateJLIClassesPlugin implements Plugin { * A better long-term solution is to define and run a set of quick * generators and extracting this list as a step in the build process. */ - public static List defaultSpecies() { - return List.of("LL", "L3", "L4", "L5", "L6", "L7", "L7I", + public static Set defaultSpecies() { + return Set.of("LL", "L3", "L4", "L5", "L6", "L7", "L7I", "L7II", "L7IIL", "L8", "L9", "L10", "L10I", "L10II", "L10IIL", "L11", "L12", "L13", "LI", "D", "L3I", "LIL", "LLI", "LLIL", "LILL", "I", "LLILL"); @@ -120,23 +120,23 @@ public final class GenerateJLIClassesPlugin implements Plugin { /** * @return the default invoker forms to generate. */ - private static List defaultInvokers() { - return List.of("LL_L", "LL_I", "LILL_I", "L6_L"); + private static Set defaultInvokers() { + return Set.of("LL_L", "LL_I", "LILL_I", "L6_L"); } /** * @return the list of default DirectMethodHandle methods to generate. */ - private static Map> defaultDMHMethods() { + private static Map> defaultDMHMethods() { return Map.of( - DMH_INVOKE_VIRTUAL, List.of("L_L", "LL_L", "LLI_I", "L3_V"), - DMH_INVOKE_SPECIAL, List.of("LL_I", "LL_L", "LLF_L", "LLD_L", "L3_L", + DMH_INVOKE_VIRTUAL, Set.of("L_L", "LL_L", "LLI_I", "L3_V"), + DMH_INVOKE_SPECIAL, Set.of("LL_I", "LL_L", "LLF_L", "LLD_L", "L3_L", "L4_L", "L5_L", "L6_L", "L7_L", "L8_L", "LLI_I", "LLI_L", "LLIL_I", "LLII_I", "LLII_L", "L3I_L", "L3I_I", "LLILI_I", "LLIIL_L", "LLIILL_L", "LLIILL_I", "LLIIL_I", "LLILIL_I", "LLILILL_I", "LLILII_I", "LLI3_I", "LLI3L_I", "LLI3LL_I", "LLI3_L", "LLI4_I"), - DMH_INVOKE_STATIC, List.of("LII_I", "LIL_I", "LILIL_I", "LILII_I", + DMH_INVOKE_STATIC, Set.of("LII_I", "LIL_I", "LILIL_I", "LILII_I", "L_I", "L_L", "L_V", "LD_L", "LF_L", "LI_I", "LII_L", "LLI_L", "LL_V", "LL_L", "L3_L", "L4_L", "L5_L", "L6_L", "L7_L", "L8_L", "L9_L", "L10_L", "L10I_L", "L10II_L", "L10IIL_L", @@ -159,15 +159,48 @@ public final class GenerateJLIClassesPlugin implements Plugin { public void configure(Map config) { String mainArgument = config.get(NAME); - if (mainArgument != null && mainArgument.startsWith("@")) { + if ("none".equals(mainArgument)) { + speciesTypes = Set.of(); + invokerTypes = Set.of(); + dmhMethods = Map.of(); + return; + } + + // Start with the default configuration + Set defaultBMHSpecies = defaultSpecies(); + // Expand BMH species signatures + defaultBMHSpecies = defaultBMHSpecies.stream() + .map(type -> expandSignature(type)) + .collect(Collectors.toSet()); + + Set defaultInvokerTypes = defaultInvokers(); + validateMethodTypes(defaultInvokerTypes); + + Map> defaultDmhMethods = defaultDMHMethods(); + for (Set dmhMethodTypes : defaultDmhMethods.values()) { + validateMethodTypes(dmhMethodTypes); + } + + // Extend the default configuration with the contents in the supplied + // input file + if (mainArgument == null || !mainArgument.startsWith("@")) { + speciesTypes = defaultBMHSpecies; + invokerTypes = defaultInvokerTypes; + dmhMethods = defaultDmhMethods; + } else { File file = new File(mainArgument.substring(1)); if (file.exists()) { - speciesTypes = new ArrayList<>(); - invokerTypes = new ArrayList<>(); - dmhMethods = new HashMap<>(); - Stream lines = fileLines(file); - - lines.map(line -> line.split(" ")) + // Use TreeSet/TreeMap to keep things sorted in a deterministic + // order to avoid scrambling the layout on small changes and to + // ease finding methods in the generated code + speciesTypes = new TreeSet<>(defaultBMHSpecies); + invokerTypes = new TreeSet<>(defaultInvokerTypes); + dmhMethods = new TreeMap<>(); + for (Map.Entry> entry : defaultDmhMethods.entrySet()) { + dmhMethods.put(entry.getKey(), new TreeSet<>(entry.getValue())); + } + fileLines(file) + .map(line -> line.split(" ")) .forEach(parts -> { switch (parts[0]) { case "[BMH_RESOLVE]": @@ -191,28 +224,14 @@ public final class GenerateJLIClassesPlugin implements Plugin { } }); } - } else { - List bmhSpecies = defaultSpecies(); - // Expand BMH species signatures - speciesTypes = bmhSpecies.stream() - .map(type -> expandSignature(type)) - .collect(Collectors.toList()); - - invokerTypes = defaultInvokers(); - validateMethodTypes(invokerTypes); - - dmhMethods = defaultDMHMethods(); - for (List dmhMethodTypes : dmhMethods.values()) { - validateMethodTypes(dmhMethodTypes); - } } } private void addDMHMethodType(String dmh, String methodType) { validateMethodType(methodType); - List methodTypes = dmhMethods.get(dmh); + Set methodTypes = dmhMethods.get(dmh); if (methodTypes == null) { - methodTypes = new ArrayList<>(); + methodTypes = new TreeSet<>(); dmhMethods.put(dmh, methodTypes); } methodTypes.add(methodType); @@ -226,7 +245,7 @@ public final class GenerateJLIClassesPlugin implements Plugin { } } - private void validateMethodTypes(List dmhMethodTypes) { + private void validateMethodTypes(Set dmhMethodTypes) { for (String type : dmhMethodTypes) { validateMethodType(type); } @@ -291,13 +310,13 @@ public final class GenerateJLIClassesPlugin implements Plugin { private void generateHolderClasses(ResourcePoolBuilder out) { int count = 0; - for (List entry : dmhMethods.values()) { + for (Set entry : dmhMethods.values()) { count += entry.size(); } MethodType[] directMethodTypes = new MethodType[count]; int[] dmhTypes = new int[count]; int index = 0; - for (Map.Entry> entry : dmhMethods.entrySet()) { + for (Map.Entry> entry : dmhMethods.entrySet()) { String dmhType = entry.getKey(); for (String type : entry.getValue()) { // The DMH type to actually ask for is retrieved by removing @@ -314,10 +333,11 @@ public final class GenerateJLIClassesPlugin implements Plugin { } } MethodType[] invokerMethodTypes = new MethodType[this.invokerTypes.size()]; - for (int i = 0; i < invokerTypes.size(); i++) { + int i = 0; + for (String invokerType : invokerTypes) { // The invoker type to ask for is retrieved by removing the first // and the last argument, which needs to be of Object.class - MethodType mt = asMethodType(invokerTypes.get(i)); + MethodType mt = asMethodType(invokerType); final int lastParam = mt.parameterCount() - 1; if (mt.parameterCount() < 2 || mt.parameterType(0) != Object.class || @@ -327,6 +347,7 @@ public final class GenerateJLIClassesPlugin implements Plugin { } mt = mt.dropParameterTypes(lastParam, lastParam + 1); invokerMethodTypes[i] = mt.dropParameterTypes(0, 1); + i++; } try { byte[] bytes = JLIA.generateDirectMethodHandleHolderClassBytes( diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties index 67c40903eb9..309187dc2d7 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties @@ -68,12 +68,12 @@ exclude-resources.argument= resources to exclude exclude-resources.description=\ Specify resources to exclude. e.g.: **.jcov,glob:**/META-INF/** -generate-jli-classes.argument=<@filename> +generate-jli-classes.argument= generate-jli-classes.description=\ Takes a file hinting to jlink what java.lang.invoke classes to pre-generate. If\n\ -this flag is not specified a default set of classes will be generated, so to \n\ -disable pre-generation supply the name of an empty or non-existing file +this flag is not specified a default set of classes will be generated. To \n\ +disable pre-generation specify none as the argument installed-modules.description=Fast loading of module descriptors (always enabled) diff --git a/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java b/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java index ae2d3ec5945..d1510affb5e 100644 --- a/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java +++ b/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java @@ -22,6 +22,7 @@ */ import java.nio.file.Path; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @@ -75,7 +76,7 @@ public class GenerateJLIClassesPluginTest { } - private static List classFilesForSpecies(List species) { + private static List classFilesForSpecies(Collection species) { return species.stream() .map(s -> "/java.base/java/lang/invoke/BoundMethodHandle$Species_" + s + ".class") .collect(Collectors.toList()); From 0fd1f32873d512edf5ca82029359ad618784492d Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 31 Aug 2016 10:27:32 -0400 Subject: [PATCH 090/296] 8162412: Ignore any System property specified as -Djdk.module that matches reserved module system properties Change the checks for module related properties to look for specific properties, not just jdk.module Reviewed-by: coleenp, gziemski, ddmitriev --- hotspot/src/share/vm/runtime/arguments.cpp | 55 +++++++++++----- .../runtime/modules/ModuleOptionsWarn.java | 62 ++++++++++++++++++- 2 files changed, 98 insertions(+), 19 deletions(-) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index a4decf9c983..18cd2374e3f 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -163,26 +163,47 @@ static void logOption(const char* opt) { bool needs_module_property_warning = false; -#define MODULE_PROPERTY_PREFIX "jdk.module" -#define MODULE_PROPERTY_PREFIX_LEN 10 -#define MODULE_MAIN_PROPERTY "jdk.module.main" -#define MODULE_MAIN_PROPERTY_LEN 15 +#define MODULE_PROPERTY_PREFIX "jdk.module." +#define MODULE_PROPERTY_PREFIX_LEN 11 +#define ADDEXPORTS "addexports" +#define ADDEXPORTS_LEN 10 +#define ADDREADS "addreads" +#define ADDREADS_LEN 8 +#define PATCH "patch" +#define PATCH_LEN 5 +#define ADDMODS "addmods" +#define ADDMODS_LEN 7 +#define LIMITMODS "limitmods" +#define LIMITMODS_LEN 9 +#define PATH "path" +#define PATH_LEN 4 +#define UPGRADE_PATH "upgrade.path" +#define UPGRADE_PATH_LEN 12 -// Return TRUE if option matches property, or property=, or property.. -static bool matches_property_prefix(const char* option, const char* property, size_t len) { - return (strncmp(option, property, len) == 0) && - (option[len] == '=' || option[len] == '.' || option[len] == '\0'); +// Return TRUE if option matches 'property', or 'property=', or 'property.'. +static bool matches_property_suffix(const char* option, const char* property, size_t len) { + return ((strncmp(option, property, len) == 0) && + (option[len] == '=' || option[len] == '.' || option[len] == '\0')); } -// Return true if the property is either "jdk.module" or starts with "jdk.module.", -// but does not start with "jdk.module.main". -// Return false if jdk.module.main because jdk.module.main and jdk.module.main.class -// are valid non-internal system properties. -// "property" should be passed without the leading "-D". +// Return true if property starts with "jdk.module." and its ensuing chars match +// any of the reserved module properties. +// property should be passed without the leading "-D". bool Arguments::is_internal_module_property(const char* property) { assert((strncmp(property, "-D", 2) != 0), "Unexpected leading -D"); - return (matches_property_prefix(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) && - !matches_property_prefix(property, MODULE_MAIN_PROPERTY, MODULE_MAIN_PROPERTY_LEN)); + if (strncmp(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) == 0) { + const char* property_suffix = property + MODULE_PROPERTY_PREFIX_LEN; + if (matches_property_suffix(property_suffix, ADDEXPORTS, ADDEXPORTS_LEN) || + matches_property_suffix(property_suffix, ADDREADS, ADDREADS_LEN) || + matches_property_suffix(property_suffix, PATCH, PATCH_LEN) || + matches_property_suffix(property_suffix, ADDMODS, ADDMODS_LEN) || + matches_property_suffix(property_suffix, LIMITMODS, LIMITMODS_LEN) || + matches_property_suffix(property_suffix, PATH, PATH_LEN) || + matches_property_suffix(property_suffix, UPGRADE_PATH, UPGRADE_PATH_LEN)) { + return true; + } + } + return false; } // Process java launcher properties. @@ -4287,8 +4308,8 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) { } if (needs_module_property_warning) { - warning("Ignoring system property options whose names start with '-Djdk.module'." - " They are reserved for internal use."); + warning("Ignoring system property options whose names match the '-Djdk.module.*'." + " names that are reserved for internal use."); } #if defined(_ALLBSD_SOURCE) || defined(AIX) // UseLargePages is not yet supported on BSD and AIX. diff --git a/hotspot/test/runtime/modules/ModuleOptionsWarn.java b/hotspot/test/runtime/modules/ModuleOptionsWarn.java index 7ad1f9b2ca9..6446e0ae5fd 100644 --- a/hotspot/test/runtime/modules/ModuleOptionsWarn.java +++ b/hotspot/test/runtime/modules/ModuleOptionsWarn.java @@ -29,6 +29,7 @@ * @library /test/lib */ +import java.util.Map; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; @@ -37,16 +38,65 @@ public class ModuleOptionsWarn { public static void main(String[] args) throws Exception { - // Test that a warning is issued for module related properties that get ignored. + // Test that a warning is not issued for extraneous jdk.module properties. ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.ignored", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property. + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.addmods", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in '.'. + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.limitmods.", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in '='. + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.addexports=", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in ".stuff" + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.addreads.stuff", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in "=stuff" + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.path=stuff", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in ".=" + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.upgrade.path.=xx", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in "." + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.patch.3=xx", "-version"); + output = new OutputAnalyzer(pb.start()); output.shouldContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning can be suppressed for module related properties that get ignored. pb = ProcessTools.createJavaProcessBuilder( - "-Djdk.module.ignored", "-XX:-PrintWarnings", "-version"); + "-Djdk.module.addmods", "-XX:-PrintWarnings", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Ignoring system property option"); output.shouldHaveExitValue(0); @@ -57,5 +107,13 @@ public class ModuleOptionsWarn { output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Ignoring system property option"); output.shouldHaveExitValue(0); + + // Test that a warning is issued for module related properties specified using _JAVA_OPTIONS. + pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintWarnings", "-version"); + Map env = pb.environment(); + env.put("_JAVA_OPTIONS", "-Djdk.module.addreads"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); } } From 992e74a1831ec01940173aa594cb82964d9832ed Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 31 Aug 2016 16:48:26 +0200 Subject: [PATCH 091/296] 8164862: 2 JVMCI tests should not be executed on linux-x86 Reviewed-by: kvn, gtriantafill --- .../src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java | 2 +- .../src/jdk/vm/ci/code/test/NativeCallTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java index 9caed4279dd..4a9532809c7 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9") & os.arch != "aarch64" * @library / * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java index ccbc9d981a3..0800e7bea10 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9") & os.arch != "aarch64" * @library /test/lib / * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code From 2822e9e2d60beb26b8b42460d0996cb08266f9c6 Mon Sep 17 00:00:00 2001 From: Sibabrata Sahoo Date: Wed, 31 Aug 2016 08:34:59 -0700 Subject: [PATCH 092/296] 8015595: Test sun/security/krb5/auto/Unreachable.java fails with Timeout error Unreachable.java was getting timeout due to PortUnreachableException was not thrown Reviewed-by: weijun --- jdk/test/ProblemList.txt | 2 - .../sun/security/krb5/auto/Unreachable.java | 105 +++++++++++++++--- .../security/krb5/auto/unreachable.krb5.conf | 9 -- 3 files changed, 91 insertions(+), 25 deletions(-) delete mode 100644 jdk/test/sun/security/krb5/auto/unreachable.krb5.conf diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 2165bef4aba..38f2392ea0f 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -213,8 +213,6 @@ java/rmi/transport/dgcDeadLock/DGCDeadLock.java 8029360 macosx-a sun/security/pkcs11/ec/TestKeyFactory.java 8026976 generic-all -sun/security/krb5/auto/Unreachable.java 7164518 macosx-all - sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-all sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java 8026393 generic-all diff --git a/jdk/test/sun/security/krb5/auto/Unreachable.java b/jdk/test/sun/security/krb5/auto/Unreachable.java index b010b54837e..fdc1aa2ee25 100644 --- a/jdk/test/sun/security/krb5/auto/Unreachable.java +++ b/jdk/test/sun/security/krb5/auto/Unreachable.java @@ -23,31 +23,108 @@ /* * @test - * @bug 7162687 + * @bug 7162687 8015595 * @key intermittent * @summary enhance KDC server availability detection * @compile -XDignore.symbol.file Unreachable.java - * @run main/othervm/timeout=10 Unreachable + * @run main/othervm Unreachable */ - -import java.io.File; +import java.net.PortUnreachableException; +import java.net.SocketTimeoutException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetSocketAddress; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.Executors; import javax.security.auth.login.LoginException; import sun.security.krb5.Config; public class Unreachable { - public static void main(String[] args) throws Exception { - File f = new File( - System.getProperty("test.src", "."), "unreachable.krb5.conf"); - System.setProperty("java.security.krb5.conf", f.getPath()); - Config.refresh(); + // Wait for 20 second until unreachable KDC throws PortUnreachableException. + private static final int TIMEOUT = 20; + private static final String REALM = "RABBIT.HOLE"; + private static final String HOST = "127.0.0.1"; + private static final int PORT = 13434; + private static final String KRB_CONF = "unreachable.krb5.conf"; - // If PortUnreachableException is not received, the login will consume - // about 3*3*30 seconds and the test will timeout. + public static void main(String[] args) throws Exception { + + // - Only PortUnreachableException will allow to continue execution. + // - SocketTimeoutException may occur on Mac because it will not throw + // PortUnreachableException for unreachable port in which case the Test + // execution will be skipped. + // - For Reachable port, the Test execution will get skipped. + // - Any other Exception will be treated as Test failure. + if (!findPortUnreachableExc()) { + System.out.println(String.format("WARNING: Either a reachable " + + "connection found to %s:%s or SocketTimeoutException " + + "occured which means PortUnreachableException not thrown" + + " by the platform.", HOST, PORT)); + return; + } + KDC kdc = KDC.existing(REALM, HOST, PORT); + KDC.saveConfig(KRB_CONF, kdc); + ExecutorService executor = Executors.newSingleThreadExecutor(); + Future future = executor.submit(new Callable() { + @Override + public Exception call() { + System.setProperty("java.security.krb5.conf", KRB_CONF); + try { + Config.refresh(); + // If PortUnreachableException is not received, the login + // will consume about 3*3*30 seconds and the test will + // timeout. + try { + Context.fromUserPass("name", "pass".toCharArray(), true); + } catch (LoginException le) { + // This is OK + } + System.out.println("Execution successful."); + } catch (Exception e) { + return e; + } + return null; + } + }); try { - Context.fromUserPass("name", "pass".toCharArray(), true); - } catch (LoginException le) { - // This is OK + Exception ex = null; + if ((ex = future.get(TIMEOUT, TimeUnit.SECONDS)) != null) { + throw new RuntimeException(ex); + } + } catch (TimeoutException e) { + future.cancel(true); + throw new RuntimeException("PortUnreachableException not thrown."); + } finally { + executor.shutdownNow(); } } + + /** + * If the remote destination to which the socket is connected does not + * exist, or is otherwise unreachable, and if an ICMP destination unreachable + * packet has been received for that address, then a subsequent call to + * send or receive may throw a PortUnreachableException. Note, there is no + * guarantee that the exception will be thrown. + */ + private static boolean findPortUnreachableExc() throws Exception { + try { + InetSocketAddress iaddr = new InetSocketAddress(HOST, PORT); + DatagramSocket dgSocket = new DatagramSocket(); + dgSocket.setSoTimeout(5000); + dgSocket.connect(iaddr); + byte[] data = new byte[]{}; + dgSocket.send(new DatagramPacket(data, data.length, iaddr)); + dgSocket.receive(new DatagramPacket(data, data.length)); + } catch (PortUnreachableException e) { + return true; + } catch (SocketTimeoutException e) { + return false; + } + return false; + } } diff --git a/jdk/test/sun/security/krb5/auto/unreachable.krb5.conf b/jdk/test/sun/security/krb5/auto/unreachable.krb5.conf deleted file mode 100644 index 8ff4cc173aa..00000000000 --- a/jdk/test/sun/security/krb5/auto/unreachable.krb5.conf +++ /dev/null @@ -1,9 +0,0 @@ -[libdefaults] - default_realm = RABBIT.HOLE -[realms] - -RABBIT.HOLE = { - kdc = 127.0.0.1:13434 - kdc = 127.0.0.1:13435 - kdc = 127.0.0.1:13436 -} From 3d17ae2b1d1fee894b805e91f87866161127fc41 Mon Sep 17 00:00:00 2001 From: Sibabrata Sahoo Date: Wed, 31 Aug 2016 08:44:12 -0700 Subject: [PATCH 093/296] 8164922: sun/security/provider/SecureRandom/AutoReseed.java failed with timeout in Ubuntu Linux The test timeout waiting to get seed in an exhausted Linux platform. Reviewed-by: weijun --- .../provider/SecureRandom/AutoReseed.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java b/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java index 48361f225d5..0cdce177b1e 100644 --- a/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java +++ b/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java @@ -20,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.security.SecureRandom; import java.security.Security; @@ -27,15 +28,15 @@ import java.security.Security; * @test * @bug 8051408 * @summary make sure nextBytes etc can be called before setSeed + * @run main/othervm -Djava.security.egd=file:/dev/urandom AutoReseed */ public class AutoReseed { public static void main(String[] args) throws Exception { SecureRandom sr; - String old = Security.getProperty("securerandom.drbg.config"); - try { - for (String mech : - new String[]{"Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + boolean pass = true; + for (String mech : new String[]{"Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + try { System.out.println("Testing " + mech + "..."); Security.setProperty("securerandom.drbg.config", mech); @@ -46,9 +47,13 @@ public class AutoReseed { sr.reseed(); sr = SecureRandom.getInstance("DRBG"); sr.generateSeed(10); + } catch (Exception e) { + pass = false; + e.printStackTrace(System.out); } - } finally { - Security.setProperty("securerandom.drbg.config", old); + } + if (!pass) { + throw new RuntimeException("At least one test case failed"); } } } From 3ff1d554b483076f40115746558a89b6d88ba1ef Mon Sep 17 00:00:00 2001 From: Alexandre Iline Date: Wed, 31 Aug 2016 09:46:50 -0700 Subject: [PATCH 094/296] 8164982: Fix legal notices in java/lang, java/net, java/util tests Reviewed-by: darcy, iris --- jdk/test/java/lang/Class/GetModuleTest.java | 2 +- jdk/test/java/lang/Class/GetPackageTest.java | 2 +- jdk/test/java/lang/ClassLoader/GetSystemPackage.java | 2 +- jdk/test/java/lang/ClassLoader/deadlock/GetResource.java | 2 +- jdk/test/java/lang/ProcessBuilder/CloseRace.java | 2 +- jdk/test/java/lang/ProcessBuilder/PipelineTest.java | 1 - jdk/test/java/lang/StackWalker/CountLocalSlots.java | 2 +- jdk/test/java/lang/StackWalker/LocalsAndOperands.java | 2 +- jdk/test/java/lang/StackWalker/LocalsCrash.java | 2 +- .../java/lang/String/concat/CompactStringsInitialCoder.java | 2 +- .../lang/String/concat/StringConcatFactoryEmptyMethods.java | 2 +- jdk/test/java/lang/String/concat/WithSecurityManager.java | 2 +- jdk/test/java/lang/Thread/ThreadStateController.java | 2 +- .../annotation/typeAnnotations/GetAnnotatedReceiverType.java | 2 +- jdk/test/java/lang/instrument/NMTHelper.java | 2 +- jdk/test/java/lang/invoke/6987555/Test6987555.java | 1 - jdk/test/java/lang/invoke/6991596/Test6991596.java | 1 - jdk/test/java/lang/invoke/6998541/Test6998541.java | 1 - jdk/test/java/lang/invoke/7087570/Test7087570.java | 1 - jdk/test/java/lang/invoke/7157574/Test7157574.java | 1 - jdk/test/java/lang/invoke/7196190/ClassForNameTest.java | 1 - jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java | 1 - jdk/test/java/lang/invoke/8009222/Test8009222.java | 1 - jdk/test/java/lang/invoke/8022701/BogoLoader.java | 1 - jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java | 1 - jdk/test/java/lang/invoke/8022701/Invoker.java | 1 - jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java | 1 - jdk/test/java/lang/invoke/8022701/MethodSupplier.java | 1 - jdk/test/java/lang/invoke/CallSiteTest.java | 1 - jdk/test/java/lang/invoke/CallStaticInitOrder.java | 1 - .../lang/invoke/ProtectedMemberDifferentPackage/Test.java | 1 - .../lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java | 2 +- .../lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java | 2 +- .../invoke/VarHandles/VarHandleTestMethodTypeBoolean.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java | 2 +- .../invoke/VarHandles/VarHandleTestMethodTypeDouble.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java | 2 +- .../invoke/VarHandles/VarHandleTestMethodTypeString.java | 2 +- .../java/lang/invoke/accessProtectedSuper/BogoLoader.java | 1 - .../java/lang/invoke/accessProtectedSuper/MethodInvoker.java | 1 - jdk/test/java/lang/invoke/accessProtectedSuper/Test.java | 1 - .../accessProtectedSuper/anotherpkg/MethodSupplierOuter.java | 1 - .../GarbageCollectorMXBean/GcInfoCompositeType.java | 2 +- jdk/test/java/net/Inet4Address/textToNumericFormat.java | 2 +- jdk/test/java/net/ProxySelector/B8035158.java | 1 + .../java/net/URLClassLoader/definePackage/SplitPackage.java | 2 +- jdk/test/java/net/URLPermission/nstest/LookupTest.java | 2 +- jdk/test/java/net/httpclient/BasicAuthTest.java | 1 + jdk/test/java/net/httpclient/HeadersTest1.java | 1 + jdk/test/java/net/httpclient/ImmutableHeaders.java | 1 + jdk/test/java/net/httpclient/security/Driver.java | 1 + jdk/test/java/net/httpclient/security/Security.java | 1 + jdk/test/java/util/Arrays/Correct.java | 2 +- jdk/test/java/util/Map/FunctionalCMEs.java | 3 ++- jdk/test/java/util/Objects/CheckIndex.java | 2 +- .../java/util/concurrent/FutureTask/NegativeTimeout.java | 2 +- .../logging/Logger/entering/LoggerEnteringWithParams.java | 1 - jdk/test/java/util/logging/XMLFormatterDate.java | 2 +- jdk/test/java/util/regex/PatternStreamTest.java | 2 +- jdk/test/java/util/zip/TestCRC32.java | 5 ++--- jdk/test/java/util/zip/TestCRC32C.java | 5 ++--- jdk/test/java/util/zip/ZipFile/TestZipFile.java | 2 +- 66 files changed, 47 insertions(+), 64 deletions(-) diff --git a/jdk/test/java/lang/Class/GetModuleTest.java b/jdk/test/java/lang/Class/GetModuleTest.java index 918e4dd9dd1..359f7ca2ff7 100644 --- a/jdk/test/java/lang/Class/GetModuleTest.java +++ b/jdk/test/java/lang/Class/GetModuleTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/jdk/test/java/lang/Class/GetPackageTest.java b/jdk/test/java/lang/Class/GetPackageTest.java index f9cb5fb31ff..5f6c96f0d44 100644 --- a/jdk/test/java/lang/Class/GetPackageTest.java +++ b/jdk/test/java/lang/Class/GetPackageTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/jdk/test/java/lang/ClassLoader/GetSystemPackage.java b/jdk/test/java/lang/ClassLoader/GetSystemPackage.java index fba5648f5f4..56152b5907f 100644 --- a/jdk/test/java/lang/ClassLoader/GetSystemPackage.java +++ b/jdk/test/java/lang/ClassLoader/GetSystemPackage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 diff --git a/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java b/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java index 26fbe3dd586..691c509e2e9 100644 --- a/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java +++ b/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 diff --git a/jdk/test/java/lang/ProcessBuilder/CloseRace.java b/jdk/test/java/lang/ProcessBuilder/CloseRace.java index a9afbd2ba91..1fa6d8d5e15 100644 --- a/jdk/test/java/lang/ProcessBuilder/CloseRace.java +++ b/jdk/test/java/lang/ProcessBuilder/CloseRace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, 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 diff --git a/jdk/test/java/lang/ProcessBuilder/PipelineTest.java b/jdk/test/java/lang/ProcessBuilder/PipelineTest.java index 9f6ec99fb70..90b277ad9eb 100644 --- a/jdk/test/java/lang/ProcessBuilder/PipelineTest.java +++ b/jdk/test/java/lang/ProcessBuilder/PipelineTest.java @@ -19,7 +19,6 @@ * 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. - * */ import java.io.File; diff --git a/jdk/test/java/lang/StackWalker/CountLocalSlots.java b/jdk/test/java/lang/StackWalker/CountLocalSlots.java index c78a4cb7bf4..066055b0a1d 100644 --- a/jdk/test/java/lang/StackWalker/CountLocalSlots.java +++ b/jdk/test/java/lang/StackWalker/CountLocalSlots.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java index b253ab27e81..f4f646549ec 100644 --- a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java +++ b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/StackWalker/LocalsCrash.java b/jdk/test/java/lang/StackWalker/LocalsCrash.java index b50dd263f00..87415e4df0c 100644 --- a/jdk/test/java/lang/StackWalker/LocalsCrash.java +++ b/jdk/test/java/lang/StackWalker/LocalsCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java b/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java index 6f566c33eb9..5669bce2fd8 100644 --- a/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java +++ b/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java b/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java index 31b29cd30fd..7ee0d988529 100644 --- a/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java +++ b/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/jdk/test/java/lang/String/concat/WithSecurityManager.java b/jdk/test/java/lang/String/concat/WithSecurityManager.java index 9359d29fbb1..2835a3813f4 100644 --- a/jdk/test/java/lang/String/concat/WithSecurityManager.java +++ b/jdk/test/java/lang/String/concat/WithSecurityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/jdk/test/java/lang/Thread/ThreadStateController.java b/jdk/test/java/lang/Thread/ThreadStateController.java index 728a115c271..c426d1b34b4 100644 --- a/jdk/test/java/lang/Thread/ThreadStateController.java +++ b/jdk/test/java/lang/Thread/ThreadStateController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 diff --git a/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java b/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java index e9608089763..084ed563809 100644 --- a/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java +++ b/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, 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 diff --git a/jdk/test/java/lang/instrument/NMTHelper.java b/jdk/test/java/lang/instrument/NMTHelper.java index 09e60e4a623..07ee25be38d 100644 --- a/jdk/test/java/lang/instrument/NMTHelper.java +++ b/jdk/test/java/lang/instrument/NMTHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/jdk/test/java/lang/invoke/6987555/Test6987555.java b/jdk/test/java/lang/invoke/6987555/Test6987555.java index 7a2f45c6efe..eb939007326 100644 --- a/jdk/test/java/lang/invoke/6987555/Test6987555.java +++ b/jdk/test/java/lang/invoke/6987555/Test6987555.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/6991596/Test6991596.java b/jdk/test/java/lang/invoke/6991596/Test6991596.java index a7083bd8114..193009deafd 100644 --- a/jdk/test/java/lang/invoke/6991596/Test6991596.java +++ b/jdk/test/java/lang/invoke/6991596/Test6991596.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/6998541/Test6998541.java b/jdk/test/java/lang/invoke/6998541/Test6998541.java index 1edf14f9dc6..983c23b3640 100644 --- a/jdk/test/java/lang/invoke/6998541/Test6998541.java +++ b/jdk/test/java/lang/invoke/6998541/Test6998541.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/7087570/Test7087570.java b/jdk/test/java/lang/invoke/7087570/Test7087570.java index 732467b8c62..165968c6069 100644 --- a/jdk/test/java/lang/invoke/7087570/Test7087570.java +++ b/jdk/test/java/lang/invoke/7087570/Test7087570.java @@ -19,7 +19,6 @@ * 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. - * */ /* @test diff --git a/jdk/test/java/lang/invoke/7157574/Test7157574.java b/jdk/test/java/lang/invoke/7157574/Test7157574.java index acf9ef48a04..d2a91d92626 100644 --- a/jdk/test/java/lang/invoke/7157574/Test7157574.java +++ b/jdk/test/java/lang/invoke/7157574/Test7157574.java @@ -19,7 +19,6 @@ * 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. - * */ /* diff --git a/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java b/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java index 4730efafb6c..e0797f0f741 100644 --- a/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java +++ b/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java b/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java index 24a9512ffaf..57a06d16b05 100644 --- a/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java +++ b/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/8009222/Test8009222.java b/jdk/test/java/lang/invoke/8009222/Test8009222.java index 711969387ed..62ee09c066a 100644 --- a/jdk/test/java/lang/invoke/8009222/Test8009222.java +++ b/jdk/test/java/lang/invoke/8009222/Test8009222.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/8022701/BogoLoader.java b/jdk/test/java/lang/invoke/8022701/BogoLoader.java index e77be6f44ff..e8c579a27c8 100644 --- a/jdk/test/java/lang/invoke/8022701/BogoLoader.java +++ b/jdk/test/java/lang/invoke/8022701/BogoLoader.java @@ -19,7 +19,6 @@ * 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. - * */ import java.io.BufferedInputStream; diff --git a/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java b/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java index 5c1f64bf9b0..011ae7f43a5 100644 --- a/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java +++ b/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java @@ -19,7 +19,6 @@ * 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. - * */ import java.lang.reflect.InvocationTargetException; diff --git a/jdk/test/java/lang/invoke/8022701/Invoker.java b/jdk/test/java/lang/invoke/8022701/Invoker.java index a97159e9e29..62015fae371 100644 --- a/jdk/test/java/lang/invoke/8022701/Invoker.java +++ b/jdk/test/java/lang/invoke/8022701/Invoker.java @@ -19,7 +19,6 @@ * 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. - * */ public class Invoker { diff --git a/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java b/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java index badc1a817f3..18d4a4c6752 100644 --- a/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java +++ b/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/8022701/MethodSupplier.java b/jdk/test/java/lang/invoke/8022701/MethodSupplier.java index 4699a52aaff..5ef4d20f1ac 100644 --- a/jdk/test/java/lang/invoke/8022701/MethodSupplier.java +++ b/jdk/test/java/lang/invoke/8022701/MethodSupplier.java @@ -19,7 +19,6 @@ * 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. - * */ /* diff --git a/jdk/test/java/lang/invoke/CallSiteTest.java b/jdk/test/java/lang/invoke/CallSiteTest.java index 48b0d7b6d9a..bf0fe2e4dc7 100644 --- a/jdk/test/java/lang/invoke/CallSiteTest.java +++ b/jdk/test/java/lang/invoke/CallSiteTest.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/CallStaticInitOrder.java b/jdk/test/java/lang/invoke/CallStaticInitOrder.java index 83808f8fb9f..4090e8fff2d 100644 --- a/jdk/test/java/lang/invoke/CallStaticInitOrder.java +++ b/jdk/test/java/lang/invoke/CallStaticInitOrder.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java index edfe52af8a7..7356b290768 100644 --- a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java +++ b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java index 154109c883a..771e87f67aa 100644 --- a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java +++ b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java @@ -19,8 +19,8 @@ * 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. - * */ + package p1; import p2.T3; diff --git a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java index 9f4d7cee9bc..0deba761a74 100644 --- a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java +++ b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java @@ -19,8 +19,8 @@ * 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. - * */ + package p2; import p1.T2; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java index 624f98a8407..4a1d0103411 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java index 692d667ac05..a067b57182a 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java index 268e521f294..0638b88aef4 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java index e3bf8363a15..0bc17bab3b9 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java index 34617e2102e..12efef61cda 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java index 33b33970f80..7291c0ebbc2 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java index 654619335fe..d081ddec842 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java index 82b6f3cab78..eba0cd204b3 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java index 41d0e6b4702..91e25c99bb9 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java b/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java index 190761dd6df..a129ea254a4 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java @@ -19,7 +19,6 @@ * 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. - * */ import java.io.BufferedInputStream; diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java b/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java index d14e7ef8a35..fae5e466646 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java @@ -19,7 +19,6 @@ * 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. - * */ import anotherpkg.MethodSupplierOuter; diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java b/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java index b83496f692f..96b3fb637a1 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java b/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java index 314f8eab707..cd40ed2050c 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java @@ -19,7 +19,6 @@ * 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. - * */ package anotherpkg; diff --git a/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java b/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java index a8bb8badf9b..13ae1e030c5 100644 --- a/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java +++ b/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, 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 diff --git a/jdk/test/java/net/Inet4Address/textToNumericFormat.java b/jdk/test/java/net/Inet4Address/textToNumericFormat.java index 1d010d0b912..7d75bc9f534 100644 --- a/jdk/test/java/net/Inet4Address/textToNumericFormat.java +++ b/jdk/test/java/net/Inet4Address/textToNumericFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 diff --git a/jdk/test/java/net/ProxySelector/B8035158.java b/jdk/test/java/net/ProxySelector/B8035158.java index 21b1e99d702..432e457c303 100644 --- a/jdk/test/java/net/ProxySelector/B8035158.java +++ b/jdk/test/java/net/ProxySelector/B8035158.java @@ -20,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + /* * @test * @bug 8035158 8145732 diff --git a/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java b/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java index 0b009606624..c31441d8b1a 100644 --- a/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java +++ b/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/jdk/test/java/net/URLPermission/nstest/LookupTest.java b/jdk/test/java/net/URLPermission/nstest/LookupTest.java index f69522de22f..d5b9141c1d4 100644 --- a/jdk/test/java/net/URLPermission/nstest/LookupTest.java +++ b/jdk/test/java/net/URLPermission/nstest/LookupTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 diff --git a/jdk/test/java/net/httpclient/BasicAuthTest.java b/jdk/test/java/net/httpclient/BasicAuthTest.java index fb227e3f672..b78739e682a 100644 --- a/jdk/test/java/net/httpclient/BasicAuthTest.java +++ b/jdk/test/java/net/httpclient/BasicAuthTest.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/HeadersTest1.java b/jdk/test/java/net/httpclient/HeadersTest1.java index 79f62006722..e3c892ef2c1 100644 --- a/jdk/test/java/net/httpclient/HeadersTest1.java +++ b/jdk/test/java/net/httpclient/HeadersTest1.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/ImmutableHeaders.java b/jdk/test/java/net/httpclient/ImmutableHeaders.java index 7286c2e1b0b..7773061dc30 100644 --- a/jdk/test/java/net/httpclient/ImmutableHeaders.java +++ b/jdk/test/java/net/httpclient/ImmutableHeaders.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/security/Driver.java b/jdk/test/java/net/httpclient/security/Driver.java index 078be5f5e51..3253fe2fd3c 100644 --- a/jdk/test/java/net/httpclient/security/Driver.java +++ b/jdk/test/java/net/httpclient/security/Driver.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/security/Security.java b/jdk/test/java/net/httpclient/security/Security.java index 2108c9fce29..5c282be9a36 100644 --- a/jdk/test/java/net/httpclient/security/Security.java +++ b/jdk/test/java/net/httpclient/security/Security.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/util/Arrays/Correct.java b/jdk/test/java/util/Arrays/Correct.java index e9ddc7edef5..f69ea9160ff 100644 --- a/jdk/test/java/util/Arrays/Correct.java +++ b/jdk/test/java/util/Arrays/Correct.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, 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 diff --git a/jdk/test/java/util/Map/FunctionalCMEs.java b/jdk/test/java/util/Map/FunctionalCMEs.java index 6f92b018185..4d83d241c94 100644 --- a/jdk/test/java/util/Map/FunctionalCMEs.java +++ b/jdk/test/java/util/Map/FunctionalCMEs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.util.Arrays; import java.util.ConcurrentModificationException; import java.util.HashMap; diff --git a/jdk/test/java/util/Objects/CheckIndex.java b/jdk/test/java/util/Objects/CheckIndex.java index bcfa1d5b23d..594e806dcd0 100644 --- a/jdk/test/java/util/Objects/CheckIndex.java +++ b/jdk/test/java/util/Objects/CheckIndex.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java b/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java index f2e18f6d1bf..37cf4359580 100644 --- a/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java +++ b/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 diff --git a/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java b/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java index d63e619830a..d9b494741ab 100644 --- a/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java +++ b/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. diff --git a/jdk/test/java/util/logging/XMLFormatterDate.java b/jdk/test/java/util/logging/XMLFormatterDate.java index ee0eeb98b57..3b0d7029464 100644 --- a/jdk/test/java/util/logging/XMLFormatterDate.java +++ b/jdk/test/java/util/logging/XMLFormatterDate.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -21,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/jdk/test/java/util/regex/PatternStreamTest.java b/jdk/test/java/util/regex/PatternStreamTest.java index 1f02e410321..9809ea20aef 100644 --- a/jdk/test/java/util/regex/PatternStreamTest.java +++ b/jdk/test/java/util/regex/PatternStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 diff --git a/jdk/test/java/util/zip/TestCRC32.java b/jdk/test/java/util/zip/TestCRC32.java index 68c15aed44b..15d919ddb61 100644 --- a/jdk/test/java/util/zip/TestCRC32.java +++ b/jdk/test/java/util/zip/TestCRC32.java @@ -1,6 +1,3 @@ - -import java.util.zip.CRC32; - /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -24,6 +21,8 @@ import java.util.zip.CRC32; * questions. */ +import java.util.zip.CRC32; + /** * @test @summary Check that CRC-32 returns the expected CRC value for the * string 123456789 diff --git a/jdk/test/java/util/zip/TestCRC32C.java b/jdk/test/java/util/zip/TestCRC32C.java index bb5ea0447c5..6adf260dbab 100644 --- a/jdk/test/java/util/zip/TestCRC32C.java +++ b/jdk/test/java/util/zip/TestCRC32C.java @@ -1,6 +1,3 @@ - -import java.util.zip.CRC32C; - /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -24,6 +21,8 @@ import java.util.zip.CRC32C; * questions. */ +import java.util.zip.CRC32C; + /** * @test @summary Check that CRC-32C returns the expected CRC value for the * string 123456789 diff --git a/jdk/test/java/util/zip/ZipFile/TestZipFile.java b/jdk/test/java/util/zip/ZipFile/TestZipFile.java index 515ed356c2b..25b87ff1242 100644 --- a/jdk/test/java/util/zip/ZipFile/TestZipFile.java +++ b/jdk/test/java/util/zip/ZipFile/TestZipFile.java @@ -8,7 +8,7 @@ * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * From 4a0362efffba9e29c10644e29dd97f81c9a68af4 Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Wed, 31 Aug 2016 11:53:58 -0700 Subject: [PATCH 095/296] 8081388: JNI exception pending in jdk/src/windows/bin/java_md.c Reviewed-by: ksrini --- jdk/src/java.base/share/native/libjli/java.c | 1 + jdk/src/java.base/share/native/libjli/java.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c index 4b869ceb56f..6dc9674a6ed 100644 --- a/jdk/src/java.base/share/native/libjli/java.c +++ b/jdk/src/java.base/share/native/libjli/java.c @@ -1497,6 +1497,7 @@ NewPlatformStringArray(JNIEnv *env, char **strv, int strc) NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String")); NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0)); + CHECK_EXCEPTION_RETURN_VALUE(0); for (i = 0; i < strc; i++) { jstring str = NewPlatformString(env, *strv++); NULL_CHECK0(str); diff --git a/jdk/src/java.base/share/native/libjli/java.h b/jdk/src/java.base/share/native/libjli/java.h index c18c66e5b51..41a232714c8 100644 --- a/jdk/src/java.base/share/native/libjli/java.h +++ b/jdk/src/java.base/share/native/libjli/java.h @@ -253,6 +253,13 @@ typedef struct { #define NULL_CHECK(NC_check_pointer) \ NULL_CHECK_RETURN_VALUE(NC_check_pointer, ) +#define CHECK_EXCEPTION_RETURN_VALUE(CER_value) \ + do { \ + if ((*env)->ExceptionOccurred(env)) { \ + return CER_value; \ + } \ + } while (JNI_FALSE) + #define CHECK_EXCEPTION_RETURN() \ do { \ if ((*env)->ExceptionOccurred(env)) { \ From 0d1ad07556ac5e366a439bccd6dd0d0568cffce2 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 31 Aug 2016 13:40:06 -0700 Subject: [PATCH 096/296] 8164818: Reg. test java/awt/font/TextLayout/VisibleAdvance.java fails Reviewed-by: serb, psadhukhan --- .../share/native/libfontmanager/HBShaper.c | 2 +- .../native/libfontmanager/hb-jdk-font.cc | 20 ++++++++----------- .../share/native/libfontmanager/hb-jdk.h | 4 ++++ .../awt/font/TextLayout/VisibleAdvance.java | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c index d8de3e36d92..3b35e27efda 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c +++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c @@ -78,7 +78,7 @@ int storeGVData(JNIEnv* env, int i; float x=0, y=0; float startX, startY; - float scale = 1.0f/64.0f/devScale; + float scale = 1.0f / FloatToFixedScale / devScale; unsigned int* glyphs; float* positions; int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc index 93ac190b4d1..c65c673e4ae 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc @@ -55,10 +55,6 @@ hb_jdk_get_glyph (hb_font_t *font HB_UNUSED, return (*glyph != 0); } -// This is also define in freetypescaler.c and similar macros are -// in fontscalerdefs.h. Consider tidying this up. -#define FloatToF26Dot6(x) ((unsigned int) ((x)*64)) - static hb_position_t hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, void *font_data, @@ -84,7 +80,7 @@ hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, fadv *= jdkFontInfo->devScale; env->DeleteLocalRef(pt); - return FloatToF26Dot6(fadv); // should this round ? + return FloatToFixed(fadv); } static hb_position_t @@ -111,7 +107,7 @@ hb_jdk_get_glyph_v_advance (hb_font_t *font HB_UNUSED, fadv = env->GetFloatField(pt, sunFontIDs.yFID); env->DeleteLocalRef(pt); - return FloatToF26Dot6(fadv); // should this round ? + return FloatToFixed(fadv); } @@ -205,8 +201,8 @@ hb_jdk_get_glyph_contour_point (hb_font_t *font HB_UNUSED, *x = 0; *y = 0; return true; } - *x = FloatToF26Dot6(env->GetFloatField(pt, sunFontIDs.xFID)); - *y = FloatToF26Dot6(env->GetFloatField(pt, sunFontIDs.yFID)); + *x = FloatToFixed(env->GetFloatField(pt, sunFontIDs.xFID)); + *y = FloatToFixed(env->GetFloatField(pt, sunFontIDs.yFID)); env->DeleteLocalRef(pt); return true; @@ -325,8 +321,8 @@ static hb_font_t* _hb_jdk_font_create(JDKFontInfo *jdkFontInfo, _hb_jdk_get_font_funcs (), jdkFontInfo, (hb_destroy_func_t) _do_nothing); hb_font_set_scale (font, - FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale), - FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale)); + FloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale), + FloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale)); return font; } @@ -343,8 +339,8 @@ static hb_font_t* _hb_jdk_ct_font_create(JDKFontInfo *jdkFontInfo) { hb_face_destroy(face); hb_font_set_scale(font, - FloatToF26Dot6(jdkFontInfo->ptSize), - FloatToF26Dot6(jdkFontInfo->ptSize)); + FloatToFixed(jdkFontInfo->ptSize), + FloatToFixed(jdkFontInfo->ptSize)); return font; } #endif diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h index 1cd8d5ba241..8c08fb036ed 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h @@ -48,6 +48,10 @@ typedef struct JDKFontInfo_Struct { } JDKFontInfo; +// Use 16.16 for better precision than 26.6 +#define FloatToFixedScale ((float)(1 << 16)) +#define FloatToFixed(f) ((unsigned int)((f) * FloatToFixedScale)) + /* * Note: * diff --git a/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java b/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java index c0ed438cee1..4598dfd21fa 100644 --- a/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java +++ b/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java @@ -29,7 +29,7 @@ import java.text.*; /* @test * @summary verify TextLine advance - * @bug 6582460 + * @bug 6582460 8164818 */ /* From 6784b0b5eae7bcd472f8cf91a4a4cf3d574d881e Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Wed, 31 Aug 2016 14:33:23 -0700 Subject: [PATCH 097/296] 8162431: CatalogUriResolver with circular/self referencing catalog file is not throwing CatalogException as expected Reviewed-by: lancea --- .../javax/xml/catalog/CatalogImpl.java | 54 +++++++++++-------- .../javax/xml/catalog/CatalogManager.java | 4 +- .../javax/xml/catalog/CatalogReader.java | 9 ---- .../xml/catalog/CatalogResolverImpl.java | 4 ++ .../classes/javax/xml/catalog/GroupEntry.java | 37 ++++++++++--- .../functional/catalog/DeferFeatureTest.java | 8 +-- .../jaxp/unittest/catalog/CatalogTest.java | 28 ++++++++++ .../catalog/catalogReferCircle-itself.xml | 6 +++ .../catalog/catalogReferCircle-left.xml | 6 +++ .../catalog/catalogReferCircle-right.xml | 6 +++ 10 files changed, 117 insertions(+), 45 deletions(-) create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-itself.xml create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-left.xml create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-right.xml diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java index 5336a8cb8e1..6630424c15a 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java @@ -31,6 +31,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; @@ -72,9 +73,6 @@ class CatalogImpl extends GroupEntry implements Catalog { //System Id for this catalog String systemId; - //The parent - CatalogImpl parent = null; - /* A list of catalog entry files from the input, excluding the current catalog. Paths in the List are normalized. @@ -107,7 +105,7 @@ class CatalogImpl extends GroupEntry implements Catalog { * catalog file. */ public CatalogImpl(CatalogImpl parent, CatalogFeatures f, String... file) throws CatalogException { - super(CatalogEntryType.CATALOG); + super(CatalogEntryType.CATALOG, parent); if (f == null) { throw new NullPointerException( formatMessage(CatalogMessages.ERR_NULL_ARGUMENT, new Object[]{"CatalogFeatures"})); @@ -117,7 +115,7 @@ class CatalogImpl extends GroupEntry implements Catalog { CatalogMessages.reportNPEOnNull("The path to the catalog file", file[0]); } - init(parent, f); + init(f); //Path of catalog files String[] catalogFile = file; @@ -159,19 +157,34 @@ class CatalogImpl extends GroupEntry implements Catalog { } } } - - if (systemId != null) { - parse(systemId); - } } } - private void init(CatalogImpl parent, CatalogFeatures f) { - this.parent = parent; + /** + * Loads the catalog + */ + void load() { + if (systemId != null) { + parse(systemId); + } + + //save this catalog before loading the next + loadedCatalogs.put(systemId, this); + + //Load delegate and alternative catalogs if defer is false. + if (!isDeferred()) { + loadDelegateCatalogs(); + loadNextCatalogs(); + } + } + + private void init(CatalogFeatures f) { if (parent == null) { level = 0; } else { level = parent.level + 1; + this.loadedCatalogs = parent.loadedCatalogs; + this.catalogsSearched = parent.catalogsSearched; } if (f == null) { this.features = CatalogFeatures.defaults(); @@ -196,11 +209,6 @@ class CatalogImpl extends GroupEntry implements Catalog { entries.stream().filter((entry) -> (entry.type == CatalogEntryType.GROUP)).forEach((entry) -> { ((GroupEntry) entry).reset(); }); - - if (parent != null) { - this.loadedCatalogs = parent.loadedCatalogs; - this.catalogsSearched = parent.catalogsSearched; - } } /** @@ -421,16 +429,16 @@ class CatalogImpl extends GroupEntry implements Catalog { void loadNextCatalogs() { //loads catalogs specified in nextCatalogs if (nextCatalogs != null) { - for (NextCatalog next : nextCatalogs) { + nextCatalogs.stream().forEach((next) -> { getCatalog(next.getCatalogURI()); - } + }); } //loads catalogs from the input list if (inputFiles != null) { - for (String file : inputFiles) { + inputFiles.stream().forEach((file) -> { getCatalog(getSystemId(file)); - } + }); } } @@ -445,14 +453,14 @@ class CatalogImpl extends GroupEntry implements Catalog { return null; } - Catalog c = null; + CatalogImpl c = null; String path = uri.toASCIIString(); if (verifyCatalogFile(uri)) { c = getLoadedCatalog(path); if (c == null) { c = new CatalogImpl(this, features, path); - saveLoadedCatalog(path, c); + c.load(); } } return c; @@ -464,7 +472,7 @@ class CatalogImpl extends GroupEntry implements Catalog { * @param catalogId the catalogId associated with the Catalog object * @param c the Catalog to be saved */ - void saveLoadedCatalog(String catalogId, Catalog c) { + void saveLoadedCatalog(String catalogId, CatalogImpl c) { loadedCatalogs.put(catalogId, c); } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java index bc8518685f7..7dd1e9cf873 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java @@ -62,7 +62,9 @@ public final class CatalogManager { * @throws CatalogException If an error occurs while parsing the catalog */ public static Catalog catalog(CatalogFeatures features, String... paths) { - return new CatalogImpl(features, paths); + CatalogImpl catalog = new CatalogImpl(features, paths); + catalog.load(); + return catalog; } /** diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java index bf4e95b963f..5f08c54cc12 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java @@ -259,15 +259,6 @@ class CatalogReader extends DefaultHandler implements EntityResolver, URIResolve CatalogEntryType type = CatalogEntryType.getType(localName); if (type == CatalogEntryType.GROUP) { inGroup = false; - } else if (type == CatalogEntryType.CATALOGENTRY) { - /* - Done reading the catalog file. - Load delegate and alternative catalogs if defer is false. - */ - if (!catalog.isDeferred()) { - catalog.loadDelegateCatalogs(); - catalog.loadNextCatalogs(); - } } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java index 9bf8b357adc..fe6223d9324 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java @@ -119,6 +119,10 @@ final class CatalogResolverImpl implements CatalogResolver { String result = null; CatalogImpl c = (CatalogImpl)catalog; String uri = Normalizer.normalizeURI(href); + if (uri == null) { + return null; + } + //check whether uri is an urn if (uri != null && uri.startsWith(Util.URN)) { String publicId = Normalizer.decodeURN(uri); diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java index 2c1a59c360c..e04f8cdb363 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java @@ -48,6 +48,9 @@ class GroupEntry extends BaseEntry { //Value of the prefer attribute boolean isPreferPublic = true; + //The parent of the catalog instance + CatalogImpl parent = null; + //The catalog instance this group belongs to CatalogImpl catalog; @@ -55,10 +58,10 @@ class GroupEntry extends BaseEntry { List entries = new ArrayList<>(); //loaded delegated catalog by system id - Map delegateCatalogs = new HashMap<>(); + Map delegateCatalogs = new HashMap<>(); //A list of all loaded Catalogs, including this, and next catalogs - Map loadedCatalogs = new HashMap<>(); + Map loadedCatalogs = new HashMap<>(); /* A list of Catalog Ids that have already been searched in a matching @@ -136,8 +139,9 @@ class GroupEntry extends BaseEntry { * * @param type The type of the entry */ - public GroupEntry(CatalogEntryType type) { + public GroupEntry(CatalogEntryType type, CatalogImpl parent) { super(type); + this.parent = parent; } /** @@ -163,7 +167,7 @@ class GroupEntry extends BaseEntry { } /** * Constructs a group entry. - * @param catalog The parent catalog + * @param catalog The catalog this GroupEntry belongs * @param base The baseURI attribute * @param attributes The attributes */ @@ -445,13 +449,14 @@ class GroupEntry extends BaseEntry { * @param catalogId the catalog Id */ Catalog loadCatalog(URI catalogURI) { - Catalog delegateCatalog = null; + CatalogImpl delegateCatalog = null; if (catalogURI != null) { String catalogId = catalogURI.toASCIIString(); delegateCatalog = getLoadedCatalog(catalogId); if (delegateCatalog == null) { if (verifyCatalogFile(catalogURI)) { delegateCatalog = new CatalogImpl(catalog, features, catalogId); + delegateCatalog.load(); delegateCatalogs.put(catalogId, delegateCatalog); } } @@ -467,8 +472,8 @@ class GroupEntry extends BaseEntry { * @return a Catalog object previously loaded, or null if none in the saved * list */ - Catalog getLoadedCatalog(String catalogId) { - Catalog c = null; + CatalogImpl getLoadedCatalog(String catalogId) { + CatalogImpl c = null; //checl delegate Catalogs c = delegateCatalogs.get(catalogId); @@ -504,7 +509,7 @@ class GroupEntry extends BaseEntry { } String catalogId = catalogURI.toASCIIString(); - if (catalogsSearched.contains(catalogId)) { + if (catalogsSearched.contains(catalogId) || isCircular(catalogId)) { CatalogMessages.reportRunTimeError(CatalogMessages.ERR_CIRCULAR_REFERENCE, new Object[]{CatalogMessages.sanitize(catalogId)}); } @@ -512,4 +517,20 @@ class GroupEntry extends BaseEntry { return true; } + /** + * Checks whether the catalog is circularly referenced + * @param systemId the system identifier of the catalog to be loaded + * @return true if is circular, false otherwise + */ + boolean isCircular(String systemId) { + if (parent == null) { + return false; + } + + if (parent.systemId.equals(systemId)) { + return true; + } + + return parent.isCircular(systemId); + } } diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java index 626943a335b..b5368158ab1 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java @@ -64,12 +64,12 @@ public class DeferFeatureTest { public Object[][] data() { return new Object[][]{ // By default, alternative catalogs are not loaded. - {createCatalog(CatalogFeatures.defaults()), 0}, + {createCatalog(CatalogFeatures.defaults()), 1}, // Alternative catalogs are not loaded when DEFER is set to true. - {createCatalog(createDeferFeature(DEFER_TRUE)), 0}, - // The 3 alternative catalogs are not pre-loaded + {createCatalog(createDeferFeature(DEFER_TRUE)), 1}, + // The 3 alternative catalogs are pre-loaded along with the parent //when DEFER is set to false. - {createCatalog(createDeferFeature(DEFER_FALSE)), 3}}; + {createCatalog(createDeferFeature(DEFER_FALSE)), 4}}; } private CatalogFeatures createDeferFeature(String defer) { diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java index 6f622f9ab25..4b9ea77826d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java @@ -92,6 +92,34 @@ public class CatalogTest extends CatalogSupportBase { super.setUp(); } + /* + * @bug 8162431 + * Verifies that circular references are caught and + * CatalogException is thrown. + */ + @Test(dataProvider = "getFeatures", expectedExceptions = CatalogException.class) + public void testCircularRef(CatalogFeatures cf, String xml) { + CatalogResolver catalogResolver = CatalogManager.catalogResolver( + cf, + getClass().getResource(xml).getFile()); + catalogResolver.resolve("anyuri", ""); + } + + /* + DataProvider: used to verify circular reference + Data columns: CatalogFeatures, catalog + */ + @DataProvider(name = "getFeatures") + public Object[][] getFeatures() { + + return new Object[][]{ + {CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "false").build(), + "catalogReferCircle-itself.xml"}, + {CatalogFeatures.defaults(), "catalogReferCircle-itself.xml"}, + {CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "false").build(), + "catalogReferCircle-left.xml"}, + {CatalogFeatures.defaults(), "catalogReferCircle-left.xml"},}; + } /* * @bug 8163232 diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-itself.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-itself.xml new file mode 100644 index 00000000000..c3cfaa66443 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-itself.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-left.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-left.xml new file mode 100644 index 00000000000..852b1a56ac3 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-left.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-right.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-right.xml new file mode 100644 index 00000000000..0c556a4b123 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-right.xml @@ -0,0 +1,6 @@ + + + + + + From b5172ce65ea0fe1d0f658e206cab279562a0f3cc Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 31 Aug 2016 15:20:31 -0700 Subject: [PATCH 098/296] 8165180: Provide a shared secret to access non-public ServerSocket constructor Reviewed-by: chegar --- .../share/classes/java/net/ServerSocket.java | 28 +++++++++++++ .../internal/misc/JavaNetSocketAccess.java | 41 +++++++++++++++++++ .../jdk/internal/misc/SharedSecrets.java | 11 +++++ 3 files changed, 80 insertions(+) create mode 100644 jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java diff --git a/jdk/src/java.base/share/classes/java/net/ServerSocket.java b/jdk/src/java.base/share/classes/java/net/ServerSocket.java index a86fca6af3c..256c9a6e2ee 100644 --- a/jdk/src/java.base/share/classes/java/net/ServerSocket.java +++ b/jdk/src/java.base/share/classes/java/net/ServerSocket.java @@ -25,8 +25,13 @@ package java.net; +import jdk.internal.misc.JavaNetSocketAccess; +import jdk.internal.misc.SharedSecrets; + import java.io.FileDescriptor; import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.nio.channels.ServerSocketChannel; import java.security.AccessController; import java.security.PrivilegedExceptionAction; @@ -1011,4 +1016,27 @@ class ServerSocket implements java.io.Closeable { return options; } } + + static { + SharedSecrets.setJavaNetSocketAccess( + new JavaNetSocketAccess() { + @Override + public ServerSocket newServerSocket(SocketImpl impl) { + return new ServerSocket(impl); + } + + @Override + public SocketImpl newSocketImpl(Class implClass) { + try { + Constructor ctor = + implClass.getDeclaredConstructor(); + return ctor.newInstance(); + } catch (NoSuchMethodException | InstantiationException | + IllegalAccessException | InvocationTargetException e) { + throw new AssertionError(e); + } + } + } + ); + } } diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java new file mode 100644 index 00000000000..39dd153731e --- /dev/null +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +package jdk.internal.misc; + +import java.net.ServerSocket; +import java.net.SocketImpl; + +public interface JavaNetSocketAccess { + /** + * Creates a ServerSocket associated with the given SocketImpl. + */ + ServerSocket newServerSocket(SocketImpl impl); + + /* + * Constructs a SocketImpl instance of the given class. + */ + SocketImpl newSocketImpl(Class implClass); +} diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java index fed1b694548..052d1119f09 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java @@ -55,6 +55,7 @@ public class SharedSecrets { private static JavaNetAccess javaNetAccess; private static JavaNetInetAddressAccess javaNetInetAddressAccess; private static JavaNetHttpCookieAccess javaNetHttpCookieAccess; + private static JavaNetSocketAccess javaNetSocketAccess; private static JavaNioAccess javaNioAccess; private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess; private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess; @@ -161,6 +162,16 @@ public class SharedSecrets { return javaNetHttpCookieAccess; } + public static void setJavaNetSocketAccess(JavaNetSocketAccess jnsa) { + javaNetSocketAccess = jnsa; + } + + public static JavaNetSocketAccess getJavaNetSocketAccess() { + if (javaNetSocketAccess == null) + unsafe.ensureClassInitialized(java.net.ServerSocket.class); + return javaNetSocketAccess; + } + public static void setJavaNioAccess(JavaNioAccess jna) { javaNioAccess = jna; } From 53db4a4609e9b11fbd4d9c2c3b92c5f3cdc5321d Mon Sep 17 00:00:00 2001 From: Rajan Halade Date: Wed, 31 Aug 2016 16:16:01 -0700 Subject: [PATCH 099/296] 8164229: Redundant "sun/net/www/protocol/https" tests in jdk_security3 group Reviewed-by: chegar --- jdk/test/TEST.groups | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index be1540695df..d24280a517b 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -189,7 +189,6 @@ jdk_security3 = \ -sun/security/krb5 \ -sun/security/jgss \ javax/net \ - sun/net/www/protocol/https \ com/sun/net/ssl \ lib/security From 252779d212e5f299c86a668a3607c400908172ed Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 1 Sep 2016 10:21:29 +0530 Subject: [PATCH 100/296] 8165146: [PIT][TEST_BUG] Doubtful usability of java/awt/print/PrinterJob/TestMediaTraySelection.java Reviewed-by: prr --- jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java b/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java index 374928a56c5..9076c6b08cf 100644 --- a/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java +++ b/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java @@ -21,8 +21,7 @@ * questions. */ /* - * @test - * @bug 6357887 + * @bug 6357887 8165146 * @summary Verifies if selected printertray is used * @requires (os.family == "linux" | os.family == "solaris") * @run main/manual TestMediaTraySelection From 82d48917bbd4d06e0c331026c387349ca360cc3f Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 1 Sep 2016 10:16:57 -0700 Subject: [PATCH 101/296] 8161444: VarHandles should provide access bitwise atomics 8162107: Add acquire/release variants for getAndSet and getAndAdd Reviewed-by: shade, redestad --- jdk/make/gensrc/GensrcVarHandles.gmk | 6 + .../java/lang/invoke/MethodHandles.java | 47 +- .../classes/java/lang/invoke/VarHandle.java | 571 +++++++- .../lang/invoke/X-VarHandle.java.template | 308 ++++- .../X-VarHandleByteArrayView.java.template | 406 ++++++ .../classes/jdk/internal/misc/Unsafe.java | 760 +++++++++++ .../invoke/VarHandles/VarHandleBaseTest.java | 19 +- .../VarHandleTestAccessBoolean.java | 415 ++++++ .../VarHandles/VarHandleTestAccessByte.java | 447 +++++- .../VarHandles/VarHandleTestAccessChar.java | 447 +++++- .../VarHandles/VarHandleTestAccessDouble.java | 338 ++++- .../VarHandles/VarHandleTestAccessFloat.java | 338 ++++- .../VarHandles/VarHandleTestAccessInt.java | 447 +++++- .../VarHandles/VarHandleTestAccessLong.java | 447 +++++- .../VarHandles/VarHandleTestAccessShort.java | 447 +++++- .../VarHandles/VarHandleTestAccessString.java | 306 +++++ .../VarHandleTestByteArrayAsChar.java | 174 +++ .../VarHandleTestByteArrayAsDouble.java | 230 ++++ .../VarHandleTestByteArrayAsFloat.java | 230 ++++ .../VarHandleTestByteArrayAsInt.java | 522 ++++++- .../VarHandleTestByteArrayAsLong.java | 522 ++++++- .../VarHandleTestByteArrayAsShort.java | 174 +++ ...arHandleTestMethodHandleAccessBoolean.java | 305 ++++- .../VarHandleTestMethodHandleAccessByte.java | 369 ++++- .../VarHandleTestMethodHandleAccessChar.java | 369 ++++- ...VarHandleTestMethodHandleAccessDouble.java | 130 +- .../VarHandleTestMethodHandleAccessFloat.java | 130 +- .../VarHandleTestMethodHandleAccessInt.java | 369 ++++- .../VarHandleTestMethodHandleAccessLong.java | 369 ++++- .../VarHandleTestMethodHandleAccessShort.java | 369 ++++- ...VarHandleTestMethodHandleAccessString.java | 66 +- .../VarHandleTestMethodTypeBoolean.java | 1024 ++++++++++++++ .../VarHandleTestMethodTypeByte.java | 1189 ++++++++++++++++ .../VarHandleTestMethodTypeChar.java | 1189 ++++++++++++++++ .../VarHandleTestMethodTypeDouble.java | 337 +++++ .../VarHandleTestMethodTypeFloat.java | 337 +++++ .../VarHandleTestMethodTypeInt.java | 1189 ++++++++++++++++ .../VarHandleTestMethodTypeLong.java | 1189 ++++++++++++++++ .../VarHandleTestMethodTypeShort.java | 1189 ++++++++++++++++ .../VarHandleTestMethodTypeString.java | 172 +++ .../X-VarHandleTestAccess.java.template | 742 +++++++++- ...X-VarHandleTestByteArrayView.java.template | 714 +++++++++- ...HandleTestMethodHandleAccess.java.template | 402 +++++- .../X-VarHandleTestMethodType.java.template | 1201 +++++++++++++++++ .../invoke/VarHandles/generate-vh-tests.sh | 12 + 45 files changed, 20838 insertions(+), 125 deletions(-) diff --git a/jdk/make/gensrc/GensrcVarHandles.gmk b/jdk/make/gensrc/GensrcVarHandles.gmk index 3ad7e630e9c..b4a2bab9873 100644 --- a/jdk/make/gensrc/GensrcVarHandles.gmk +++ b/jdk/make/gensrc/GensrcVarHandles.gmk @@ -44,6 +44,10 @@ define GenerateVarHandle $1_ARGS += -KAtomicAdd endif + ifneq ($$(findstring $$($1_Type), Boolean Byte Short Char Int Long), ) + $1_ARGS += -KBitwise + endif + ifneq ($$(findstring $$($1_Type), Byte Short Char), ) $1_ARGS += -KShorterThanInt endif @@ -101,6 +105,7 @@ define GenerateVarHandleByteArray $1_ARGS += -KCAS $1_ARGS += -KAtomicAdd + $1_ARGS += -KBitwise endif ifeq ($$($1_Type), Long) @@ -113,6 +118,7 @@ define GenerateVarHandleByteArray $1_ARGS += -KCAS $1_ARGS += -KAtomicAdd + $1_ARGS += -KBitwise endif ifeq ($$($1_Type), Float) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index a02e2f18b23..cec799ec1a3 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -1207,11 +1207,16 @@ assertEquals(""+l, (String) MH_this.invokeExact(subl)); // Listie method * the following conditions: *

    *
  • if the field is declared {@code final}, then the write, atomic - * update, and numeric atomic update access modes are unsupported. + * update, numeric atomic update, and bitwise atomic update access + * modes are unsupported. *
  • if the field type is anything other than {@code byte}, - * {@code short}, {@code char}, {@code int} or {@code long}, + * {@code short}, {@code char}, {@code int}, {@code long}, * {@code float}, or {@code double} then numeric atomic update * access modes are unsupported. + *
  • if the field type is anything other than {@code boolean}, + * {@code byte}, {@code short}, {@code char}, {@code int} or + * {@code long} then bitwise atomic update access modes are + * unsupported. *
*

* If the field is declared {@code volatile} then the returned VarHandle @@ -1326,11 +1331,16 @@ assertEquals(""+l, (String) MH_this.invokeExact(subl)); // Listie method * the following conditions: *

    *
  • if the field is declared {@code final}, then the write, atomic - * update, and numeric atomic update access modes are unsupported. + * update, numeric atomic update, and bitwise atomic update access + * modes are unsupported. *
  • if the field type is anything other than {@code byte}, - * {@code short}, {@code char}, {@code int} or {@code long}, + * {@code short}, {@code char}, {@code int}, {@code long}, * {@code float}, or {@code double}, then numeric atomic update * access modes are unsupported. + *
  • if the field type is anything other than {@code boolean}, + * {@code byte}, {@code short}, {@code char}, {@code int} or + * {@code long} then bitwise atomic update access modes are + * unsupported. *
*

* If the field is declared {@code volatile} then the returned VarHandle @@ -1631,11 +1641,16 @@ return mh1; * the following conditions: *

    *
  • if the field is declared {@code final}, then the write, atomic - * update, and numeric atomic update access modes are unsupported. + * update, numeric atomic update, and bitwise atomic update access + * modes are unsupported. *
  • if the field type is anything other than {@code byte}, - * {@code short}, {@code char}, {@code int} or {@code long}, + * {@code short}, {@code char}, {@code int}, {@code long}, * {@code float}, or {@code double} then numeric atomic update * access modes are unsupported. + *
  • if the field type is anything other than {@code boolean}, + * {@code byte}, {@code short}, {@code char}, {@code int} or + * {@code long} then bitwise atomic update access modes are + * unsupported. *
*

* If the field is declared {@code volatile} then the returned VarHandle @@ -2353,9 +2368,13 @@ return mh1; * the following conditions: *

    *
  • if the component type is anything other than {@code byte}, - * {@code short}, {@code char}, {@code int} or {@code long}, + * {@code short}, {@code char}, {@code int}, {@code long}, * {@code float}, or {@code double} then numeric atomic update access * modes are unsupported. + *
  • if the field type is anything other than {@code boolean}, + * {@code byte}, {@code short}, {@code char}, {@code int} or + * {@code long} then bitwise atomic update access modes are + * unsupported. *
*

* If the component type is {@code float} or {@code double} then numeric @@ -2426,7 +2445,9 @@ return mh1; * If access is aligned then following access modes are supported and are * guaranteed to support atomic access: *

    - *
  • read write access modes for all {@code T}; + *
  • read write access modes for all {@code T}, with the exception of + * access modes {@code get} and {@code set} for {@code long} and + * {@code double} on 32-bit platforms. *
  • atomic update access modes for {@code int}, {@code long}, * {@code float} or {@code double}. * (Future major platform releases of the JDK may support additional @@ -2434,6 +2455,9 @@ return mh1; *
  • numeric atomic update access modes for {@code int} and {@code long}. * (Future major platform releases of the JDK may support additional * numeric types for certain currently unsupported access modes.) + *
  • bitwise atomic update access modes for {@code int} and {@code long}. + * (Future major platform releases of the JDK may support additional + * numeric types for certain currently unsupported access modes.) *
*

* Misaligned access, and therefore atomicity guarantees, may be determined @@ -2508,7 +2532,9 @@ return mh1; * If access is aligned then following access modes are supported and are * guaranteed to support atomic access: *

    - *
  • read write access modes for all {@code T}; + *
  • read write access modes for all {@code T}, with the exception of + * access modes {@code get} and {@code set} for {@code long} and + * {@code double} on 32-bit platforms. *
  • atomic update access modes for {@code int}, {@code long}, * {@code float} or {@code double}. * (Future major platform releases of the JDK may support additional @@ -2516,6 +2542,9 @@ return mh1; *
  • numeric atomic update access modes for {@code int} and {@code long}. * (Future major platform releases of the JDK may support additional * numeric types for certain currently unsupported access modes.) + *
  • bitwise atomic update access modes for {@code int} and {@code long}. + * (Future major platform releases of the JDK may support additional + * numeric types for certain currently unsupported access modes.) *
*

* Misaligned access, and therefore atomicity guarantees, may be determined diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java index 5e71204b6d0..09734f38f10 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java @@ -141,14 +141,32 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; * {@link #compareAndExchangeAcquire compareAndExchangeAcquire}, * {@link #compareAndExchange compareAndExchange}, * {@link #compareAndExchangeRelease compareAndExchangeRelease}, - * {@link #getAndSet getAndSet}. + * {@link #getAndSet getAndSet}, + * {@link #getAndSetAcquire getAndSetAcquire}, + * {@link #getAndSetRelease getAndSetRelease}. *

  • numeric atomic update access modes that, for example, atomically get and * set with addition the value of a variable under specified memory ordering * effects. * The set of corresponding access mode methods belonging to this group * consists of the methods * {@link #getAndAdd getAndAdd}, + * {@link #getAndAddAcquire getAndAddAcquire}, + * {@link #getAndAddRelease getAndAddRelease}, * {@link #addAndGet addAndGet}. + *
  • bitwise atomic update access modes that, for example, atomically get and + * bitwise OR the value of a variable under specified memory ordering + * effects. + * The set of corresponding access mode methods belonging to this group + * consists of the methods + * {@link #getAndBitwiseOr getAndBitwiseOr}, + * {@link #getAndBitwiseOrAcquire getAndBitwiseOrAcquire}, + * {@link #getAndBitwiseOrRelease getAndBitwiseOrRelease}, + * {@link #getAndBitwiseAnd getAndBitwiseAnd}, + * {@link #getAndBitwiseAndAcquire getAndBitwiseAndAcquire}, + * {@link #getAndBitwiseAndRelease getAndBitwiseAndRelease}, + * {@link #getAndBitwiseXor getAndBitwiseXor}, + * {@link #getAndBitwiseXorAcquire getAndBitwiseXorAcquire}, + * {@link #getAndBitwiseXorRelease getAndBitwiseXorRelease}. * * *

    Factory methods that produce or {@link java.lang.invoke.MethodHandles.Lookup @@ -163,8 +181,8 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; * VarHandle instances and the corresponding method never throws * {@code UnsupportedOperationException}. * If a VarHandle references a read-only variable (for example a {@code final} - * field) then write, atomic update and numeric atomic update access modes are - * not supported and corresponding methods throw + * field) then write, atomic update, numeric atomic update, and bitwise atomic + * update access modes are not supported and corresponding methods throw * {@code UnsupportedOperationException}. * Read/write access modes (if supported), with the exception of * {@code get} and {@code set}, provide atomic access for @@ -986,6 +1004,71 @@ public abstract class VarHandle { @HotSpotIntrinsicCandidate Object getAndSet(Object... args); + /** + * Atomically sets the value of a variable to the {@code newValue} with the + * memory semantics of {@link #set} and returns the variable's + * previous value, as accessed with the memory semantics of + * {@link #getAcquire}. + * + *

    The method signature is of the form {@code (CT, T newValue)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndSetAcquire} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T newValue)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndSetAcquire(Object... args); + + /** + * Atomically sets the value of a variable to the {@code newValue} with the + * memory semantics of {@link #setRelease} and returns the variable's + * previous value, as accessed with the memory semantics of + * {@link #get}. + * + *

    The method signature is of the form {@code (CT, T newValue)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndSetRelease} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_SET_RELEASE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T newValue)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndSetRelease(Object... args); // Primitive adders // Throw UnsupportedOperationException for refs @@ -1023,6 +1106,72 @@ public abstract class VarHandle { @HotSpotIntrinsicCandidate Object getAndAdd(Object... args); + /** + * Atomically adds the {@code value} to the current value of a variable with + * the memory semantics of {@link #set}, and returns the variable's + * previous value, as accessed with the memory semantics of + * {@link #getAcquire}. + * + *

    The method signature is of the form {@code (CT, T value)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndAddAcquire} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T value)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndAddAcquire(Object... args); + + /** + * Atomically adds the {@code value} to the current value of a variable with + * the memory semantics of {@link #setRelease}, and returns the variable's + * previous value, as accessed with the memory semantics of + * {@link #get}. + * + *

    The method signature is of the form {@code (CT, T value)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndAddRelease} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_ADD_RELEASE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T value)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndAddRelease(Object... args); + /** * Atomically adds the {@code value} to the current value of a variable with * the memory semantics of {@link #setVolatile}, and returns the variable's @@ -1056,6 +1205,344 @@ public abstract class VarHandle { @HotSpotIntrinsicCandidate Object addAndGet(Object... args); + + // Bitwise operations + // Throw UnsupportedOperationException for refs + + /** + * Atomically sets the value of a variable to the result of + * bitwise OR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setVolatile} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getVolatile}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical OR is performed instead of a bitwise OR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseOr} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseOr(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise OR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #set} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getAcquire}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical OR is performed instead of a bitwise OR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseOrAcquire} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #set(Object...) + * @see #getAcquire(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseOrAcquire(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise OR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setRelease} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #get}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical OR is performed instead of a bitwise OR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseOrRelease} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setRelease(Object...) + * @see #get(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseOrRelease(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise AND between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setVolatile} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getVolatile}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical AND is performed instead of a bitwise AND. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseAnd} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseAnd(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise AND between the variable's current value and the {@code mask} + * with the memory semantics of {@link #set} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getAcquire}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical AND is performed instead of a bitwise AND. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseAndAcquire} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #set(Object...) + * @see #getAcquire(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseAndAcquire(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise AND between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setRelease} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #get}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical AND is performed instead of a bitwise AND. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseAndRelease} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setRelease(Object...) + * @see #get(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseAndRelease(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise XOR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setVolatile} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getVolatile}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical XOR is performed instead of a bitwise XOR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseXor} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseXor(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise XOR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #set} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getAcquire}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical XOR is performed instead of a bitwise XOR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseXorAcquire} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #set(Object...) + * @see #getAcquire(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseXorAcquire(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise XOR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setRelease} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #get}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical XOR is performed instead of a bitwise XOR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseXorRelease} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setRelease(Object...) + * @see #get(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseXorRelease(Object... args); + + enum AccessType { GET(Object.class), SET(void.class), @@ -1231,18 +1718,96 @@ public abstract class VarHandle { * {@link VarHandle#getAndSet VarHandle.getAndSet} */ GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndSetAcquire VarHandle.getAndSetAcquire} + */ + GET_AND_SET_ACQUIRE("getAndSetAcquire", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndSetRelease VarHandle.getAndSetRelease} + */ + GET_AND_SET_RELEASE("getAndSetRelease", AccessType.GET_AND_UPDATE), /** * The access mode whose access is specified by the corresponding * method * {@link VarHandle#getAndAdd VarHandle.getAndAdd} */ GET_AND_ADD("getAndAdd", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndAddAcquire VarHandle.getAndAddAcquire} + */ + GET_AND_ADD_ACQUIRE("getAndAddAcquire", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndAddRelease VarHandle.getAndAddRelease} + */ + GET_AND_ADD_RELEASE("getAndAddRelease", AccessType.GET_AND_UPDATE), /** * The access mode whose access is specified by the corresponding * method * {@link VarHandle#addAndGet VarHandle.addAndGet} */ ADD_AND_GET("addAndGet", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseOr VarHandle.getAndBitwiseOr} + */ + GET_AND_BITWISE_OR("getAndBitwiseOr", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseOrRelease VarHandle.getAndBitwiseOrRelease} + */ + GET_AND_BITWISE_OR_RELEASE("getAndBitwiseOrRelease", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseOrAcquire VarHandle.getAndBitwiseOrAcquire} + */ + GET_AND_BITWISE_OR_ACQUIRE("getAndBitwiseOrAcquire", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseAnd VarHandle.getAndBitwiseAnd} + */ + GET_AND_BITWISE_AND("getAndBitwiseAnd", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseAndRelease VarHandle.getAndBitwiseAndRelease} + */ + GET_AND_BITWISE_AND_RELEASE("getAndBitwiseAndRelease", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseAndAcquire VarHandle.getAndBitwiseAndAcquire} + */ + GET_AND_BITWISE_AND_ACQUIRE("getAndBitwiseAndAcquire", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseXor VarHandle.getAndBitwiseXor} + */ + GET_AND_BITWISE_XOR("getAndBitwiseXor", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseXorRelease VarHandle.getAndBitwiseXorRelease} + */ + GET_AND_BITWISE_XOR_RELEASE("getAndBitwiseXorRelease", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseXorAcquire VarHandle.getAndBitwiseXorAcquire} + */ + GET_AND_BITWISE_XOR_ACQUIRE("getAndBitwiseXorAcquire", AccessType.GET_AND_UPDATE), ; static final Map methodNameToAccessMode; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template index d6f5aaa380c..2383daed5ff 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template @@ -193,6 +193,20 @@ final class VarHandle$Type$s { handle.fieldOffset, {#if[Object]?handle.fieldType.cast(value):value}); } + + @ForceInline + static $type$ getAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + {#if[Object]?handle.fieldType.cast(value):value}); + } + + @ForceInline + static $type$ getAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + {#if[Object]?handle.fieldType.cast(value):value}); + } #end[CAS] #if[AtomicAdd] @@ -203,6 +217,20 @@ final class VarHandle$Type$s { value); } + @ForceInline + static $type$ getAndAddAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndAdd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndAddRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndAdd$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + @ForceInline static $type$ addAndGet(FieldInstanceReadWrite handle, Object holder, $type$ value) { return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), @@ -210,6 +238,71 @@ final class VarHandle$Type$s { value) + value); } #end[AtomicAdd] +#if[Bitwise] + + @ForceInline + static $type$ getAndBitwiseOr(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAnd(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXor(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } +#end[Bitwise] static final VarForm FORM = new VarForm(FieldInstanceReadWrite.class, Object.class, $type$.class); } @@ -374,6 +467,20 @@ final class VarHandle$Type$s { handle.fieldOffset, {#if[Object]?handle.fieldType.cast(value):value}); } + + @ForceInline + static $type$ getAndSetAcquire(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndSet$Type$Acquire(handle.base, + handle.fieldOffset, + {#if[Object]?handle.fieldType.cast(value):value}); + } + + @ForceInline + static $type$ getAndSetRelease(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndSet$Type$Release(handle.base, + handle.fieldOffset, + {#if[Object]?handle.fieldType.cast(value):value}); + } #end[CAS] #if[AtomicAdd] @@ -384,6 +491,20 @@ final class VarHandle$Type$s { value); } + @ForceInline + static $type$ getAndAddAcquire(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndAdd$Type$Acquire(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndAddRelease(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndAdd$Type$Release(handle.base, + handle.fieldOffset, + value); + } + @ForceInline static $type$ addAndGet(FieldStaticReadWrite handle, $type$ value) { return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(handle.base, @@ -391,6 +512,71 @@ final class VarHandle$Type$s { value) + value); } #end[AtomicAdd] +#if[Bitwise] + + @ForceInline + static $type$ getAndBitwiseOr(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrRelease(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$Release(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrAcquire(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$Acquire(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAnd(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndRelease(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$Release(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndAcquire(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$Acquire(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXor(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorRelease(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$Release(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorAcquire(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$Acquire(handle.base, + handle.fieldOffset, + value); + } +#end[Bitwise] static final VarForm FORM = new VarForm(FieldStaticReadWrite.class, null, $type$.class); } @@ -624,33 +810,139 @@ final class VarHandle$Type$s { (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(value):value}); } -#end[CAS] -#if[AtomicAdd] @ForceInline - static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) { + static $type$ getAndSetAcquire(Array handle, Object oarray, int index, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] + return UNSAFE.getAndSet$Type$Acquire(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + {#if[Object]?handle.componentType.cast(value):value}); + } + + @ForceInline + static $type$ getAndSetRelease(Array handle, Object oarray, int index, $type$ value) { +#if[Object] + Object[] array = (Object[]) handle.arrayType.cast(oarray); +#else[Object] + $type$[] array = ($type$[]) oarray; +#end[Object] + return UNSAFE.getAndSet$Type$Release(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + {#if[Object]?handle.componentType.cast(value):value}); + } +#end[CAS] +#if[AtomicAdd] + + @ForceInline + static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; return UNSAFE.getAndAdd$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline - static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) { -#if[Object] - Object[] array = (Object[]) handle.arrayType.cast(oarray); -#else[Object] + static $type$ getAndAddAcquire(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndAdd$Type$Acquire(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndAddRelease(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndAdd$Type$Release(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; -#end[Object] return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value) + value); } #end[AtomicAdd] +#if[Bitwise] + + @ForceInline + static $type$ getAndBitwiseOr(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseOr$Type$(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrRelease(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseOr$Type$Release(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrAcquire(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseOr$Type$Acquire(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseAnd(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseAnd$Type$(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndRelease(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseAnd$Type$Release(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndAcquire(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseAnd$Type$Acquire(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseXor(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseXor$Type$(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorRelease(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseXor$Type$Release(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorAcquire(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseXor$Type$Acquire(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } +#end[Bitwise] static final VarForm FORM = new VarForm(Array.class, {#if[Object]?Object[].class:$type$[].class}, {#if[Object]?Object.class:$type$.class}, int.class); } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template index bb2f7f0ae10..669e8c08a7c 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template @@ -267,6 +267,26 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { address(ba, index(ba, index)), convEndian(handle.be, value))); } + + @ForceInline + static $type$ getAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + return convEndian(handle.be, + UNSAFE.getAndSet$RawType$Acquire( + ba, + address(ba, index(ba, index)), + convEndian(handle.be, value))); + } + + @ForceInline + static $type$ getAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + return convEndian(handle.be, + UNSAFE.getAndSet$RawType$Release( + ba, + address(ba, index(ba, index)), + convEndian(handle.be, value))); + } #end[CAS] #if[AtomicAdd] @@ -283,6 +303,32 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } } + @ForceInline + static $type$ getAndAddAcquire(ArrayHandle handle, Object oba, int index, $type$ delta) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndAdd$RawType$Acquire( + ba, + address(ba, index(ba, index)), + delta); + } else { + return getAndAddConvEndianWithCAS(ba, index, delta); + } + } + + @ForceInline + static $type$ getAndAddRelease(ArrayHandle handle, Object oba, int index, $type$ delta) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndAdd$RawType$Release( + ba, + address(ba, index(ba, index)), + delta); + } else { + return getAndAddConvEndianWithCAS(ba, index, delta); + } + } + @ForceInline static $type$ getAndAddConvEndianWithCAS(byte[] ba, int index, $type$ delta) { $type$ nativeExpectedValue, expectedValue; @@ -300,6 +346,161 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { return getAndAdd(handle, oba, index, delta) + delta; } #end[AtomicAdd] +#if[Bitwise] + + @ForceInline + static $type$ getAndBitwiseOr(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseOrRelease(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$Release( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseOrAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$Acquire( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseOrConvEndianWithCAS(byte[] ba, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + long offset = address(ba, index(ba, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); + return expectedValue; + } + + @ForceInline + static $type$ getAndBitwiseAnd(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndRelease(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$Release( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$Acquire( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndConvEndianWithCAS(byte[] ba, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + long offset = address(ba, index(ba, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); + return expectedValue; + } + + @ForceInline + static $type$ getAndBitwiseXor(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorRelease(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$Release( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$Acquire( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorConvEndianWithCAS(byte[] ba, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + long offset = address(ba, index(ba, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); + return expectedValue; + } +#end[Bitwise] static final VarForm FORM = new VarForm(ArrayHandle.class, byte[].class, $type$.class, int.class); } @@ -510,6 +711,26 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { address(bb, indexRO(bb, index)), convEndian(handle.be, value))); } + + @ForceInline + static $type$ getAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + return convEndian(handle.be, + UNSAFE.getAndSet$RawType$Acquire( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + convEndian(handle.be, value))); + } + + @ForceInline + static $type$ getAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + return convEndian(handle.be, + UNSAFE.getAndSet$RawType$Release( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + convEndian(handle.be, value))); + } #end[CAS] #if[AtomicAdd] @@ -526,6 +747,32 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } } + @ForceInline + static $type$ getAndAddAcquire(ByteBufferHandle handle, Object obb, int index, $type$ delta) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndAdd$RawType$Acquire( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + delta); + } else { + return getAndAddConvEndianWithCAS(bb, index, delta); + } + } + + @ForceInline + static $type$ getAndAddRelease(ByteBufferHandle handle, Object obb, int index, $type$ delta) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndAdd$RawType$Release( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + delta); + } else { + return getAndAddConvEndianWithCAS(bb, index, delta); + } + } + @ForceInline static $type$ getAndAddConvEndianWithCAS(ByteBuffer bb, int index, $type$ delta) { $type$ nativeExpectedValue, expectedValue; @@ -544,6 +791,165 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { return getAndAdd(handle, obb, index, delta) + delta; } #end[AtomicAdd] +#if[Bitwise] + + @ForceInline + static $type$ getAndBitwiseOr(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseOrRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$Release( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseOrAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$Acquire( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseOrConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); + long offset = address(bb, indexRO(bb, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); + return expectedValue; + } + + @ForceInline + static $type$ getAndBitwiseAnd(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$Release( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$Acquire( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); + long offset = address(bb, indexRO(bb, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); + return expectedValue; + } + + + @ForceInline + static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$Release( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$Acquire( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); + long offset = address(bb, indexRO(bb, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); + return expectedValue; + } +#end[Bitwise] static final VarForm FORM = new VarForm(ByteBufferHandle.class, ByteBuffer.class, $type$.class, int.class); } diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index d37b3e7de5b..f86f5ab69d3 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -2278,6 +2278,24 @@ public final class Unsafe { return v; } + @ForceInline + public final int getAndAddIntRelease(Object o, long offset, int delta) { + int v; + do { + v = getInt(o, offset); + } while (!weakCompareAndSwapIntRelease(o, offset, v, v + delta)); + return v; + } + + @ForceInline + public final int getAndAddIntAcquire(Object o, long offset, int delta) { + int v; + do { + v = getIntAcquire(o, offset); + } while (!weakCompareAndSwapIntAcquire(o, offset, v, v + delta)); + return v; + } + /** * Atomically adds the given value to the current value of a field * or array element within the given object {@code o} @@ -2298,6 +2316,24 @@ public final class Unsafe { return v; } + @ForceInline + public final long getAndAddLongRelease(Object o, long offset, long delta) { + long v; + do { + v = getLong(o, offset); + } while (!weakCompareAndSwapLongRelease(o, offset, v, v + delta)); + return v; + } + + @ForceInline + public final long getAndAddLongAcquire(Object o, long offset, long delta) { + long v; + do { + v = getLongAcquire(o, offset); + } while (!weakCompareAndSwapLongAcquire(o, offset, v, v + delta)); + return v; + } + @HotSpotIntrinsicCandidate public final byte getAndAddByte(Object o, long offset, byte delta) { byte v; @@ -2307,6 +2343,24 @@ public final class Unsafe { return v; } + @ForceInline + public final byte getAndAddByteRelease(Object o, long offset, byte delta) { + byte v; + do { + v = getByte(o, offset); + } while (!weakCompareAndSwapByteRelease(o, offset, v, (byte) (v + delta))); + return v; + } + + @ForceInline + public final byte getAndAddByteAcquire(Object o, long offset, byte delta) { + byte v; + do { + v = getByteAcquire(o, offset); + } while (!weakCompareAndSwapByteAcquire(o, offset, v, (byte) (v + delta))); + return v; + } + @HotSpotIntrinsicCandidate public final short getAndAddShort(Object o, long offset, short delta) { short v; @@ -2316,11 +2370,39 @@ public final class Unsafe { return v; } + @ForceInline + public final short getAndAddShortRelease(Object o, long offset, short delta) { + short v; + do { + v = getShort(o, offset); + } while (!weakCompareAndSwapShortRelease(o, offset, v, (short) (v + delta))); + return v; + } + + @ForceInline + public final short getAndAddShortAcquire(Object o, long offset, short delta) { + short v; + do { + v = getShortAcquire(o, offset); + } while (!weakCompareAndSwapShortAcquire(o, offset, v, (short) (v + delta))); + return v; + } + @ForceInline public final char getAndAddChar(Object o, long offset, char delta) { return (char) getAndAddShort(o, offset, (short) delta); } + @ForceInline + public final char getAndAddCharRelease(Object o, long offset, char delta) { + return (char) getAndAddShortRelease(o, offset, (short) delta); + } + + @ForceInline + public final char getAndAddCharAcquire(Object o, long offset, char delta) { + return (char) getAndAddShortAcquire(o, offset, (short) delta); + } + @ForceInline public final float getAndAddFloat(Object o, long offset, float delta) { int expectedBits; @@ -2336,6 +2418,36 @@ public final class Unsafe { return v; } + @ForceInline + public final float getAndAddFloatRelease(Object o, long offset, float delta) { + int expectedBits; + float v; + do { + // Load and CAS with the raw bits to avoid issues with NaNs and + // possible bit conversion from signaling NaNs to quiet NaNs that + // may result in the loop not terminating. + expectedBits = getInt(o, offset); + v = Float.intBitsToFloat(expectedBits); + } while (!weakCompareAndSwapIntRelease(o, offset, + expectedBits, Float.floatToRawIntBits(v + delta))); + return v; + } + + @ForceInline + public final float getAndAddFloatAcquire(Object o, long offset, float delta) { + int expectedBits; + float v; + do { + // Load and CAS with the raw bits to avoid issues with NaNs and + // possible bit conversion from signaling NaNs to quiet NaNs that + // may result in the loop not terminating. + expectedBits = getIntAcquire(o, offset); + v = Float.intBitsToFloat(expectedBits); + } while (!weakCompareAndSwapIntAcquire(o, offset, + expectedBits, Float.floatToRawIntBits(v + delta))); + return v; + } + @ForceInline public final double getAndAddDouble(Object o, long offset, double delta) { long expectedBits; @@ -2351,6 +2463,36 @@ public final class Unsafe { return v; } + @ForceInline + public final double getAndAddDoubleRelease(Object o, long offset, double delta) { + long expectedBits; + double v; + do { + // Load and CAS with the raw bits to avoid issues with NaNs and + // possible bit conversion from signaling NaNs to quiet NaNs that + // may result in the loop not terminating. + expectedBits = getLong(o, offset); + v = Double.longBitsToDouble(expectedBits); + } while (!weakCompareAndSwapLongRelease(o, offset, + expectedBits, Double.doubleToRawLongBits(v + delta))); + return v; + } + + @ForceInline + public final double getAndAddDoubleAcquire(Object o, long offset, double delta) { + long expectedBits; + double v; + do { + // Load and CAS with the raw bits to avoid issues with NaNs and + // possible bit conversion from signaling NaNs to quiet NaNs that + // may result in the loop not terminating. + expectedBits = getLongAcquire(o, offset); + v = Double.longBitsToDouble(expectedBits); + } while (!weakCompareAndSwapLongAcquire(o, offset, + expectedBits, Double.doubleToRawLongBits(v + delta))); + return v; + } + /** * Atomically exchanges the given value with the current value of * a field or array element within the given object {@code o} @@ -2371,6 +2513,24 @@ public final class Unsafe { return v; } + @ForceInline + public final int getAndSetIntRelease(Object o, long offset, int newValue) { + int v; + do { + v = getInt(o, offset); + } while (!weakCompareAndSwapIntRelease(o, offset, v, newValue)); + return v; + } + + @ForceInline + public final int getAndSetIntAcquire(Object o, long offset, int newValue) { + int v; + do { + v = getIntAcquire(o, offset); + } while (!weakCompareAndSwapIntAcquire(o, offset, v, newValue)); + return v; + } + /** * Atomically exchanges the given value with the current value of * a field or array element within the given object {@code o} @@ -2391,6 +2551,24 @@ public final class Unsafe { return v; } + @ForceInline + public final long getAndSetLongRelease(Object o, long offset, long newValue) { + long v; + do { + v = getLong(o, offset); + } while (!weakCompareAndSwapLongRelease(o, offset, v, newValue)); + return v; + } + + @ForceInline + public final long getAndSetLongAcquire(Object o, long offset, long newValue) { + long v; + do { + v = getLongAcquire(o, offset); + } while (!weakCompareAndSwapLongAcquire(o, offset, v, newValue)); + return v; + } + /** * Atomically exchanges the given reference value with the current * reference value of a field or array element within the given @@ -2411,6 +2589,24 @@ public final class Unsafe { return v; } + @ForceInline + public final Object getAndSetObjectRelease(Object o, long offset, Object newValue) { + Object v; + do { + v = getObject(o, offset); + } while (!weakCompareAndSwapObjectRelease(o, offset, v, newValue)); + return v; + } + + @ForceInline + public final Object getAndSetObjectAcquire(Object o, long offset, Object newValue) { + Object v; + do { + v = getObjectAcquire(o, offset); + } while (!weakCompareAndSwapObjectAcquire(o, offset, v, newValue)); + return v; + } + @HotSpotIntrinsicCandidate public final byte getAndSetByte(Object o, long offset, byte newValue) { byte v; @@ -2420,11 +2616,39 @@ public final class Unsafe { return v; } + @ForceInline + public final byte getAndSetByteRelease(Object o, long offset, byte newValue) { + byte v; + do { + v = getByte(o, offset); + } while (!weakCompareAndSwapByteRelease(o, offset, v, newValue)); + return v; + } + + @ForceInline + public final byte getAndSetByteAcquire(Object o, long offset, byte newValue) { + byte v; + do { + v = getByteAcquire(o, offset); + } while (!weakCompareAndSwapByteAcquire(o, offset, v, newValue)); + return v; + } + @ForceInline public final boolean getAndSetBoolean(Object o, long offset, boolean newValue) { return byte2bool(getAndSetByte(o, offset, bool2byte(newValue))); } + @ForceInline + public final boolean getAndSetBooleanRelease(Object o, long offset, boolean newValue) { + return byte2bool(getAndSetByteRelease(o, offset, bool2byte(newValue))); + } + + @ForceInline + public final boolean getAndSetBooleanAcquire(Object o, long offset, boolean newValue) { + return byte2bool(getAndSetByteAcquire(o, offset, bool2byte(newValue))); + } + @HotSpotIntrinsicCandidate public final short getAndSetShort(Object o, long offset, short newValue) { short v; @@ -2434,23 +2658,559 @@ public final class Unsafe { return v; } + @ForceInline + public final short getAndSetShortRelease(Object o, long offset, short newValue) { + short v; + do { + v = getShort(o, offset); + } while (!weakCompareAndSwapShortRelease(o, offset, v, newValue)); + return v; + } + + @ForceInline + public final short getAndSetShortAcquire(Object o, long offset, short newValue) { + short v; + do { + v = getShortAcquire(o, offset); + } while (!weakCompareAndSwapShortAcquire(o, offset, v, newValue)); + return v; + } + @ForceInline public final char getAndSetChar(Object o, long offset, char newValue) { return s2c(getAndSetShort(o, offset, c2s(newValue))); } + @ForceInline + public final char getAndSetCharRelease(Object o, long offset, char newValue) { + return s2c(getAndSetShortRelease(o, offset, c2s(newValue))); + } + + @ForceInline + public final char getAndSetCharAcquire(Object o, long offset, char newValue) { + return s2c(getAndSetShortAcquire(o, offset, c2s(newValue))); + } + @ForceInline public final float getAndSetFloat(Object o, long offset, float newValue) { int v = getAndSetInt(o, offset, Float.floatToRawIntBits(newValue)); return Float.intBitsToFloat(v); } + @ForceInline + public final float getAndSetFloatRelease(Object o, long offset, float newValue) { + int v = getAndSetIntRelease(o, offset, Float.floatToRawIntBits(newValue)); + return Float.intBitsToFloat(v); + } + + @ForceInline + public final float getAndSetFloatAcquire(Object o, long offset, float newValue) { + int v = getAndSetIntAcquire(o, offset, Float.floatToRawIntBits(newValue)); + return Float.intBitsToFloat(v); + } + @ForceInline public final double getAndSetDouble(Object o, long offset, double newValue) { long v = getAndSetLong(o, offset, Double.doubleToRawLongBits(newValue)); return Double.longBitsToDouble(v); } + @ForceInline + public final double getAndSetDoubleRelease(Object o, long offset, double newValue) { + long v = getAndSetLongRelease(o, offset, Double.doubleToRawLongBits(newValue)); + return Double.longBitsToDouble(v); + } + + @ForceInline + public final double getAndSetDoubleAcquire(Object o, long offset, double newValue) { + long v = getAndSetLongAcquire(o, offset, Double.doubleToRawLongBits(newValue)); + return Double.longBitsToDouble(v); + } + + + // The following contain CAS-based Java implementations used on + // platforms not supporting native instructions + + @ForceInline + public final boolean getAndBitwiseOrBoolean(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseOrByte(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseOrBooleanRelease(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseOrByteRelease(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseOrBooleanAcquire(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseOrByteAcquire(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseAndBoolean(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseAndByte(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseAndBooleanRelease(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseAndByteRelease(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseAndBooleanAcquire(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseAndByteAcquire(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseXorBoolean(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseXorByte(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseXorBooleanRelease(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseXorByteRelease(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseXorBooleanAcquire(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseXorByteAcquire(o, offset, bool2byte(mask))); + } + + + @ForceInline + public final byte getAndBitwiseOrByte(Object o, long offset, byte mask) { + byte current; + do { + current = getByteVolatile(o, offset); + } while (!weakCompareAndSwapByteVolatile(o, offset, + current, (byte) (current | mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseOrByteRelease(Object o, long offset, byte mask) { + byte current; + do { + current = getByte(o, offset); + } while (!weakCompareAndSwapByteRelease(o, offset, + current, (byte) (current | mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseOrByteAcquire(Object o, long offset, byte mask) { + byte current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getByte(o, offset); + } while (!weakCompareAndSwapByteAcquire(o, offset, + current, (byte) (current | mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseAndByte(Object o, long offset, byte mask) { + byte current; + do { + current = getByteVolatile(o, offset); + } while (!weakCompareAndSwapByteVolatile(o, offset, + current, (byte) (current & mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseAndByteRelease(Object o, long offset, byte mask) { + byte current; + do { + current = getByte(o, offset); + } while (!weakCompareAndSwapByteRelease(o, offset, + current, (byte) (current & mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseAndByteAcquire(Object o, long offset, byte mask) { + byte current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getByte(o, offset); + } while (!weakCompareAndSwapByteAcquire(o, offset, + current, (byte) (current & mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseXorByte(Object o, long offset, byte mask) { + byte current; + do { + current = getByteVolatile(o, offset); + } while (!weakCompareAndSwapByteVolatile(o, offset, + current, (byte) (current ^ mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseXorByteRelease(Object o, long offset, byte mask) { + byte current; + do { + current = getByte(o, offset); + } while (!weakCompareAndSwapByteRelease(o, offset, + current, (byte) (current ^ mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseXorByteAcquire(Object o, long offset, byte mask) { + byte current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getByte(o, offset); + } while (!weakCompareAndSwapByteAcquire(o, offset, + current, (byte) (current ^ mask))); + return current; + } + + + @ForceInline + public final char getAndBitwiseOrChar(Object o, long offset, char mask) { + return s2c(getAndBitwiseOrShort(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseOrCharRelease(Object o, long offset, char mask) { + return s2c(getAndBitwiseOrShortRelease(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseOrCharAcquire(Object o, long offset, char mask) { + return s2c(getAndBitwiseOrShortAcquire(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseAndChar(Object o, long offset, char mask) { + return s2c(getAndBitwiseAndShort(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseAndCharRelease(Object o, long offset, char mask) { + return s2c(getAndBitwiseAndShortRelease(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseAndCharAcquire(Object o, long offset, char mask) { + return s2c(getAndBitwiseAndShortAcquire(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseXorChar(Object o, long offset, char mask) { + return s2c(getAndBitwiseXorShort(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseXorCharRelease(Object o, long offset, char mask) { + return s2c(getAndBitwiseXorShortRelease(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseXorCharAcquire(Object o, long offset, char mask) { + return s2c(getAndBitwiseXorShortAcquire(o, offset, c2s(mask))); + } + + + @ForceInline + public final short getAndBitwiseOrShort(Object o, long offset, short mask) { + short current; + do { + current = getShortVolatile(o, offset); + } while (!weakCompareAndSwapShortVolatile(o, offset, + current, (short) (current | mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseOrShortRelease(Object o, long offset, short mask) { + short current; + do { + current = getShort(o, offset); + } while (!weakCompareAndSwapShortRelease(o, offset, + current, (short) (current | mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseOrShortAcquire(Object o, long offset, short mask) { + short current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getShort(o, offset); + } while (!weakCompareAndSwapShortAcquire(o, offset, + current, (short) (current | mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseAndShort(Object o, long offset, short mask) { + short current; + do { + current = getShortVolatile(o, offset); + } while (!weakCompareAndSwapShortVolatile(o, offset, + current, (short) (current & mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseAndShortRelease(Object o, long offset, short mask) { + short current; + do { + current = getShort(o, offset); + } while (!weakCompareAndSwapShortRelease(o, offset, + current, (short) (current & mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseAndShortAcquire(Object o, long offset, short mask) { + short current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getShort(o, offset); + } while (!weakCompareAndSwapShortAcquire(o, offset, + current, (short) (current & mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseXorShort(Object o, long offset, short mask) { + short current; + do { + current = getShortVolatile(o, offset); + } while (!weakCompareAndSwapShortVolatile(o, offset, + current, (short) (current ^ mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseXorShortRelease(Object o, long offset, short mask) { + short current; + do { + current = getShort(o, offset); + } while (!weakCompareAndSwapShortRelease(o, offset, + current, (short) (current ^ mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseXorShortAcquire(Object o, long offset, short mask) { + short current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getShort(o, offset); + } while (!weakCompareAndSwapShortAcquire(o, offset, + current, (short) (current ^ mask))); + return current; + } + + + @ForceInline + public final int getAndBitwiseOrInt(Object o, long offset, int mask) { + int current; + do { + current = getIntVolatile(o, offset); + } while (!weakCompareAndSwapIntVolatile(o, offset, + current, current | mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseOrIntRelease(Object o, long offset, int mask) { + int current; + do { + current = getInt(o, offset); + } while (!weakCompareAndSwapIntRelease(o, offset, + current, current | mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseOrIntAcquire(Object o, long offset, int mask) { + int current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getInt(o, offset); + } while (!weakCompareAndSwapIntAcquire(o, offset, + current, current | mask)); + return current; + } + + /** + * Atomically replaces the current value of a field or array element within + * the given object with the result of bitwise AND between the current value + * and mask. + * + * @param o object/array to update the field/element in + * @param offset field/element offset + * @param mask the mask value + * @return the previous value + * @since 1.9 + */ + @ForceInline + public final int getAndBitwiseAndInt(Object o, long offset, int mask) { + int current; + do { + current = getIntVolatile(o, offset); + } while (!weakCompareAndSwapIntVolatile(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseAndIntRelease(Object o, long offset, int mask) { + int current; + do { + current = getInt(o, offset); + } while (!weakCompareAndSwapIntRelease(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseAndIntAcquire(Object o, long offset, int mask) { + int current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getInt(o, offset); + } while (!weakCompareAndSwapIntAcquire(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseXorInt(Object o, long offset, int mask) { + int current; + do { + current = getIntVolatile(o, offset); + } while (!weakCompareAndSwapIntVolatile(o, offset, + current, current ^ mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseXorIntRelease(Object o, long offset, int mask) { + int current; + do { + current = getInt(o, offset); + } while (!weakCompareAndSwapIntRelease(o, offset, + current, current ^ mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseXorIntAcquire(Object o, long offset, int mask) { + int current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getInt(o, offset); + } while (!weakCompareAndSwapIntAcquire(o, offset, + current, current ^ mask)); + return current; + } + + + @ForceInline + public final long getAndBitwiseOrLong(Object o, long offset, long mask) { + long current; + do { + current = getLongVolatile(o, offset); + } while (!weakCompareAndSwapLongVolatile(o, offset, + current, current | mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseOrLongRelease(Object o, long offset, long mask) { + long current; + do { + current = getLong(o, offset); + } while (!weakCompareAndSwapLongRelease(o, offset, + current, current | mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseOrLongAcquire(Object o, long offset, long mask) { + long current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getLong(o, offset); + } while (!weakCompareAndSwapLongAcquire(o, offset, + current, current | mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseAndLong(Object o, long offset, long mask) { + long current; + do { + current = getLongVolatile(o, offset); + } while (!weakCompareAndSwapLongVolatile(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseAndLongRelease(Object o, long offset, long mask) { + long current; + do { + current = getLong(o, offset); + } while (!weakCompareAndSwapLongRelease(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseAndLongAcquire(Object o, long offset, long mask) { + long current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getLong(o, offset); + } while (!weakCompareAndSwapLongAcquire(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseXorLong(Object o, long offset, long mask) { + long current; + do { + current = getLongVolatile(o, offset); + } while (!weakCompareAndSwapLongVolatile(o, offset, + current, current ^ mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseXorLongRelease(Object o, long offset, long mask) { + long current; + do { + current = getLong(o, offset); + } while (!weakCompareAndSwapLongRelease(o, offset, + current, current ^ mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseXorLongAcquire(Object o, long offset, long mask) { + long current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getLong(o, offset); + } while (!weakCompareAndSwapLongAcquire(o, offset, + current, current ^ mask)); + return current; + } + + + /** * Ensures that loads before the fence will not be reordered with loads and * stores after the fence; a "LoadLoad plus LoadStore barrier". diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java index ed3160b9979..8bfd8ff1072 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java @@ -132,7 +132,8 @@ abstract class VarHandleBaseTest { COMPARE_AND_SET, COMPARE_AND_EXCHANGE, GET_AND_SET, - GET_AND_ADD; + GET_AND_ADD, + GET_AND_BITWISE; } enum TestAccessMode { @@ -153,8 +154,22 @@ abstract class VarHandleBaseTest { WEAK_COMPARE_AND_SET_ACQUIRE(TestAccessType.COMPARE_AND_SET), WEAK_COMPARE_AND_SET_RELEASE(TestAccessType.COMPARE_AND_SET), GET_AND_SET(TestAccessType.GET_AND_SET), + GET_AND_SET_ACQUIRE(TestAccessType.GET_AND_SET), + GET_AND_SET_RELEASE(TestAccessType.GET_AND_SET), GET_AND_ADD(TestAccessType.GET_AND_ADD), - ADD_AND_GET(TestAccessType.GET_AND_ADD),; + GET_AND_ADD_ACQUIRE(TestAccessType.GET_AND_ADD), + GET_AND_ADD_RELEASE(TestAccessType.GET_AND_ADD), + ADD_AND_GET(TestAccessType.GET_AND_ADD), + GET_AND_BITWISE_OR(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_OR_ACQUIRE(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_OR_RELEASE(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_AND(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_AND_ACQUIRE(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_AND_RELEASE(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_XOR(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_XOR_ACQUIRE(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_XOR_RELEASE(TestAccessType.GET_AND_BITWISE), + ; final TestAccessType at; final boolean isPolyMorphicInReturnType; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java index ae23346c689..ab255e31c47 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java @@ -108,9 +108,23 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -265,9 +279,18 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndAdd(recv, true); }); + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddAcquire(recv, true); + }); + + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddRelease(recv, true); + }); + checkUOE(() -> { boolean o = (boolean) vh.addAndGet(recv, true); }); + } @@ -320,9 +343,18 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndAdd(true); }); + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddAcquire(true); + }); + + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddRelease(true); + }); + checkUOE(() -> { boolean o = (boolean) vh.addAndGet(true); }); + } @@ -457,12 +489,116 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { // Compare set and get { + vh.set(recv, true); + boolean o = (boolean) vh.getAndSet(recv, false); assertEquals(o, true, "getAndSet boolean"); boolean x = (boolean) vh.get(recv); assertEquals(x, false, "getAndSet boolean value"); } + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndSetAcquire(recv, false); + assertEquals(o, true, "getAndSetAcquire boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, false, "getAndSetAcquire boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndSetRelease(recv, false); + assertEquals(o, true, "getAndSetRelease boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, false, "getAndSetRelease boolean value"); + } + + + // get and bitwise or + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseOr(recv, false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseOrAcquire(recv, false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseOrRelease(recv, false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseAnd(recv, false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseAndAcquire(recv, false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseAndRelease(recv, false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseXor(recv, false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseXorAcquire(recv, false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseXorRelease(recv, false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } static void testInstanceFieldUnsupported(VarHandleTestAccessBoolean recv, VarHandle vh) { @@ -471,9 +607,18 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndAdd(recv, true); }); + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddAcquire(recv, true); + }); + + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddRelease(recv, true); + }); + checkUOE(() -> { boolean o = (boolean) vh.addAndGet(recv, true); }); + } @@ -608,12 +753,116 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { // Compare set and get { + vh.set(true); + boolean o = (boolean) vh.getAndSet(false); assertEquals(o, true, "getAndSet boolean"); boolean x = (boolean) vh.get(); assertEquals(x, false, "getAndSet boolean value"); } + { + vh.set(true); + + boolean o = (boolean) vh.getAndSetAcquire(false); + assertEquals(o, true, "getAndSetAcquire boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, false, "getAndSetAcquire boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndSetRelease(false); + assertEquals(o, true, "getAndSetRelease boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, false, "getAndSetRelease boolean value"); + } + + + // get and bitwise or + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseOr(false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseOrAcquire(false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseOrRelease(false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseAnd(false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseAndAcquire(false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseAndRelease(false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseXor(false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseXorAcquire(false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseXorRelease(false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } static void testStaticFieldUnsupported(VarHandle vh) { @@ -622,9 +871,18 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndAdd(true); }); + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddAcquire(true); + }); + + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddRelease(true); + }); + checkUOE(() -> { boolean o = (boolean) vh.addAndGet(true); }); + } @@ -762,12 +1020,116 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { // Compare set and get { + vh.set(array, i, true); + boolean o = (boolean) vh.getAndSet(array, i, false); assertEquals(o, true, "getAndSet boolean"); boolean x = (boolean) vh.get(array, i); assertEquals(x, false, "getAndSet boolean value"); } + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndSetAcquire(array, i, false); + assertEquals(o, true, "getAndSetAcquire boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, false, "getAndSetAcquire boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndSetRelease(array, i, false); + assertEquals(o, true, "getAndSetRelease boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, false, "getAndSetRelease boolean value"); + } + + + // get and bitwise or + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseOr(array, i, false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseOrAcquire(array, i, false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseOrRelease(array, i, false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseAnd(array, i, false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseAndAcquire(array, i, false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseAndRelease(array, i, false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseXor(array, i, false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseXorAcquire(array, i, false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseXorRelease(array, i, false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } } @@ -780,9 +1142,18 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndAdd(array, i, true); }); + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddAcquire(array, i, true); + }); + + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddRelease(array, i, true); + }); + checkUOE(() -> { boolean o = (boolean) vh.addAndGet(array, i, true); }); + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -859,6 +1230,50 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndSet(array, ci, true); }); + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndSetAcquire(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndSetRelease(array, ci, true); + }); + + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseOr(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseOrAcquire(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseOrRelease(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseAnd(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseAndAcquire(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseAndRelease(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseXor(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseXorAcquire(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseXorRelease(array, ci, true); + }); } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java index 754f4908a8a..84c1faab50d 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java @@ -108,9 +108,23 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +275,7 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { }); + } @@ -309,6 +324,7 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { }); + } @@ -443,25 +459,148 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { // Compare set and get { + vh.set(recv, (byte)0x01); + byte o = (byte) vh.getAndSet(recv, (byte)0x23); assertEquals(o, (byte)0x01, "getAndSet byte"); byte x = (byte) vh.get(recv); assertEquals(x, (byte)0x23, "getAndSet byte value"); } - vh.set(recv, (byte)0x01); + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndSetAcquire(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetAcquire byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)0x23, "getAndSetAcquire byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndSetRelease(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetRelease byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)0x23, "getAndSetRelease byte value"); + } // get and add, add and get { + vh.set(recv, (byte)0x01); + byte o = (byte) vh.getAndAdd(recv, (byte)0x45); assertEquals(o, (byte)0x01, "getAndAdd byte"); byte c = (byte) vh.addAndGet(recv, (byte)0x45); assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndAddAcquire(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndAddRelease(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddReleasebyte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOr(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrAcquire(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrRelease(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAnd(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndAcquire(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndRelease(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXor(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorAcquire(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorRelease(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); + } } static void testInstanceFieldUnsupported(VarHandleTestAccessByte recv, VarHandle vh) { + } @@ -596,25 +735,148 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { // Compare set and get { + vh.set((byte)0x01); + byte o = (byte) vh.getAndSet((byte)0x23); assertEquals(o, (byte)0x01, "getAndSet byte"); byte x = (byte) vh.get(); assertEquals(x, (byte)0x23, "getAndSet byte value"); } - vh.set((byte)0x01); + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndSetAcquire((byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetAcquire byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)0x23, "getAndSetAcquire byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndSetRelease((byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetRelease byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)0x23, "getAndSetRelease byte value"); + } // get and add, add and get { + vh.set((byte)0x01); + byte o = (byte) vh.getAndAdd( (byte)0x45); assertEquals(o, (byte)0x01, "getAndAdd byte"); byte c = (byte) vh.addAndGet((byte)0x45); assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndAddAcquire((byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndAddRelease((byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddReleasebyte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseOr((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrAcquire((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrRelease((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseAnd((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndAcquire((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndRelease((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseXor((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorAcquire((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorRelease((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); + } } static void testStaticFieldUnsupported(VarHandle vh) { + } @@ -752,21 +1014,143 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { // Compare set and get { + vh.set(array, i, (byte)0x01); + byte o = (byte) vh.getAndSet(array, i, (byte)0x23); assertEquals(o, (byte)0x01, "getAndSet byte"); byte x = (byte) vh.get(array, i); assertEquals(x, (byte)0x23, "getAndSet byte value"); } - vh.set(array, i, (byte)0x01); + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndSetAcquire(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetAcquire byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)0x23, "getAndSetAcquire byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndSetRelease(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetRelease byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)0x23, "getAndSetRelease byte value"); + } // get and add, add and get { + vh.set(array, i, (byte)0x01); + byte o = (byte) vh.getAndAdd(array, i, (byte)0x45); assertEquals(o, (byte)0x01, "getAndAdd byte"); byte c = (byte) vh.addAndGet(array, i, (byte)0x45); assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndAddAcquire(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndAddRelease(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddReleasebyte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOr(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrAcquire(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrRelease(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAnd(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndAcquire(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndRelease(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXor(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorAcquire(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorRelease(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); + } } } @@ -775,6 +1159,7 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { int i = 0; + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -852,11 +1237,63 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { }); checkIOOBE(() -> { - byte o = (byte) vh.getAndAdd(array, ci, (byte)0x45); + byte o = (byte) vh.getAndSetAcquire(array, ci, (byte)0x01); }); checkIOOBE(() -> { - byte o = (byte) vh.addAndGet(array, ci, (byte)0x45); + byte o = (byte) vh.getAndSetRelease(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndAdd(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndAddAcquire(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndAddRelease(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.addAndGet(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseOr(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseOrAcquire(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseOrRelease(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseAnd(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseAndAcquire(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseAndRelease(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseXor(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseXorAcquire(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseXorRelease(array, ci, (byte)0x01); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java index 9a0af41e930..b0c89a4ac3b 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java @@ -108,9 +108,23 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +275,7 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { }); + } @@ -309,6 +324,7 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { }); + } @@ -443,25 +459,148 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { // Compare set and get { + vh.set(recv, '\u0123'); + char o = (char) vh.getAndSet(recv, '\u4567'); assertEquals(o, '\u0123', "getAndSet char"); char x = (char) vh.get(recv); assertEquals(x, '\u4567', "getAndSet char value"); } - vh.set(recv, '\u0123'); + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndSetAcquire(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndSetAcquire char"); + char x = (char) vh.get(recv); + assertEquals(x, '\u4567', "getAndSetAcquire char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndSetRelease(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndSetRelease char"); + char x = (char) vh.get(recv); + assertEquals(x, '\u4567', "getAndSetRelease char value"); + } // get and add, add and get { + vh.set(recv, '\u0123'); + char o = (char) vh.getAndAdd(recv, '\u89AB'); assertEquals(o, '\u0123', "getAndAdd char"); char c = (char) vh.addAndGet(recv, '\u89AB'); assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndAddAcquire(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndAddRelease(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndAddReleasechar"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseOr(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseOrAcquire(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseOrRelease(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseAnd(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseAndAcquire(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseAndRelease(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseXor(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseXorAcquire(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseXorRelease(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); + } } static void testInstanceFieldUnsupported(VarHandleTestAccessChar recv, VarHandle vh) { + } @@ -596,25 +735,148 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { // Compare set and get { + vh.set('\u0123'); + char o = (char) vh.getAndSet('\u4567'); assertEquals(o, '\u0123', "getAndSet char"); char x = (char) vh.get(); assertEquals(x, '\u4567', "getAndSet char value"); } - vh.set('\u0123'); + { + vh.set('\u0123'); + + char o = (char) vh.getAndSetAcquire('\u4567'); + assertEquals(o, '\u0123', "getAndSetAcquire char"); + char x = (char) vh.get(); + assertEquals(x, '\u4567', "getAndSetAcquire char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndSetRelease('\u4567'); + assertEquals(o, '\u0123', "getAndSetRelease char"); + char x = (char) vh.get(); + assertEquals(x, '\u4567', "getAndSetRelease char value"); + } // get and add, add and get { + vh.set('\u0123'); + char o = (char) vh.getAndAdd( '\u89AB'); assertEquals(o, '\u0123', "getAndAdd char"); char c = (char) vh.addAndGet('\u89AB'); assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndAddAcquire('\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndAddRelease('\u4567'); + assertEquals(o, '\u0123', "getAndAddReleasechar"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseOr('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseOrAcquire('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseOrRelease('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseAnd('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseAndAcquire('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseAndRelease('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseXor('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseXorAcquire('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseXorRelease('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); + } } static void testStaticFieldUnsupported(VarHandle vh) { + } @@ -752,21 +1014,143 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { // Compare set and get { + vh.set(array, i, '\u0123'); + char o = (char) vh.getAndSet(array, i, '\u4567'); assertEquals(o, '\u0123', "getAndSet char"); char x = (char) vh.get(array, i); assertEquals(x, '\u4567', "getAndSet char value"); } - vh.set(array, i, '\u0123'); + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndSetAcquire(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndSetAcquire char"); + char x = (char) vh.get(array, i); + assertEquals(x, '\u4567', "getAndSetAcquire char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndSetRelease(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndSetRelease char"); + char x = (char) vh.get(array, i); + assertEquals(x, '\u4567', "getAndSetRelease char value"); + } // get and add, add and get { + vh.set(array, i, '\u0123'); + char o = (char) vh.getAndAdd(array, i, '\u89AB'); assertEquals(o, '\u0123', "getAndAdd char"); char c = (char) vh.addAndGet(array, i, '\u89AB'); assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndAddAcquire(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndAddRelease(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndAddReleasechar"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseOr(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseOrAcquire(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseOrRelease(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseAnd(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseAndAcquire(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseAndRelease(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseXor(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseXorAcquire(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseXorRelease(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); + } } } @@ -775,6 +1159,7 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { int i = 0; + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -852,11 +1237,63 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { }); checkIOOBE(() -> { - char o = (char) vh.getAndAdd(array, ci, '\u89AB'); + char o = (char) vh.getAndSetAcquire(array, ci, '\u0123'); }); checkIOOBE(() -> { - char o = (char) vh.addAndGet(array, ci, '\u89AB'); + char o = (char) vh.getAndSetRelease(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndAdd(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndAddAcquire(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndAddRelease(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.addAndGet(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseOr(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseOrAcquire(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseOrRelease(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseAnd(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseAndAcquire(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseAndRelease(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseXor(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseXorAcquire(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseXorRelease(array, ci, '\u0123'); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java index 710aae87fc1..1ae86e490b5 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java @@ -108,9 +108,23 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +275,42 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(recv, 1.0d); + }); } @@ -309,6 +359,42 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(1.0d); + }); } @@ -443,25 +529,100 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { // Compare set and get { + vh.set(recv, 1.0d); + double o = (double) vh.getAndSet(recv, 2.0d); assertEquals(o, 1.0d, "getAndSet double"); double x = (double) vh.get(recv); assertEquals(x, 2.0d, "getAndSet double value"); } - vh.set(recv, 1.0d); + { + vh.set(recv, 1.0d); + + double o = (double) vh.getAndSetAcquire(recv, 2.0d); + assertEquals(o, 1.0d, "getAndSetAcquire double"); + double x = (double) vh.get(recv); + assertEquals(x, 2.0d, "getAndSetAcquire double value"); + } + + { + vh.set(recv, 1.0d); + + double o = (double) vh.getAndSetRelease(recv, 2.0d); + assertEquals(o, 1.0d, "getAndSetRelease double"); + double x = (double) vh.get(recv); + assertEquals(x, 2.0d, "getAndSetRelease double value"); + } // get and add, add and get { + vh.set(recv, 1.0d); + double o = (double) vh.getAndAdd(recv, 3.0d); assertEquals(o, 1.0d, "getAndAdd double"); double c = (double) vh.addAndGet(recv, 3.0d); assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); } + + { + vh.set(recv, 1.0d); + + double o = (double) vh.getAndAddAcquire(recv, 2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) vh.get(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + vh.set(recv, 1.0d); + + double o = (double) vh.getAndAddRelease(recv, 2.0d); + assertEquals(o, 1.0d, "getAndAddReleasedouble"); + double x = (double) vh.get(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } static void testInstanceFieldUnsupported(VarHandleTestAccessDouble recv, VarHandle vh) { + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(recv, 1.0d); + }); } @@ -596,25 +757,100 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { // Compare set and get { + vh.set(1.0d); + double o = (double) vh.getAndSet(2.0d); assertEquals(o, 1.0d, "getAndSet double"); double x = (double) vh.get(); assertEquals(x, 2.0d, "getAndSet double value"); } - vh.set(1.0d); + { + vh.set(1.0d); + + double o = (double) vh.getAndSetAcquire(2.0d); + assertEquals(o, 1.0d, "getAndSetAcquire double"); + double x = (double) vh.get(); + assertEquals(x, 2.0d, "getAndSetAcquire double value"); + } + + { + vh.set(1.0d); + + double o = (double) vh.getAndSetRelease(2.0d); + assertEquals(o, 1.0d, "getAndSetRelease double"); + double x = (double) vh.get(); + assertEquals(x, 2.0d, "getAndSetRelease double value"); + } // get and add, add and get { + vh.set(1.0d); + double o = (double) vh.getAndAdd( 3.0d); assertEquals(o, 1.0d, "getAndAdd double"); double c = (double) vh.addAndGet(3.0d); assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); } + + { + vh.set(1.0d); + + double o = (double) vh.getAndAddAcquire(2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) vh.get(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + vh.set(1.0d); + + double o = (double) vh.getAndAddRelease(2.0d); + assertEquals(o, 1.0d, "getAndAddReleasedouble"); + double x = (double) vh.get(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } static void testStaticFieldUnsupported(VarHandle vh) { + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(1.0d); + }); } @@ -752,21 +988,60 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { // Compare set and get { + vh.set(array, i, 1.0d); + double o = (double) vh.getAndSet(array, i, 2.0d); assertEquals(o, 1.0d, "getAndSet double"); double x = (double) vh.get(array, i); assertEquals(x, 2.0d, "getAndSet double value"); } - vh.set(array, i, 1.0d); + { + vh.set(array, i, 1.0d); + + double o = (double) vh.getAndSetAcquire(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndSetAcquire double"); + double x = (double) vh.get(array, i); + assertEquals(x, 2.0d, "getAndSetAcquire double value"); + } + + { + vh.set(array, i, 1.0d); + + double o = (double) vh.getAndSetRelease(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndSetRelease double"); + double x = (double) vh.get(array, i); + assertEquals(x, 2.0d, "getAndSetRelease double value"); + } // get and add, add and get { + vh.set(array, i, 1.0d); + double o = (double) vh.getAndAdd(array, i, 3.0d); assertEquals(o, 1.0d, "getAndAdd double"); double c = (double) vh.addAndGet(array, i, 3.0d); assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); } + + { + vh.set(array, i, 1.0d); + + double o = (double) vh.getAndAddAcquire(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) vh.get(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + vh.set(array, i, 1.0d); + + double o = (double) vh.getAndAddRelease(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndAddReleasedouble"); + double x = (double) vh.get(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } } @@ -775,6 +1050,42 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { int i = 0; + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(array, i, 1.0d); + }); } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -852,12 +1163,29 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { }); checkIOOBE(() -> { - double o = (double) vh.getAndAdd(array, ci, 3.0d); + double o = (double) vh.getAndSetAcquire(array, ci, 1.0d); }); checkIOOBE(() -> { - double o = (double) vh.addAndGet(array, ci, 3.0d); + double o = (double) vh.getAndSetRelease(array, ci, 1.0d); }); + + checkIOOBE(() -> { + double o = (double) vh.getAndAdd(array, ci, 1.0d); + }); + + checkIOOBE(() -> { + double o = (double) vh.getAndAddAcquire(array, ci, 1.0d); + }); + + checkIOOBE(() -> { + double o = (double) vh.getAndAddRelease(array, ci, 1.0d); + }); + + checkIOOBE(() -> { + double o = (double) vh.addAndGet(array, ci, 1.0d); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java index 4a2306bcab6..7b8f7046300 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java @@ -108,9 +108,23 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +275,42 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(recv, 1.0f); + }); } @@ -309,6 +359,42 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(1.0f); + }); } @@ -443,25 +529,100 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { // Compare set and get { + vh.set(recv, 1.0f); + float o = (float) vh.getAndSet(recv, 2.0f); assertEquals(o, 1.0f, "getAndSet float"); float x = (float) vh.get(recv); assertEquals(x, 2.0f, "getAndSet float value"); } - vh.set(recv, 1.0f); + { + vh.set(recv, 1.0f); + + float o = (float) vh.getAndSetAcquire(recv, 2.0f); + assertEquals(o, 1.0f, "getAndSetAcquire float"); + float x = (float) vh.get(recv); + assertEquals(x, 2.0f, "getAndSetAcquire float value"); + } + + { + vh.set(recv, 1.0f); + + float o = (float) vh.getAndSetRelease(recv, 2.0f); + assertEquals(o, 1.0f, "getAndSetRelease float"); + float x = (float) vh.get(recv); + assertEquals(x, 2.0f, "getAndSetRelease float value"); + } // get and add, add and get { + vh.set(recv, 1.0f); + float o = (float) vh.getAndAdd(recv, 3.0f); assertEquals(o, 1.0f, "getAndAdd float"); float c = (float) vh.addAndGet(recv, 3.0f); assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); } + + { + vh.set(recv, 1.0f); + + float o = (float) vh.getAndAddAcquire(recv, 2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) vh.get(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + vh.set(recv, 1.0f); + + float o = (float) vh.getAndAddRelease(recv, 2.0f); + assertEquals(o, 1.0f, "getAndAddReleasefloat"); + float x = (float) vh.get(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } static void testInstanceFieldUnsupported(VarHandleTestAccessFloat recv, VarHandle vh) { + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(recv, 1.0f); + }); } @@ -596,25 +757,100 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { // Compare set and get { + vh.set(1.0f); + float o = (float) vh.getAndSet(2.0f); assertEquals(o, 1.0f, "getAndSet float"); float x = (float) vh.get(); assertEquals(x, 2.0f, "getAndSet float value"); } - vh.set(1.0f); + { + vh.set(1.0f); + + float o = (float) vh.getAndSetAcquire(2.0f); + assertEquals(o, 1.0f, "getAndSetAcquire float"); + float x = (float) vh.get(); + assertEquals(x, 2.0f, "getAndSetAcquire float value"); + } + + { + vh.set(1.0f); + + float o = (float) vh.getAndSetRelease(2.0f); + assertEquals(o, 1.0f, "getAndSetRelease float"); + float x = (float) vh.get(); + assertEquals(x, 2.0f, "getAndSetRelease float value"); + } // get and add, add and get { + vh.set(1.0f); + float o = (float) vh.getAndAdd( 3.0f); assertEquals(o, 1.0f, "getAndAdd float"); float c = (float) vh.addAndGet(3.0f); assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); } + + { + vh.set(1.0f); + + float o = (float) vh.getAndAddAcquire(2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) vh.get(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + vh.set(1.0f); + + float o = (float) vh.getAndAddRelease(2.0f); + assertEquals(o, 1.0f, "getAndAddReleasefloat"); + float x = (float) vh.get(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } static void testStaticFieldUnsupported(VarHandle vh) { + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(1.0f); + }); } @@ -752,21 +988,60 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { // Compare set and get { + vh.set(array, i, 1.0f); + float o = (float) vh.getAndSet(array, i, 2.0f); assertEquals(o, 1.0f, "getAndSet float"); float x = (float) vh.get(array, i); assertEquals(x, 2.0f, "getAndSet float value"); } - vh.set(array, i, 1.0f); + { + vh.set(array, i, 1.0f); + + float o = (float) vh.getAndSetAcquire(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndSetAcquire float"); + float x = (float) vh.get(array, i); + assertEquals(x, 2.0f, "getAndSetAcquire float value"); + } + + { + vh.set(array, i, 1.0f); + + float o = (float) vh.getAndSetRelease(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndSetRelease float"); + float x = (float) vh.get(array, i); + assertEquals(x, 2.0f, "getAndSetRelease float value"); + } // get and add, add and get { + vh.set(array, i, 1.0f); + float o = (float) vh.getAndAdd(array, i, 3.0f); assertEquals(o, 1.0f, "getAndAdd float"); float c = (float) vh.addAndGet(array, i, 3.0f); assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); } + + { + vh.set(array, i, 1.0f); + + float o = (float) vh.getAndAddAcquire(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) vh.get(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + vh.set(array, i, 1.0f); + + float o = (float) vh.getAndAddRelease(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndAddReleasefloat"); + float x = (float) vh.get(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } } @@ -775,6 +1050,42 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { int i = 0; + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(array, i, 1.0f); + }); } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -852,12 +1163,29 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { }); checkIOOBE(() -> { - float o = (float) vh.getAndAdd(array, ci, 3.0f); + float o = (float) vh.getAndSetAcquire(array, ci, 1.0f); }); checkIOOBE(() -> { - float o = (float) vh.addAndGet(array, ci, 3.0f); + float o = (float) vh.getAndSetRelease(array, ci, 1.0f); }); + + checkIOOBE(() -> { + float o = (float) vh.getAndAdd(array, ci, 1.0f); + }); + + checkIOOBE(() -> { + float o = (float) vh.getAndAddAcquire(array, ci, 1.0f); + }); + + checkIOOBE(() -> { + float o = (float) vh.getAndAddRelease(array, ci, 1.0f); + }); + + checkIOOBE(() -> { + float o = (float) vh.addAndGet(array, ci, 1.0f); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java index 930ba12eb89..bdd06f5a681 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java @@ -108,9 +108,23 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +275,7 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { }); + } @@ -309,6 +324,7 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { }); + } @@ -443,25 +459,148 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { // Compare set and get { + vh.set(recv, 0x01234567); + int o = (int) vh.getAndSet(recv, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndSet int"); int x = (int) vh.get(recv); assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - vh.set(recv, 0x01234567); + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndSetAcquire(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetAcquire int"); + int x = (int) vh.get(recv); + assertEquals(x, 0x89ABCDEF, "getAndSetAcquire int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndSetRelease(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetRelease int"); + int x = (int) vh.get(recv); + assertEquals(x, 0x89ABCDEF, "getAndSetRelease int value"); + } // get and add, add and get { + vh.set(recv, 0x01234567); + int o = (int) vh.getAndAdd(recv, 0xCAFEBABE); assertEquals(o, 0x01234567, "getAndAdd int"); int c = (int) vh.addAndGet(recv, 0xCAFEBABE); assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndAddAcquire(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndAddRelease(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddReleaseint"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseOr(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseOrAcquire(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseOrRelease(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseAnd(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseAndAcquire(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseAndRelease(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseXor(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseXorAcquire(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseXorRelease(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); + } } static void testInstanceFieldUnsupported(VarHandleTestAccessInt recv, VarHandle vh) { + } @@ -596,25 +735,148 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { // Compare set and get { + vh.set(0x01234567); + int o = (int) vh.getAndSet(0x89ABCDEF); assertEquals(o, 0x01234567, "getAndSet int"); int x = (int) vh.get(); assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - vh.set(0x01234567); + { + vh.set(0x01234567); + + int o = (int) vh.getAndSetAcquire(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetAcquire int"); + int x = (int) vh.get(); + assertEquals(x, 0x89ABCDEF, "getAndSetAcquire int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndSetRelease(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetRelease int"); + int x = (int) vh.get(); + assertEquals(x, 0x89ABCDEF, "getAndSetRelease int value"); + } // get and add, add and get { + vh.set(0x01234567); + int o = (int) vh.getAndAdd( 0xCAFEBABE); assertEquals(o, 0x01234567, "getAndAdd int"); int c = (int) vh.addAndGet(0xCAFEBABE); assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndAddAcquire(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndAddRelease(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddReleaseint"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseOr(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseOrAcquire(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseOrRelease(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseAnd(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseAndAcquire(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseAndRelease(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseXor(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseXorAcquire(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseXorRelease(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); + } } static void testStaticFieldUnsupported(VarHandle vh) { + } @@ -752,21 +1014,143 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { // Compare set and get { + vh.set(array, i, 0x01234567); + int o = (int) vh.getAndSet(array, i, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - vh.set(array, i, 0x01234567); + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndSetAcquire(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, 0x89ABCDEF, "getAndSetAcquire int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndSetRelease(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, 0x89ABCDEF, "getAndSetRelease int value"); + } // get and add, add and get { + vh.set(array, i, 0x01234567); + int o = (int) vh.getAndAdd(array, i, 0xCAFEBABE); assertEquals(o, 0x01234567, "getAndAdd int"); int c = (int) vh.addAndGet(array, i, 0xCAFEBABE); assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndAddAcquire(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndAddRelease(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddReleaseint"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseOr(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseOrAcquire(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseOrRelease(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseAnd(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseAndAcquire(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseAndRelease(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseXor(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseXorAcquire(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseXorRelease(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); + } } } @@ -775,6 +1159,7 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { int i = 0; + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -852,11 +1237,63 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { }); checkIOOBE(() -> { - int o = (int) vh.getAndAdd(array, ci, 0xCAFEBABE); + int o = (int) vh.getAndSetAcquire(array, ci, 0x01234567); }); checkIOOBE(() -> { - int o = (int) vh.addAndGet(array, ci, 0xCAFEBABE); + int o = (int) vh.getAndSetRelease(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndAdd(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndAddAcquire(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.addAndGet(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, 0x01234567); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java index 257e56b3b32..c58fc2d4ef7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java @@ -108,9 +108,23 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +275,7 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { }); + } @@ -309,6 +324,7 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { }); + } @@ -443,25 +459,148 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { // Compare set and get { + vh.set(recv, 0x0123456789ABCDEFL); + long o = (long) vh.getAndSet(recv, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long"); long x = (long) vh.get(recv); assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - vh.set(recv, 0x0123456789ABCDEFL); + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetAcquire(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetAcquire long"); + long x = (long) vh.get(recv); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetAcquire long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetRelease(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetRelease long"); + long x = (long) vh.get(recv); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetRelease long value"); + } // get and add, add and get { + vh.set(recv, 0x0123456789ABCDEFL); + long o = (long) vh.getAndAdd(recv, 0xDEADBEEFDEADBEEFL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); long c = (long) vh.addAndGet(recv, 0xDEADBEEFDEADBEEFL); assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddAcquire(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddRelease(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddReleaselong"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOr(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrAcquire(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrRelease(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAnd(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndAcquire(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndRelease(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXor(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorAcquire(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorRelease(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); + } } static void testInstanceFieldUnsupported(VarHandleTestAccessLong recv, VarHandle vh) { + } @@ -596,25 +735,148 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { // Compare set and get { + vh.set(0x0123456789ABCDEFL); + long o = (long) vh.getAndSet(0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long"); long x = (long) vh.get(); assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - vh.set(0x0123456789ABCDEFL); + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetAcquire(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetAcquire long"); + long x = (long) vh.get(); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetAcquire long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetRelease(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetRelease long"); + long x = (long) vh.get(); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetRelease long value"); + } // get and add, add and get { + vh.set(0x0123456789ABCDEFL); + long o = (long) vh.getAndAdd( 0xDEADBEEFDEADBEEFL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); long c = (long) vh.addAndGet(0xDEADBEEFDEADBEEFL); assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddAcquire(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddRelease(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddReleaselong"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOr(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrAcquire(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrRelease(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAnd(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndAcquire(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndRelease(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXor(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorAcquire(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorRelease(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); + } } static void testStaticFieldUnsupported(VarHandle vh) { + } @@ -752,21 +1014,143 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { // Compare set and get { + vh.set(array, i, 0x0123456789ABCDEFL); + long o = (long) vh.getAndSet(array, i, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - vh.set(array, i, 0x0123456789ABCDEFL); + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetAcquire(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetAcquire long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetRelease(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetRelease long value"); + } // get and add, add and get { + vh.set(array, i, 0x0123456789ABCDEFL); + long o = (long) vh.getAndAdd(array, i, 0xDEADBEEFDEADBEEFL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); long c = (long) vh.addAndGet(array, i, 0xDEADBEEFDEADBEEFL); assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddAcquire(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddRelease(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddReleaselong"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOr(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrAcquire(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrRelease(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAnd(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndAcquire(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndRelease(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXor(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorAcquire(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorRelease(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); + } } } @@ -775,6 +1159,7 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { int i = 0; + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -852,11 +1237,63 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { }); checkIOOBE(() -> { - long o = (long) vh.getAndAdd(array, ci, 0xDEADBEEFDEADBEEFL); + long o = (long) vh.getAndSetAcquire(array, ci, 0x0123456789ABCDEFL); }); checkIOOBE(() -> { - long o = (long) vh.addAndGet(array, ci, 0xDEADBEEFDEADBEEFL); + long o = (long) vh.getAndSetRelease(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndAdd(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndAddAcquire(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.addAndGet(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, 0x0123456789ABCDEFL); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java index 53535de28c9..7f930529257 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java @@ -108,9 +108,23 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +275,7 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { }); + } @@ -309,6 +324,7 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { }); + } @@ -443,25 +459,148 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { // Compare set and get { + vh.set(recv, (short)0x0123); + short o = (short) vh.getAndSet(recv, (short)0x4567); assertEquals(o, (short)0x0123, "getAndSet short"); short x = (short) vh.get(recv); assertEquals(x, (short)0x4567, "getAndSet short value"); } - vh.set(recv, (short)0x0123); + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndSetAcquire(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetAcquire short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)0x4567, "getAndSetAcquire short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndSetRelease(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetRelease short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)0x4567, "getAndSetRelease short value"); + } // get and add, add and get { + vh.set(recv, (short)0x0123); + short o = (short) vh.getAndAdd(recv, (short)0x89AB); assertEquals(o, (short)0x0123, "getAndAdd short"); short c = (short) vh.addAndGet(recv, (short)0x89AB); assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndAddAcquire(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndAddRelease(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddReleaseshort"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseOr(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseOrAcquire(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseOrRelease(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseAnd(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseAndAcquire(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseAndRelease(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseXor(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseXorAcquire(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseXorRelease(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); + } } static void testInstanceFieldUnsupported(VarHandleTestAccessShort recv, VarHandle vh) { + } @@ -596,25 +735,148 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { // Compare set and get { + vh.set((short)0x0123); + short o = (short) vh.getAndSet((short)0x4567); assertEquals(o, (short)0x0123, "getAndSet short"); short x = (short) vh.get(); assertEquals(x, (short)0x4567, "getAndSet short value"); } - vh.set((short)0x0123); + { + vh.set((short)0x0123); + + short o = (short) vh.getAndSetAcquire((short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetAcquire short"); + short x = (short) vh.get(); + assertEquals(x, (short)0x4567, "getAndSetAcquire short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndSetRelease((short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetRelease short"); + short x = (short) vh.get(); + assertEquals(x, (short)0x4567, "getAndSetRelease short value"); + } // get and add, add and get { + vh.set((short)0x0123); + short o = (short) vh.getAndAdd( (short)0x89AB); assertEquals(o, (short)0x0123, "getAndAdd short"); short c = (short) vh.addAndGet((short)0x89AB); assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndAddAcquire((short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndAddRelease((short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddReleaseshort"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseOr((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseOrAcquire((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseOrRelease((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseAnd((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseAndAcquire((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseAndRelease((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseXor((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseXorAcquire((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseXorRelease((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); + } } static void testStaticFieldUnsupported(VarHandle vh) { + } @@ -752,21 +1014,143 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { // Compare set and get { + vh.set(array, i, (short)0x0123); + short o = (short) vh.getAndSet(array, i, (short)0x4567); assertEquals(o, (short)0x0123, "getAndSet short"); short x = (short) vh.get(array, i); assertEquals(x, (short)0x4567, "getAndSet short value"); } - vh.set(array, i, (short)0x0123); + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndSetAcquire(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetAcquire short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)0x4567, "getAndSetAcquire short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndSetRelease(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetRelease short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)0x4567, "getAndSetRelease short value"); + } // get and add, add and get { + vh.set(array, i, (short)0x0123); + short o = (short) vh.getAndAdd(array, i, (short)0x89AB); assertEquals(o, (short)0x0123, "getAndAdd short"); short c = (short) vh.addAndGet(array, i, (short)0x89AB); assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndAddAcquire(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndAddRelease(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddReleaseshort"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseOr(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseOrAcquire(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseOrRelease(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseAnd(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseAndAcquire(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseAndRelease(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseXor(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseXorAcquire(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseXorRelease(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); + } } } @@ -775,6 +1159,7 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { int i = 0; + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -852,11 +1237,63 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { }); checkIOOBE(() -> { - short o = (short) vh.getAndAdd(array, ci, (short)0x89AB); + short o = (short) vh.getAndSetAcquire(array, ci, (short)0x0123); }); checkIOOBE(() -> { - short o = (short) vh.addAndGet(array, ci, (short)0x89AB); + short o = (short) vh.getAndSetRelease(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndAdd(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndAddAcquire(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndAddRelease(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.addAndGet(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseOr(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseOrAcquire(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseOrRelease(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseAnd(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseAndAcquire(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseAndRelease(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseXor(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseXorAcquire(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseXorRelease(array, ci, (short)0x0123); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java index 0ac329d65f8..136ab72cb1d 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java @@ -108,9 +108,23 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -265,9 +279,53 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndAdd(recv, "foo"); }); + checkUOE(() -> { + String o = (String) vh.getAndAddAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndAddRelease(recv, "foo"); + }); + checkUOE(() -> { String o = (String) vh.addAndGet(recv, "foo"); }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOr(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrRelease(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAnd(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndRelease(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXor(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorRelease(recv, "foo"); + }); } @@ -320,9 +378,53 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndAdd("foo"); }); + checkUOE(() -> { + String o = (String) vh.getAndAddAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndAddRelease("foo"); + }); + checkUOE(() -> { String o = (String) vh.addAndGet("foo"); }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOr("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrRelease("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAnd("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndRelease("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXor("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorRelease("foo"); + }); } @@ -457,12 +559,33 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { // Compare set and get { + vh.set(recv, "foo"); + String o = (String) vh.getAndSet(recv, "bar"); assertEquals(o, "foo", "getAndSet String"); String x = (String) vh.get(recv); assertEquals(x, "bar", "getAndSet String value"); } + { + vh.set(recv, "foo"); + + String o = (String) vh.getAndSetAcquire(recv, "bar"); + assertEquals(o, "foo", "getAndSetAcquire String"); + String x = (String) vh.get(recv); + assertEquals(x, "bar", "getAndSetAcquire String value"); + } + + { + vh.set(recv, "foo"); + + String o = (String) vh.getAndSetRelease(recv, "bar"); + assertEquals(o, "foo", "getAndSetRelease String"); + String x = (String) vh.get(recv); + assertEquals(x, "bar", "getAndSetRelease String value"); + } + + } static void testInstanceFieldUnsupported(VarHandleTestAccessString recv, VarHandle vh) { @@ -471,9 +594,53 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndAdd(recv, "foo"); }); + checkUOE(() -> { + String o = (String) vh.getAndAddAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndAddRelease(recv, "foo"); + }); + checkUOE(() -> { String o = (String) vh.addAndGet(recv, "foo"); }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOr(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrRelease(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAnd(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndRelease(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXor(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorRelease(recv, "foo"); + }); } @@ -608,12 +775,33 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { // Compare set and get { + vh.set("foo"); + String o = (String) vh.getAndSet("bar"); assertEquals(o, "foo", "getAndSet String"); String x = (String) vh.get(); assertEquals(x, "bar", "getAndSet String value"); } + { + vh.set("foo"); + + String o = (String) vh.getAndSetAcquire("bar"); + assertEquals(o, "foo", "getAndSetAcquire String"); + String x = (String) vh.get(); + assertEquals(x, "bar", "getAndSetAcquire String value"); + } + + { + vh.set("foo"); + + String o = (String) vh.getAndSetRelease("bar"); + assertEquals(o, "foo", "getAndSetRelease String"); + String x = (String) vh.get(); + assertEquals(x, "bar", "getAndSetRelease String value"); + } + + } static void testStaticFieldUnsupported(VarHandle vh) { @@ -622,9 +810,53 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndAdd("foo"); }); + checkUOE(() -> { + String o = (String) vh.getAndAddAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndAddRelease("foo"); + }); + checkUOE(() -> { String o = (String) vh.addAndGet("foo"); }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOr("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrRelease("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAnd("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndRelease("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXor("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorRelease("foo"); + }); } @@ -762,12 +994,33 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { // Compare set and get { + vh.set(array, i, "foo"); + String o = (String) vh.getAndSet(array, i, "bar"); assertEquals(o, "foo", "getAndSet String"); String x = (String) vh.get(array, i); assertEquals(x, "bar", "getAndSet String value"); } + { + vh.set(array, i, "foo"); + + String o = (String) vh.getAndSetAcquire(array, i, "bar"); + assertEquals(o, "foo", "getAndSetAcquire String"); + String x = (String) vh.get(array, i); + assertEquals(x, "bar", "getAndSetAcquire String value"); + } + + { + vh.set(array, i, "foo"); + + String o = (String) vh.getAndSetRelease(array, i, "bar"); + assertEquals(o, "foo", "getAndSetRelease String"); + String x = (String) vh.get(array, i); + assertEquals(x, "bar", "getAndSetRelease String value"); + } + + } } @@ -780,9 +1033,53 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndAdd(array, i, "foo"); }); + checkUOE(() -> { + String o = (String) vh.getAndAddAcquire(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndAddRelease(array, i, "foo"); + }); + checkUOE(() -> { String o = (String) vh.addAndGet(array, i, "foo"); }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOr(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrAcquire(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrRelease(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAnd(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndAcquire(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndRelease(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXor(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorAcquire(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorRelease(array, i, "foo"); + }); } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -859,6 +1156,15 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndSet(array, ci, "foo"); }); + checkIOOBE(() -> { + String o = (String) vh.getAndSetAcquire(array, ci, "foo"); + }); + + checkIOOBE(() -> { + String o = (String) vh.getAndSetRelease(array, ci, "foo"); + }); + + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java index dc9db6f2d26..4083c0024e6 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java @@ -97,9 +97,23 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -220,13 +234,65 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { char o = (char) vh.getAndSet(array, ci, VALUE_1); }); + checkUOE(() -> { + char o = (char) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { char o = (char) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + char o = (char) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { char o = (char) vh.addAndGet(array, ci, VALUE_1); }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } static void testArrayUnsupported(ByteBufferSource bs, VarHandleSource vhs) { @@ -289,13 +355,65 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { char o = (char) vh.getAndSet(array, ci, VALUE_1); }); + checkUOE(() -> { + char o = (char) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { char o = (char) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + char o = (char) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { char o = (char) vh.addAndGet(array, ci, VALUE_1); }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } else { checkUOE(() -> { @@ -333,13 +451,64 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { checkUOE(() -> { char o = (char) vh.getAndSet(array, ci, VALUE_1); }); + + checkUOE(() -> { + char o = (char) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndSetRelease(array, ci, VALUE_1); + }); checkUOE(() -> { char o = (char) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + char o = (char) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { char o = (char) vh.addAndGet(array, ci, VALUE_1); }); + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } @@ -385,6 +554,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); + } } @@ -434,6 +604,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); + } } } @@ -518,6 +689,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); + } } } @@ -564,6 +736,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { assertEquals(x, VALUE_2, "setOpaque char value"); } + } } } @@ -609,6 +782,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { assertEquals(x, VALUE_2, "setOpaque char value"); } + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java index a713e91b979..e33fdbf718c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java @@ -97,9 +97,23 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -189,9 +203,53 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + double o = (double) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { double o = (double) vh.addAndGet(array, ci, VALUE_1); }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } static void testArrayUnsupported(ByteBufferSource bs, VarHandleSource vhs) { @@ -255,23 +313,118 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); + checkROBE(() -> { + double o = (double) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + double o = (double) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { double o = (double) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + double o = (double) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { double o = (double) vh.addAndGet(array, ci, VALUE_1); }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } else { checkUOE(() -> { double o = (double) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + double o = (double) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { double o = (double) vh.addAndGet(array, ci, VALUE_1); }); + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } @@ -352,6 +505,15 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + double o = (double) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + double o = (double) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } @@ -437,6 +599,15 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + double o = (double) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + double o = (double) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } } @@ -513,6 +684,14 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + double o = (double) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + double o = (double) vh.getAndSetRelease(array, ci, VALUE_1); + }); + } } @@ -592,6 +771,15 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + double o = (double) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + double o = (double) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } } @@ -736,12 +924,33 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { // Compare set and get { + vh.set(array, i, VALUE_1); + double o = (double) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet double value"); } + { + vh.set(array, i, VALUE_1); + + double o = (double) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire double"); + double x = (double) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire double value"); + } + + { + vh.set(array, i, VALUE_1); + + double o = (double) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease double"); + double x = (double) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease double value"); + } + + } } } @@ -885,12 +1094,33 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { // Compare set and get { + vh.set(array, i, VALUE_1); + double o = (double) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet double value"); } + { + vh.set(array, i, VALUE_1); + + double o = (double) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire double"); + double x = (double) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire double value"); + } + + { + vh.set(array, i, VALUE_1); + + double o = (double) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease double"); + double x = (double) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease double value"); + } + + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java index 3e964dcd46a..d56bb6e8933 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java @@ -97,9 +97,23 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -189,9 +203,53 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + float o = (float) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { float o = (float) vh.addAndGet(array, ci, VALUE_1); }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } static void testArrayUnsupported(ByteBufferSource bs, VarHandleSource vhs) { @@ -255,23 +313,118 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); + checkROBE(() -> { + float o = (float) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + float o = (float) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { float o = (float) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + float o = (float) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { float o = (float) vh.addAndGet(array, ci, VALUE_1); }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } else { checkUOE(() -> { float o = (float) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + float o = (float) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { float o = (float) vh.addAndGet(array, ci, VALUE_1); }); + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } @@ -352,6 +505,15 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + float o = (float) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + float o = (float) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } @@ -437,6 +599,15 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + float o = (float) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + float o = (float) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } } @@ -513,6 +684,14 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + float o = (float) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + float o = (float) vh.getAndSetRelease(array, ci, VALUE_1); + }); + } } @@ -592,6 +771,15 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + float o = (float) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + float o = (float) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } } @@ -736,12 +924,33 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { // Compare set and get { + vh.set(array, i, VALUE_1); + float o = (float) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet float value"); } + { + vh.set(array, i, VALUE_1); + + float o = (float) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire float"); + float x = (float) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire float value"); + } + + { + vh.set(array, i, VALUE_1); + + float o = (float) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease float"); + float x = (float) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease float value"); + } + + } } } @@ -885,12 +1094,33 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { // Compare set and get { + vh.set(array, i, VALUE_1); + float o = (float) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet float value"); } + { + vh.set(array, i, VALUE_1); + + float o = (float) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire float"); + float x = (float) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire float value"); + } + + { + vh.set(array, i, VALUE_1); + + float o = (float) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease float"); + float x = (float) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease float value"); + } + + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java index bbda8c0270f..05655eef4d1 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java @@ -97,9 +97,23 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -185,6 +199,7 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int ci = 1; + } static void testArrayUnsupported(ByteBufferSource bs, VarHandleSource vhs) { @@ -248,14 +263,66 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); + checkROBE(() -> { + int o = (int) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkROBE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); }); + checkROBE(() -> { + int o = (int) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkROBE(() -> { int o = (int) vh.addAndGet(array, ci, VALUE_1); }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } else { } @@ -338,14 +405,66 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + int o = (int) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); }); + checkIOOBE(() -> { + int o = (int) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { int o = (int) vh.addAndGet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); + } } @@ -430,13 +549,65 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + int o = (int) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); }); + checkIOOBE(() -> { + int o = (int) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { int o = (int) vh.addAndGet(array, ci, VALUE_1); }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } } @@ -513,14 +684,65 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + int o = (int) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkISE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); }); + checkISE(() -> { + int o = (int) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkISE(() -> { int o = (int) vh.addAndGet(array, ci, VALUE_1); }); + checkISE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } } @@ -599,13 +821,65 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + int o = (int) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkISE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); }); + checkISE(() -> { + int o = (int) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkISE(() -> { int o = (int) vh.addAndGet(array, ci, VALUE_1); }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } } @@ -750,21 +1024,143 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { // Compare set and get { + vh.set(array, i, VALUE_1); + int o = (int) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet int value"); } - vh.set(array, i, VALUE_1); + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease int value"); + } // get and add, add and get { + vh.set(array, i, VALUE_1); + int o = (int) vh.getAndAdd(array, i, VALUE_3); assertEquals(o, VALUE_1, "getAndAdd int"); int c = (int) vh.addAndGet(array, i, VALUE_3); assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd int value"); } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease int value"); + } + + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease int value"); + } } } } @@ -908,21 +1304,143 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { // Compare set and get { + vh.set(array, i, VALUE_1); + int o = (int) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet int value"); } - vh.set(array, i, VALUE_1); + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease int value"); + } // get and add, add and get { + vh.set(array, i, VALUE_1); + int o = (int) vh.getAndAdd(array, i, VALUE_3); assertEquals(o, VALUE_1, "getAndAdd int"); int c = (int) vh.addAndGet(array, i, VALUE_3); assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd int value"); } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease int value"); + } + + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease int value"); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java index e203f8e23f7..d5a264ade98 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java @@ -97,9 +97,23 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -185,6 +199,7 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { int ci = 1; + } static void testArrayUnsupported(ByteBufferSource bs, VarHandleSource vhs) { @@ -248,14 +263,66 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); + checkROBE(() -> { + long o = (long) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkROBE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); }); + checkROBE(() -> { + long o = (long) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkROBE(() -> { long o = (long) vh.addAndGet(array, ci, VALUE_1); }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } else { } @@ -338,14 +405,66 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + long o = (long) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); }); + checkIOOBE(() -> { + long o = (long) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { long o = (long) vh.addAndGet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); + } } @@ -430,13 +549,65 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + long o = (long) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); }); + checkIOOBE(() -> { + long o = (long) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { long o = (long) vh.addAndGet(array, ci, VALUE_1); }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } } @@ -513,14 +684,65 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + long o = (long) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkISE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); }); + checkISE(() -> { + long o = (long) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkISE(() -> { long o = (long) vh.addAndGet(array, ci, VALUE_1); }); + checkISE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } } @@ -599,13 +821,65 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + long o = (long) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkISE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); }); + checkISE(() -> { + long o = (long) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkISE(() -> { long o = (long) vh.addAndGet(array, ci, VALUE_1); }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } } @@ -750,21 +1024,143 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { // Compare set and get { + vh.set(array, i, VALUE_1); + long o = (long) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet long value"); } - vh.set(array, i, VALUE_1); + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease long value"); + } // get and add, add and get { + vh.set(array, i, VALUE_1); + long o = (long) vh.getAndAdd(array, i, VALUE_3); assertEquals(o, VALUE_1, "getAndAdd long"); long c = (long) vh.addAndGet(array, i, VALUE_3); assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd long value"); } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease long value"); + } + + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease long value"); + } } } } @@ -908,21 +1304,143 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { // Compare set and get { + vh.set(array, i, VALUE_1); + long o = (long) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet long value"); } - vh.set(array, i, VALUE_1); + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease long value"); + } // get and add, add and get { + vh.set(array, i, VALUE_1); + long o = (long) vh.getAndAdd(array, i, VALUE_3); assertEquals(o, VALUE_1, "getAndAdd long"); long c = (long) vh.addAndGet(array, i, VALUE_3); assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd long value"); } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease long value"); + } + + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease long value"); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java index d96715ed083..8c473e6e0d7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java @@ -97,9 +97,23 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -220,13 +234,65 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { short o = (short) vh.getAndSet(array, ci, VALUE_1); }); + checkUOE(() -> { + short o = (short) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { short o = (short) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + short o = (short) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { short o = (short) vh.addAndGet(array, ci, VALUE_1); }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } static void testArrayUnsupported(ByteBufferSource bs, VarHandleSource vhs) { @@ -289,13 +355,65 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { short o = (short) vh.getAndSet(array, ci, VALUE_1); }); + checkUOE(() -> { + short o = (short) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { short o = (short) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + short o = (short) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { short o = (short) vh.addAndGet(array, ci, VALUE_1); }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } else { checkUOE(() -> { @@ -333,13 +451,64 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { checkUOE(() -> { short o = (short) vh.getAndSet(array, ci, VALUE_1); }); + + checkUOE(() -> { + short o = (short) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndSetRelease(array, ci, VALUE_1); + }); checkUOE(() -> { short o = (short) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + short o = (short) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { short o = (short) vh.addAndGet(array, ci, VALUE_1); }); + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } @@ -385,6 +554,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); + } } @@ -434,6 +604,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); + } } } @@ -518,6 +689,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); + } } } @@ -564,6 +736,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { assertEquals(x, VALUE_2, "setOpaque short value"); } + } } } @@ -609,6 +782,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { assertEquals(x, VALUE_2, "setOpaque short value"); } + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java index 544fcb3c0ee..ba52f280645 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java @@ -255,6 +255,90 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { assertEquals(x, false, "getAndSet boolean value"); } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessBoolean recv, Handles hs) throws Throwable { @@ -264,6 +348,7 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { boolean r = (boolean) hs.get(am).invokeExact(recv, true); }); } + } @@ -398,12 +483,118 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { // Compare set and get { - boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact( false); + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(false); assertEquals(o, true, "getAndSet boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, false, "getAndSet boolean value"); } + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(false); + assertEquals(o, true, "getAndSetAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, false, "getAndSetAcquire boolean value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(false); + assertEquals(o, true, "getAndSetRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, false, "getAndSetRelease boolean value"); + } + + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { @@ -413,6 +604,7 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { boolean r = (boolean) hs.get(am).invokeExact(true); }); } + } @@ -550,12 +742,116 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, false); assertEquals(o, true, "getAndSet boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, false, "getAndSet boolean value"); } + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, false); + assertEquals(o, true, "getAndSetAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, false, "getAndSetAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, false); + assertEquals(o, true, "getAndSetRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, false, "getAndSetRelease boolean value"); + } + + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } } @@ -569,6 +865,7 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) hs.get(am).invokeExact(array, i, true); }); } + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -607,6 +904,12 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + boolean o = (boolean) hs.get(am).invokeExact(array, ci, false); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java index 21e09b83953..c5410833d10 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java @@ -255,19 +255,122 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { assertEquals(x, (byte)0x23, "getAndSet byte value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); - // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (byte)0x45); assertEquals(o, (byte)0x01, "getAndAdd byte"); byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, (byte)0x45); assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); + } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessByte recv, Handles hs) throws Throwable { + } @@ -402,25 +505,150 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { // Compare set and get { - byte o = (byte) hs.get(TestAccessMode.GET_AND_SET).invokeExact( (byte)0x23); + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET).invokeExact((byte)0x23); assertEquals(o, (byte)0x01, "getAndSet byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, (byte)0x23, "getAndSet byte value"); } - hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)0x23, "getAndSetAcquire byte value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)0x23, "getAndSetRelease byte value"); + } // get and add, add and get { - byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( (byte)0x45); + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact((byte)0x45); assertEquals(o, (byte)0x01, "getAndAdd byte"); byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact((byte)0x45); assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); + } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + } @@ -558,21 +786,143 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, (byte)0x23); assertEquals(o, (byte)0x01, "getAndSet byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, (byte)0x23, "getAndSet byte value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)0x23, "getAndSetAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)0x23, "getAndSetRelease byte value"); + } // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (byte)0x45); assertEquals(o, (byte)0x01, "getAndAdd byte"); byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, (byte)0x45); assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); + } } } @@ -581,6 +931,7 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { final int i = 0; + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +975,12 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { byte o = (byte) hs.get(am).invokeExact(array, ci, (byte)0x45); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + byte o = (byte) hs.get(am).invokeExact(array, ci, (byte)0x45); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java index 1f2e5ee10c6..6186ba7b522 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java @@ -255,19 +255,122 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { assertEquals(x, '\u4567', "getAndSet char value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); - // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, '\u89AB'); assertEquals(o, '\u0123', "getAndAdd char"); char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, '\u89AB'); assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndAddRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); + } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessChar recv, Handles hs) throws Throwable { + } @@ -402,25 +505,150 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { // Compare set and get { - char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact( '\u4567'); + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact('\u4567'); assertEquals(o, '\u0123', "getAndSet char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, '\u4567', "getAndSet char value"); } - hs.get(TestAccessMode.SET).invokeExact('\u0123'); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndSetAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, '\u4567', "getAndSetAcquire char value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndSetRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, '\u4567', "getAndSetRelease char value"); + } // get and add, add and get { - char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( '\u89AB'); + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact('\u89AB'); assertEquals(o, '\u0123', "getAndAdd char"); char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact('\u89AB'); assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndAddRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); + } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + } @@ -558,21 +786,143 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, '\u4567'); assertEquals(o, '\u0123', "getAndSet char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, '\u4567', "getAndSet char value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndSetAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, '\u4567', "getAndSetAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndSetRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, '\u4567', "getAndSetRelease char value"); + } // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, '\u89AB'); assertEquals(o, '\u0123', "getAndAdd char"); char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, '\u89AB'); assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndAddRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); + } } } @@ -581,6 +931,7 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { final int i = 0; + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +975,12 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { char o = (char) hs.get(am).invokeExact(array, ci, '\u89AB'); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + char o = (char) hs.get(am).invokeExact(array, ci, '\u89AB'); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java index 26cb426ab81..2d09668c2bb 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java @@ -255,19 +255,44 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { assertEquals(x, 2.0d, "getAndSet double value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, 1.0d); - // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0d); + double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 3.0d); assertEquals(o, 1.0d, "getAndAdd double"); double c = (double) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 3.0d); assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, 2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, 2.0d); + assertEquals(o, 1.0d, "getAndAddRelease double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessDouble recv, Handles hs) throws Throwable { + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + double r = (double) hs.get(am).invokeExact(recv, 1.0d); + }); + } } @@ -402,25 +427,72 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { // Compare set and get { - double o = (double) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2.0d); + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_SET).invokeExact(2.0d); assertEquals(o, 1.0d, "getAndSet double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2.0d, "getAndSet double value"); } - hs.get(TestAccessMode.SET).invokeExact(1.0d); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(2.0d); + assertEquals(o, 1.0d, "getAndSetAcquire double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 2.0d, "getAndSetAcquire double value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(2.0d); + assertEquals(o, 1.0d, "getAndSetRelease double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 2.0d, "getAndSetRelease double value"); + } // get and add, add and get { - double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 3.0d); + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(3.0d); assertEquals(o, 1.0d, "getAndAdd double"); double c = (double) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(3.0d); assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(2.0d); + assertEquals(o, 1.0d, "getAndAddRelease double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + double r = (double) hs.get(am).invokeExact(1.0d); + }); + } } @@ -558,21 +630,60 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + double o = (double) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 2.0d); assertEquals(o, 1.0d, "getAndSet double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2.0d, "getAndSet double value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndSetAcquire double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 2.0d, "getAndSetAcquire double value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndSetRelease double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 2.0d, "getAndSetRelease double value"); + } // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 3.0d); assertEquals(o, 1.0d, "getAndAdd double"); double c = (double) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 3.0d); assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndAddRelease double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } } @@ -581,6 +692,12 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { final int i = 0; + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + double o = (double) hs.get(am).invokeExact(array, i, 1.0d); + }); + } } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +741,7 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { double o = (double) hs.get(am).invokeExact(array, ci, 3.0d); }); } + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java index d28e2f41b6e..9b6b631d25d 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java @@ -255,19 +255,44 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { assertEquals(x, 2.0f, "getAndSet float value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, 1.0f); - // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0f); + float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 3.0f); assertEquals(o, 1.0f, "getAndAdd float"); float c = (float) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 3.0f); assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, 2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, 2.0f); + assertEquals(o, 1.0f, "getAndAddRelease float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessFloat recv, Handles hs) throws Throwable { + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + float r = (float) hs.get(am).invokeExact(recv, 1.0f); + }); + } } @@ -402,25 +427,72 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { // Compare set and get { - float o = (float) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2.0f); + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_SET).invokeExact(2.0f); assertEquals(o, 1.0f, "getAndSet float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2.0f, "getAndSet float value"); } - hs.get(TestAccessMode.SET).invokeExact(1.0f); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(2.0f); + assertEquals(o, 1.0f, "getAndSetAcquire float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 2.0f, "getAndSetAcquire float value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(2.0f); + assertEquals(o, 1.0f, "getAndSetRelease float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 2.0f, "getAndSetRelease float value"); + } // get and add, add and get { - float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 3.0f); + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(3.0f); assertEquals(o, 1.0f, "getAndAdd float"); float c = (float) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(3.0f); assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(2.0f); + assertEquals(o, 1.0f, "getAndAddRelease float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + float r = (float) hs.get(am).invokeExact(1.0f); + }); + } } @@ -558,21 +630,60 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + float o = (float) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 2.0f); assertEquals(o, 1.0f, "getAndSet float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2.0f, "getAndSet float value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndSetAcquire float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 2.0f, "getAndSetAcquire float value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndSetRelease float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 2.0f, "getAndSetRelease float value"); + } // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 3.0f); assertEquals(o, 1.0f, "getAndAdd float"); float c = (float) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 3.0f); assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndAddRelease float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } } @@ -581,6 +692,12 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { final int i = 0; + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + float o = (float) hs.get(am).invokeExact(array, i, 1.0f); + }); + } } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +741,7 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { float o = (float) hs.get(am).invokeExact(array, ci, 3.0f); }); } + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java index 56954238e27..a7d4f03b82f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java @@ -255,19 +255,122 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); - // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0xCAFEBABE); assertEquals(o, 0x01234567, "getAndAdd int"); int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 0xCAFEBABE); assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); + } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessInt recv, Handles hs) throws Throwable { + } @@ -402,25 +505,150 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { // Compare set and get { - int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 0x89ABCDEF); + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(0x89ABCDEF); assertEquals(o, 0x01234567, "getAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - hs.get(TestAccessMode.SET).invokeExact(0x01234567); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 0x89ABCDEF, "getAndSetAcquire int value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 0x89ABCDEF, "getAndSetRelease int value"); + } // get and add, add and get { - int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 0xCAFEBABE); + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(0xCAFEBABE); assertEquals(o, 0x01234567, "getAndAdd int"); int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(0xCAFEBABE); assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); + } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + } @@ -558,21 +786,143 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 0x89ABCDEF, "getAndSetAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 0x89ABCDEF, "getAndSetRelease int value"); + } // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0xCAFEBABE); assertEquals(o, 0x01234567, "getAndAdd int"); int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 0xCAFEBABE); assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); + } } } @@ -581,6 +931,7 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { final int i = 0; + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +975,12 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { int o = (int) hs.get(am).invokeExact(array, ci, 0xCAFEBABE); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + int o = (int) hs.get(am).invokeExact(array, ci, 0xCAFEBABE); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java index 848da74e166..7a39dd19a89 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java @@ -255,19 +255,122 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); - // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0xDEADBEEFDEADBEEFL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 0xDEADBEEFDEADBEEFL); assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); + } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessLong recv, Handles hs) throws Throwable { + } @@ -402,25 +505,150 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { // Compare set and get { - long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 0xCAFEBABECAFEBABEL); + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetAcquire long value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetRelease long value"); + } // get and add, add and get { - long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 0xDEADBEEFDEADBEEFL); + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(0xDEADBEEFDEADBEEFL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(0xDEADBEEFDEADBEEFL); assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); + } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + } @@ -558,21 +786,143 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetRelease long value"); + } // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0xDEADBEEFDEADBEEFL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 0xDEADBEEFDEADBEEFL); assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); + } } } @@ -581,6 +931,7 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { final int i = 0; + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +975,12 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { long o = (long) hs.get(am).invokeExact(array, ci, 0xDEADBEEFDEADBEEFL); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + long o = (long) hs.get(am).invokeExact(array, ci, 0xDEADBEEFDEADBEEFL); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java index ca4121e412e..456d2f3a7c4 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java @@ -255,19 +255,122 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { assertEquals(x, (short)0x4567, "getAndSet short value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); - // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (short)0x89AB); assertEquals(o, (short)0x0123, "getAndAdd short"); short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, (short)0x89AB); assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); + } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessShort recv, Handles hs) throws Throwable { + } @@ -402,25 +505,150 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { // Compare set and get { - short o = (short) hs.get(TestAccessMode.GET_AND_SET).invokeExact( (short)0x4567); + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_SET).invokeExact((short)0x4567); assertEquals(o, (short)0x0123, "getAndSet short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, (short)0x4567, "getAndSet short value"); } - hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)0x4567, "getAndSetAcquire short value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)0x4567, "getAndSetRelease short value"); + } // get and add, add and get { - short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( (short)0x89AB); + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact((short)0x89AB); assertEquals(o, (short)0x0123, "getAndAdd short"); short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact((short)0x89AB); assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); + } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + } @@ -558,21 +786,143 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + short o = (short) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, (short)0x4567); assertEquals(o, (short)0x0123, "getAndSet short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, (short)0x4567, "getAndSet short value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)0x4567, "getAndSetAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)0x4567, "getAndSetRelease short value"); + } // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (short)0x89AB); assertEquals(o, (short)0x0123, "getAndAdd short"); short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, (short)0x89AB); assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); + } } } @@ -581,6 +931,7 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { final int i = 0; + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +975,12 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { short o = (short) hs.get(am).invokeExact(array, ci, (short)0x89AB); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + short o = (short) hs.get(am).invokeExact(array, ci, (short)0x89AB); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java index 079d8053606..b99bf086205 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java @@ -255,6 +255,7 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { assertEquals(x, "bar", "getAndSet String value"); } + } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessString recv, Handles hs) throws Throwable { @@ -264,6 +265,12 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { String r = (String) hs.get(am).invokeExact(recv, "foo"); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + String r = (String) hs.get(am).invokeExact(recv, "foo"); + }); + } } @@ -398,12 +405,35 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { // Compare set and get { - String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact( "bar"); + hs.get(TestAccessMode.SET).invokeExact("foo"); + + String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact("bar"); assertEquals(o, "foo", "getAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, "bar", "getAndSet String value"); } + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact("foo"); + + String o = (String) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact("bar"); + assertEquals(o, "foo", "getAndSetAcquire String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, "bar", "getAndSetAcquire String value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact("foo"); + + String o = (String) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact("bar"); + assertEquals(o, "foo", "getAndSetRelease String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, "bar", "getAndSetRelease String value"); + } + + } static void testStaticFieldUnsupported(Handles hs) throws Throwable { @@ -413,6 +443,12 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { String r = (String) hs.get(am).invokeExact("foo"); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + String r = (String) hs.get(am).invokeExact("foo"); + }); + } } @@ -550,12 +586,33 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, "foo"); + String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, "bar"); assertEquals(o, "foo", "getAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, "bar", "getAndSet String value"); } + { + hs.get(TestAccessMode.SET).invokeExact(array, i, "foo"); + + String o = (String) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, "bar"); + assertEquals(o, "foo", "getAndSetAcquire String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, "bar", "getAndSetAcquire String value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, "foo"); + + String o = (String) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, "bar"); + assertEquals(o, "foo", "getAndSetRelease String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, "bar", "getAndSetRelease String value"); + } + + } } @@ -569,6 +626,12 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { String o = (String) hs.get(am).invokeExact(array, i, "foo"); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + String o = (String) hs.get(am).invokeExact(array, i, "foo"); + }); + } } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -607,6 +670,7 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { }); } + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java index 4a1d0103411..13382f6e6b9 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java @@ -582,6 +582,333 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { boolean x = (boolean) vh.getAndSet(recv, true, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndSetAcquire(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndSetAcquire(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndSetAcquire(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetAcquire(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetAcquire(recv, true, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndSetRelease(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndSetRelease(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndSetRelease(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetRelease(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetRelease(recv, true, Void.class); + }); + + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseOr(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseOr(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseOr(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOr(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOr(recv, true, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseOrAcquire(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOrAcquire(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, true, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseOrRelease(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseOr(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseOr(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOr(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOr(recv, true, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseAnd(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseAnd(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAnd(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAnd(recv, true, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseAndAcquire(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAndAcquire(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, true, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseAndRelease(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseAnd(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAnd(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAnd(recv, true, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseXor(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseXor(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseXor(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXor(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXor(recv, true, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseXorAcquire(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXorAcquire(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, true, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseXorRelease(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseXor(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseXor(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXor(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXor(recv, true, Void.class); + }); } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeBoolean recv, Handles hs) throws Throwable { @@ -759,6 +1086,43 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class)). + invokeExact((VarHandleTestMethodTypeBoolean) null, true); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class)). + invokeExact(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, boolean.class)). + invokeExact(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeBoolean.class, boolean.class)). + invokeExact(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class, boolean.class)). + invokeExact(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) hs.get(am, methodType(boolean.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class)). + invokeExact(recv, true, Void.class); + }); + } } @@ -1049,6 +1413,236 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { boolean x = (boolean) vh.getAndSet(true, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetAcquire(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetAcquire(true, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetRelease(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetRelease(true, Void.class); + }); + + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOr(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOr(true, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOrAcquire(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOrAcquire(true, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOrRelease(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOrRelease(true, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAnd(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAnd(true, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAndAcquire(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAndAcquire(true, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAndRelease(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAndRelease(true, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXor(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXor(true, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXorAcquire(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXorAcquire(true, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXorRelease(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXorRelease(true, Void.class); + }); } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1163,6 +1757,32 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, boolean.class)). + invokeExact(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) hs.get(am, methodType(int.class, boolean.class)). + invokeExact(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) hs.get(am, methodType(boolean.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean.class, Class.class)). + invokeExact(true, Void.class); + }); + } } @@ -1679,6 +2299,368 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { boolean x = (boolean) vh.getAndSet(array, 0, true, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndSetAcquire(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndSetAcquire(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + boolean x = (boolean) vh.getAndSetAcquire(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndSetAcquire(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetAcquire(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetAcquire(array, 0, true, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndSetRelease(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndSetRelease(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + boolean x = (boolean) vh.getAndSetRelease(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndSetRelease(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetRelease(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetRelease(array, 0, true, Void.class); + }); + + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseOr(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseOr(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseOr(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseOr(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOr(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, true, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseOrAcquire(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOrAcquire(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, true, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseOrRelease(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseOrRelease(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOrRelease(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, true, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseAnd(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseAnd(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseAnd(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAnd(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, true, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseAndAcquire(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAndAcquire(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, true, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseAndRelease(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseAndRelease(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAndRelease(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, true, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseXor(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseXor(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseXor(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseXor(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXor(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, true, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseXorAcquire(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXorAcquire(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, true, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseXorRelease(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseXorRelease(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXorRelease(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, true, Void.class); + }); } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -1880,6 +2862,48 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class)). + invokeExact((boolean[]) null, 0, true); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, boolean.class)). + invokeExact(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, boolean.class)). + invokeExact(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class, boolean.class)). + invokeExact(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class, boolean.class)). + invokeExact(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class, boolean.class)). + invokeExact(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) hs.get(am, methodType(boolean.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, Class.class)). + invokeExact(array, 0, true, Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java index a067b57182a..41c9e06e700 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndSet(recv, (byte)0x01, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndSetAcquire(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndSetAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndSetAcquire(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetAcquire(recv, (byte)0x01, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndSetRelease(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndSetRelease(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndSetRelease(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetRelease(recv, (byte)0x01, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,6 +669,63 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndAdd(recv, (byte)0x01, Void.class); }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndAddAcquire(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndAddAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAddAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndAddAcquire(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAddAcquire(recv, (byte)0x01, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndAddRelease(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndAddRelease(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndAddRelease(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAddRelease(recv, (byte)0x01, Void.class); + }); // AddAndGet // Incorrect argument types @@ -640,6 +755,275 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { checkWMTE(() -> { // > byte x = (byte) vh.addAndGet(recv, (byte)0x01, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseOr(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseOr(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseOr(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOr(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseOrAcquire(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseOrAcquire(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOrAcquire(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseOrRelease(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseOr(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseOr(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOr(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseAnd(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseAnd(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseAnd(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAnd(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseAndAcquire(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseAndAcquire(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAndAcquire(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseAndRelease(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseAnd(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseAnd(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAnd(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseXor(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseXor(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseXor(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXor(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseXorAcquire(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseXorAcquire(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXorAcquire(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseXorRelease(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseXor(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseXor(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXor(recv, (byte)0x01, Void.class); + }); } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeByte recv, Handles hs) throws Throwable { @@ -853,6 +1237,43 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { invokeExact(recv, (byte)0x01, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class)). + invokeExact((VarHandleTestMethodTypeByte) null, (byte)0x01); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, byte.class)). + invokeExact(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class, byte.class)). + invokeExact(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class, byte.class)). + invokeExact(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, byte.class)). + invokeExact(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class)). + invokeExact(recv, (byte)0x01, Void.class); + }); + } } @@ -1143,6 +1564,48 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndSet((byte)0x01, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetAcquire((byte)0x01, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetRelease((byte)0x01, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,6 +1627,48 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAddAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAddAcquire((byte)0x01, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAddRelease((byte)0x01, Void.class); + }); + + // AddAndGet // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1183,6 +1688,194 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { checkWMTE(() -> { // > byte x = (byte) vh.addAndGet((byte)0x01, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOr((byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOrAcquire((byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOrRelease((byte)0x01, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAnd((byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAndAcquire((byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAndRelease((byte)0x01, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXor((byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXorAcquire((byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXorRelease((byte)0x01, Void.class); + }); } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1322,6 +2015,32 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { invokeExact((byte)0x01, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, byte.class)). + invokeExact((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, byte.class)). + invokeExact((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, byte.class, Class.class)). + invokeExact((byte)0x01, Void.class); + }); + } } @@ -1838,6 +2557,72 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndSet(array, 0, (byte)0x01, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndSetAcquire(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndSetAcquire(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + byte x = (byte) vh.getAndSetAcquire(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndSetAcquire(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetAcquire(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndSetRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndSetRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + byte x = (byte) vh.getAndSetRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndSetRelease(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetRelease(array, 0, (byte)0x01, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,6 +2656,72 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndAddAcquire(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndAddAcquire(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAddAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndAddAcquire(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndAddAcquire(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAddAcquire(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndAddRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndAddRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndAddRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndAddRelease(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAddRelease(array, 0, (byte)0x01, Void.class); + }); + + // AddAndGet // Incorrect argument types checkNPE(() -> { // null array @@ -1902,6 +2753,302 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { checkWMTE(() -> { // > byte x = (byte) vh.addAndGet(array, 0, (byte)0x01, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseOr(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseOr(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseOr(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseOr(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOr(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseOrAcquire(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseOrAcquire(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOrAcquire(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseOrRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseOrRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseOrRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseOrRelease(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOrRelease(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseAnd(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseAnd(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseAnd(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseAnd(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAnd(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseAndAcquire(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseAndAcquire(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAndAcquire(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseAndRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseAndRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseAndRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseAndRelease(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAndRelease(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseXor(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseXor(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseXor(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseXor(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXor(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseXorAcquire(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseXorAcquire(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXorAcquire(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseXorRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseXorRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseXorRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseXorRelease(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXorRelease(array, 0, (byte)0x01, Void.class); + }); } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2144,6 +3291,48 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { invokeExact(array, 0, (byte)0x01, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class)). + invokeExact((byte[]) null, 0, (byte)0x01); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class, byte.class)). + invokeExact(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class, byte.class)). + invokeExact(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class, byte.class)). + invokeExact(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, byte[].class, int.class, byte.class)). + invokeExact(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, byte.class)). + invokeExact(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class, Class.class)). + invokeExact(array, 0, (byte)0x01, Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java index 0638b88aef4..f16d7655e9e 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndSet(recv, '\u0123', Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndSetAcquire(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndSetAcquire(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndSetAcquire(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetAcquire(recv, '\u0123', Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndSetRelease(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndSetRelease(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndSetRelease(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetRelease(recv, '\u0123', Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,6 +669,63 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndAdd(recv, '\u0123', Void.class); }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndAddAcquire(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndAddAcquire(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndAddAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndAddAcquire(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndAddAcquire(recv, '\u0123', Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndAddRelease(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndAddRelease(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndAddRelease(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndAddRelease(recv, '\u0123', Void.class); + }); // AddAndGet // Incorrect argument types @@ -640,6 +755,275 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { checkWMTE(() -> { // > char x = (char) vh.addAndGet(recv, '\u0123', Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseOr(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseOr(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseOr(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOr(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseOrAcquire(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseOrAcquire(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseOrAcquire(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOrAcquire(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseOrRelease(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseOr(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseOr(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOr(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseAnd(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseAnd(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseAnd(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAnd(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseAndAcquire(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseAndAcquire(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseAndAcquire(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAndAcquire(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseAndRelease(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseAnd(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseAnd(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAnd(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseXor(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseXor(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseXor(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXor(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseXorAcquire(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseXorAcquire(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseXorAcquire(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXorAcquire(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseXorRelease(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseXor(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseXor(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXor(recv, '\u0123', Void.class); + }); } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeChar recv, Handles hs) throws Throwable { @@ -853,6 +1237,43 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { invokeExact(recv, '\u0123', Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class)). + invokeExact((VarHandleTestMethodTypeChar) null, '\u0123'); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + char x = (char) hs.get(am, methodType(char.class, Class.class, char.class)). + invokeExact(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) hs.get(am, methodType(char.class, int.class, char.class)). + invokeExact(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeChar.class, char.class)). + invokeExact(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class, char.class)). + invokeExact(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) hs.get(am, methodType(char.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class)). + invokeExact(recv, '\u0123', Void.class); + }); + } } @@ -1143,6 +1564,48 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndSet('\u0123', Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetAcquire('\u0123', Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetRelease('\u0123', Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,6 +1627,48 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndAddAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndAddAcquire('\u0123', Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndAddRelease('\u0123', Void.class); + }); + + // AddAndGet // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1183,6 +1688,194 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { checkWMTE(() -> { // > char x = (char) vh.addAndGet('\u0123', Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOr('\u0123', Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOrAcquire('\u0123', Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOrRelease('\u0123', Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAnd('\u0123', Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAndAcquire('\u0123', Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAndRelease('\u0123', Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXor('\u0123', Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXorAcquire('\u0123', Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXorRelease('\u0123', Void.class); + }); } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1322,6 +2015,32 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { invokeExact('\u0123', Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) hs.get(am, methodType(char.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, char.class)). + invokeExact('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, char.class)). + invokeExact('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) hs.get(am, methodType(char.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + char x = (char) hs.get(am, methodType(char.class, char.class, Class.class)). + invokeExact('\u0123', Void.class); + }); + } } @@ -1838,6 +2557,72 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndSet(array, 0, '\u0123', Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndSetAcquire(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndSetAcquire(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + char x = (char) vh.getAndSetAcquire(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndSetAcquire(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetAcquire(array, 0, '\u0123', Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndSetRelease(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndSetRelease(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + char x = (char) vh.getAndSetRelease(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndSetRelease(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetRelease(array, 0, '\u0123', Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,6 +2656,72 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndAddAcquire(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndAddAcquire(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndAddAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndAddAcquire(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndAddAcquire(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndAddAcquire(array, 0, '\u0123', Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndAddRelease(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndAddRelease(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndAddRelease(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndAddRelease(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndAddRelease(array, 0, '\u0123', Void.class); + }); + + // AddAndGet // Incorrect argument types checkNPE(() -> { // null array @@ -1902,6 +2753,302 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { checkWMTE(() -> { // > char x = (char) vh.addAndGet(array, 0, '\u0123', Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseOr(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseOr(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseOr(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseOr(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOr(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseOrAcquire(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseOrAcquire(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseOrAcquire(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseOrAcquire(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOrAcquire(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseOrRelease(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseOrRelease(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseOrRelease(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseOrRelease(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOrRelease(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseAnd(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseAnd(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseAnd(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseAnd(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAnd(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseAndAcquire(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseAndAcquire(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseAndAcquire(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseAndAcquire(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAndAcquire(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseAndRelease(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseAndRelease(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseAndRelease(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseAndRelease(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAndRelease(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseXor(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseXor(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseXor(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseXor(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXor(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseXorAcquire(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseXorAcquire(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseXorAcquire(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseXorAcquire(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXorAcquire(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseXorRelease(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseXorRelease(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseXorRelease(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseXorRelease(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXorRelease(array, 0, '\u0123', Void.class); + }); } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2144,6 +3291,48 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { invokeExact(array, 0, '\u0123', Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class)). + invokeExact((char[]) null, 0, '\u0123'); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + char x = (char) hs.get(am, methodType(char.class, Class.class, int.class, char.class)). + invokeExact(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) hs.get(am, methodType(char.class, int.class, int.class, char.class)). + invokeExact(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) hs.get(am, methodType(char.class, char[].class, Class.class, char.class)). + invokeExact(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, char[].class, int.class, char.class)). + invokeExact(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class, char.class)). + invokeExact(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) hs.get(am, methodType(char.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class, Class.class)). + invokeExact(array, 0, '\u0123', Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java index 0bc17bab3b9..97f5c5f8b87 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndSet(recv, 1.0d, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + double x = (double) vh.getAndSetAcquire(null, 1.0d); + }); + checkCCE(() -> { // receiver reference class + double x = (double) vh.getAndSetAcquire(Void.class, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + double x = (double) vh.getAndSetAcquire(0, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetAcquire(recv, 1.0d, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + double x = (double) vh.getAndSetRelease(null, 1.0d); + }); + checkCCE(() -> { // receiver reference class + double x = (double) vh.getAndSetRelease(Void.class, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + double x = (double) vh.getAndSetRelease(0, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetRelease(recv, 1.0d, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,6 +669,63 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndAdd(recv, 1.0d, Void.class); }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + double x = (double) vh.getAndAddAcquire(null, 1.0d); + }); + checkCCE(() -> { // receiver reference class + double x = (double) vh.getAndAddAcquire(Void.class, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndAddAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + double x = (double) vh.getAndAddAcquire(0, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(recv, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(recv, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndAddAcquire(recv, 1.0d, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + double x = (double) vh.getAndAddRelease(null, 1.0d); + }); + checkCCE(() -> { // receiver reference class + double x = (double) vh.getAndAddRelease(Void.class, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + double x = (double) vh.getAndAddRelease(0, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndAddRelease(recv, 1.0d, Void.class); + }); // AddAndGet // Incorrect argument types @@ -640,6 +755,7 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { checkWMTE(() -> { // > double x = (double) vh.addAndGet(recv, 1.0d, Void.class); }); + } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeDouble recv, Handles hs) throws Throwable { @@ -853,6 +969,7 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { invokeExact(recv, 1.0d, Void.class); }); } + } @@ -1143,6 +1260,48 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndSet(1.0d, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetAcquire(1.0d, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetRelease(1.0d, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,6 +1323,48 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndAddAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndAddAcquire(1.0d, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndAddRelease(1.0d, Void.class); + }); + + // AddAndGet // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1183,6 +1384,7 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { checkWMTE(() -> { // > double x = (double) vh.addAndGet(1.0d, Void.class); }); + } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1322,6 +1524,7 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { invokeExact(1.0d, Void.class); }); } + } @@ -1838,6 +2041,72 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndSet(array, 0, 1.0d, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + double x = (double) vh.getAndSetAcquire(null, 0, 1.0d); + }); + checkCCE(() -> { // array reference class + double x = (double) vh.getAndSetAcquire(Void.class, 0, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + double x = (double) vh.getAndSetAcquire(0, 0, 1.0d); + }); + checkWMTE(() -> { // index reference class + double x = (double) vh.getAndSetAcquire(array, Void.class, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetAcquire(array, 0, 1.0d, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + double x = (double) vh.getAndSetRelease(null, 0, 1.0d); + }); + checkCCE(() -> { // array reference class + double x = (double) vh.getAndSetRelease(Void.class, 0, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + double x = (double) vh.getAndSetRelease(0, 0, 1.0d); + }); + checkWMTE(() -> { // index reference class + double x = (double) vh.getAndSetRelease(array, Void.class, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetRelease(array, 0, 1.0d, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,6 +2140,72 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null array + double x = (double) vh.getAndAddAcquire(null, 0, 1.0d); + }); + checkCCE(() -> { // array reference class + double x = (double) vh.getAndAddAcquire(Void.class, 0, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndAddAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + double x = (double) vh.getAndAddAcquire(0, 0, 1.0d); + }); + checkWMTE(() -> { // index reference class + double x = (double) vh.getAndAddAcquire(array, Void.class, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(array, 0, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(array, 0, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndAddAcquire(array, 0, 1.0d, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + double x = (double) vh.getAndAddRelease(null, 0, 1.0d); + }); + checkCCE(() -> { // array reference class + double x = (double) vh.getAndAddRelease(Void.class, 0, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + double x = (double) vh.getAndAddRelease(0, 0, 1.0d); + }); + checkWMTE(() -> { // index reference class + double x = (double) vh.getAndAddRelease(array, Void.class, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndAddRelease(array, 0, 1.0d, Void.class); + }); + + // AddAndGet // Incorrect argument types checkNPE(() -> { // null array @@ -1902,6 +2237,7 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { checkWMTE(() -> { // > double x = (double) vh.addAndGet(array, 0, 1.0d, Void.class); }); + } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2144,6 +2480,7 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { invokeExact(array, 0, 1.0d, Void.class); }); } + } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java index 12efef61cda..749224281cc 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndSet(recv, 1.0f, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + float x = (float) vh.getAndSetAcquire(null, 1.0f); + }); + checkCCE(() -> { // receiver reference class + float x = (float) vh.getAndSetAcquire(Void.class, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + float x = (float) vh.getAndSetAcquire(0, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetAcquire(recv, 1.0f, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + float x = (float) vh.getAndSetRelease(null, 1.0f); + }); + checkCCE(() -> { // receiver reference class + float x = (float) vh.getAndSetRelease(Void.class, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + float x = (float) vh.getAndSetRelease(0, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetRelease(recv, 1.0f, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,6 +669,63 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndAdd(recv, 1.0f, Void.class); }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + float x = (float) vh.getAndAddAcquire(null, 1.0f); + }); + checkCCE(() -> { // receiver reference class + float x = (float) vh.getAndAddAcquire(Void.class, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndAddAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + float x = (float) vh.getAndAddAcquire(0, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(recv, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(recv, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndAddAcquire(recv, 1.0f, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + float x = (float) vh.getAndAddRelease(null, 1.0f); + }); + checkCCE(() -> { // receiver reference class + float x = (float) vh.getAndAddRelease(Void.class, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + float x = (float) vh.getAndAddRelease(0, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndAddRelease(recv, 1.0f, Void.class); + }); // AddAndGet // Incorrect argument types @@ -640,6 +755,7 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { checkWMTE(() -> { // > float x = (float) vh.addAndGet(recv, 1.0f, Void.class); }); + } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeFloat recv, Handles hs) throws Throwable { @@ -853,6 +969,7 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { invokeExact(recv, 1.0f, Void.class); }); } + } @@ -1143,6 +1260,48 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndSet(1.0f, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetAcquire(1.0f, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetRelease(1.0f, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,6 +1323,48 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndAddAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndAddAcquire(1.0f, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndAddRelease(1.0f, Void.class); + }); + + // AddAndGet // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1183,6 +1384,7 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { checkWMTE(() -> { // > float x = (float) vh.addAndGet(1.0f, Void.class); }); + } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1322,6 +1524,7 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { invokeExact(1.0f, Void.class); }); } + } @@ -1838,6 +2041,72 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndSet(array, 0, 1.0f, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + float x = (float) vh.getAndSetAcquire(null, 0, 1.0f); + }); + checkCCE(() -> { // array reference class + float x = (float) vh.getAndSetAcquire(Void.class, 0, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + float x = (float) vh.getAndSetAcquire(0, 0, 1.0f); + }); + checkWMTE(() -> { // index reference class + float x = (float) vh.getAndSetAcquire(array, Void.class, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetAcquire(array, 0, 1.0f, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + float x = (float) vh.getAndSetRelease(null, 0, 1.0f); + }); + checkCCE(() -> { // array reference class + float x = (float) vh.getAndSetRelease(Void.class, 0, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + float x = (float) vh.getAndSetRelease(0, 0, 1.0f); + }); + checkWMTE(() -> { // index reference class + float x = (float) vh.getAndSetRelease(array, Void.class, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetRelease(array, 0, 1.0f, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,6 +2140,72 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null array + float x = (float) vh.getAndAddAcquire(null, 0, 1.0f); + }); + checkCCE(() -> { // array reference class + float x = (float) vh.getAndAddAcquire(Void.class, 0, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndAddAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + float x = (float) vh.getAndAddAcquire(0, 0, 1.0f); + }); + checkWMTE(() -> { // index reference class + float x = (float) vh.getAndAddAcquire(array, Void.class, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(array, 0, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(array, 0, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndAddAcquire(array, 0, 1.0f, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + float x = (float) vh.getAndAddRelease(null, 0, 1.0f); + }); + checkCCE(() -> { // array reference class + float x = (float) vh.getAndAddRelease(Void.class, 0, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + float x = (float) vh.getAndAddRelease(0, 0, 1.0f); + }); + checkWMTE(() -> { // index reference class + float x = (float) vh.getAndAddRelease(array, Void.class, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndAddRelease(array, 0, 1.0f, Void.class); + }); + + // AddAndGet // Incorrect argument types checkNPE(() -> { // null array @@ -1902,6 +2237,7 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { checkWMTE(() -> { // > float x = (float) vh.addAndGet(array, 0, 1.0f, Void.class); }); + } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2144,6 +2480,7 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { invokeExact(array, 0, 1.0f, Void.class); }); } + } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java index 7291c0ebbc2..a4277fb9615 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndSet(recv, 0x01234567, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndSetAcquire(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndSetAcquire(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndSetAcquire(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetAcquire(recv, 0x01234567, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndSetRelease(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndSetRelease(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndSetRelease(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetRelease(recv, 0x01234567, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,6 +669,63 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndAdd(recv, 0x01234567, Void.class); }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndAddAcquire(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndAddAcquire(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndAddAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndAddAcquire(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndAddAcquire(recv, 0x01234567, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndAddRelease(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndAddRelease(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndAddRelease(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndAddRelease(recv, 0x01234567, Void.class); + }); // AddAndGet // Incorrect argument types @@ -640,6 +755,275 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { checkWMTE(() -> { // > int x = (int) vh.addAndGet(recv, 0x01234567, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseOr(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseOr(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseOr(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOr(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseOrAcquire(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseOrAcquire(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseOrAcquire(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOrAcquire(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseOrRelease(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseOr(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseOr(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOr(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseAnd(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseAnd(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseAnd(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAnd(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseAndAcquire(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseAndAcquire(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseAndAcquire(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAndAcquire(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseAndRelease(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseAnd(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseAnd(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAnd(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseXor(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseXor(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseXor(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXor(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseXorAcquire(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseXorAcquire(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseXorAcquire(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXorAcquire(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseXorRelease(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseXor(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseXor(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXor(recv, 0x01234567, Void.class); + }); } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeInt recv, Handles hs) throws Throwable { @@ -853,6 +1237,43 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { invokeExact(recv, 0x01234567, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)). + invokeExact(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) hs.get(am, methodType(int.class, int.class, int.class)). + invokeExact(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) hs.get(am, methodType(int.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact(recv, 0x01234567, Void.class); + }); + } } @@ -1143,6 +1564,48 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndSet(0x01234567, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetAcquire(0x01234567, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetRelease(0x01234567, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,6 +1627,48 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndAddAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndAddAcquire(0x01234567, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndAddRelease(0x01234567, Void.class); + }); + + // AddAndGet // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1183,6 +1688,194 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { checkWMTE(() -> { // > int x = (int) vh.addAndGet(0x01234567, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOr(0x01234567, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOrAcquire(0x01234567, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOrRelease(0x01234567, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAnd(0x01234567, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAndAcquire(0x01234567, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAndRelease(0x01234567, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXor(0x01234567, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXorAcquire(0x01234567, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXorRelease(0x01234567, Void.class); + }); } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1322,6 +2015,32 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { invokeExact(0x01234567, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) hs.get(am, methodType(int.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, int.class)). + invokeExact(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)). + invokeExact(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) hs.get(am, methodType(int.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)). + invokeExact(0x01234567, Void.class); + }); + } } @@ -1838,6 +2557,72 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndSet(array, 0, 0x01234567, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndSetAcquire(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndSetAcquire(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + int x = (int) vh.getAndSetAcquire(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndSetAcquire(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetAcquire(array, 0, 0x01234567, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndSetRelease(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndSetRelease(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + int x = (int) vh.getAndSetRelease(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndSetRelease(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetRelease(array, 0, 0x01234567, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,6 +2656,72 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndAddAcquire(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndAddAcquire(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndAddAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndAddAcquire(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndAddAcquire(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndAddAcquire(array, 0, 0x01234567, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndAddRelease(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndAddRelease(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndAddRelease(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndAddRelease(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndAddRelease(array, 0, 0x01234567, Void.class); + }); + + // AddAndGet // Incorrect argument types checkNPE(() -> { // null array @@ -1902,6 +2753,302 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { checkWMTE(() -> { // > int x = (int) vh.addAndGet(array, 0, 0x01234567, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseOr(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseOr(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseOr(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseOr(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOr(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseOrAcquire(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseOrAcquire(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseOrAcquire(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseOrAcquire(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOrAcquire(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseOrRelease(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseOrRelease(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseOrRelease(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseOrRelease(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOrRelease(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseAnd(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseAnd(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseAnd(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseAnd(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAnd(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseAndAcquire(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseAndAcquire(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseAndAcquire(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseAndAcquire(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAndAcquire(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseAndRelease(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseAndRelease(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseAndRelease(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseAndRelease(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAndRelease(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseXor(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseXor(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseXor(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseXor(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXor(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseXorAcquire(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseXorAcquire(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseXorAcquire(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseXorAcquire(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXorAcquire(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseXorRelease(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseXorRelease(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseXorRelease(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseXorRelease(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXorRelease(array, 0, 0x01234567, Void.class); + }); } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2144,6 +3291,48 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { invokeExact(array, 0, 0x01234567, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)). + invokeExact((int[]) null, 0, 0x01234567); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)). + invokeExact(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)). + invokeExact(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)). + invokeExact(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)). + invokeExact(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)). + invokeExact(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) hs.get(am, methodType(int.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)). + invokeExact(array, 0, 0x01234567, Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java index d081ddec842..afaebfdcac6 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndSet(recv, 0x0123456789ABCDEFL, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndSetAcquire(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndSetAcquire(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndSetAcquire(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetAcquire(recv, 0x0123456789ABCDEFL, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndSetRelease(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndSetRelease(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndSetRelease(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetRelease(recv, 0x0123456789ABCDEFL, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,6 +669,63 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndAdd(recv, 0x0123456789ABCDEFL, Void.class); }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndAddAcquire(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndAddAcquire(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndAddAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndAddAcquire(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndAddAcquire(recv, 0x0123456789ABCDEFL, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndAddRelease(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndAddRelease(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndAddRelease(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndAddRelease(recv, 0x0123456789ABCDEFL, Void.class); + }); // AddAndGet // Incorrect argument types @@ -640,6 +755,275 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { checkWMTE(() -> { // > long x = (long) vh.addAndGet(recv, 0x0123456789ABCDEFL, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseOr(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseOr(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseOr(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseOrAcquire(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseOrAcquire(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseOrAcquire(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOrAcquire(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseOrRelease(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseOr(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseOr(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseAnd(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseAnd(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseAnd(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseAndAcquire(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseAndAcquire(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseAndAcquire(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAndAcquire(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseAndRelease(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseAnd(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseAnd(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseXor(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseXor(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseXor(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseXorAcquire(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseXorAcquire(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseXorAcquire(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXorAcquire(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseXorRelease(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseXor(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseXor(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL, Void.class); + }); } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeLong recv, Handles hs) throws Throwable { @@ -853,6 +1237,43 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { invokeExact(recv, 0x0123456789ABCDEFL, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact((VarHandleTestMethodTypeLong) null, 0x0123456789ABCDEFL); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)). + invokeExact(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) hs.get(am, methodType(long.class, int.class, long.class)). + invokeExact(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) hs.get(am, methodType(long.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact(recv, 0x0123456789ABCDEFL, Void.class); + }); + } } @@ -1143,6 +1564,48 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndSet(0x0123456789ABCDEFL, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetAcquire(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetRelease(0x0123456789ABCDEFL, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,6 +1627,48 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndAddAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndAddAcquire(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndAddRelease(0x0123456789ABCDEFL, Void.class); + }); + + // AddAndGet // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1183,6 +1688,194 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { checkWMTE(() -> { // > long x = (long) vh.addAndGet(0x0123456789ABCDEFL, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOr(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOrAcquire(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOrRelease(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAnd(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAndAcquire(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAndRelease(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXor(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXorAcquire(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXorRelease(0x0123456789ABCDEFL, Void.class); + }); } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1322,6 +2015,32 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { invokeExact(0x0123456789ABCDEFL, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) hs.get(am, methodType(long.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, long.class)). + invokeExact(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)). + invokeExact(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) hs.get(am, methodType(long.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)). + invokeExact(0x0123456789ABCDEFL, Void.class); + }); + } } @@ -1838,6 +2557,72 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndSet(array, 0, 0x0123456789ABCDEFL, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndSetAcquire(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndSetAcquire(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + long x = (long) vh.getAndSetAcquire(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndSetAcquire(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetAcquire(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndSetRelease(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndSetRelease(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + long x = (long) vh.getAndSetRelease(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndSetRelease(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetRelease(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,6 +2656,72 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndAddAcquire(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndAddAcquire(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndAddAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndAddAcquire(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndAddAcquire(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndAddAcquire(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndAddRelease(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndAddRelease(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndAddRelease(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndAddRelease(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndAddRelease(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + // AddAndGet // Incorrect argument types checkNPE(() -> { // null array @@ -1902,6 +2753,302 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { checkWMTE(() -> { // > long x = (long) vh.addAndGet(array, 0, 0x0123456789ABCDEFL, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseOr(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseOr(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseOr(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseOr(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOr(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseOrAcquire(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseOrAcquire(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseOrAcquire(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseOrAcquire(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOrAcquire(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseOrRelease(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseOrRelease(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseOrRelease(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseOrRelease(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOrRelease(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseAnd(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseAnd(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseAnd(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseAnd(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAnd(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseAndAcquire(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseAndAcquire(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseAndAcquire(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseAndAcquire(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAndAcquire(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseAndRelease(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseAndRelease(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseAndRelease(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseAndRelease(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAndRelease(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseXor(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseXor(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseXor(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseXor(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXor(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseXorAcquire(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseXorAcquire(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseXorAcquire(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseXorAcquire(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXorAcquire(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseXorRelease(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseXorRelease(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseXorRelease(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseXorRelease(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXorRelease(array, 0, 0x0123456789ABCDEFL, Void.class); + }); } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2144,6 +3291,48 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { invokeExact(array, 0, 0x0123456789ABCDEFL, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)). + invokeExact((long[]) null, 0, 0x0123456789ABCDEFL); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)). + invokeExact(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)). + invokeExact(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)). + invokeExact(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)). + invokeExact(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)). + invokeExact(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) hs.get(am, methodType(long.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)). + invokeExact(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java index eba0cd204b3..f97bf26fec6 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndSet(recv, (short)0x0123, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndSetAcquire(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndSetAcquire(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndSetAcquire(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetAcquire(recv, (short)0x0123, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndSetRelease(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndSetRelease(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndSetRelease(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetRelease(recv, (short)0x0123, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,6 +669,63 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndAdd(recv, (short)0x0123, Void.class); }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndAddAcquire(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndAddAcquire(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndAddAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndAddAcquire(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndAddAcquire(recv, (short)0x0123, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndAddRelease(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndAddRelease(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndAddRelease(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndAddRelease(recv, (short)0x0123, Void.class); + }); // AddAndGet // Incorrect argument types @@ -640,6 +755,275 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { checkWMTE(() -> { // > short x = (short) vh.addAndGet(recv, (short)0x0123, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseOr(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseOr(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseOr(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOr(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseOrAcquire(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseOrAcquire(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseOrAcquire(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOrAcquire(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseOrRelease(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseOr(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseOr(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOr(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseAnd(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseAnd(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseAnd(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAnd(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseAndAcquire(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseAndAcquire(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseAndAcquire(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAndAcquire(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseAndRelease(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseAnd(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseAnd(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAnd(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseXor(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseXor(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseXor(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXor(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseXorAcquire(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseXorAcquire(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseXorAcquire(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXorAcquire(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseXorRelease(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseXor(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseXor(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXor(recv, (short)0x0123, Void.class); + }); } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeShort recv, Handles hs) throws Throwable { @@ -853,6 +1237,43 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { invokeExact(recv, (short)0x0123, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class)). + invokeExact((VarHandleTestMethodTypeShort) null, (short)0x0123); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + short x = (short) hs.get(am, methodType(short.class, Class.class, short.class)). + invokeExact(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) hs.get(am, methodType(short.class, int.class, short.class)). + invokeExact(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeShort.class, short.class)). + invokeExact(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class, short.class)). + invokeExact(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) hs.get(am, methodType(short.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class)). + invokeExact(recv, (short)0x0123, Void.class); + }); + } } @@ -1143,6 +1564,48 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndSet((short)0x0123, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetAcquire((short)0x0123, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetRelease((short)0x0123, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,6 +1627,48 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndAddAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndAddAcquire((short)0x0123, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndAddRelease((short)0x0123, Void.class); + }); + + // AddAndGet // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1183,6 +1688,194 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { checkWMTE(() -> { // > short x = (short) vh.addAndGet((short)0x0123, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOr((short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOrAcquire((short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOrRelease((short)0x0123, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAnd((short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAndAcquire((short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAndRelease((short)0x0123, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXor((short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXorAcquire((short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXorRelease((short)0x0123, Void.class); + }); } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1322,6 +2015,32 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { invokeExact((short)0x0123, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) hs.get(am, methodType(short.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, short.class)). + invokeExact((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, short.class)). + invokeExact((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) hs.get(am, methodType(short.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + short x = (short) hs.get(am, methodType(short.class, short.class, Class.class)). + invokeExact((short)0x0123, Void.class); + }); + } } @@ -1838,6 +2557,72 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndSet(array, 0, (short)0x0123, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndSetAcquire(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndSetAcquire(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + short x = (short) vh.getAndSetAcquire(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndSetAcquire(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetAcquire(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndSetRelease(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndSetRelease(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + short x = (short) vh.getAndSetRelease(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndSetRelease(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetRelease(array, 0, (short)0x0123, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,6 +2656,72 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndAddAcquire(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndAddAcquire(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndAddAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndAddAcquire(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndAddAcquire(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddAcquire(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndAddAcquire(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndAddRelease(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndAddRelease(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndAddRelease(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndAddRelease(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndAddRelease(array, 0, (short)0x0123, Void.class); + }); + + // AddAndGet // Incorrect argument types checkNPE(() -> { // null array @@ -1902,6 +2753,302 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { checkWMTE(() -> { // > short x = (short) vh.addAndGet(array, 0, (short)0x0123, Void.class); }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseOr(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseOr(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseOr(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseOr(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOr(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseOrAcquire(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseOrAcquire(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseOrAcquire(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseOrAcquire(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOrAcquire(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseOrRelease(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseOrRelease(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseOrRelease(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseOrRelease(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOrRelease(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseAnd(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseAnd(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseAnd(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseAnd(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAnd(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseAndAcquire(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseAndAcquire(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseAndAcquire(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseAndAcquire(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAndAcquire(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseAndRelease(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseAndRelease(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseAndRelease(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseAndRelease(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAndRelease(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseXor(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseXor(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseXor(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseXor(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXor(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseXorAcquire(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseXorAcquire(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseXorAcquire(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseXorAcquire(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXorAcquire(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseXorRelease(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseXorRelease(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseXorRelease(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseXorRelease(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXorRelease(array, 0, (short)0x0123, Void.class); + }); } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2144,6 +3291,48 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { invokeExact(array, 0, (short)0x0123, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class)). + invokeExact((short[]) null, 0, (short)0x0123); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + short x = (short) hs.get(am, methodType(short.class, Class.class, int.class, short.class)). + invokeExact(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) hs.get(am, methodType(short.class, int.class, int.class, short.class)). + invokeExact(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) hs.get(am, methodType(short.class, short[].class, Class.class, short.class)). + invokeExact(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, short[].class, int.class, short.class)). + invokeExact(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class, short.class)). + invokeExact(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) hs.get(am, methodType(short.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class, Class.class)). + invokeExact(array, 0, (short)0x0123, Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java index 91e25c99bb9..883bfed71da 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java @@ -582,6 +582,65 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { String x = (String) vh.getAndSet(recv, "foo", Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + String x = (String) vh.getAndSetAcquire(null, "foo"); + }); + checkCCE(() -> { // receiver reference class + String x = (String) vh.getAndSetAcquire(Void.class, "foo"); + }); + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + String x = (String) vh.getAndSetAcquire(0, "foo"); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, "foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetAcquire(recv, "foo", Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + String x = (String) vh.getAndSetRelease(null, "foo"); + }); + checkCCE(() -> { // receiver reference class + String x = (String) vh.getAndSetRelease(Void.class, "foo"); + }); + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + String x = (String) vh.getAndSetRelease(0, "foo"); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, "foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetRelease(recv, "foo", Void.class); + }); + + } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeString recv, Handles hs) throws Throwable { @@ -759,6 +818,7 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); } + } @@ -1049,6 +1109,49 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { String x = (String) vh.getAndSet("foo", Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire("foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire("foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetAcquire("foo", Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease("foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease("foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetRelease("foo", Void.class); + }); + + } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1163,6 +1266,7 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); } + } @@ -1679,6 +1783,73 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { String x = (String) vh.getAndSet(array, 0, "foo", Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + String x = (String) vh.getAndSetAcquire(null, 0, "foo"); + }); + checkCCE(() -> { // array reference class + String x = (String) vh.getAndSetAcquire(Void.class, 0, "foo"); + }); + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + String x = (String) vh.getAndSetAcquire(0, 0, "foo"); + }); + checkWMTE(() -> { // index reference class + String x = (String) vh.getAndSetAcquire(array, Void.class, "foo"); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, "foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetAcquire(array, 0, "foo", Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + String x = (String) vh.getAndSetRelease(null, 0, "foo"); + }); + checkCCE(() -> { // array reference class + String x = (String) vh.getAndSetRelease(Void.class, 0, "foo"); + }); + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + String x = (String) vh.getAndSetRelease(0, 0, "foo"); + }); + checkWMTE(() -> { // index reference class + String x = (String) vh.getAndSetRelease(array, Void.class, "foo"); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, "foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetRelease(array, 0, "foo", Void.class); + }); + + } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -1880,6 +2051,7 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); } + } } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template index a0b48a90bda..021bc31bf19 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template @@ -109,6 +109,8 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); #else[CAS] assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); @@ -119,15 +121,43 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); #end[CAS] #if[AtomicAdd] assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); #else[AtomicAdd] assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); #end[AtomicAdd] + +#if[Bitwise] + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); +#else[Bitwise] + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); +#end[Bitwise] } @@ -313,6 +343,14 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ r = ($type$) vh.getAndSet(recv, $value1$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetRelease(recv, $value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -320,10 +358,56 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { $type$ o = ($type$) vh.getAndAdd(recv, $value1$); }); + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(recv, $value1$); + }); + checkUOE(() -> { $type$ o = ($type$) vh.addAndGet(recv, $value1$); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(recv, $value1$); + }); +#end[Bitwise] } @@ -407,6 +491,14 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ r = ($type$) vh.getAndSet($value1$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetAcquire($value1$); + }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetRelease($value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -414,10 +506,56 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { $type$ o = ($type$) vh.getAndAdd($value1$); }); + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease($value1$); + }); + checkUOE(() -> { $type$ o = ($type$) vh.addAndGet($value1$); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease($value1$); + }); +#end[Bitwise] } @@ -553,24 +691,148 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { // Compare set and get { + vh.set(recv, $value1$); + $type$ o = ($type$) vh.getAndSet(recv, $value2$); assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) vh.get(recv); assertEquals(x, $value2$, "getAndSet $type$ value"); } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndSetAcquire(recv, $value2$); + assertEquals(o, $value1$, "getAndSetAcquire $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndSetRelease(recv, $value2$); + assertEquals(o, $value1$, "getAndSetRelease $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, $value2$, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - vh.set(recv, $value1$); - // get and add, add and get { + vh.set(recv, $value1$); + $type$ o = ($type$) vh.getAndAdd(recv, $value3$); assertEquals(o, $value1$, "getAndAdd $type$"); $type$ c = ($type$) vh.addAndGet(recv, $value3$); assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndAddAcquire(recv, $value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndAddRelease(recv, $value2$); + assertEquals(o, $value1$, "getAndAddRelease$type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); + } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOr(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrRelease(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAnd(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndRelease(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXor(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorRelease(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } static void testInstanceFieldUnsupported(VarHandleTestAccess$Type$ recv, VarHandle vh) { @@ -610,6 +872,14 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ r = ($type$) vh.getAndSet(recv, $value1$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetRelease(recv, $value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -617,10 +887,56 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { $type$ o = ($type$) vh.getAndAdd(recv, $value1$); }); + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(recv, $value1$); + }); + checkUOE(() -> { $type$ o = ($type$) vh.addAndGet(recv, $value1$); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(recv, $value1$); + }); +#end[Bitwise] } @@ -756,24 +1072,148 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { // Compare set and get { + vh.set($value1$); + $type$ o = ($type$) vh.getAndSet($value2$); assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) vh.get(); assertEquals(x, $value2$, "getAndSet $type$ value"); } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndSetAcquire($value2$); + assertEquals(o, $value1$, "getAndSetAcquire $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndSetRelease($value2$); + assertEquals(o, $value1$, "getAndSetRelease $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, $value2$, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - vh.set($value1$); - // get and add, add and get { + vh.set($value1$); + $type$ o = ($type$) vh.getAndAdd( $value3$); assertEquals(o, $value1$, "getAndAdd $type$"); $type$ c = ($type$) vh.addAndGet($value3$); assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndAddAcquire($value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndAddRelease($value2$); + assertEquals(o, $value1$, "getAndAddRelease$type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); + } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseOr($value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrAcquire($value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrRelease($value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseAnd($value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndAcquire($value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndRelease($value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseXor($value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorAcquire($value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorRelease($value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } static void testStaticFieldUnsupported(VarHandle vh) { @@ -813,6 +1253,14 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ r = ($type$) vh.getAndSet($value1$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetAcquire($value1$); + }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetRelease($value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -820,10 +1268,56 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { $type$ o = ($type$) vh.getAndAdd($value1$); }); + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease($value1$); + }); + checkUOE(() -> { $type$ o = ($type$) vh.addAndGet($value1$); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease($value1$); + }); +#end[Bitwise] } @@ -962,24 +1456,148 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { // Compare set and get { + vh.set(array, i, $value1$); + $type$ o = ($type$) vh.getAndSet(array, i, $value2$); assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, $value2$, "getAndSet $type$ value"); } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndSetAcquire(array, i, $value2$); + assertEquals(o, $value1$, "getAndSetAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndSetRelease(array, i, $value2$); + assertEquals(o, $value1$, "getAndSetRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, $value2$, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - vh.set(array, i, $value1$); - // get and add, add and get { + vh.set(array, i, $value1$); + $type$ o = ($type$) vh.getAndAdd(array, i, $value3$); assertEquals(o, $value1$, "getAndAdd $type$"); $type$ c = ($type$) vh.addAndGet(array, i, $value3$); assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndAddAcquire(array, i, $value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndAddRelease(array, i, $value2$); + assertEquals(o, $value1$, "getAndAddRelease$type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); + } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOr(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAnd(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXor(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } } @@ -1023,6 +1641,14 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ r = ($type$) vh.getAndSet(array, i, $value1$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetAcquire(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetRelease(array, i, $value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -1030,10 +1656,56 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { $type$ o = ($type$) vh.getAndAdd(array, i, $value1$); }); + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, i, $value1$); + }); + checkUOE(() -> { $type$ o = ($type$) vh.addAndGet(array, i, $value1$); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, i, $value1$); + }); +#end[Bitwise] } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -1110,17 +1782,71 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkIOOBE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, $value1$); }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, $value1$); + }); #end[CAS] #if[AtomicAdd] checkIOOBE(() -> { - $type$ o = ($type$) vh.getAndAdd(array, ci, $value3$); + $type$ o = ($type$) vh.getAndAdd(array, ci, $value1$); }); checkIOOBE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, $value3$); + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.addAndGet(array, ci, $value1$); }); #end[AtomicAdd] + +#if[Bitwise] + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, $value1$); + }); +#end[Bitwise] } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template index a7aef2b898c..92c1ae98b38 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template @@ -98,6 +98,8 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); #else[CAS] assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); @@ -108,15 +110,43 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); #end[CAS] #if[AtomicAdd] assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); #else[AtomicAdd] assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); #end[AtomicAdd] + +#if[Bitwise] + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); +#else[Bitwise] + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); +#end[Bitwise] } @Test(dataProvider = "typesProvider") @@ -237,6 +267,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[!AtomicAdd] @@ -244,10 +282,56 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { $type$ o = ($type$) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } static void testArrayUnsupported(ByteBufferSource bs, VarHandleSource vhs) { @@ -312,6 +396,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + checkROBE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); + #else[CAS] checkUOE(() -> { boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2); @@ -348,6 +440,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[AtomicAdd] @@ -355,6 +455,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { $type$ o = ($type$) vh.getAndAdd(array, ci, VALUE_1); }); + checkROBE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkROBE(() -> { $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); }); @@ -363,10 +471,92 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { $type$ o = ($type$) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); }); #end[AtomicAdd] + +#if[Bitwise] + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#else[Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } else { #if[!CAS] @@ -405,16 +595,69 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[!AtomicAdd] checkUOE(() -> { $type$ o = ($type$) vh.getAndAdd(array, ci, VALUE_1); }); + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); }); #end[AtomicAdd] +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } } @@ -495,6 +738,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkIOOBE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[AtomicAdd] @@ -502,11 +753,57 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { $type$ o = ($type$) vh.getAndAdd(array, ci, VALUE_1); }); + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); }); #end[AtomicAdd] +#if[Bitwise] + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] + } } @@ -591,6 +888,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkIOOBE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[AtomicAdd] @@ -598,10 +903,56 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { $type$ o = ($type$) vh.getAndAdd(array, ci, VALUE_1); }); + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); }); #end[AtomicAdd] + +#if[Bitwise] + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } } } @@ -678,6 +1029,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkISE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[AtomicAdd] @@ -685,11 +1044,56 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { $type$ o = ($type$) vh.getAndAdd(array, ci, VALUE_1); }); + checkISE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkISE(() -> { $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); }); #end[AtomicAdd] +#if[Bitwise] + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } } } @@ -768,6 +1172,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkISE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[AtomicAdd] @@ -775,10 +1187,56 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { $type$ o = ($type$) vh.getAndAdd(array, ci, VALUE_1); }); + checkISE(() -> { + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkISE(() -> { $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); }); #end[AtomicAdd] + +#if[Bitwise] + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } } } @@ -924,24 +1382,148 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { // Compare set and get { + vh.set(array, i, VALUE_1); + $type$ o = ($type$) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet $type$ value"); } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - vh.set(array, i, VALUE_1); - // get and add, add and get { + vh.set(array, i, VALUE_1); + $type$ o = ($type$) vh.getAndAdd(array, i, VALUE_3); assertEquals(o, VALUE_1, "getAndAdd $type$"); $type$ c = ($type$) vh.addAndGet(array, i, VALUE_3); assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd $type$ value"); } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease $type$ value"); + } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } } } @@ -1086,24 +1668,148 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { // Compare set and get { + vh.set(array, i, VALUE_1); + $type$ o = ($type$) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet $type$ value"); } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - vh.set(array, i, VALUE_1); - // get and add, add and get { + vh.set(array, i, VALUE_1); + $type$ o = ($type$) vh.getAndAdd(array, i, VALUE_3); assertEquals(o, VALUE_1, "getAndAdd $type$"); $type$ c = ($type$) vh.addAndGet(array, i, VALUE_3); assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd $type$ value"); } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease $type$ value"); + } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template index 6df8b203e3a..a5011c753b8 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template @@ -258,16 +258,120 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { #end[CAS] #if[AtomicAdd] - hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); - // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, $value3$); assertEquals(o, $value1$, "getAndAdd $type$"); $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, $value3$); assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndAddRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); + } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccess$Type$ recv, Handles hs) throws Throwable { @@ -298,6 +402,14 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[!Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + $type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$); + }); + } +#end[Bitwise] } @@ -433,24 +545,150 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { // Compare set and get { - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact( $value2$); + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact($value2$); assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, $value2$, "getAndSet $type$ value"); } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndSetAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndSetRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, $value2$, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - hs.get(TestAccessMode.SET).invokeExact($value1$); - // get and add, add and get { - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( $value3$); + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact($value3$); assertEquals(o, $value1$, "getAndAdd $type$"); $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact($value3$); assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndAddRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); + } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } static void testStaticFieldUnsupported(Handles hs) throws Throwable { @@ -481,6 +719,14 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[!Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + $type$ r = ($type$) hs.get(am).invokeExact($value1$); + }); + } +#end[Bitwise] } @@ -619,24 +865,148 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, $value2$); assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, $value2$, "getAndSet $type$ value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndSetAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndSetRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, $value2$, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); - // get and add, add and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, $value3$); assertEquals(o, $value1$, "getAndAdd $type$"); $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, $value3$); assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndAddRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); + } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } } @@ -671,6 +1041,14 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[!Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + $type$ o = ($type$) hs.get(am).invokeExact(array, i, $value1$); + }); + } +#end[Bitwise] } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -718,6 +1096,14 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + $type$ o = ($type$) hs.get(am).invokeExact(array, ci, $value3$); + }); + } +#end[Bitwise] } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template index 15c4610df43..88127d51066 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template @@ -582,6 +582,64 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { checkWMTE(() -> { // > $type$ x = ($type$) vh.getAndSet(recv, $value1$, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndSetAcquire(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndSetAcquire(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndSetAcquire(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetAcquire(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetAcquire(recv, $value1$, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndSetRelease(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndSetRelease(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndSetRelease(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetRelease(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetRelease(recv, $value1$, Void.class); + }); #end[CAS] #if[AtomicAdd] @@ -614,6 +672,63 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { $type$ x = ($type$) vh.getAndAdd(recv, $value1$, Void.class); }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndAddAcquire(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndAddAcquire(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndAddAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndAddAcquire(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddAcquire(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndAddAcquire(recv, $value1$, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndAddRelease(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndAddRelease(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndAddRelease(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddRelease(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndAddRelease(recv, $value1$, Void.class); + }); // AddAndGet // Incorrect argument types @@ -644,6 +759,277 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { $type$ x = ($type$) vh.addAndGet(recv, $value1$, Void.class); }); #end[AtomicAdd] + +#if[Bitwise] + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseOr(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseOr(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseOr(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOr(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOr(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOrAcquire(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseOrRelease(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseOr(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseOr(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOr(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOr(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseAnd(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseAnd(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAnd(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAnd(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAndAcquire(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseAndRelease(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseAnd(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAnd(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAnd(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseXor(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseXor(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseXor(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXor(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXor(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXorAcquire(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseXorRelease(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseXor(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseXor(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXor(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXor(recv, $value1$, Void.class); + }); +#end[Bitwise] } static void testInstanceFieldWrongMethodType(VarHandleTestMethodType$Type$ recv, Handles hs) throws Throwable { @@ -861,6 +1247,45 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact((VarHandleTestMethodType$Type$) null, $value1$); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). + invokeExact(Void.class, $value1$); + }); + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)). + invokeExact(0, $value1$); + }); + // Incorrect return type + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) hs.get(am, methodType($type$.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact(recv, $value1$, Void.class); + }); + } +#end[Bitwise] } @@ -1151,6 +1576,48 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { checkWMTE(() -> { // > $type$ x = ($type$) vh.getAndSet($value1$, Void.class); }); + + + // GetAndSetAcquire + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetAcquire($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetAcquire($value1$, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetRelease($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetRelease($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetRelease($value1$, Void.class); + }); #end[CAS] #if[AtomicAdd] @@ -1175,6 +1642,48 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndAddAcquire(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddAcquire($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndAddAcquire($value1$, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndAddRelease($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddRelease($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndAddRelease($value1$, Void.class); + }); + + // AddAndGet // Incorrect argument types check{#if[String]?CCE:WMTE}(() -> { // value reference class @@ -1195,6 +1704,196 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { $type$ x = ($type$) vh.addAndGet($value1$, Void.class); }); #end[AtomicAdd] + +#if[Bitwise] + // GetAndBitwiseOr + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOr($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOr($value1$, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOrAcquire($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOrAcquire($value1$, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOrRelease($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOrRelease($value1$, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAnd($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAnd($value1$, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAndAcquire($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAndAcquire($value1$, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAndRelease($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAndRelease($value1$, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXor($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXor($value1$, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXorAcquire($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXorAcquire($value1$, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXorRelease($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXorRelease($value1$, Void.class); + }); +#end[Bitwise] } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1338,6 +2037,34 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)). + invokeExact($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)). + invokeExact($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) hs.get(am, methodType($type$.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). + invokeExact($value1$, Void.class); + }); + } +#end[Bitwise] } @@ -1854,6 +2581,72 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { checkWMTE(() -> { // > $type$ x = ($type$) vh.getAndSet(array, 0, $value1$, Void.class); }); + + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndSetAcquire(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndSetAcquire(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + $type$ x = ($type$) vh.getAndSetAcquire(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndSetAcquire(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetAcquire(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetAcquire(array, 0, $value1$, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndSetRelease(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndSetRelease(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + $type$ x = ($type$) vh.getAndSetRelease(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndSetRelease(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetRelease(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetRelease(array, 0, $value1$, Void.class); + }); #end[CAS] #if[AtomicAdd] @@ -1890,6 +2683,72 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); + // GetAndAddAcquire + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndAddAcquire(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndAddAcquire(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndAddAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndAddAcquire(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndAddAcquire(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndAddAcquire(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddAcquire(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndAddAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndAddAcquire(array, 0, $value1$, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndAddRelease(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndAddRelease(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndAddRelease(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndAddRelease(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddRelease(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndAddRelease(array, 0, $value1$, Void.class); + }); + + // AddAndGet // Incorrect argument types checkNPE(() -> { // null array @@ -1922,6 +2781,304 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { $type$ x = ($type$) vh.addAndGet(array, 0, $value1$, Void.class); }); #end[AtomicAdd] + +#if[Bitwise] + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseOr(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseOr(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseOr(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseOr(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOr(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOr(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOrAcquire(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseOrRelease(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseOrRelease(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseOrRelease(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseOrRelease(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOrRelease(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOrRelease(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseAnd(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseAnd(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAnd(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAnd(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAndAcquire(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseAndRelease(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseAndRelease(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseAndRelease(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseAndRelease(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAndRelease(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAndRelease(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseXor(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseXor(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseXor(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseXor(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXor(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXor(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXorAcquire(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseXorRelease(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseXorRelease(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseXorRelease(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseXorRelease(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXorRelease(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXorRelease(array, 0, $value1$, Void.class); + }); +#end[Bitwise] } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2168,6 +3325,50 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)). + invokeExact(($type$[]) null, 0, $value1$); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)). + invokeExact(Void.class, 0, $value1$); + }); + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)). + invokeExact(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)). + invokeExact(array, Void.class, $value1$); + }); + // Incorrect return type + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)). + invokeExact(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)). + invokeExact(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) hs.get(am, methodType($type$.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). + invokeExact(array, 0, $value1$, Void.class); + }); + } +#end[Bitwise] } } diff --git a/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh b/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh index 02ae5ae304f..2641f8d58d5 100644 --- a/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh +++ b/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh @@ -22,6 +22,12 @@ do ;; esac + case $type in + boolean|byte|short|char|int|long) + args="$args -KBitwise" + ;; + esac + wrong_primitive_type=boolean case $type in @@ -109,6 +115,12 @@ do ;; esac + case $type in + int|long) + args="$args -KBitwise" + ;; + esac + # The value of `value3` is chosen such that when added to `value1` or `value2` # it will result in carrying of bits over to the next byte, thereby detecting # possible errors in endianness conversion e.g. if say for atomic addition the From c073edc24c6ebd0b052092c24a1428157e9678c3 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 1 Sep 2016 10:17:01 -0700 Subject: [PATCH 102/296] 8162106: Remove VarHandle.addAndGet Reviewed-by: shade, redestad --- .../classes/java/lang/invoke/VarHandle.java | 39 --------- .../lang/invoke/X-VarHandle.java.template | 21 ----- .../X-VarHandleByteArrayView.java.template | 10 --- .../util/concurrent/atomic/AtomicInteger.java | 2 +- .../concurrent/atomic/AtomicIntegerArray.java | 12 +-- .../util/concurrent/atomic/AtomicLong.java | 6 +- .../concurrent/atomic/AtomicLongArray.java | 12 +-- .../invoke/VarHandles/VarHandleBaseTest.java | 1 - .../VarHandleTestAccessBoolean.java | 21 ----- .../VarHandles/VarHandleTestAccessByte.java | 23 ++--- .../VarHandles/VarHandleTestAccessChar.java | 23 ++--- .../VarHandles/VarHandleTestAccessDouble.java | 23 ++--- .../VarHandles/VarHandleTestAccessFloat.java | 23 ++--- .../VarHandles/VarHandleTestAccessInt.java | 23 ++--- .../VarHandles/VarHandleTestAccessLong.java | 23 ++--- .../VarHandles/VarHandleTestAccessShort.java | 23 ++--- .../VarHandles/VarHandleTestAccessString.java | 21 ----- .../VarHandleTestByteArrayAsChar.java | 13 --- .../VarHandleTestByteArrayAsDouble.java | 13 --- .../VarHandleTestByteArrayAsFloat.java | 13 --- .../VarHandleTestByteArrayAsInt.java | 33 ++------ .../VarHandleTestByteArrayAsLong.java | 33 ++------ .../VarHandleTestByteArrayAsShort.java | 13 --- .../VarHandleTestMethodHandleAccessByte.java | 18 ++-- .../VarHandleTestMethodHandleAccessChar.java | 18 ++-- ...VarHandleTestMethodHandleAccessDouble.java | 18 ++-- .../VarHandleTestMethodHandleAccessFloat.java | 18 ++-- .../VarHandleTestMethodHandleAccessInt.java | 18 ++-- .../VarHandleTestMethodHandleAccessLong.java | 18 ++-- .../VarHandleTestMethodHandleAccessShort.java | 18 ++-- .../VarHandleTestMethodTypeByte.java | 83 ------------------- .../VarHandleTestMethodTypeChar.java | 83 ------------------- .../VarHandleTestMethodTypeDouble.java | 83 ------------------- .../VarHandleTestMethodTypeFloat.java | 83 ------------------- .../VarHandleTestMethodTypeInt.java | 83 ------------------- .../VarHandleTestMethodTypeLong.java | 83 ------------------- .../VarHandleTestMethodTypeShort.java | 83 ------------------- .../X-VarHandleTestAccess.java.template | 44 ++-------- ...X-VarHandleTestByteArrayView.java.template | 46 ++-------- ...HandleTestMethodHandleAccess.java.template | 18 ++-- .../X-VarHandleTestMethodType.java.template | 83 ------------------- 41 files changed, 178 insertions(+), 1144 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java index 09734f38f10..428906ed618 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java @@ -1172,39 +1172,6 @@ public abstract class VarHandle { @HotSpotIntrinsicCandidate Object getAndAddRelease(Object... args); - /** - * Atomically adds the {@code value} to the current value of a variable with - * the memory semantics of {@link #setVolatile}, and returns the variable's - * current (updated) value, as accessed with the memory semantics of - * {@link #getVolatile}. - * - *

    The method signature is of the form {@code (CT, T value)T}. - * - *

    The symbolic type descriptor at the call site of {@code addAndGet} - * must match the access mode type that is the result of calling - * {@code accessModeType(VarHandle.AccessMode.ADD_AND_GET)} on this - * VarHandle. - * - * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T value)} - * , statically represented using varargs. - * @return the signature-polymorphic result that is the current value of - * the variable - * , statically represented using {@code Object}. - * @throws UnsupportedOperationException if the access mode is unsupported - * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. - * @see #setVolatile(Object...) - * @see #getVolatile(Object...) - */ - public final native - @MethodHandle.PolymorphicSignature - @HotSpotIntrinsicCandidate - Object addAndGet(Object... args); - // Bitwise operations // Throw UnsupportedOperationException for refs @@ -1748,12 +1715,6 @@ public abstract class VarHandle { * {@link VarHandle#getAndAddRelease VarHandle.getAndAddRelease} */ GET_AND_ADD_RELEASE("getAndAddRelease", AccessType.GET_AND_UPDATE), - /** - * The access mode whose access is specified by the corresponding - * method - * {@link VarHandle#addAndGet VarHandle.addAndGet} - */ - ADD_AND_GET("addAndGet", AccessType.GET_AND_UPDATE), /** * The access mode whose access is specified by the corresponding * method diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template index 2383daed5ff..e7fc86eea64 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template @@ -231,12 +231,6 @@ final class VarHandle$Type$s { value); } - @ForceInline - static $type$ addAndGet(FieldInstanceReadWrite handle, Object holder, $type$ value) { - return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), - handle.fieldOffset, - value) + value); - } #end[AtomicAdd] #if[Bitwise] @@ -504,13 +498,6 @@ final class VarHandle$Type$s { handle.fieldOffset, value); } - - @ForceInline - static $type$ addAndGet(FieldStaticReadWrite handle, $type$ value) { - return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(handle.base, - handle.fieldOffset, - value) + value); - } #end[AtomicAdd] #if[Bitwise] @@ -860,14 +847,6 @@ final class VarHandle$Type$s { (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } - - @ForceInline - static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) { - $type$[] array = ($type$[]) oarray; - return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(array, - (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, - value) + value); - } #end[AtomicAdd] #if[Bitwise] diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template index 669e8c08a7c..e596c1306fb 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template @@ -340,11 +340,6 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); return expectedValue; } - - @ForceInline - static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ delta) { - return getAndAdd(handle, oba, index, delta) + delta; - } #end[AtomicAdd] #if[Bitwise] @@ -785,11 +780,6 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); return expectedValue; } - - @ForceInline - static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ delta) { - return getAndAdd(handle, obb, index, delta) + delta; - } #end[AtomicAdd] #if[Bitwise] diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java index fa7af454788..f7bcfdbe075 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java @@ -217,7 +217,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { /** * Atomically adds the given value to the current value, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * * @param delta the value to add * @return the updated value diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java index 301aa4a5844..8732a169dce 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java @@ -200,7 +200,7 @@ public class AtomicIntegerArray implements java.io.Serializable { /** * Atomically increments the value of the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

    Equivalent to {@code addAndGet(i, 1)}. * @@ -208,12 +208,12 @@ public class AtomicIntegerArray implements java.io.Serializable { * @return the updated value */ public final int incrementAndGet(int i) { - return (int)AA.addAndGet(array, i, 1); + return (int)AA.getAndAdd(array, i, 1) + 1; } /** * Atomically decrements the value of the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

    Equivalent to {@code addAndGet(i, -1)}. * @@ -221,19 +221,19 @@ public class AtomicIntegerArray implements java.io.Serializable { * @return the updated value */ public final int decrementAndGet(int i) { - return (int)AA.addAndGet(array, i, -1); + return (int)AA.getAndAdd(array, i, -1) - 1; } /** * Atomically adds the given value to the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * * @param i the index * @param delta the value to add * @return the updated value */ public final int addAndGet(int i, int delta) { - return (int)AA.addAndGet(array, i, delta); + return (int)AA.getAndAdd(array, i, delta) + delta; } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java index 726e7a3b7e3..f95ab65c48f 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java @@ -209,7 +209,7 @@ public class AtomicLong extends Number implements java.io.Serializable { /** * Atomically increments the current value, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

    Equivalent to {@code addAndGet(1)}. * @@ -221,7 +221,7 @@ public class AtomicLong extends Number implements java.io.Serializable { /** * Atomically decrements the current value, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

    Equivalent to {@code addAndGet(-1)}. * @@ -233,7 +233,7 @@ public class AtomicLong extends Number implements java.io.Serializable { /** * Atomically adds the given value to the current value, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * * @param delta the value to add * @return the updated value diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java index 3d584cf44e0..a3200d43f6a 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java @@ -200,7 +200,7 @@ public class AtomicLongArray implements java.io.Serializable { /** * Atomically increments the value of the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

    Equivalent to {@code addAndGet(i, 1)}. * @@ -208,12 +208,12 @@ public class AtomicLongArray implements java.io.Serializable { * @return the updated value */ public final long incrementAndGet(int i) { - return (long)AA.addAndGet(array, i, 1L); + return (long)AA.getAndAdd(array, i, 1L) + 1L; } /** * Atomically decrements the value of the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

    Equivalent to {@code addAndGet(i, -1)}. * @@ -221,19 +221,19 @@ public class AtomicLongArray implements java.io.Serializable { * @return the updated value */ public final long decrementAndGet(int i) { - return (long)AA.addAndGet(array, i, -1L); + return (long)AA.getAndAdd(array, i, -1L) - 1L; } /** * Atomically adds the given value to the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * * @param i the index * @param delta the value to add * @return the updated value */ public long addAndGet(int i, long delta) { - return (long)AA.addAndGet(array, i, delta); + return (long)AA.getAndAdd(array, i, delta) + delta; } /** diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java index 8bfd8ff1072..7eb739ff97d 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java @@ -159,7 +159,6 @@ abstract class VarHandleBaseTest { GET_AND_ADD(TestAccessType.GET_AND_ADD), GET_AND_ADD_ACQUIRE(TestAccessType.GET_AND_ADD), GET_AND_ADD_RELEASE(TestAccessType.GET_AND_ADD), - ADD_AND_GET(TestAccessType.GET_AND_ADD), GET_AND_BITWISE_OR(TestAccessType.GET_AND_BITWISE), GET_AND_BITWISE_OR_ACQUIRE(TestAccessType.GET_AND_BITWISE), GET_AND_BITWISE_OR_RELEASE(TestAccessType.GET_AND_BITWISE), diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java index ab255e31c47..d2a22c733cf 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java @@ -114,7 +114,6 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -287,10 +286,6 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndAddRelease(recv, true); }); - checkUOE(() -> { - boolean o = (boolean) vh.addAndGet(recv, true); - }); - } @@ -351,10 +346,6 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndAddRelease(true); }); - checkUOE(() -> { - boolean o = (boolean) vh.addAndGet(true); - }); - } @@ -615,10 +606,6 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndAddRelease(recv, true); }); - checkUOE(() -> { - boolean o = (boolean) vh.addAndGet(recv, true); - }); - } @@ -879,10 +866,6 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndAddRelease(true); }); - checkUOE(() -> { - boolean o = (boolean) vh.addAndGet(true); - }); - } @@ -1150,10 +1133,6 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndAddRelease(array, i, true); }); - checkUOE(() -> { - boolean o = (boolean) vh.addAndGet(array, i, true); - }); - } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java index 84c1faab50d..a3b9a3b8013 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java @@ -114,7 +114,6 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -489,10 +488,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { vh.set(recv, (byte)0x01); - byte o = (byte) vh.getAndAdd(recv, (byte)0x45); + byte o = (byte) vh.getAndAdd(recv, (byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) vh.addAndGet(recv, (byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); } { @@ -765,10 +764,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { vh.set((byte)0x01); - byte o = (byte) vh.getAndAdd( (byte)0x45); + byte o = (byte) vh.getAndAdd((byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) vh.addAndGet((byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); } { @@ -1044,10 +1043,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { vh.set(array, i, (byte)0x01); - byte o = (byte) vh.getAndAdd(array, i, (byte)0x45); + byte o = (byte) vh.getAndAdd(array, i, (byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) vh.addAndGet(array, i, (byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); } { @@ -1256,10 +1255,6 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { byte o = (byte) vh.getAndAddRelease(array, ci, (byte)0x01); }); - checkIOOBE(() -> { - byte o = (byte) vh.addAndGet(array, ci, (byte)0x01); - }); - checkIOOBE(() -> { byte o = (byte) vh.getAndBitwiseOr(array, ci, (byte)0x01); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java index b0c89a4ac3b..090e75a1558 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java @@ -114,7 +114,6 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -489,10 +488,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { vh.set(recv, '\u0123'); - char o = (char) vh.getAndAdd(recv, '\u89AB'); + char o = (char) vh.getAndAdd(recv, '\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) vh.addAndGet(recv, '\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); } { @@ -765,10 +764,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { vh.set('\u0123'); - char o = (char) vh.getAndAdd( '\u89AB'); + char o = (char) vh.getAndAdd('\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) vh.addAndGet('\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); } { @@ -1044,10 +1043,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { vh.set(array, i, '\u0123'); - char o = (char) vh.getAndAdd(array, i, '\u89AB'); + char o = (char) vh.getAndAdd(array, i, '\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) vh.addAndGet(array, i, '\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); } { @@ -1256,10 +1255,6 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { char o = (char) vh.getAndAddRelease(array, ci, '\u0123'); }); - checkIOOBE(() -> { - char o = (char) vh.addAndGet(array, ci, '\u0123'); - }); - checkIOOBE(() -> { char o = (char) vh.getAndBitwiseOr(array, ci, '\u0123'); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java index 1ae86e490b5..1d8e068cbeb 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java @@ -114,7 +114,6 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -559,10 +558,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { vh.set(recv, 1.0d); - double o = (double) vh.getAndAdd(recv, 3.0d); + double o = (double) vh.getAndAdd(recv, 2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) vh.addAndGet(recv, 3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) vh.get(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } { @@ -787,10 +786,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { vh.set(1.0d); - double o = (double) vh.getAndAdd( 3.0d); + double o = (double) vh.getAndAdd(2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) vh.addAndGet(3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) vh.get(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } { @@ -1018,10 +1017,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { vh.set(array, i, 1.0d); - double o = (double) vh.getAndAdd(array, i, 3.0d); + double o = (double) vh.getAndAdd(array, i, 2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) vh.addAndGet(array, i, 3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) vh.get(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } { @@ -1182,10 +1181,6 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { double o = (double) vh.getAndAddRelease(array, ci, 1.0d); }); - checkIOOBE(() -> { - double o = (double) vh.addAndGet(array, ci, 1.0d); - }); - } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java index 7b8f7046300..5990a152a54 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java @@ -114,7 +114,6 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -559,10 +558,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { vh.set(recv, 1.0f); - float o = (float) vh.getAndAdd(recv, 3.0f); + float o = (float) vh.getAndAdd(recv, 2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) vh.addAndGet(recv, 3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) vh.get(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } { @@ -787,10 +786,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { vh.set(1.0f); - float o = (float) vh.getAndAdd( 3.0f); + float o = (float) vh.getAndAdd(2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) vh.addAndGet(3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) vh.get(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } { @@ -1018,10 +1017,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { vh.set(array, i, 1.0f); - float o = (float) vh.getAndAdd(array, i, 3.0f); + float o = (float) vh.getAndAdd(array, i, 2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) vh.addAndGet(array, i, 3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) vh.get(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } { @@ -1182,10 +1181,6 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { float o = (float) vh.getAndAddRelease(array, ci, 1.0f); }); - checkIOOBE(() -> { - float o = (float) vh.addAndGet(array, ci, 1.0f); - }); - } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java index bdd06f5a681..a21c2f3a545 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java @@ -114,7 +114,6 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -489,10 +488,10 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { vh.set(recv, 0x01234567); - int o = (int) vh.getAndAdd(recv, 0xCAFEBABE); + int o = (int) vh.getAndAdd(recv, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) vh.addAndGet(recv, 0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); } { @@ -765,10 +764,10 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { vh.set(0x01234567); - int o = (int) vh.getAndAdd( 0xCAFEBABE); + int o = (int) vh.getAndAdd(0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) vh.addAndGet(0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); } { @@ -1044,10 +1043,10 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { vh.set(array, i, 0x01234567); - int o = (int) vh.getAndAdd(array, i, 0xCAFEBABE); + int o = (int) vh.getAndAdd(array, i, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) vh.addAndGet(array, i, 0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); } { @@ -1256,10 +1255,6 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { int o = (int) vh.getAndAddRelease(array, ci, 0x01234567); }); - checkIOOBE(() -> { - int o = (int) vh.addAndGet(array, ci, 0x01234567); - }); - checkIOOBE(() -> { int o = (int) vh.getAndBitwiseOr(array, ci, 0x01234567); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java index c58fc2d4ef7..d401bce06d5 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java @@ -114,7 +114,6 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -489,10 +488,10 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { vh.set(recv, 0x0123456789ABCDEFL); - long o = (long) vh.getAndAdd(recv, 0xDEADBEEFDEADBEEFL); + long o = (long) vh.getAndAdd(recv, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) vh.addAndGet(recv, 0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); } { @@ -765,10 +764,10 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { vh.set(0x0123456789ABCDEFL); - long o = (long) vh.getAndAdd( 0xDEADBEEFDEADBEEFL); + long o = (long) vh.getAndAdd(0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) vh.addAndGet(0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); } { @@ -1044,10 +1043,10 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { vh.set(array, i, 0x0123456789ABCDEFL); - long o = (long) vh.getAndAdd(array, i, 0xDEADBEEFDEADBEEFL); + long o = (long) vh.getAndAdd(array, i, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) vh.addAndGet(array, i, 0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); } { @@ -1256,10 +1255,6 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { long o = (long) vh.getAndAddRelease(array, ci, 0x0123456789ABCDEFL); }); - checkIOOBE(() -> { - long o = (long) vh.addAndGet(array, ci, 0x0123456789ABCDEFL); - }); - checkIOOBE(() -> { long o = (long) vh.getAndBitwiseOr(array, ci, 0x0123456789ABCDEFL); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java index 7f930529257..4e20386d6f8 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java @@ -114,7 +114,6 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -489,10 +488,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { vh.set(recv, (short)0x0123); - short o = (short) vh.getAndAdd(recv, (short)0x89AB); + short o = (short) vh.getAndAdd(recv, (short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) vh.addAndGet(recv, (short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); } { @@ -765,10 +764,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { vh.set((short)0x0123); - short o = (short) vh.getAndAdd( (short)0x89AB); + short o = (short) vh.getAndAdd((short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) vh.addAndGet((short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); } { @@ -1044,10 +1043,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { vh.set(array, i, (short)0x0123); - short o = (short) vh.getAndAdd(array, i, (short)0x89AB); + short o = (short) vh.getAndAdd(array, i, (short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) vh.addAndGet(array, i, (short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); } { @@ -1256,10 +1255,6 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { short o = (short) vh.getAndAddRelease(array, ci, (short)0x0123); }); - checkIOOBE(() -> { - short o = (short) vh.addAndGet(array, ci, (short)0x0123); - }); - checkIOOBE(() -> { short o = (short) vh.getAndBitwiseOr(array, ci, (short)0x0123); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java index 136ab72cb1d..5fc758cc6f4 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java @@ -114,7 +114,6 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -287,10 +286,6 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndAddRelease(recv, "foo"); }); - checkUOE(() -> { - String o = (String) vh.addAndGet(recv, "foo"); - }); - checkUOE(() -> { String o = (String) vh.getAndBitwiseOr(recv, "foo"); }); @@ -386,10 +381,6 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndAddRelease("foo"); }); - checkUOE(() -> { - String o = (String) vh.addAndGet("foo"); - }); - checkUOE(() -> { String o = (String) vh.getAndBitwiseOr("foo"); }); @@ -602,10 +593,6 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndAddRelease(recv, "foo"); }); - checkUOE(() -> { - String o = (String) vh.addAndGet(recv, "foo"); - }); - checkUOE(() -> { String o = (String) vh.getAndBitwiseOr(recv, "foo"); }); @@ -818,10 +805,6 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndAddRelease("foo"); }); - checkUOE(() -> { - String o = (String) vh.addAndGet("foo"); - }); - checkUOE(() -> { String o = (String) vh.getAndBitwiseOr("foo"); }); @@ -1041,10 +1024,6 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndAddRelease(array, i, "foo"); }); - checkUOE(() -> { - String o = (String) vh.addAndGet(array, i, "foo"); - }); - checkUOE(() -> { String o = (String) vh.getAndBitwiseOr(array, i, "foo"); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java index 4083c0024e6..e15028a6f5f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java @@ -103,7 +103,6 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -254,10 +253,6 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { char o = (char) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkUOE(() -> { - char o = (char) vh.addAndGet(array, ci, VALUE_1); - }); - checkUOE(() -> { char o = (char) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -375,10 +370,6 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { char o = (char) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkUOE(() -> { - char o = (char) vh.addAndGet(array, ci, VALUE_1); - }); - checkUOE(() -> { char o = (char) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -470,10 +461,6 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { checkUOE(() -> { char o = (char) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkUOE(() -> { - char o = (char) vh.addAndGet(array, ci, VALUE_1); - }); checkUOE(() -> { char o = (char) vh.getAndBitwiseOr(array, ci, VALUE_1); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java index e33fdbf718c..a8ed8e9b662 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java @@ -103,7 +103,6 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -211,10 +210,6 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkUOE(() -> { - double o = (double) vh.addAndGet(array, ci, VALUE_1); - }); - checkUOE(() -> { double o = (double) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -334,10 +329,6 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkUOE(() -> { - double o = (double) vh.addAndGet(array, ci, VALUE_1); - }); - checkUOE(() -> { double o = (double) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -386,10 +377,6 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { checkUOE(() -> { double o = (double) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkUOE(() -> { - double o = (double) vh.addAndGet(array, ci, VALUE_1); - }); checkUOE(() -> { double o = (double) vh.getAndBitwiseOr(array, ci, VALUE_1); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java index d56bb6e8933..0ed28217595 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java @@ -103,7 +103,6 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -211,10 +210,6 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkUOE(() -> { - float o = (float) vh.addAndGet(array, ci, VALUE_1); - }); - checkUOE(() -> { float o = (float) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -334,10 +329,6 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkUOE(() -> { - float o = (float) vh.addAndGet(array, ci, VALUE_1); - }); - checkUOE(() -> { float o = (float) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -386,10 +377,6 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { checkUOE(() -> { float o = (float) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkUOE(() -> { - float o = (float) vh.addAndGet(array, ci, VALUE_1); - }); checkUOE(() -> { float o = (float) vh.getAndBitwiseOr(array, ci, VALUE_1); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java index 05655eef4d1..8b63bb36715 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java @@ -103,7 +103,6 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -284,10 +283,6 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkROBE(() -> { - int o = (int) vh.addAndGet(array, ci, VALUE_1); - }); - checkROBE(() -> { int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -425,10 +420,6 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkIOOBE(() -> { - int o = (int) vh.addAndGet(array, ci, VALUE_1); - }); - checkIOOBE(() -> { int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -569,10 +560,6 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkIOOBE(() -> { - int o = (int) vh.addAndGet(array, ci, VALUE_1); - }); - checkIOOBE(() -> { int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -704,10 +691,6 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkISE(() -> { - int o = (int) vh.addAndGet(array, ci, VALUE_1); - }); - checkISE(() -> { int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -841,10 +824,6 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkISE(() -> { - int o = (int) vh.addAndGet(array, ci, VALUE_1); - }); - checkISE(() -> { int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -1054,10 +1033,10 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { { vh.set(array, i, VALUE_1); - int o = (int) vh.getAndAdd(array, i, VALUE_3); + int o = (int) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd int"); - int c = (int) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd int value"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd int value"); } { @@ -1334,10 +1313,10 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { { vh.set(array, i, VALUE_1); - int o = (int) vh.getAndAdd(array, i, VALUE_3); + int o = (int) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd int"); - int c = (int) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd int value"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd int value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java index d5a264ade98..a94c0f5280b 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java @@ -103,7 +103,6 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -284,10 +283,6 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkROBE(() -> { - long o = (long) vh.addAndGet(array, ci, VALUE_1); - }); - checkROBE(() -> { long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -425,10 +420,6 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkIOOBE(() -> { - long o = (long) vh.addAndGet(array, ci, VALUE_1); - }); - checkIOOBE(() -> { long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -569,10 +560,6 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkIOOBE(() -> { - long o = (long) vh.addAndGet(array, ci, VALUE_1); - }); - checkIOOBE(() -> { long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -704,10 +691,6 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkISE(() -> { - long o = (long) vh.addAndGet(array, ci, VALUE_1); - }); - checkISE(() -> { long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -841,10 +824,6 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkISE(() -> { - long o = (long) vh.addAndGet(array, ci, VALUE_1); - }); - checkISE(() -> { long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -1054,10 +1033,10 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { { vh.set(array, i, VALUE_1); - long o = (long) vh.getAndAdd(array, i, VALUE_3); + long o = (long) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd long"); - long c = (long) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd long value"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd long value"); } { @@ -1334,10 +1313,10 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { { vh.set(array, i, VALUE_1); - long o = (long) vh.getAndAdd(array, i, VALUE_3); + long o = (long) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd long"); - long c = (long) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd long value"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd long value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java index 8c473e6e0d7..e058789fddc 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java @@ -103,7 +103,6 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); @@ -254,10 +253,6 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { short o = (short) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkUOE(() -> { - short o = (short) vh.addAndGet(array, ci, VALUE_1); - }); - checkUOE(() -> { short o = (short) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -375,10 +370,6 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { short o = (short) vh.getAndAddRelease(array, ci, VALUE_1); }); - checkUOE(() -> { - short o = (short) vh.addAndGet(array, ci, VALUE_1); - }); - checkUOE(() -> { short o = (short) vh.getAndBitwiseOr(array, ci, VALUE_1); }); @@ -470,10 +461,6 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { checkUOE(() -> { short o = (short) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkUOE(() -> { - short o = (short) vh.addAndGet(array, ci, VALUE_1); - }); checkUOE(() -> { short o = (short) vh.getAndBitwiseOr(array, ci, VALUE_1); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java index c5410833d10..4bf019bcdec 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java @@ -259,10 +259,10 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); - byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (byte)0x45); + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, (byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); } { @@ -537,10 +537,10 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact((byte)0x01); - byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact((byte)0x45); + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact((byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact((byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); } { @@ -816,10 +816,10 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); - byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (byte)0x45); + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, (byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java index 6186ba7b522..cbffb98f727 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java @@ -259,10 +259,10 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); - char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, '\u89AB'); + char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, '\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, '\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); } { @@ -537,10 +537,10 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact('\u0123'); - char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact('\u89AB'); + char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact('\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact('\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); } { @@ -816,10 +816,10 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); - char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, '\u89AB'); + char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, '\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, '\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java index 2d09668c2bb..3bf1bdb4ea6 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java @@ -259,10 +259,10 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(recv, 1.0d); - double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 3.0d); + double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } { @@ -459,10 +459,10 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(1.0d); - double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(3.0d); + double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } { @@ -660,10 +660,10 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); - double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 3.0d); + double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java index 9b6b631d25d..aa0b06d9f6f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java @@ -259,10 +259,10 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(recv, 1.0f); - float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 3.0f); + float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } { @@ -459,10 +459,10 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(1.0f); - float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(3.0f); + float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } { @@ -660,10 +660,10 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); - float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 3.0f); + float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java index a7d4f03b82f..64d5cab6104 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java @@ -259,10 +259,10 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); - int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0xCAFEBABE); + int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); } { @@ -537,10 +537,10 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(0x01234567); - int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(0xCAFEBABE); + int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); } { @@ -816,10 +816,10 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); - int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0xCAFEBABE); + int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java index 7a39dd19a89..058cb4e5113 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java @@ -259,10 +259,10 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); - long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0xDEADBEEFDEADBEEFL); + long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); } { @@ -537,10 +537,10 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); - long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(0xDEADBEEFDEADBEEFL); + long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); } { @@ -816,10 +816,10 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); - long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0xDEADBEEFDEADBEEFL); + long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java index 456d2f3a7c4..554e9c8a3cf 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java @@ -259,10 +259,10 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); - short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (short)0x89AB); + short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, (short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); } { @@ -537,10 +537,10 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact((short)0x0123); - short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact((short)0x89AB); + short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact((short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact((short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); } { @@ -816,10 +816,10 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); - short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (short)0x89AB); + short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, (short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java index 41c9e06e700..25d1e34bbac 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java @@ -727,35 +727,6 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndAddRelease(recv, (byte)0x01, Void.class); }); - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null receiver - byte x = (byte) vh.addAndGet(null, (byte)0x01); - }); - checkCCE(() -> { // receiver reference class - byte x = (byte) vh.addAndGet(Void.class, (byte)0x01); - }); - checkWMTE(() -> { // value reference class - byte x = (byte) vh.addAndGet(recv, Void.class); - }); - checkWMTE(() -> { // reciever primitive class - byte x = (byte) vh.addAndGet(0, (byte)0x01); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, (byte)0x01); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, (byte)0x01); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - byte x = (byte) vh.addAndGet(); - }); - checkWMTE(() -> { // > - byte x = (byte) vh.addAndGet(recv, (byte)0x01, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkNPE(() -> { // null receiver @@ -1668,27 +1639,6 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndAddRelease((byte)0x01, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkWMTE(() -> { // value reference class - byte x = (byte) vh.addAndGet(Void.class); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet((byte)0x01); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet((byte)0x01); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - byte x = (byte) vh.addAndGet(); - }); - checkWMTE(() -> { // > - byte x = (byte) vh.addAndGet((byte)0x01, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkWMTE(() -> { // value reference class @@ -2721,39 +2671,6 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndAddRelease(array, 0, (byte)0x01, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null array - byte x = (byte) vh.addAndGet(null, 0, (byte)0x01); - }); - checkCCE(() -> { // array reference class - byte x = (byte) vh.addAndGet(Void.class, 0, (byte)0x01); - }); - checkWMTE(() -> { // value reference class - byte x = (byte) vh.addAndGet(array, 0, Void.class); - }); - checkWMTE(() -> { // array primitive class - byte x = (byte) vh.addAndGet(0, 0, (byte)0x01); - }); - checkWMTE(() -> { // index reference class - byte x = (byte) vh.addAndGet(array, Void.class, (byte)0x01); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, (byte)0x01); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, (byte)0x01); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - byte x = (byte) vh.addAndGet(); - }); - checkWMTE(() -> { // > - byte x = (byte) vh.addAndGet(array, 0, (byte)0x01, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkNPE(() -> { // null array diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java index f16d7655e9e..e00c3b2b26c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java @@ -727,35 +727,6 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndAddRelease(recv, '\u0123', Void.class); }); - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null receiver - char x = (char) vh.addAndGet(null, '\u0123'); - }); - checkCCE(() -> { // receiver reference class - char x = (char) vh.addAndGet(Void.class, '\u0123'); - }); - checkWMTE(() -> { // value reference class - char x = (char) vh.addAndGet(recv, Void.class); - }); - checkWMTE(() -> { // reciever primitive class - char x = (char) vh.addAndGet(0, '\u0123'); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, '\u0123'); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, '\u0123'); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - char x = (char) vh.addAndGet(); - }); - checkWMTE(() -> { // > - char x = (char) vh.addAndGet(recv, '\u0123', Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkNPE(() -> { // null receiver @@ -1668,27 +1639,6 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndAddRelease('\u0123', Void.class); }); - - // AddAndGet - // Incorrect argument types - checkWMTE(() -> { // value reference class - char x = (char) vh.addAndGet(Void.class); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet('\u0123'); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet('\u0123'); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - char x = (char) vh.addAndGet(); - }); - checkWMTE(() -> { // > - char x = (char) vh.addAndGet('\u0123', Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkWMTE(() -> { // value reference class @@ -2721,39 +2671,6 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndAddRelease(array, 0, '\u0123', Void.class); }); - - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null array - char x = (char) vh.addAndGet(null, 0, '\u0123'); - }); - checkCCE(() -> { // array reference class - char x = (char) vh.addAndGet(Void.class, 0, '\u0123'); - }); - checkWMTE(() -> { // value reference class - char x = (char) vh.addAndGet(array, 0, Void.class); - }); - checkWMTE(() -> { // array primitive class - char x = (char) vh.addAndGet(0, 0, '\u0123'); - }); - checkWMTE(() -> { // index reference class - char x = (char) vh.addAndGet(array, Void.class, '\u0123'); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, '\u0123'); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, '\u0123'); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - char x = (char) vh.addAndGet(); - }); - checkWMTE(() -> { // > - char x = (char) vh.addAndGet(array, 0, '\u0123', Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkNPE(() -> { // null array diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java index 97f5c5f8b87..cd3e1439722 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java @@ -727,35 +727,6 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndAddRelease(recv, 1.0d, Void.class); }); - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null receiver - double x = (double) vh.addAndGet(null, 1.0d); - }); - checkCCE(() -> { // receiver reference class - double x = (double) vh.addAndGet(Void.class, 1.0d); - }); - checkWMTE(() -> { // value reference class - double x = (double) vh.addAndGet(recv, Void.class); - }); - checkWMTE(() -> { // reciever primitive class - double x = (double) vh.addAndGet(0, 1.0d); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, 1.0d); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, 1.0d); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - double x = (double) vh.addAndGet(); - }); - checkWMTE(() -> { // > - double x = (double) vh.addAndGet(recv, 1.0d, Void.class); - }); - } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeDouble recv, Handles hs) throws Throwable { @@ -1364,27 +1335,6 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndAddRelease(1.0d, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkWMTE(() -> { // value reference class - double x = (double) vh.addAndGet(Void.class); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(1.0d); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(1.0d); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - double x = (double) vh.addAndGet(); - }); - checkWMTE(() -> { // > - double x = (double) vh.addAndGet(1.0d, Void.class); - }); - } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -2205,39 +2155,6 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndAddRelease(array, 0, 1.0d, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null array - double x = (double) vh.addAndGet(null, 0, 1.0d); - }); - checkCCE(() -> { // array reference class - double x = (double) vh.addAndGet(Void.class, 0, 1.0d); - }); - checkWMTE(() -> { // value reference class - double x = (double) vh.addAndGet(array, 0, Void.class); - }); - checkWMTE(() -> { // array primitive class - double x = (double) vh.addAndGet(0, 0, 1.0d); - }); - checkWMTE(() -> { // index reference class - double x = (double) vh.addAndGet(array, Void.class, 1.0d); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, 1.0d); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, 1.0d); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - double x = (double) vh.addAndGet(); - }); - checkWMTE(() -> { // > - double x = (double) vh.addAndGet(array, 0, 1.0d, Void.class); - }); - } static void testArrayWrongMethodType(Handles hs) throws Throwable { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java index 749224281cc..499d71389fa 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java @@ -727,35 +727,6 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndAddRelease(recv, 1.0f, Void.class); }); - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null receiver - float x = (float) vh.addAndGet(null, 1.0f); - }); - checkCCE(() -> { // receiver reference class - float x = (float) vh.addAndGet(Void.class, 1.0f); - }); - checkWMTE(() -> { // value reference class - float x = (float) vh.addAndGet(recv, Void.class); - }); - checkWMTE(() -> { // reciever primitive class - float x = (float) vh.addAndGet(0, 1.0f); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, 1.0f); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, 1.0f); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - float x = (float) vh.addAndGet(); - }); - checkWMTE(() -> { // > - float x = (float) vh.addAndGet(recv, 1.0f, Void.class); - }); - } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeFloat recv, Handles hs) throws Throwable { @@ -1364,27 +1335,6 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndAddRelease(1.0f, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkWMTE(() -> { // value reference class - float x = (float) vh.addAndGet(Void.class); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(1.0f); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(1.0f); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - float x = (float) vh.addAndGet(); - }); - checkWMTE(() -> { // > - float x = (float) vh.addAndGet(1.0f, Void.class); - }); - } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -2205,39 +2155,6 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndAddRelease(array, 0, 1.0f, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null array - float x = (float) vh.addAndGet(null, 0, 1.0f); - }); - checkCCE(() -> { // array reference class - float x = (float) vh.addAndGet(Void.class, 0, 1.0f); - }); - checkWMTE(() -> { // value reference class - float x = (float) vh.addAndGet(array, 0, Void.class); - }); - checkWMTE(() -> { // array primitive class - float x = (float) vh.addAndGet(0, 0, 1.0f); - }); - checkWMTE(() -> { // index reference class - float x = (float) vh.addAndGet(array, Void.class, 1.0f); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, 1.0f); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, 1.0f); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - float x = (float) vh.addAndGet(); - }); - checkWMTE(() -> { // > - float x = (float) vh.addAndGet(array, 0, 1.0f, Void.class); - }); - } static void testArrayWrongMethodType(Handles hs) throws Throwable { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java index a4277fb9615..17deb396f0c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java @@ -727,35 +727,6 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndAddRelease(recv, 0x01234567, Void.class); }); - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null receiver - int x = (int) vh.addAndGet(null, 0x01234567); - }); - checkCCE(() -> { // receiver reference class - int x = (int) vh.addAndGet(Void.class, 0x01234567); - }); - checkWMTE(() -> { // value reference class - int x = (int) vh.addAndGet(recv, Void.class); - }); - checkWMTE(() -> { // reciever primitive class - int x = (int) vh.addAndGet(0, 0x01234567); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, 0x01234567); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, 0x01234567); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - int x = (int) vh.addAndGet(); - }); - checkWMTE(() -> { // > - int x = (int) vh.addAndGet(recv, 0x01234567, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkNPE(() -> { // null receiver @@ -1668,27 +1639,6 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndAddRelease(0x01234567, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkWMTE(() -> { // value reference class - int x = (int) vh.addAndGet(Void.class); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(0x01234567); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(0x01234567); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - int x = (int) vh.addAndGet(); - }); - checkWMTE(() -> { // > - int x = (int) vh.addAndGet(0x01234567, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkWMTE(() -> { // value reference class @@ -2721,39 +2671,6 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndAddRelease(array, 0, 0x01234567, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null array - int x = (int) vh.addAndGet(null, 0, 0x01234567); - }); - checkCCE(() -> { // array reference class - int x = (int) vh.addAndGet(Void.class, 0, 0x01234567); - }); - checkWMTE(() -> { // value reference class - int x = (int) vh.addAndGet(array, 0, Void.class); - }); - checkWMTE(() -> { // array primitive class - int x = (int) vh.addAndGet(0, 0, 0x01234567); - }); - checkWMTE(() -> { // index reference class - int x = (int) vh.addAndGet(array, Void.class, 0x01234567); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, 0x01234567); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, 0x01234567); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - int x = (int) vh.addAndGet(); - }); - checkWMTE(() -> { // > - int x = (int) vh.addAndGet(array, 0, 0x01234567, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkNPE(() -> { // null array diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java index afaebfdcac6..882039d3eb3 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java @@ -727,35 +727,6 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndAddRelease(recv, 0x0123456789ABCDEFL, Void.class); }); - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null receiver - long x = (long) vh.addAndGet(null, 0x0123456789ABCDEFL); - }); - checkCCE(() -> { // receiver reference class - long x = (long) vh.addAndGet(Void.class, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // value reference class - long x = (long) vh.addAndGet(recv, Void.class); - }); - checkWMTE(() -> { // reciever primitive class - long x = (long) vh.addAndGet(0, 0x0123456789ABCDEFL); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, 0x0123456789ABCDEFL); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - long x = (long) vh.addAndGet(); - }); - checkWMTE(() -> { // > - long x = (long) vh.addAndGet(recv, 0x0123456789ABCDEFL, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkNPE(() -> { // null receiver @@ -1668,27 +1639,6 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndAddRelease(0x0123456789ABCDEFL, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkWMTE(() -> { // value reference class - long x = (long) vh.addAndGet(Void.class); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(0x0123456789ABCDEFL); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - long x = (long) vh.addAndGet(); - }); - checkWMTE(() -> { // > - long x = (long) vh.addAndGet(0x0123456789ABCDEFL, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkWMTE(() -> { // value reference class @@ -2721,39 +2671,6 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndAddRelease(array, 0, 0x0123456789ABCDEFL, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null array - long x = (long) vh.addAndGet(null, 0, 0x0123456789ABCDEFL); - }); - checkCCE(() -> { // array reference class - long x = (long) vh.addAndGet(Void.class, 0, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // value reference class - long x = (long) vh.addAndGet(array, 0, Void.class); - }); - checkWMTE(() -> { // array primitive class - long x = (long) vh.addAndGet(0, 0, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // index reference class - long x = (long) vh.addAndGet(array, Void.class, 0x0123456789ABCDEFL); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, 0x0123456789ABCDEFL); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - long x = (long) vh.addAndGet(); - }); - checkWMTE(() -> { // > - long x = (long) vh.addAndGet(array, 0, 0x0123456789ABCDEFL, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkNPE(() -> { // null array diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java index f97bf26fec6..c1e5277f9e0 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java @@ -727,35 +727,6 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndAddRelease(recv, (short)0x0123, Void.class); }); - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null receiver - short x = (short) vh.addAndGet(null, (short)0x0123); - }); - checkCCE(() -> { // receiver reference class - short x = (short) vh.addAndGet(Void.class, (short)0x0123); - }); - checkWMTE(() -> { // value reference class - short x = (short) vh.addAndGet(recv, Void.class); - }); - checkWMTE(() -> { // reciever primitive class - short x = (short) vh.addAndGet(0, (short)0x0123); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, (short)0x0123); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, (short)0x0123); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - short x = (short) vh.addAndGet(); - }); - checkWMTE(() -> { // > - short x = (short) vh.addAndGet(recv, (short)0x0123, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkNPE(() -> { // null receiver @@ -1668,27 +1639,6 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndAddRelease((short)0x0123, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkWMTE(() -> { // value reference class - short x = (short) vh.addAndGet(Void.class); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet((short)0x0123); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet((short)0x0123); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - short x = (short) vh.addAndGet(); - }); - checkWMTE(() -> { // > - short x = (short) vh.addAndGet((short)0x0123, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkWMTE(() -> { // value reference class @@ -2721,39 +2671,6 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndAddRelease(array, 0, (short)0x0123, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null array - short x = (short) vh.addAndGet(null, 0, (short)0x0123); - }); - checkCCE(() -> { // array reference class - short x = (short) vh.addAndGet(Void.class, 0, (short)0x0123); - }); - checkWMTE(() -> { // value reference class - short x = (short) vh.addAndGet(array, 0, Void.class); - }); - checkWMTE(() -> { // array primitive class - short x = (short) vh.addAndGet(0, 0, (short)0x0123); - }); - checkWMTE(() -> { // index reference class - short x = (short) vh.addAndGet(array, Void.class, (short)0x0123); - }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, (short)0x0123); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, (short)0x0123); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - short x = (short) vh.addAndGet(); - }); - checkWMTE(() -> { // > - short x = (short) vh.addAndGet(array, 0, (short)0x0123, Void.class); - }); - // GetAndBitwiseOr // Incorrect argument types checkNPE(() -> { // null array diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template index 021bc31bf19..222889ca4ad 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template @@ -129,12 +129,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); #else[AtomicAdd] assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); #end[AtomicAdd] #if[Bitwise] @@ -365,10 +363,6 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndAddRelease(recv, $value1$); }); - - checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(recv, $value1$); - }); #end[AtomicAdd] #if[!Bitwise] @@ -513,10 +507,6 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndAddRelease($value1$); }); - - checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet($value1$); - }); #end[AtomicAdd] #if[!Bitwise] @@ -723,10 +713,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { vh.set(recv, $value1$); - $type$ o = ($type$) vh.getAndAdd(recv, $value3$); + $type$ o = ($type$) vh.getAndAdd(recv, $value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) vh.addAndGet(recv, $value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); } { @@ -894,10 +884,6 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndAddRelease(recv, $value1$); }); - - checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(recv, $value1$); - }); #end[AtomicAdd] #if[!Bitwise] @@ -1104,10 +1090,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { vh.set($value1$); - $type$ o = ($type$) vh.getAndAdd( $value3$); + $type$ o = ($type$) vh.getAndAdd($value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) vh.addAndGet($value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); } { @@ -1275,10 +1261,6 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndAddRelease($value1$); }); - - checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet($value1$); - }); #end[AtomicAdd] #if[!Bitwise] @@ -1488,10 +1470,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { vh.set(array, i, $value1$); - $type$ o = ($type$) vh.getAndAdd(array, i, $value3$); + $type$ o = ($type$) vh.getAndAdd(array, i, $value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) vh.addAndGet(array, i, $value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); } { @@ -1663,10 +1645,6 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndAddRelease(array, i, $value1$); }); - - checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(array, i, $value1$); - }); #end[AtomicAdd] #if[!Bitwise] @@ -1804,10 +1782,6 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkIOOBE(() -> { $type$ o = ($type$) vh.getAndAddRelease(array, ci, $value1$); }); - - checkIOOBE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, $value1$); - }); #end[AtomicAdd] #if[Bitwise] diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template index 92c1ae98b38..c9edc652321 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template @@ -118,12 +118,10 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); #else[AtomicAdd] assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); #end[AtomicAdd] #if[Bitwise] @@ -289,10 +287,6 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); - }); #end[AtomicAdd] #if[!Bitwise] @@ -462,10 +456,6 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkROBE(() -> { $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkROBE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); - }); #else[AtomicAdd] checkUOE(() -> { $type$ o = ($type$) vh.getAndAdd(array, ci, VALUE_1); @@ -478,10 +468,6 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); - }); #end[AtomicAdd] #if[Bitwise] @@ -616,10 +602,6 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); - }); #end[AtomicAdd] #if[!Bitwise] checkUOE(() -> { @@ -760,10 +742,6 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkIOOBE(() -> { $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkIOOBE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); - }); #end[AtomicAdd] #if[Bitwise] @@ -910,10 +888,6 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkIOOBE(() -> { $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkIOOBE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); - }); #end[AtomicAdd] #if[Bitwise] @@ -1051,10 +1025,6 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkISE(() -> { $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkISE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); - }); #end[AtomicAdd] #if[Bitwise] @@ -1194,10 +1164,6 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkISE(() -> { $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); - - checkISE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); - }); #end[AtomicAdd] #if[Bitwise] @@ -1414,10 +1380,10 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { { vh.set(array, i, VALUE_1); - $type$ o = ($type$) vh.getAndAdd(array, i, VALUE_3); + $type$ o = ($type$) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd $type$"); - $type$ c = ($type$) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd $type$ value"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd $type$ value"); } { @@ -1700,10 +1666,10 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { { vh.set(array, i, VALUE_1); - $type$ o = ($type$) vh.getAndAdd(array, i, VALUE_3); + $type$ o = ($type$) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd $type$"); - $type$ c = ($type$) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd $type$ value"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd $type$ value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template index a5011c753b8..d59462c6b3f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template @@ -262,10 +262,10 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, $value3$); + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, $value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, $value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); } { @@ -579,10 +579,10 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact($value1$); - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact($value3$); + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact($value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact($value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); } { @@ -897,10 +897,10 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, $value3$); + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, $value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, $value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); } { diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template index 88127d51066..a65fccb5dfc 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template @@ -729,35 +729,6 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { checkWMTE(() -> { // > $type$ x = ($type$) vh.getAndAddRelease(recv, $value1$, Void.class); }); - - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null receiver - $type$ x = ($type$) vh.addAndGet(null, $value1$); - }); - checkCCE(() -> { // receiver reference class - $type$ x = ($type$) vh.addAndGet(Void.class, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // value reference class - $type$ x = ($type$) vh.addAndGet(recv, Void.class); - }); - checkWMTE(() -> { // reciever primitive class - $type$ x = ($type$) vh.addAndGet(0, $value1$); - }); - // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, $value1$); - }); - checkWMTE(() -> { // primitive class - $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.addAndGet(recv, $value1$); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - $type$ x = ($type$) vh.addAndGet(); - }); - checkWMTE(() -> { // > - $type$ x = ($type$) vh.addAndGet(recv, $value1$, Void.class); - }); #end[AtomicAdd] #if[Bitwise] @@ -1682,27 +1653,6 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { checkWMTE(() -> { // > $type$ x = ($type$) vh.getAndAddRelease($value1$, Void.class); }); - - - // AddAndGet - // Incorrect argument types - check{#if[String]?CCE:WMTE}(() -> { // value reference class - $type$ x = ($type$) vh.addAndGet(Void.class); - }); - // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class - Void r = (Void) vh.addAndGet($value1$); - }); - checkWMTE(() -> { // primitive class - $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.addAndGet($value1$); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - $type$ x = ($type$) vh.addAndGet(); - }); - checkWMTE(() -> { // > - $type$ x = ($type$) vh.addAndGet($value1$, Void.class); - }); #end[AtomicAdd] #if[Bitwise] @@ -2747,39 +2697,6 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { checkWMTE(() -> { // > $type$ x = ($type$) vh.getAndAddRelease(array, 0, $value1$, Void.class); }); - - - // AddAndGet - // Incorrect argument types - checkNPE(() -> { // null array - $type$ x = ($type$) vh.addAndGet(null, 0, $value1$); - }); - checkCCE(() -> { // array reference class - $type$ x = ($type$) vh.addAndGet(Void.class, 0, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // value reference class - $type$ x = ($type$) vh.addAndGet(array, 0, Void.class); - }); - checkWMTE(() -> { // array primitive class - $type$ x = ($type$) vh.addAndGet(0, 0, $value1$); - }); - checkWMTE(() -> { // index reference class - $type$ x = ($type$) vh.addAndGet(array, Void.class, $value1$); - }); - // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, $value1$); - }); - checkWMTE(() -> { // primitive class - $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.addAndGet(array, 0, $value1$); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - $type$ x = ($type$) vh.addAndGet(); - }); - checkWMTE(() -> { // > - $type$ x = ($type$) vh.addAndGet(array, 0, $value1$, Void.class); - }); #end[AtomicAdd] #if[Bitwise] From 3bd5ebe2ef39ec0e170aad9804438ee386fe21f3 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 1 Sep 2016 13:56:13 -0700 Subject: [PATCH 103/296] 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet Reviewed-by: martin --- .../classes/java/lang/invoke/VarHandle.java | 22 +-- .../lang/invoke/X-VarHandle.java.template | 12 +- .../X-VarHandleByteArrayView.java.template | 8 +- .../util/concurrent/CompletableFuture.java | 4 +- .../concurrent/ConcurrentLinkedDeque.java | 8 +- .../concurrent/ConcurrentLinkedQueue.java | 8 +- .../util/concurrent/CountedCompleter.java | 8 +- .../java/util/concurrent/ForkJoinPool.java | 9 +- .../java/util/concurrent/FutureTask.java | 4 +- .../classes/java/util/concurrent/Phaser.java | 4 +- .../util/concurrent/SubmissionPublisher.java | 2 +- .../util/concurrent/atomic/AtomicBoolean.java | 16 +- .../util/concurrent/atomic/AtomicInteger.java | 4 +- .../concurrent/atomic/AtomicIntegerArray.java | 8 +- .../util/concurrent/atomic/AtomicLong.java | 4 +- .../concurrent/atomic/AtomicLongArray.java | 8 +- .../concurrent/atomic/AtomicReference.java | 8 +- .../atomic/AtomicReferenceArray.java | 8 +- .../util/concurrent/locks/StampedLock.java | 10 +- .../invoke/VarHandles/VarHandleBaseTest.java | 2 +- .../VarHandleTestAccessBoolean.java | 42 ++--- .../VarHandles/VarHandleTestAccessByte.java | 42 ++--- .../VarHandles/VarHandleTestAccessChar.java | 42 ++--- .../VarHandles/VarHandleTestAccessDouble.java | 42 ++--- .../VarHandles/VarHandleTestAccessFloat.java | 42 ++--- .../VarHandles/VarHandleTestAccessInt.java | 42 ++--- .../VarHandles/VarHandleTestAccessLong.java | 42 ++--- .../VarHandles/VarHandleTestAccessShort.java | 42 ++--- .../VarHandles/VarHandleTestAccessString.java | 42 ++--- .../VarHandleTestByteArrayAsChar.java | 14 +- .../VarHandleTestByteArrayAsDouble.java | 52 ++++--- .../VarHandleTestByteArrayAsFloat.java | 52 ++++--- .../VarHandleTestByteArrayAsInt.java | 52 ++++--- .../VarHandleTestByteArrayAsLong.java | 52 ++++--- .../VarHandleTestByteArrayAsShort.java | 14 +- ...arHandleTestMethodHandleAccessBoolean.java | 36 ++--- .../VarHandleTestMethodHandleAccessByte.java | 36 ++--- .../VarHandleTestMethodHandleAccessChar.java | 36 ++--- ...VarHandleTestMethodHandleAccessDouble.java | 36 ++--- .../VarHandleTestMethodHandleAccessFloat.java | 36 ++--- .../VarHandleTestMethodHandleAccessInt.java | 36 ++--- .../VarHandleTestMethodHandleAccessLong.java | 36 ++--- .../VarHandleTestMethodHandleAccessShort.java | 36 ++--- ...VarHandleTestMethodHandleAccessString.java | 36 ++--- .../VarHandleTestMethodTypeBoolean.java | 144 +++++++++--------- .../VarHandleTestMethodTypeByte.java | 144 +++++++++--------- .../VarHandleTestMethodTypeChar.java | 144 +++++++++--------- .../VarHandleTestMethodTypeDouble.java | 144 +++++++++--------- .../VarHandleTestMethodTypeFloat.java | 144 +++++++++--------- .../VarHandleTestMethodTypeInt.java | 144 +++++++++--------- .../VarHandleTestMethodTypeLong.java | 144 +++++++++--------- .../VarHandleTestMethodTypeShort.java | 144 +++++++++--------- .../VarHandleTestMethodTypeString.java | 144 +++++++++--------- .../X-VarHandleTestAccess.java.template | 64 ++++---- ...X-VarHandleTestByteArrayView.java.template | 66 ++++---- ...HandleTestMethodHandleAccess.java.template | 36 ++--- .../X-VarHandleTestMethodType.java.template | 144 +++++++++--------- 57 files changed, 1363 insertions(+), 1338 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java index 428906ed618..50e81913c16 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java @@ -134,8 +134,8 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; * The set of corresponding access mode methods belonging to this group * consists of the methods * {@link #compareAndSet compareAndSet}, + * {@link #weakCompareAndSetPlain weakCompareAndSetPlain}, * {@link #weakCompareAndSet weakCompareAndSet}, - * {@link #weakCompareAndSetVolatile weakCompareAndSetVolatile}, * {@link #weakCompareAndSetAcquire weakCompareAndSetAcquire}, * {@link #weakCompareAndSetRelease weakCompareAndSetRelease}, * {@link #compareAndExchangeAcquire compareAndExchangeAcquire}, @@ -834,8 +834,8 @@ public abstract class VarHandle { *

    The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}. * *

    The symbolic type descriptor at the call site of {@code - * weakCompareAndSet} must match the access mode type that is the result of - * calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)} + * weakCompareAndSetPlain} must match the access mode type that is the result of + * calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)} * on this VarHandle. * * @param args the signature-polymorphic parameter list of the form @@ -856,7 +856,7 @@ public abstract class VarHandle { public final native @MethodHandle.PolymorphicSignature @HotSpotIntrinsicCandidate - boolean weakCompareAndSet(Object... args); + boolean weakCompareAndSetPlain(Object... args); /** * Possibly atomically sets the value of a variable to the {@code newValue} @@ -871,8 +871,8 @@ public abstract class VarHandle { *

    The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}. * *

    The symbolic type descriptor at the call site of {@code - * weakCompareAndSetVolatile} must match the access mode type that is the - * result of calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)} + * weakCompareAndSet} must match the access mode type that is the + * result of calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)} * on this VarHandle. * * @param args the signature-polymorphic parameter list of the form @@ -893,7 +893,7 @@ public abstract class VarHandle { public final native @MethodHandle.PolymorphicSignature @HotSpotIntrinsicCandidate - boolean weakCompareAndSetVolatile(Object... args); + boolean weakCompareAndSet(Object... args); /** * Possibly atomically sets the value of a variable to the {@code newValue} @@ -1658,15 +1658,15 @@ public abstract class VarHandle { /** * The access mode whose access is specified by the corresponding * method - * {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet} + * {@link VarHandle#weakCompareAndSetPlain VarHandle.weakCompareAndSetPlain} */ - WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP), + WEAK_COMPARE_AND_SET_PLAIN("weakCompareAndSetPlain", AccessType.COMPARE_AND_SWAP), /** * The access mode whose access is specified by the corresponding * method - * {@link VarHandle#weakCompareAndSetVolatile VarHandle.weakCompareAndSetVolatile} + * {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet} */ - WEAK_COMPARE_AND_SET_VOLATILE("weakCompareAndSetVolatile", AccessType.COMPARE_AND_SWAP), + WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP), /** * The access mode whose access is specified by the corresponding * method diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template index e7fc86eea64..634d64d8327 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template @@ -156,7 +156,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { + static boolean weakCompareAndSetPlain(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, @@ -164,7 +164,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSetVolatile(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { + static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSwap$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, @@ -424,7 +424,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) { + static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSwap$Type$(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, @@ -432,7 +432,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSetVolatile(FieldStaticReadWrite handle, $type$ expected, $type$ value) { + static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSwap$Type$Volatile(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, @@ -735,7 +735,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSetPlain(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] @@ -748,7 +748,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSetVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template index e596c1306fb..da57311e39d 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template @@ -223,7 +223,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } @ForceInline - static boolean weakCompareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSetPlain(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; return UNSAFE.weakCompareAndSwap$RawType$( ba, @@ -232,7 +232,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } @ForceInline - static boolean weakCompareAndSetVolatile(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; return UNSAFE.weakCompareAndSwap$RawType$Volatile( ba, @@ -662,7 +662,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } @ForceInline - static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; return UNSAFE.weakCompareAndSwap$RawType$( UNSAFE.getObject(bb, BYTE_BUFFER_HB), @@ -671,7 +671,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } @ForceInline - static boolean weakCompareAndSetVolatile(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; return UNSAFE.weakCompareAndSwap$RawType$Volatile( UNSAFE.getObject(bb, BYTE_BUFFER_HB), diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java index fd116b5343a..ea2ab9c4d24 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java @@ -521,7 +521,7 @@ public class CompletableFuture implements Future, CompletionStage { else break; } - else if (STACK.weakCompareAndSetVolatile(this, p, (p = p.next))) + else if (STACK.weakCompareAndSet(this, p, (p = p.next))) unlinked = true; else p = stack; @@ -532,7 +532,7 @@ public class CompletableFuture implements Future, CompletionStage { if (q.isLive()) { p = q; q = s; - } else if (NEXT.weakCompareAndSetVolatile(p, q, s)) + } else if (NEXT.weakCompareAndSet(p, q, s)) break; else q = p.next; diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java index e8193a00256..5c1c7069da7 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java @@ -330,7 +330,7 @@ public class ConcurrentLinkedDeque // for e to become an element of this deque, // and for newNode to become "live". if (p != h) // hop two nodes at a time; failure is OK - HEAD.weakCompareAndSetVolatile(this, h, newNode); + HEAD.weakCompareAndSet(this, h, newNode); return; } // Lost CAS race to another thread; re-read prev @@ -362,7 +362,7 @@ public class ConcurrentLinkedDeque // for e to become an element of this deque, // and for newNode to become "live". if (p != t) // hop two nodes at a time; failure is OK - TAIL.weakCompareAndSetVolatile(this, t, newNode); + TAIL.weakCompareAndSet(this, t, newNode); return; } // Lost CAS race to another thread; re-read next @@ -1153,12 +1153,12 @@ public class ConcurrentLinkedDeque if (NEXT.compareAndSet(p, null, beginningOfTheEnd)) { // Successful CAS is the linearization point // for all elements to be added to this deque. - if (!TAIL.weakCompareAndSetVolatile(this, t, last)) { + if (!TAIL.weakCompareAndSet(this, t, last)) { // Try a little harder to update tail, // since we may be adding many elements. t = tail; if (last.next == null) - TAIL.weakCompareAndSetVolatile(this, t, last); + TAIL.weakCompareAndSet(this, t, last); } return true; } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java index 1e3f1aad4f6..56ccb3317fa 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java @@ -308,7 +308,7 @@ public class ConcurrentLinkedQueue extends AbstractQueue // for e to become an element of this queue, // and for newNode to become "live". if (p != t) // hop two nodes at a time; failure is OK - TAIL.weakCompareAndSetVolatile(this, t, newNode); + TAIL.weakCompareAndSet(this, t, newNode); return true; } // Lost CAS race to another thread; re-read next @@ -477,7 +477,7 @@ public class ConcurrentLinkedQueue extends AbstractQueue next = succ(p); if (pred != null && next != null) // unlink - NEXT.weakCompareAndSetVolatile(pred, p, next); + NEXT.weakCompareAndSet(pred, p, next); if (removed) return true; } @@ -524,12 +524,12 @@ public class ConcurrentLinkedQueue extends AbstractQueue if (NEXT.compareAndSet(p, null, beginningOfTheEnd)) { // Successful CAS is the linearization point // for all elements to be added to this queue. - if (!TAIL.weakCompareAndSetVolatile(this, t, last)) { + if (!TAIL.weakCompareAndSet(this, t, last)) { // Try a little harder to update tail, // since we may be adding many elements. t = tail; if (last.next == null) - TAIL.weakCompareAndSetVolatile(this, t, last); + TAIL.weakCompareAndSet(this, t, last); } return true; } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java b/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java index a61762b5669..1218c75de68 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java @@ -551,7 +551,7 @@ public abstract class CountedCompleter extends ForkJoinTask { public final int decrementPendingCountUnlessZero() { int c; do {} while ((c = pending) != 0 && - !PENDING.weakCompareAndSetVolatile(this, c, c - 1)); + !PENDING.weakCompareAndSet(this, c, c - 1)); return c; } @@ -584,7 +584,7 @@ public abstract class CountedCompleter extends ForkJoinTask { return; } } - else if (PENDING.weakCompareAndSetVolatile(a, c, c - 1)) + else if (PENDING.weakCompareAndSet(a, c, c - 1)) return; } } @@ -607,7 +607,7 @@ public abstract class CountedCompleter extends ForkJoinTask { return; } } - else if (PENDING.weakCompareAndSetVolatile(a, c, c - 1)) + else if (PENDING.weakCompareAndSet(a, c, c - 1)) return; } } @@ -652,7 +652,7 @@ public abstract class CountedCompleter extends ForkJoinTask { for (int c;;) { if ((c = pending) == 0) return this; - else if (PENDING.weakCompareAndSetVolatile(this, c, c - 1)) + else if (PENDING.weakCompareAndSet(this, c, c - 1)) return null; } } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 9cc3aef305b..4169ec323e5 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -42,15 +42,10 @@ import java.security.AccessControlContext; import java.security.Permissions; import java.security.ProtectionDomain; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.function.Predicate; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.CountedCompleter; -import java.util.concurrent.ForkJoinTask; -import java.util.concurrent.ForkJoinWorkerThread; import java.util.concurrent.locks.LockSupport; /** @@ -1413,7 +1408,7 @@ public class ForkJoinPool extends AbstractExecutorService { } if (phase != QUIET) { // else pre-adjusted long c; // decrement counts - do {} while (!CTL.weakCompareAndSetVolatile + do {} while (!CTL.weakCompareAndSet (this, c = ctl, ((RC_MASK & (c - RC_UNIT)) | (TC_MASK & (c - TC_UNIT)) | (SP_MASK & c)))); @@ -1608,7 +1603,7 @@ public class ForkJoinPool extends AbstractExecutorService { do { w.stackPred = (int)(c = ctl); nc = ((c - RC_UNIT) & UC_MASK) | (SP_MASK & np); - } while (!CTL.weakCompareAndSetVolatile(this, c, nc)); + } while (!CTL.weakCompareAndSet(this, c, nc)); } else { // already queued int pred = w.stackPred; diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java b/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java index 82e773c7630..ec90f2334c9 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java @@ -361,7 +361,7 @@ public class FutureTask implements RunnableFuture { private void finishCompletion() { // assert state > COMPLETING; for (WaitNode q; (q = waiters) != null;) { - if (WAITERS.weakCompareAndSetVolatile(this, q, null)) { + if (WAITERS.weakCompareAndSet(this, q, null)) { for (;;) { Thread t = q.thread; if (t != null) { @@ -423,7 +423,7 @@ public class FutureTask implements RunnableFuture { q = new WaitNode(); } else if (!queued) - queued = WAITERS.weakCompareAndSetVolatile(this, q.next = waiters, q); + queued = WAITERS.weakCompareAndSet(this, q.next = waiters, q); else if (timed) { final long parkNanos; if (startTime == 0L) { // first time diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java b/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java index c0e6fbadb01..043c0b2b2c8 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java @@ -456,7 +456,7 @@ public class Phaser { // finish registration whenever parent registration // succeeded, even when racing with termination, // since these are part of the same "transaction". - while (!STATE.weakCompareAndSetVolatile + while (!STATE.weakCompareAndSet (this, s, ((long)phase << PHASE_SHIFT) | adjust)) { s = state; @@ -488,7 +488,7 @@ public class Phaser { // CAS to root phase with current parties, tripping unarrived while ((phase = (int)(root.state >>> PHASE_SHIFT)) != (int)(s >>> PHASE_SHIFT) && - !STATE.weakCompareAndSetVolatile + !STATE.weakCompareAndSet (this, s, s = (((long)phase << PHASE_SHIFT) | ((phase < 0) ? (s & COUNTS_MASK) : diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java index 8ba78b3aeb8..b59887d415c 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java @@ -1203,7 +1203,7 @@ public class SubmissionPublisher implements Flow.Publisher, } catch (RuntimeException | Error ex) { // back out do {} while (((c = ctl) & DISABLED) == 0 && (c & ACTIVE) != 0 && - !CTL.weakCompareAndSetVolatile + !CTL.weakCompareAndSet (this, c, c & ~ACTIVE)); throw ex; } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java index 44b9e5aea68..9410db99bc4 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java @@ -106,16 +106,16 @@ public class AtomicBoolean implements java.io.Serializable { /** * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param expectedValue the expected value * @param newValue the new value * @return {@code true} if successful */ public boolean weakCompareAndSet(boolean expectedValue, boolean newValue) { - return VALUE.weakCompareAndSet(this, - (expectedValue ? 1 : 0), - (newValue ? 1 : 0)); + return VALUE.weakCompareAndSetPlain(this, + (expectedValue ? 1 : 0), + (newValue ? 1 : 0)); } /** @@ -285,7 +285,7 @@ public class AtomicBoolean implements java.io.Serializable { * Possibly atomically sets the value to {@code newValue} if the current * value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param expectedValue the expected value * @param newValue the new value @@ -293,9 +293,9 @@ public class AtomicBoolean implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(boolean expectedValue, boolean newValue) { - return VALUE.weakCompareAndSetVolatile(this, - (expectedValue ? 1 : 0), - (newValue ? 1 : 0)); + return VALUE.weakCompareAndSet(this, + (expectedValue ? 1 : 0), + (newValue ? 1 : 0)); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java index f7bcfdbe075..c7fa1c66e52 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java @@ -146,7 +146,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { /** * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param expectedValue the expected value * @param newValue the new value @@ -490,7 +490,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { * Possibly atomically sets the value to {@code newValue} if * the current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param expectedValue the expected value * @param newValue the new value diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java index 8732a169dce..8bce29b6f95 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java @@ -149,7 +149,7 @@ public class AtomicIntegerArray implements java.io.Serializable { /** * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param i the index * @param expectedValue the expected value @@ -157,7 +157,7 @@ public class AtomicIntegerArray implements java.io.Serializable { * @return {@code true} if successful */ public final boolean weakCompareAndSet(int i, int expectedValue, int newValue) { - return AA.weakCompareAndSet(array, i, expectedValue, newValue); + return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue); } /** @@ -489,7 +489,7 @@ public class AtomicIntegerArray implements java.io.Serializable { * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param i the index * @param expectedValue the expected value @@ -498,7 +498,7 @@ public class AtomicIntegerArray implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(int i, int expectedValue, int newValue) { - return AA.weakCompareAndSetVolatile(array, i, expectedValue, newValue); + return AA.weakCompareAndSet(array, i, expectedValue, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java index f95ab65c48f..5ee7104fdb8 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java @@ -162,7 +162,7 @@ public class AtomicLong extends Number implements java.io.Serializable { /** * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param expectedValue the expected value * @param newValue the new value @@ -504,7 +504,7 @@ public class AtomicLong extends Number implements java.io.Serializable { * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param expectedValue the expected value * @param newValue the new value diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java index a3200d43f6a..84182c44f74 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java @@ -149,7 +149,7 @@ public class AtomicLongArray implements java.io.Serializable { /** * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param i the index * @param expectedValue the expected value @@ -157,7 +157,7 @@ public class AtomicLongArray implements java.io.Serializable { * @return {@code true} if successful */ public final boolean weakCompareAndSet(int i, long expectedValue, long newValue) { - return AA.weakCompareAndSet(array, i, expectedValue, newValue); + return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue); } /** @@ -489,7 +489,7 @@ public class AtomicLongArray implements java.io.Serializable { * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param i the index * @param expectedValue the expected value @@ -498,7 +498,7 @@ public class AtomicLongArray implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(int i, long expectedValue, long newValue) { - return AA.weakCompareAndSetVolatile(array, i, expectedValue, newValue); + return AA.weakCompareAndSet(array, i, expectedValue, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java index d8bd6e4a7bc..0098d31bf2e 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java @@ -125,14 +125,14 @@ public class AtomicReference implements java.io.Serializable { /** * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param expectedValue the expected value * @param newValue the new value * @return {@code true} if successful */ public final boolean weakCompareAndSet(V expectedValue, V newValue) { - return VALUE.weakCompareAndSet(this, expectedValue, newValue); + return VALUE.weakCompareAndSetPlain(this, expectedValue, newValue); } /** @@ -370,7 +370,7 @@ public class AtomicReference implements java.io.Serializable { * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param expectedValue the expected value * @param newValue the new value @@ -378,7 +378,7 @@ public class AtomicReference implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(V expectedValue, V newValue) { - return VALUE.weakCompareAndSetVolatile(this, expectedValue, newValue); + return VALUE.weakCompareAndSet(this, expectedValue, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java index 34bb0f135da..998f167d5cc 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java @@ -155,7 +155,7 @@ public class AtomicReferenceArray implements java.io.Serializable { /** * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param i the index * @param expectedValue the expected value @@ -163,7 +163,7 @@ public class AtomicReferenceArray implements java.io.Serializable { * @return {@code true} if successful */ public final boolean weakCompareAndSet(int i, E expectedValue, E newValue) { - return AA.weakCompareAndSet(array, i, expectedValue, newValue); + return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue); } /** @@ -451,7 +451,7 @@ public class AtomicReferenceArray implements java.io.Serializable { * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param i the index * @param expectedValue the expected value @@ -460,7 +460,7 @@ public class AtomicReferenceArray implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(int i, E expectedValue, E newValue) { - return AA.weakCompareAndSetVolatile(array, i, expectedValue, newValue); + return AA.weakCompareAndSet(array, i, expectedValue, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java index 24be8fbe580..8b9d401ee10 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java @@ -1123,14 +1123,14 @@ public class StampedLock implements java.io.Serializable { } else if ((p = wtail) == null) { // initialize queue WNode hd = new WNode(WMODE, null); - if (WHEAD.weakCompareAndSetVolatile(this, null, hd)) + if (WHEAD.weakCompareAndSet(this, null, hd)) wtail = hd; } else if (node == null) node = new WNode(WMODE, p); else if (node.prev != p) node.prev = p; - else if (WTAIL.weakCompareAndSetVolatile(this, p, node)) { + else if (WTAIL.weakCompareAndSet(this, p, node)) { p.next = node; break; } @@ -1162,7 +1162,7 @@ public class StampedLock implements java.io.Serializable { else if (h != null) { // help release stale waiters WNode c; Thread w; while ((c = h.cowait) != null) { - if (WCOWAIT.weakCompareAndSetVolatile(h, c, c.cowait) && + if (WCOWAIT.weakCompareAndSet(h, c, c.cowait) && (w = c.thread) != null) LockSupport.unpark(w); } @@ -1247,7 +1247,7 @@ public class StampedLock implements java.io.Serializable { } if (p == null) { // initialize queue WNode hd = new WNode(WMODE, null); - if (WHEAD.weakCompareAndSetVolatile(this, null, hd)) + if (WHEAD.weakCompareAndSet(this, null, hd)) wtail = hd; } else if (node == null) @@ -1255,7 +1255,7 @@ public class StampedLock implements java.io.Serializable { else if (h == p || p.mode != RMODE) { if (node.prev != p) node.prev = p; - else if (WTAIL.weakCompareAndSetVolatile(this, p, node)) { + else if (WTAIL.weakCompareAndSet(this, p, node)) { p.next = node; break; } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java index 7eb739ff97d..aa66b2fd726 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java @@ -149,8 +149,8 @@ abstract class VarHandleBaseTest { COMPARE_AND_EXCHANGE(TestAccessType.COMPARE_AND_EXCHANGE), COMPARE_AND_EXCHANGE_ACQUIRE(TestAccessType.COMPARE_AND_EXCHANGE), COMPARE_AND_EXCHANGE_RELEASE(TestAccessType.COMPARE_AND_EXCHANGE), + WEAK_COMPARE_AND_SET_PLAIN(TestAccessType.COMPARE_AND_SET), WEAK_COMPARE_AND_SET(TestAccessType.COMPARE_AND_SET), - WEAK_COMPARE_AND_SET_VOLATILE(TestAccessType.COMPARE_AND_SET), WEAK_COMPARE_AND_SET_ACQUIRE(TestAccessType.COMPARE_AND_SET), WEAK_COMPARE_AND_SET_RELEASE(TestAccessType.COMPARE_AND_SET), GET_AND_SET(TestAccessType.GET_AND_SET), diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java index d2a22c733cf..a4d54635d95 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java @@ -103,8 +103,8 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -441,11 +441,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, true, false); + success = vh.weakCompareAndSetPlain(recv, true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) vh.get(recv); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -471,11 +471,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, false, true); + success = vh.weakCompareAndSet(recv, false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) vh.get(recv); - assertEquals(x, true, "weakCompareAndSetVolatile boolean value"); + assertEquals(x, true, "weakCompareAndSet boolean value"); } // Compare set and get @@ -701,11 +701,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(true, false); + success = vh.weakCompareAndSetPlain(true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) vh.get(); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -731,11 +731,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease(false, true); + success = vh.weakCompareAndSet(false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) vh.get(); - assertEquals(x, true, "weakCompareAndSetVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } // Compare set and get @@ -964,11 +964,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, true, false); + success = vh.weakCompareAndSetPlain(array, i, true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) vh.get(array, i); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -994,11 +994,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, false, true); + success = vh.weakCompareAndSet(array, i, false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) vh.get(array, i); - assertEquals(x, true, "weakCompareAndSetVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } // Compare set and get @@ -1190,11 +1190,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, true, false); + boolean r = vh.weakCompareAndSetPlain(array, ci, true, false); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, true, false); + boolean r = vh.weakCompareAndSet(array, ci, true, false); }); checkIOOBE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java index a3b9a3b8013..be79776202b 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java @@ -103,8 +103,8 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -419,11 +419,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, (byte)0x01, (byte)0x23); + success = vh.weakCompareAndSetPlain(recv, (byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) vh.get(recv); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -449,11 +449,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, (byte)0x23, (byte)0x01); + success = vh.weakCompareAndSet(recv, (byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) vh.get(recv); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte value"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte value"); } // Compare set and get @@ -695,11 +695,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet((byte)0x01, (byte)0x23); + success = vh.weakCompareAndSetPlain((byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) vh.get(); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -725,11 +725,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease((byte)0x23, (byte)0x01); + success = vh.weakCompareAndSet((byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) vh.get(); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } // Compare set and get @@ -974,11 +974,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, (byte)0x01, (byte)0x23); + success = vh.weakCompareAndSetPlain(array, i, (byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) vh.get(array, i); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -1004,11 +1004,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, (byte)0x23, (byte)0x01); + success = vh.weakCompareAndSet(array, i, (byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) vh.get(array, i); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } // Compare set and get @@ -1216,11 +1216,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, (byte)0x01, (byte)0x23); + boolean r = vh.weakCompareAndSetPlain(array, ci, (byte)0x01, (byte)0x23); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, (byte)0x01, (byte)0x23); + boolean r = vh.weakCompareAndSet(array, ci, (byte)0x01, (byte)0x23); }); checkIOOBE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java index 090e75a1558..6e2f42cee14 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java @@ -103,8 +103,8 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -419,11 +419,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, '\u0123', '\u4567'); + success = vh.weakCompareAndSetPlain(recv, '\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) vh.get(recv); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -449,11 +449,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, '\u4567', '\u0123'); + success = vh.weakCompareAndSet(recv, '\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) vh.get(recv); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char value"); + assertEquals(x, '\u0123', "weakCompareAndSet char value"); } // Compare set and get @@ -695,11 +695,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet('\u0123', '\u4567'); + success = vh.weakCompareAndSetPlain('\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) vh.get(); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -725,11 +725,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease('\u4567', '\u0123'); + success = vh.weakCompareAndSet('\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) vh.get(); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } // Compare set and get @@ -974,11 +974,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, '\u0123', '\u4567'); + success = vh.weakCompareAndSetPlain(array, i, '\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) vh.get(array, i); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -1004,11 +1004,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, '\u4567', '\u0123'); + success = vh.weakCompareAndSet(array, i, '\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) vh.get(array, i); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } // Compare set and get @@ -1216,11 +1216,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, '\u0123', '\u4567'); + boolean r = vh.weakCompareAndSetPlain(array, ci, '\u0123', '\u4567'); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, '\u0123', '\u4567'); + boolean r = vh.weakCompareAndSet(array, ci, '\u0123', '\u4567'); }); checkIOOBE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java index 1d8e068cbeb..e0564d5d002 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java @@ -103,8 +103,8 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -489,11 +489,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, 1.0d, 2.0d); + success = vh.weakCompareAndSetPlain(recv, 1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) vh.get(recv); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -519,11 +519,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, 2.0d, 1.0d); + success = vh.weakCompareAndSet(recv, 2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(recv); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double value"); + assertEquals(x, 1.0d, "weakCompareAndSet double value"); } // Compare set and get @@ -717,11 +717,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(1.0d, 2.0d); + success = vh.weakCompareAndSetPlain(1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) vh.get(); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -747,11 +747,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease(2.0d, 1.0d); + success = vh.weakCompareAndSet(2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } // Compare set and get @@ -948,11 +948,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, 1.0d, 2.0d); + success = vh.weakCompareAndSetPlain(array, i, 1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) vh.get(array, i); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -978,11 +978,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, 2.0d, 1.0d); + success = vh.weakCompareAndSet(array, i, 2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(array, i); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } // Compare set and get @@ -1142,11 +1142,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, 1.0d, 2.0d); + boolean r = vh.weakCompareAndSetPlain(array, ci, 1.0d, 2.0d); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, 1.0d, 2.0d); + boolean r = vh.weakCompareAndSet(array, ci, 1.0d, 2.0d); }); checkIOOBE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java index 5990a152a54..4fa6b41fd3c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java @@ -103,8 +103,8 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -489,11 +489,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, 1.0f, 2.0f); + success = vh.weakCompareAndSetPlain(recv, 1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) vh.get(recv); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -519,11 +519,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, 2.0f, 1.0f); + success = vh.weakCompareAndSet(recv, 2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(recv); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float value"); + assertEquals(x, 1.0f, "weakCompareAndSet float value"); } // Compare set and get @@ -717,11 +717,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(1.0f, 2.0f); + success = vh.weakCompareAndSetPlain(1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) vh.get(); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -747,11 +747,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease(2.0f, 1.0f); + success = vh.weakCompareAndSet(2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } // Compare set and get @@ -948,11 +948,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, 1.0f, 2.0f); + success = vh.weakCompareAndSetPlain(array, i, 1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) vh.get(array, i); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -978,11 +978,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, 2.0f, 1.0f); + success = vh.weakCompareAndSet(array, i, 2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(array, i); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } // Compare set and get @@ -1142,11 +1142,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, 1.0f, 2.0f); + boolean r = vh.weakCompareAndSetPlain(array, ci, 1.0f, 2.0f); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, 1.0f, 2.0f); + boolean r = vh.weakCompareAndSet(array, ci, 1.0f, 2.0f); }); checkIOOBE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java index a21c2f3a545..2fbcc9cb46d 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java @@ -103,8 +103,8 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -419,11 +419,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, 0x01234567, 0x89ABCDEF); + success = vh.weakCompareAndSetPlain(recv, 0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) vh.get(recv); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -449,11 +449,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, 0x89ABCDEF, 0x01234567); + success = vh.weakCompareAndSet(recv, 0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(recv); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int value"); + assertEquals(x, 0x01234567, "weakCompareAndSet int value"); } // Compare set and get @@ -695,11 +695,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(0x01234567, 0x89ABCDEF); + success = vh.weakCompareAndSetPlain(0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) vh.get(); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -725,11 +725,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease(0x89ABCDEF, 0x01234567); + success = vh.weakCompareAndSet(0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } // Compare set and get @@ -974,11 +974,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, 0x01234567, 0x89ABCDEF); + success = vh.weakCompareAndSetPlain(array, i, 0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) vh.get(array, i); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -1004,11 +1004,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, 0x89ABCDEF, 0x01234567); + success = vh.weakCompareAndSet(array, i, 0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } // Compare set and get @@ -1216,11 +1216,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, 0x01234567, 0x89ABCDEF); + boolean r = vh.weakCompareAndSetPlain(array, ci, 0x01234567, 0x89ABCDEF); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, 0x01234567, 0x89ABCDEF); + boolean r = vh.weakCompareAndSet(array, ci, 0x01234567, 0x89ABCDEF); }); checkIOOBE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java index d401bce06d5..d94cdc131d2 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java @@ -103,8 +103,8 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -419,11 +419,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = vh.weakCompareAndSetPlain(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) vh.get(recv); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -449,11 +449,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = vh.weakCompareAndSet(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(recv); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long value"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long value"); } // Compare set and get @@ -695,11 +695,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = vh.weakCompareAndSetPlain(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) vh.get(); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -725,11 +725,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = vh.weakCompareAndSet(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } // Compare set and get @@ -974,11 +974,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = vh.weakCompareAndSetPlain(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) vh.get(array, i); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -1004,11 +1004,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = vh.weakCompareAndSet(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } // Compare set and get @@ -1216,11 +1216,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + boolean r = vh.weakCompareAndSetPlain(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + boolean r = vh.weakCompareAndSet(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); }); checkIOOBE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java index 4e20386d6f8..7ff96eb10ea 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java @@ -103,8 +103,8 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -419,11 +419,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, (short)0x0123, (short)0x4567); + success = vh.weakCompareAndSetPlain(recv, (short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) vh.get(recv); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -449,11 +449,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, (short)0x4567, (short)0x0123); + success = vh.weakCompareAndSet(recv, (short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) vh.get(recv); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short value"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short value"); } // Compare set and get @@ -695,11 +695,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet((short)0x0123, (short)0x4567); + success = vh.weakCompareAndSetPlain((short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) vh.get(); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -725,11 +725,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease((short)0x4567, (short)0x0123); + success = vh.weakCompareAndSet((short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) vh.get(); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } // Compare set and get @@ -974,11 +974,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, (short)0x0123, (short)0x4567); + success = vh.weakCompareAndSetPlain(array, i, (short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) vh.get(array, i); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -1004,11 +1004,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, (short)0x4567, (short)0x0123); + success = vh.weakCompareAndSet(array, i, (short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) vh.get(array, i); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } // Compare set and get @@ -1216,11 +1216,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, (short)0x0123, (short)0x4567); + boolean r = vh.weakCompareAndSetPlain(array, ci, (short)0x0123, (short)0x4567); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, (short)0x0123, (short)0x4567); + boolean r = vh.weakCompareAndSet(array, ci, (short)0x0123, (short)0x4567); }); checkIOOBE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java index 5fc758cc6f4..0904505db40 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java @@ -103,8 +103,8 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -511,11 +511,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, "foo", "bar"); + success = vh.weakCompareAndSetPlain(recv, "foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) vh.get(recv); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -541,11 +541,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, "bar", "foo"); + success = vh.weakCompareAndSet(recv, "bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(recv); - assertEquals(x, "foo", "weakCompareAndSetVolatile String value"); + assertEquals(x, "foo", "weakCompareAndSet String value"); } // Compare set and get @@ -723,11 +723,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet("foo", "bar"); + success = vh.weakCompareAndSetPlain("foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) vh.get(); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -753,11 +753,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease("bar", "foo"); + success = vh.weakCompareAndSet("bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(); - assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + assertEquals(x, "foo", "weakCompareAndSet String"); } // Compare set and get @@ -938,11 +938,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, "foo", "bar"); + success = vh.weakCompareAndSetPlain(array, i, "foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) vh.get(array, i); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -968,11 +968,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, "bar", "foo"); + success = vh.weakCompareAndSet(array, i, "bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(array, i); - assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + assertEquals(x, "foo", "weakCompareAndSet String"); } // Compare set and get @@ -1116,11 +1116,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, "foo", "bar"); + boolean r = vh.weakCompareAndSetPlain(array, ci, "foo", "bar"); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, "foo", "bar"); + boolean r = vh.weakCompareAndSet(array, ci, "foo", "bar"); }); checkIOOBE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java index e15028a6f5f..89d22695e55 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java @@ -92,8 +92,8 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -214,11 +214,11 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -331,11 +331,11 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -424,11 +424,11 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java index a8ed8e9b662..5757d1958c1 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java @@ -92,8 +92,8 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -289,11 +289,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { @@ -473,11 +473,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -567,11 +567,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -652,11 +652,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -739,11 +739,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -875,11 +875,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet double value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain double value"); } { @@ -903,10 +903,13 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile double value"); + assertEquals(x, VALUE_1, "weakCompareAndSet double"); } // Compare set and get @@ -1045,11 +1048,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet double value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain double value"); } { @@ -1073,10 +1076,13 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile double value"); + assertEquals(x, VALUE_1, "weakCompareAndSet double"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java index 0ed28217595..89d8fe91502 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java @@ -92,8 +92,8 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -289,11 +289,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { @@ -473,11 +473,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -567,11 +567,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -652,11 +652,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -739,11 +739,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -875,11 +875,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet float value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain float value"); } { @@ -903,10 +903,13 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile float value"); + assertEquals(x, VALUE_1, "weakCompareAndSet float"); } // Compare set and get @@ -1045,11 +1048,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet float value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain float value"); } { @@ -1073,10 +1076,13 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile float value"); + assertEquals(x, VALUE_1, "weakCompareAndSet float"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java index 8b63bb36715..79e9daba605 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java @@ -92,8 +92,8 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -243,11 +243,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { @@ -381,11 +381,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -521,11 +521,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -652,11 +652,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -785,11 +785,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -967,11 +967,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet int value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain int value"); } { @@ -995,10 +995,13 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile int value"); + assertEquals(x, VALUE_1, "weakCompareAndSet int"); } // Compare set and get @@ -1247,11 +1250,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet int value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain int value"); } { @@ -1275,10 +1278,13 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile int value"); + assertEquals(x, VALUE_1, "weakCompareAndSet int"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java index a94c0f5280b..01cdfcef554 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java @@ -92,8 +92,8 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -243,11 +243,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { @@ -381,11 +381,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -521,11 +521,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -652,11 +652,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -785,11 +785,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -967,11 +967,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet long value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain long value"); } { @@ -995,10 +995,13 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile long value"); + assertEquals(x, VALUE_1, "weakCompareAndSet long"); } // Compare set and get @@ -1247,11 +1250,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet long value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain long value"); } { @@ -1275,10 +1278,13 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile long value"); + assertEquals(x, VALUE_1, "weakCompareAndSet long"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java index e058789fddc..29e45a04c0e 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java @@ -92,8 +92,8 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -214,11 +214,11 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -331,11 +331,11 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -424,11 +424,11 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java index ba52f280645..99904d32c02 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, true, false); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, false, true); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, true, "weakCompareAndSetVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } // Compare set and get @@ -444,11 +444,11 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(true, false); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -474,11 +474,11 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(false, true); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, true, "weakCompareAndSetVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } // Compare set and get @@ -703,11 +703,11 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, true, false); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -733,11 +733,11 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, false, true); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, true, "weakCompareAndSetVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java index 4bf019bcdec..7ab3b99f949 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, (byte)0x01, (byte)0x23); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, (byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, (byte)0x23, (byte)0x01); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, (byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } // Compare set and get @@ -466,11 +466,11 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact((byte)0x01, (byte)0x23); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact((byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -496,11 +496,11 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact((byte)0x23, (byte)0x01); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact((byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } // Compare set and get @@ -747,11 +747,11 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, (byte)0x01, (byte)0x23); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, (byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -777,11 +777,11 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, (byte)0x23, (byte)0x01); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, (byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java index cbffb98f727..762134b625f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, '\u0123', '\u4567'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, '\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, '\u4567', '\u0123'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, '\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } // Compare set and get @@ -466,11 +466,11 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact('\u0123', '\u4567'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact('\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -496,11 +496,11 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact('\u4567', '\u0123'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact('\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } // Compare set and get @@ -747,11 +747,11 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, '\u0123', '\u4567'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, '\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -777,11 +777,11 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, '\u4567', '\u0123'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, '\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java index 3bf1bdb4ea6..409d700c474 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1.0d, 2.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, 1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2.0d, 1.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } // Compare set and get @@ -388,11 +388,11 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1.0d, 2.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -418,11 +418,11 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2.0d, 1.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } // Compare set and get @@ -591,11 +591,11 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1.0d, 2.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, 1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -621,11 +621,11 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2.0d, 1.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java index aa0b06d9f6f..b826e18d483 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1.0f, 2.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, 1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2.0f, 1.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } // Compare set and get @@ -388,11 +388,11 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1.0f, 2.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -418,11 +418,11 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2.0f, 1.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } // Compare set and get @@ -591,11 +591,11 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1.0f, 2.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, 1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -621,11 +621,11 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2.0f, 1.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java index 64d5cab6104..da0c63fa155 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 0x01234567, 0x89ABCDEF); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, 0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 0x89ABCDEF, 0x01234567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } // Compare set and get @@ -466,11 +466,11 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(0x01234567, 0x89ABCDEF); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -496,11 +496,11 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(0x89ABCDEF, 0x01234567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } // Compare set and get @@ -747,11 +747,11 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 0x01234567, 0x89ABCDEF); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, 0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -777,11 +777,11 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 0x89ABCDEF, 0x01234567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java index 058cb4e5113..6e16e7c82da 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } // Compare set and get @@ -466,11 +466,11 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -496,11 +496,11 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } // Compare set and get @@ -747,11 +747,11 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -777,11 +777,11 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java index 554e9c8a3cf..5b6b8ad39c7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, (short)0x0123, (short)0x4567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, (short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, (short)0x4567, (short)0x0123); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, (short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } // Compare set and get @@ -466,11 +466,11 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact((short)0x0123, (short)0x4567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact((short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -496,11 +496,11 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact((short)0x4567, (short)0x0123); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact((short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } // Compare set and get @@ -747,11 +747,11 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, (short)0x0123, (short)0x4567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, (short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -777,11 +777,11 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, (short)0x4567, (short)0x0123); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, (short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java index b99bf086205..0eb978588b5 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, "foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, "bar", "foo"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + assertEquals(x, "foo", "weakCompareAndSet String"); } // Compare set and get @@ -366,11 +366,11 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact("foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -396,11 +396,11 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact("bar", "foo"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + assertEquals(x, "foo", "weakCompareAndSet String"); } // Compare set and get @@ -547,11 +547,11 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, "foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -577,11 +577,11 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, "bar", "foo"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + assertEquals(x, "foo", "weakCompareAndSet String"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java index 13382f6e6b9..858913fc99e 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, true, true); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, true, true); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, true); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, true, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, true, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, true, true, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, true, true); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, true, true); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, true, true); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, true); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, true, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, true, true); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, true, true, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1255,6 +1255,23 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, true); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(true, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(true, true, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, true); }); @@ -1270,23 +1287,6 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, true); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(true, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(true, true, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -2045,6 +2045,35 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, true, true); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, true, true); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, true); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, true, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, true, true); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, true, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, true, true, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, true, true); }); @@ -2072,35 +2101,6 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, true, true); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, true, true); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, true); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, true, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, true, true); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, true, true); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, true, true, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java index 25d1e34bbac..0f9097acd33 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, (byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, (byte)0x01, (byte)0x01); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, (byte)0x01, (byte)0x01); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, (byte)0x01, (byte)0x01); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, (byte)0x01); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, (byte)0x01, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, (byte)0x01, (byte)0x01); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, (byte)0x01, (byte)0x01, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1377,6 +1377,23 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain((byte)0x01, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain((byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, (byte)0x01); }); @@ -1392,23 +1409,6 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, (byte)0x01); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile((byte)0x01, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile((byte)0x01, (byte)0x01, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -2253,6 +2253,35 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, (byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, (byte)0x01, (byte)0x01); }); @@ -2280,35 +2309,6 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, (byte)0x01, (byte)0x01); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, (byte)0x01, (byte)0x01); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, (byte)0x01); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, (byte)0x01, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, (byte)0x01, (byte)0x01); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, (byte)0x01, (byte)0x01); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, (byte)0x01, (byte)0x01, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java index e00c3b2b26c..46ffc0f8cc7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, '\u0123', '\u0123'); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, '\u0123', '\u0123'); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, '\u0123'); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, '\u0123', Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, '\u0123', '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, '\u0123', '\u0123', Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, '\u0123', '\u0123'); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, '\u0123', '\u0123'); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, '\u0123', '\u0123'); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, '\u0123'); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, '\u0123', Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, '\u0123', '\u0123'); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, '\u0123', '\u0123', Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1377,6 +1377,23 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, '\u0123'); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain('\u0123', Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain('\u0123', '\u0123', Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, '\u0123'); }); @@ -1392,23 +1409,6 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, '\u0123'); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile('\u0123', Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile('\u0123', '\u0123', Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -2253,6 +2253,35 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, '\u0123', '\u0123'); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, '\u0123', '\u0123'); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, '\u0123'); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, '\u0123', Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, '\u0123', '\u0123'); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, '\u0123', '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, '\u0123', '\u0123', Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, '\u0123', '\u0123'); }); @@ -2280,35 +2309,6 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, '\u0123', '\u0123'); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, '\u0123', '\u0123'); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, '\u0123'); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, '\u0123', Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, '\u0123', '\u0123'); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, '\u0123', '\u0123'); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, '\u0123', '\u0123', Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java index cd3e1439722..af37433385c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 1.0d, 1.0d); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 1.0d, 1.0d); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, 1.0d); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, 1.0d, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 1.0d, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, 1.0d, 1.0d, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 1.0d, 1.0d); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 1.0d, 1.0d); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 1.0d, 1.0d); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 1.0d); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, 1.0d, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 1.0d, 1.0d); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, 1.0d, 1.0d, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1073,6 +1073,23 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 1.0d); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(1.0d, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(1.0d, 1.0d, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, 1.0d); }); @@ -1088,23 +1105,6 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 1.0d); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(1.0d, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(1.0d, 1.0d, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -1737,6 +1737,35 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, 1.0d, 1.0d); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, 1.0d, 1.0d); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, 1.0d); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, 1.0d, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, 1.0d, 1.0d); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, 1.0d, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, 1.0d, 1.0d, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, 1.0d, 1.0d); }); @@ -1764,35 +1793,6 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, 1.0d, 1.0d); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 1.0d, 1.0d); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 1.0d); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, 1.0d, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, 1.0d, 1.0d); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 1.0d, 1.0d); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, 1.0d, 1.0d, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java index 499d71389fa..b5d6711a3cb 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 1.0f, 1.0f); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 1.0f, 1.0f); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, 1.0f); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, 1.0f, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 1.0f, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, 1.0f, 1.0f, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 1.0f, 1.0f); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 1.0f, 1.0f); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 1.0f, 1.0f); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 1.0f); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, 1.0f, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 1.0f, 1.0f); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, 1.0f, 1.0f, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1073,6 +1073,23 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 1.0f); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(1.0f, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(1.0f, 1.0f, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, 1.0f); }); @@ -1088,23 +1105,6 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 1.0f); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(1.0f, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(1.0f, 1.0f, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -1737,6 +1737,35 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, 1.0f, 1.0f); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, 1.0f, 1.0f); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, 1.0f); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, 1.0f, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, 1.0f, 1.0f); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, 1.0f, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, 1.0f, 1.0f, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, 1.0f, 1.0f); }); @@ -1764,35 +1793,6 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, 1.0f, 1.0f); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 1.0f, 1.0f); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 1.0f); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, 1.0f, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, 1.0f, 1.0f); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 1.0f, 1.0f); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, 1.0f, 1.0f, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java index 17deb396f0c..9f0b995663c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0x01234567, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0x01234567, 0x01234567); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, 0x01234567); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, 0x01234567, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0x01234567, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, 0x01234567, 0x01234567, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0x01234567, 0x01234567); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0x01234567, 0x01234567); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x01234567, 0x01234567); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 0x01234567); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, 0x01234567, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0x01234567, 0x01234567); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, 0x01234567, 0x01234567, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1377,6 +1377,23 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0x01234567); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(0x01234567, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(0x01234567, 0x01234567, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, 0x01234567); }); @@ -1392,23 +1409,6 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x01234567); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(0x01234567, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(0x01234567, 0x01234567, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -2253,6 +2253,35 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, 0x01234567, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, 0x01234567, 0x01234567); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, 0x01234567); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, 0x01234567, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, 0x01234567, 0x01234567); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, 0x01234567, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, 0x01234567, 0x01234567, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, 0x01234567, 0x01234567); }); @@ -2280,35 +2309,6 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, 0x01234567, 0x01234567); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 0x01234567, 0x01234567); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 0x01234567); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x01234567, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, 0x01234567, 0x01234567); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 0x01234567, 0x01234567); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x01234567, 0x01234567, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java index 882039d3eb3..576d5a197f2 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, 0x0123456789ABCDEFL, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, 0x0123456789ABCDEFL, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1377,6 +1377,23 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(0x0123456789ABCDEFL, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, 0x0123456789ABCDEFL); }); @@ -1392,23 +1409,6 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(0x0123456789ABCDEFL, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -2253,6 +2253,35 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); }); @@ -2280,35 +2309,6 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x0123456789ABCDEFL, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java index c1e5277f9e0..b3f52611dcd 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, (short)0x0123, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, (short)0x0123, (short)0x0123); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, (short)0x0123); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, (short)0x0123, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, (short)0x0123, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, (short)0x0123, (short)0x0123, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, (short)0x0123, (short)0x0123); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, (short)0x0123, (short)0x0123); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, (short)0x0123, (short)0x0123); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, (short)0x0123); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, (short)0x0123, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, (short)0x0123, (short)0x0123); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, (short)0x0123, (short)0x0123, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1377,6 +1377,23 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain((short)0x0123, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain((short)0x0123, (short)0x0123, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, (short)0x0123); }); @@ -1392,23 +1409,6 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, (short)0x0123); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile((short)0x0123, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile((short)0x0123, (short)0x0123, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -2253,6 +2253,35 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, (short)0x0123, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, (short)0x0123, (short)0x0123); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, (short)0x0123); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, (short)0x0123, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, (short)0x0123, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, (short)0x0123, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, (short)0x0123, (short)0x0123, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, (short)0x0123, (short)0x0123); }); @@ -2280,35 +2309,6 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, (short)0x0123, (short)0x0123); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, (short)0x0123, (short)0x0123); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, (short)0x0123); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, (short)0x0123, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, (short)0x0123, (short)0x0123); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, (short)0x0123, (short)0x0123); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, (short)0x0123, (short)0x0123, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java index 883bfed71da..9e2debed693 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, "foo", "foo"); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, "foo", "foo"); + }); + checkCCE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, "foo"); + }); + checkCCE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, "foo", Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, "foo", "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, "foo", "foo", Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, "foo", "foo"); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, "foo", "foo"); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, "foo", "foo"); - }); - checkCCE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, "foo"); - }); - checkCCE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, "foo", Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, "foo", "foo"); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, "foo", "foo", Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -951,6 +951,23 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkCCE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, "foo"); + }); + checkCCE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain("foo", Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain("foo", "foo", Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkCCE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, "foo"); }); @@ -966,23 +983,6 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkCCE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, "foo"); - }); - checkCCE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile("foo", Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile("foo", "foo", Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkCCE(() -> { // expected reference class @@ -1529,6 +1529,35 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, "foo", "foo"); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, "foo", "foo"); + }); + checkCCE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, "foo"); + }); + checkCCE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, "foo", Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, "foo", "foo"); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, "foo", "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, "foo", "foo", Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, "foo", "foo"); }); @@ -1556,35 +1585,6 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, "foo", "foo"); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, "foo", "foo"); - }); - checkCCE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, "foo"); - }); - checkCCE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, "foo", Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, "foo", "foo"); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, "foo", "foo"); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, "foo", "foo", Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template index 222889ca4ad..3d36bd35efc 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template @@ -104,8 +104,8 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -116,8 +116,8 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -323,11 +323,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain(recv, $value1$, $value2$); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, $value2$); + boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); }); checkUOE(() -> { @@ -467,11 +467,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet($value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain($value1$, $value2$); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile($value1$, $value2$); + boolean r = vh.weakCompareAndSet($value1$, $value2$); }); checkUOE(() -> { @@ -642,11 +642,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, $value1$, $value2$); + success = vh.weakCompareAndSetPlain(recv, $value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) vh.get(recv); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -672,11 +672,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, $value2$, $value1$); + success = vh.weakCompareAndSet(recv, $value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(recv); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value"); + assertEquals(x, $value1$, "weakCompareAndSet $type$ value"); } // Compare set and get @@ -844,11 +844,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain(recv, $value1$, $value2$); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, $value2$); + boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); }); checkUOE(() -> { @@ -1019,11 +1019,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet($value1$, $value2$); + success = vh.weakCompareAndSetPlain($value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) vh.get(); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -1049,11 +1049,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease($value2$, $value1$); + success = vh.weakCompareAndSet($value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } // Compare set and get @@ -1221,11 +1221,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet($value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain($value1$, $value2$); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile($value1$, $value2$); + boolean r = vh.weakCompareAndSet($value1$, $value2$); }); checkUOE(() -> { @@ -1399,11 +1399,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, $value1$, $value2$); + success = vh.weakCompareAndSetPlain(array, i, $value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -1429,11 +1429,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, $value2$, $value1$); + success = vh.weakCompareAndSet(array, i, $value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } // Compare set and get @@ -1605,11 +1605,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, i, $value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain(array, i, $value1$, $value2$); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, i, $value1$, $value2$); + boolean r = vh.weakCompareAndSet(array, i, $value1$, $value2$); }); checkUOE(() -> { @@ -1742,11 +1742,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, $value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain(array, ci, $value1$, $value2$); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, $value1$, $value2$); + boolean r = vh.weakCompareAndSet(array, ci, $value1$, $value2$); }); checkIOOBE(() -> { diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template index c9edc652321..caf18e0566a 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template @@ -93,8 +93,8 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -105,8 +105,8 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -247,11 +247,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -371,11 +371,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { @@ -416,11 +416,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -563,11 +563,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -702,11 +702,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -848,11 +848,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -985,11 +985,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -1124,11 +1124,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -1312,11 +1312,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain $type$ value"); } { @@ -1340,10 +1340,13 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile $type$ value"); + assertEquals(x, VALUE_1, "weakCompareAndSet $type$"); } // Compare set and get @@ -1598,11 +1601,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain $type$ value"); } { @@ -1626,10 +1629,13 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile $type$ value"); + assertEquals(x, VALUE_1, "weakCompareAndSet $type$"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template index d59462c6b3f..c82d533878a 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template @@ -211,11 +211,11 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, $value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -241,11 +241,11 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, $value2$, $value1$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } // Compare set and get @@ -506,11 +506,11 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact($value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -536,11 +536,11 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact($value2$, $value1$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } // Compare set and get @@ -826,11 +826,11 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, $value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -856,11 +856,11 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, $value2$, $value1$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } // Compare set and get diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template index a65fccb5dfc..0116e5d61f1 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template @@ -353,6 +353,32 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, $value1$, $value1$); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, $value1$, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, $value1$, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, $value1$, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, $value1$, $value1$, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, $value1$, $value1$); }); @@ -377,32 +403,6 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, $value1$, $value1$); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, $value1$, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, $value1$, $value1$); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, $value1$, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1390,6 +1390,23 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain($value1$, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain($value1$, $value1$, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types check{#if[String]?CCE:WMTE}(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, $value1$); }); @@ -1405,23 +1422,6 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - check{#if[String]?CCE:WMTE}(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile($value1$, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile($value1$, $value1$, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types check{#if[String]?CCE:WMTE}(() -> { // expected reference class @@ -2278,6 +2278,35 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, $value1$, $value1$); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, $value1$, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, $value1$, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, $value1$, $value1$); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, $value1$, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, $value1$, $value1$, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, $value1$, $value1$); }); @@ -2305,35 +2334,6 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, $value1$, $value1$); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, $value1$, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, $value1$, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, $value1$, $value1$); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, $value1$, $value1$); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, $value1$, $value1$, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver From a4260270fadea75b330fd75e5e47fb10792fa805 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 1 Sep 2016 23:20:11 +0000 Subject: [PATCH 104/296] Added tag jdk-9+134 for changeset 9217de724b92 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 4639f93e55b..5a179a2c6bd 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -376,3 +376,4 @@ c40c8739bcdc88892ff58ebee3fd8a3f287be94d jdk-9+123 8c57f4c293bbc5609928308a6d91ba765760b5f9 jdk-9+131 d5c70818cd8a82e76632c8c815bdb4f75f53aeaf jdk-9+132 3cdae27c90b5e41afe75eab904fda19fac076330 jdk-9+133 +803adcd526d74ae0b64948d1f8260c2dbe514779 jdk-9+134 From e1f4b79e9e0a1c55c062612d5336e668f7d0c11b Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Fri, 2 Sep 2016 14:46:27 +0530 Subject: [PATCH 105/296] 8157992: Improve jlink help message on optimization-related options Reviewed-by: redestad, alanb --- .../share/classes/jdk/tools/jlink/resources/plugins.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties index 309187dc2d7..1303d5745c5 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties @@ -139,7 +139,8 @@ plugin.opt.plugin-module-path=\ \ --plugin-module-path Custom plugin module path plugin.opt.c=\ -\ -c, --compress=2 Enable compression of resources (level 2) +\ -c, --compress=<0|1|2> Enable compression of resources\ +\n More details in --list-plugins option plugin.opt.G=\ \ -G, --strip-debug Strip debug information From 6906b1ad96b32b0c14d26f25f66a5d6776820421 Mon Sep 17 00:00:00 2001 From: Ramanand Patil Date: Thu, 1 Sep 2016 10:35:38 +0530 Subject: [PATCH 106/296] 8161016: Strange behavior of URLConnection with proxy Reviewed-by: shade, chegar --- .../www/protocol/http/HttpURLConnection.java | 7 +- .../HttpURLConWithProxy.java | 106 ++++++++++++++++++ 2 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 jdk/test/java/net/HttpURLConnection/HttpURLConWithProxy.java diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 923fbe4d66c..35a3fa5da66 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -1074,7 +1074,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * 1) if (instProxy != null) * connect to instProxy; raise exception if failed * 2) else use system default ProxySelector - * 3) is 2) fails, make direct connection + * 3) else make a direct connection if ProxySelector is not present */ if (instProxy == null) { // no instance Proxy is set @@ -1117,10 +1117,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { if (p != Proxy.NO_PROXY) { sel.connectFailed(uri, p.address(), ioex); if (!it.hasNext()) { - // fallback to direct connection - http = getNewHttpClient(url, null, connectTimeout, false); - http.setReadTimeout(readTimeout); - break; + throw ioex; } } else { throw ioex; diff --git a/jdk/test/java/net/HttpURLConnection/HttpURLConWithProxy.java b/jdk/test/java/net/HttpURLConnection/HttpURLConWithProxy.java new file mode 100644 index 00000000000..3c2ec8922af --- /dev/null +++ b/jdk/test/java/net/HttpURLConnection/HttpURLConWithProxy.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + + /* + * @test + * @bug 8161016 + * @summary When proxy is set HttpURLConnection should not use DIRECT connection. + * @run main/othervm HttpURLConWithProxy + */ +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.ServerSocket; +import java.net.SocketAddress; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; + +public class HttpURLConWithProxy { + + public static void main(String... arg) { + // Remove the default nonProxyHosts to use localhost for testing + System.setProperty("http.nonProxyHosts", ""); + + System.setProperty("http.proxyHost", "1.1.1.1"); + System.setProperty("http.proxyPort", "1111"); + + ServerSocket ss; + URL url; + URLConnection con; + + // Test1: using Proxy set by System Property: + try { + ss = new ServerSocket(0); + url = new URL("http://localhost:" + ss.getLocalPort()); + con = url.openConnection(); + con.setConnectTimeout(10 * 1000); + con.connect(); + throw new RuntimeException("Shouldn't use DIRECT connection " + + "when proxy is invalid/down"); + } catch (IOException ie) { + System.out.println("Test1 Passed with: " + ie.getMessage()); + } + + // Test2: using custom ProxySelector implementation + MyProxySelector myProxySel = new MyProxySelector(); + ProxySelector.setDefault(myProxySel); + try { + ss = new ServerSocket(0); + url = new URL("http://localhost:" + ss.getLocalPort()); + con = url.openConnection(); + con.setConnectTimeout(10 * 1000); + con.connect(); + throw new RuntimeException("Shouldn't use DIRECT connection " + + "when proxy is invalid/down"); + } catch (IOException ie) { + System.out.println("Test2 Passed with: " + ie.getMessage()); + } + } +} + + +class MyProxySelector extends ProxySelector { + + List proxies = new ArrayList<>(); + + MyProxySelector() { + Proxy p1 = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("2.2.2.2", 2222)); + Proxy p2 = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("3.3.3.3", 3333)); + proxies.add(p1); + proxies.add(p2); + } + + @Override + public List select(URI uri) { + return proxies; + } + + @Override + public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { + // System.out.println("MyProxySelector.connectFailed(): "+sa); + } +} From 31f780a4439f2863e7d684749b17976543a415a5 Mon Sep 17 00:00:00 2001 From: Matthias Klose Date: Thu, 1 Sep 2016 10:29:37 +0200 Subject: [PATCH 107/296] 8165158: Fix zero builds for non-listed architectures Reviewed-by: tbell --- common/autoconf/generated-configure.sh | 6 +++++- common/autoconf/platform.m4 | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 92e055d9a12..b233cdcd433 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5095,7 +5095,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1470863189 +DATE_WHEN_GENERATED=1472718471 ############################################################################### # @@ -15944,6 +15944,8 @@ $as_echo "$COMPILE_TYPE" >&6; } HOTSPOT_TARGET_CPU_DEFINE=S390 elif test "x$OPENJDK_TARGET_CPU" = xs390x; then HOTSPOT_TARGET_CPU_DEFINE=S390 + elif test "x$OPENJDK_TARGET_CPU" != x; then + HOTSPOT_TARGET_CPU_DEFINE=$(echo $OPENJDK_TARGET_CPU | tr a-z A-Z) fi @@ -16117,6 +16119,8 @@ $as_echo "$COMPILE_TYPE" >&6; } HOTSPOT_BUILD_CPU_DEFINE=S390 elif test "x$OPENJDK_BUILD_CPU" = xs390x; then HOTSPOT_BUILD_CPU_DEFINE=S390 + elif test "x$OPENJDK_BUILD_CPU" != x; then + HOTSPOT_BUILD_CPU_DEFINE=$(echo $OPENJDK_BUILD_CPU | tr a-z A-Z) fi diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 index 2fbac1d0dd3..e7ffe4a2fa5 100644 --- a/common/autoconf/platform.m4 +++ b/common/autoconf/platform.m4 @@ -454,6 +454,8 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER], HOTSPOT_$1_CPU_DEFINE=S390 elif test "x$OPENJDK_$1_CPU" = xs390x; then HOTSPOT_$1_CPU_DEFINE=S390 + elif test "x$OPENJDK_$1_CPU" != x; then + HOTSPOT_$1_CPU_DEFINE=$(echo $OPENJDK_$1_CPU | tr a-z A-Z) fi AC_SUBST(HOTSPOT_$1_CPU_DEFINE) From d2f0ab6d8e22a4fe4e1b68c483a5a88883ec7cdc Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 1 Sep 2016 10:30:13 +0200 Subject: [PATCH 108/296] 8131023: JShell: System.in does not work Read prompt lentgh directly from the terminal Reviewed-by: rfield --- .../internal/jline/console/ConsoleReader.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java index 9b7edac4d33..84341e1e181 100644 --- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java +++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java @@ -39,6 +39,7 @@ import java.util.ListIterator; //import java.util.Map; import java.util.ResourceBundle; import java.util.Stack; +import java.util.regex.Matcher; import java.util.regex.Pattern; import jdk.internal.jline.Terminal; @@ -2336,6 +2337,33 @@ public class ConsoleReader out.flush(); } + Stack pushBackChar = new Stack(); + + if (terminal.isAnsiSupported()) { + //detect the prompt length by reading the cursor position from the terminal + //the real prompt length could differ from the simple prompt length due to + //use of escape sequences: + out.write("\033[6n"); + out.flush(); + StringBuilder input = new StringBuilder(); + while (true) { + int read; + while ((read = in.read()) != 'R') { + input.appendCodePoint(read); + } + input.appendCodePoint(read); + Matcher m = CURSOR_COLUMN_PATTERN.matcher(input); + if (m.matches()) { + promptLen = Integer.parseInt(m.group("column")) - 1; + String prefix = m.group("prefix"); + for (int i = prefix.length() - 1; i >= 0; i--) { + pushBackChar.push(prefix.charAt(i)); + } + break; + } + } + } + // if the terminal is unsupported, just use plain-java reading if (!terminal.isSupported()) { return readLineSimple(); @@ -2352,7 +2380,6 @@ public class ConsoleReader boolean success = true; StringBuilder sb = new StringBuilder(); - Stack pushBackChar = new Stack(); while (true) { int c = pushBackChar.isEmpty() ? readCharacter() : pushBackChar.pop (); if (c == -1) { @@ -3193,6 +3220,9 @@ public class ConsoleReader } } } + //where: + private Pattern CURSOR_COLUMN_PATTERN = + Pattern.compile("(?.*)\033\\[[0-9]+;(?[0-9]+)R"); /** * Read a line for unsupported terminals. From 44ec255a91c2eb5ec65e0c29ea16bcee32ec7d25 Mon Sep 17 00:00:00 2001 From: Li Jiang Date: Thu, 1 Sep 2016 01:39:21 -0700 Subject: [PATCH 109/296] 8145952: ISO 4217 amendment 161 8164784: ISO 4217 amendment 162 Reviewed-by: naoto --- jdk/make/data/currency/CurrencyData.properties | 6 +++--- .../sun/util/resources/CurrencyNames.properties | 10 ++++++---- .../resources/ext/CurrencyNames_be_BY.properties | 1 + jdk/test/java/util/Currency/ValidateISO4217.java | 4 ++-- jdk/test/java/util/Currency/tablea1.txt | 8 ++++---- jdk/test/sun/text/resources/LocaleData | 14 ++++++++++---- jdk/test/sun/text/resources/LocaleDataTest.java | 2 +- 7 files changed, 27 insertions(+), 18 deletions(-) diff --git a/jdk/make/data/currency/CurrencyData.properties b/jdk/make/data/currency/CurrencyData.properties index 0288b04390b..2d25c95fee5 100644 --- a/jdk/make/data/currency/CurrencyData.properties +++ b/jdk/make/data/currency/CurrencyData.properties @@ -32,14 +32,14 @@ formatVersion=3 # Version of the currency code information in this class. # It is a serial number that accompanies with each amendment. -dataVersion=160 +dataVersion=162 # List of all valid ISO 4217 currency codes. # To ensure compatibility, do not remove codes. all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036-\ AWG533-AYM945-AZM031-AZN944-BAM977-BBD052-BDT050-BEF056-BGL100-BGN975-BHD048-BIF108-\ - BMD060-BND096-BOB068-BOV984-BRL986-BSD044-BTN064-BWP072-BYB112-BYR974-\ + BMD060-BND096-BOB068-BOV984-BRL986-BSD044-BTN064-BWP072-BYB112-BYR974-BYN933-\ BZD084-CAD124-CDF976-CHE947-CHF756-CHW948-CLF990-CLP152-CNY156-COP170-COU970-CRC188-CSD891-CUP192-CUC931-\ CVE132-CYP196-CZK203-DEM276-DJF262-DKK208-DOP214-DZD012-EEK233-EGP818-\ ERN232-ESP724-ETB230-EUR978-FIM246-FJD242-FKP238-FRF250-GBP826-GEL981-\ @@ -119,7 +119,7 @@ BD=BDT # BARBADOS BB=BBD # BELARUS -BY=BYR +BY=BYN # BELGIUM BE=EUR # BELIZE diff --git a/jdk/src/java.base/share/classes/sun/util/resources/CurrencyNames.properties b/jdk/src/java.base/share/classes/sun/util/resources/CurrencyNames.properties index b002202875b..c62d518e4b5 100644 --- a/jdk/src/java.base/share/classes/sun/util/resources/CurrencyNames.properties +++ b/jdk/src/java.base/share/classes/sun/util/resources/CurrencyNames.properties @@ -92,6 +92,7 @@ BSD=BSD BTN=BTN BWP=BWP BYB=BYB +BYN=BYN BYR=BYR BZD=BZD CAD=CAD @@ -310,8 +311,9 @@ brl=Brazilian Real bsd=Bahamian Dollar btn=Bhutanese Ngultrum bwp=Botswanan Pula -byb=Belarusian New Ruble (1994-1999) -byr=Belarusian Ruble +byb=Belarusian Ruble (1994-1999) +byn=Belarusian Ruble +byr=Belarusian Ruble (2000-2016) bzd=Belize Dollar cad=Canadian Dollar cdf=Congolese Franc @@ -399,7 +401,7 @@ mro=Mauritanian Ouguiya mtl=Maltese Lira mur=Mauritian Rupee mvr=Maldivian Rufiyaa -mwk=Malawian Kwacha +mwk=Malawian Malawi Kwacha mxn=Mexican Peso mxv=Mexican Investment Unit myr=Malaysian Ringgit @@ -414,7 +416,7 @@ npr=Nepalese Rupee nzd=New Zealand Dollar omr=Omani Rial pab=Panamanian Balboa -pen=Peruvian Nuevo Sol +pen=Peruvian Sol pgk=Papua New Guinean Kina php=Philippine Peso pkr=Pakistani Rupee diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties index 4651ad1c097..54cc2a62072 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties @@ -35,4 +35,5 @@ # This notice and attribution to Taligent may not be removed. # Taligent is a registered trademark of Taligent, Inc. +BYN=\u0420\u0443\u0431 BYR=\u0420\u0443\u0431 diff --git a/jdk/test/java/util/Currency/ValidateISO4217.java b/jdk/test/java/util/Currency/ValidateISO4217.java index 98fc0a00d8a..f482cfd66c8 100644 --- a/jdk/test/java/util/Currency/ValidateISO4217.java +++ b/jdk/test/java/util/Currency/ValidateISO4217.java @@ -23,7 +23,7 @@ /* * @test * @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759 - * 8039317 8074350 8074351 + * 8039317 8074350 8074351 8145952 * @summary Validate ISO 4217 data for Currency class. */ @@ -93,7 +93,7 @@ public class ValidateISO4217 { /* Codes that are obsolete, do not have related country */ static final String otherCodes = - "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-CHE-CHW-CLF-COU-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZMK-ZWD-ZWN-ZWR"; + "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-BYR-CHE-CHW-CLF-COU-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZMK-ZWD-ZWN-ZWR"; static boolean err = false; diff --git a/jdk/test/java/util/Currency/tablea1.txt b/jdk/test/java/util/Currency/tablea1.txt index dacc0fb5210..0ef755a7a87 100644 --- a/jdk/test/java/util/Currency/tablea1.txt +++ b/jdk/test/java/util/Currency/tablea1.txt @@ -1,12 +1,12 @@ # # -# Amendments up until ISO 4217 AMENDMENT NUMBER 160 -# (As of 19 June 2015) +# Amendments up until ISO 4217 AMENDMENT NUMBER 162 +# (As of 30 Auguest 2016) # # Version FILEVERSION=3 -DATAVERSION=160 +DATAVERSION=162 # ISO 4217 currency data AF AFN 971 2 @@ -28,7 +28,7 @@ BS BSD 44 2 BH BHD 48 3 BD BDT 50 2 BB BBD 52 2 -BY BYR 974 0 +BY BYN 933 2 BE EUR 978 2 BZ BZD 84 2 BJ XOF 952 0 diff --git a/jdk/test/sun/text/resources/LocaleData b/jdk/test/sun/text/resources/LocaleData index 53516a7ead4..a4bae5a9c21 100644 --- a/jdk/test/sun/text/resources/LocaleData +++ b/jdk/test/sun/text/resources/LocaleData @@ -6403,8 +6403,8 @@ CurrencyNames//bgn=Bulgarian Lev CurrencyNames//bif=Burundian Franc CurrencyNames//bob=Bolivian Boliviano CurrencyNames//btn=Bhutanese Ngultrum -CurrencyNames//byb=Belarusian New Ruble (1994-1999) -CurrencyNames//byr=Belarusian Ruble +CurrencyNames//byb=Belarusian Ruble (1994-1999) +CurrencyNames//byr=Belarusian Ruble (2000-2016) CurrencyNames//cdf=Congolese Franc CurrencyNames//clf=Chilean Unit of Account (UF) CurrencyNames//cny=Chinese Yuan @@ -6436,7 +6436,6 @@ CurrencyNames//mop=Macanese Pataca CurrencyNames//mro=Mauritanian Ouguiya CurrencyNames//mur=Mauritian Rupee CurrencyNames//mvr=Maldivian Rufiyaa -CurrencyNames//mwk=Malawian Kwacha CurrencyNames//mxv=Mexican Investment Unit CurrencyNames//mzm=Mozambican Metical (1980-2006) CurrencyNames//mzn=Mozambican Metical @@ -6444,7 +6443,6 @@ CurrencyNames//nad=Namibian Dollar CurrencyNames//nio=Nicaraguan C\u00f3rdoba CurrencyNames//nlg=Dutch Guilder CurrencyNames//omr=Omani Rial -CurrencyNames//pen=Peruvian Nuevo Sol CurrencyNames//pgk=Papua New Guinean Kina CurrencyNames//pkr=Pakistani Rupee CurrencyNames//pyg=Paraguayan Guarani @@ -8287,3 +8285,11 @@ FormatData/de/standalone.MonthAbbreviations/2=M\u00e4r # bug #8129361 CurrencyNames//hrk=Kuna + +# bug #8164784 +CurrencyNames//mwk=Malawian Malawi Kwacha +CurrencyNames//pen=Peruvian Sol + +# bug #8145952 +CurrencyNames//byn=Belarusian Ruble +CurrencyNames/be_BY/BYN=\u0420\u0443\u0431 diff --git a/jdk/test/sun/text/resources/LocaleDataTest.java b/jdk/test/sun/text/resources/LocaleDataTest.java index 6f1dca3e0d0..809cc55865f 100644 --- a/jdk/test/sun/text/resources/LocaleDataTest.java +++ b/jdk/test/sun/text/resources/LocaleDataTest.java @@ -37,7 +37,7 @@ * 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509 * 7114053 7074882 7040556 8008577 8013836 8021121 6192407 6931564 8027695 * 8017142 8037343 8055222 8042126 8074791 8075173 8080774 8129361 8134916 - * 8145136 + * 8145136 8145952 8164784 * @summary Verify locale data * @modules java.base/sun.util.resources * @run main LocaleDataTest From 6d5b6597cdd5016769e150e69bc1787af4caf80f Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Thu, 1 Sep 2016 12:02:22 +0300 Subject: [PATCH 110/296] 8158411: Regression on Swingmark on 8u102 b03 comparing 8u102 b02 on several configs on win32 Reviewed-by: prr, ssadetsky --- .../windows/native/libawt/windows/ThemeReader.cpp | 14 +++++++++----- .../libawt/windows/awt_DesktopProperties.cpp | 15 ++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp index b3d3e09ed65..c48ae8fbe31 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp @@ -753,10 +753,15 @@ JNIEXPORT jobject JNICALL Java_sun_awt_windows_ThemeReader_getPosition } void rescale(SIZE *size) { - HWND hWnd = ::GetDesktopWindow(); - HDC hDC = ::GetDC(hWnd); - int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); - int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); + static int dpiX = -1; + static int dpiY = -1; + if (dpiX == -1 || dpiY == -1) { + HWND hWnd = ::GetDesktopWindow(); + HDC hDC = ::GetDC(hWnd); + dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); + dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); + ::ReleaseDC(hWnd, hDC); + } if (dpiX !=0 && dpiX != 96) { float invScaleX = 96.0f / dpiX; @@ -766,7 +771,6 @@ void rescale(SIZE *size) { float invScaleY = 96.0f / dpiY; size->cy = ROUND_TO_INT(size->cy * invScaleY); } - ::ReleaseDC(hWnd, hDC); } /* diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp index 497d35dc350..608138fb2eb 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp @@ -88,11 +88,16 @@ void AwtDesktopProperties::GetWindowsParameters() { } void getInvScale(float &invScaleX, float &invScaleY) { - HWND hWnd = ::GetDesktopWindow(); - HDC hDC = ::GetDC(hWnd); - int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); - int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); - ::ReleaseDC(hWnd, hDC); + static int dpiX = -1; + static int dpiY = -1; + if (dpiX == -1 || dpiY == -1) { + HWND hWnd = ::GetDesktopWindow(); + HDC hDC = ::GetDC(hWnd); + dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); + dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); + ::ReleaseDC(hWnd, hDC); + } + invScaleX = (dpiX == 0.0f) ? 1.0f : 96.0f / dpiX; invScaleY = (dpiY == 0.0f) ? 1.0f : 96.0f / dpiY; } From 277a5b423f98b52f9e507f5969dd53c3284df659 Mon Sep 17 00:00:00 2001 From: Amit Sapre Date: Thu, 1 Sep 2016 15:02:32 +0530 Subject: [PATCH 111/296] 8164609: javax/management/remote/mandatory/notif/DeadListenerTest.java fails with Assertion Error Increased test timeout to ensure test case gets all notifications. Reviewed-by: dholmes --- .../remote/mandatory/notif/DeadListenerTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java b/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java index 3f91fc38085..50777b00220 100644 --- a/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java +++ b/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -115,9 +115,8 @@ public class DeadListenerTest { mbean.sendNotification(notif); // Make sure notifs are working normally. - long deadline = System.currentTimeMillis() + 2000; - while ((count1Val.get() != 1 || count2Val.get() != 1) && System.currentTimeMillis() < deadline) { - Thread.sleep(10); + while ((count1Val.get() != 1 || count2Val.get() != 1) ) { + Thread.sleep(20); } assertTrue("New value of count1 == 1", count1Val.get() == 1); assertTrue("Initial value of count2 == 1", count2Val.get() == 1); From 9807f64dfc49de8aeeaee586bd84b4086d68ce5e Mon Sep 17 00:00:00 2001 From: Sean Coffey Date: Thu, 1 Sep 2016 11:01:47 +0100 Subject: [PATCH 112/296] 8164846: CertificateException missing cause of underlying exception Reviewed-by: xuelei --- .../sun/security/ssl/SSLContextImpl.java | 2 +- .../ssl/SSLContextImpl/TrustTrustedCert.java | 87 ++++++++++++------- 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java index 764f04cd545..86727b91997 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java @@ -1496,7 +1496,7 @@ final class AbstractTrustManagerWrapper extends X509ExtendedTrustManager } } catch (CertPathValidatorException cpve) { throw new CertificateException( - "Certificates does not conform to algorithm constraints"); + "Certificates do not conform to algorithm constraints", cpve); } } } diff --git a/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java b/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java index b812ba5f60e..b10431b6444 100644 --- a/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java +++ b/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java @@ -30,12 +30,13 @@ /* * @test - * @bug 7113275 + * @bug 7113275 8164846 * @summary compatibility issue with MD2 trust anchor and old X509TrustManager - * @run main/othervm TrustTrustedCert PKIX TLSv1.1 - * @run main/othervm TrustTrustedCert SunX509 TLSv1.1 - * @run main/othervm TrustTrustedCert PKIX TLSv1.2 - * @run main/othervm TrustTrustedCert SunX509 TLSv1.2 + * @run main/othervm TrustTrustedCert PKIX TLSv1.1 true + * @run main/othervm TrustTrustedCert PKIX TLSv1.1 false + * @run main/othervm TrustTrustedCert SunX509 TLSv1.1 false + * @run main/othervm TrustTrustedCert PKIX TLSv1.2 false + * @run main/othervm TrustTrustedCert SunX509 TLSv1.2 false */ import java.net.*; @@ -181,23 +182,32 @@ public class TrustTrustedCert { Thread.sleep(50); } - SSLContext context = generateSSLContext(); - SSLSocketFactory sslsf = context.getSocketFactory(); + SSLSocket sslSocket = null; + try { + SSLContext context = generateSSLContext(); + SSLSocketFactory sslsf = context.getSocketFactory(); - SSLSocket sslSocket = - (SSLSocket)sslsf.createSocket("localhost", serverPort); + sslSocket = (SSLSocket)sslsf.createSocket("localhost", serverPort); - // enable the specified TLS protocol - sslSocket.setEnabledProtocols(new String[] {tlsProtocol}); + // enable the specified TLS protocol + sslSocket.setEnabledProtocols(new String[] {tlsProtocol}); - InputStream sslIS = sslSocket.getInputStream(); - OutputStream sslOS = sslSocket.getOutputStream(); - - sslOS.write('B'); - sslOS.flush(); - sslIS.read(); - - sslSocket.close(); + InputStream sslIS = sslSocket.getInputStream(); + OutputStream sslOS = sslSocket.getOutputStream(); + sslOS.write('B'); + sslOS.flush(); + sslIS.read(); + } catch (SSLHandshakeException e) { + // focus in on the CertPathValidatorException + Throwable t = e.getCause().getCause(); + if ((t == null) || (expectFail && + !t.toString().contains("MD5withRSA"))) { + throw new RuntimeException( + "Expected to see MD5withRSA in exception output " + t); + } + } finally { + if (sslSocket != null) sslSocket.close(); + } } /* @@ -206,10 +216,13 @@ public class TrustTrustedCert { */ private static String tmAlgorithm; // trust manager private static String tlsProtocol; // trust manager + // set this flag to test context of CertificateException + private static boolean expectFail; private static void parseArguments(String[] args) { tmAlgorithm = args[0]; tlsProtocol = args[1]; + expectFail = Boolean.parseBoolean(args[2]); } private static SSLContext generateSSLContext() throws Exception { @@ -232,7 +245,7 @@ public class TrustTrustedCert { // generate the private key. PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( - Base64.getMimeDecoder().decode(targetPrivateKey)); + Base64.getMimeDecoder().decode(targetPrivateKey)); KeyFactory kf = KeyFactory.getInstance("RSA"); RSAPrivateKey priKey = (RSAPrivateKey)kf.generatePrivate(priKeySpec); @@ -338,20 +351,25 @@ public class TrustTrustedCert { volatile Exception clientException = null; public static void main(String[] args) throws Exception { - // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty("jdk.certpath.disabledAlgorithms", + /* + * Get the customized arguments. + */ + parseArguments(args); + + /* + * MD5 is used in this test case, don't disable MD5 algorithm. + * if expectFail is set, we're testing exception message + */ + if (!expectFail) { + Security.setProperty("jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + } Security.setProperty("jdk.tls.disabledAlgorithms", "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); - /* - * Get the customized arguments. - */ - parseArguments(args); - /* * Start the tests. */ @@ -376,7 +394,8 @@ public class TrustTrustedCert { startServer(false); } } catch (Exception e) { - // swallow for now. Show later + System.out.println("Unexpected exception: "); + e.printStackTrace(); } /* @@ -440,7 +459,11 @@ public class TrustTrustedCert { */ System.err.println("Server died..."); serverReady = true; - serverException = e; + if (!expectFail) { + // only record if we weren't expecting. + // client side will record exception + serverException = e; + } } } }; @@ -449,7 +472,11 @@ public class TrustTrustedCert { try { doServerSide(); } catch (Exception e) { - serverException = e; + // only record if we weren't expecting. + // client side will record exception + if (!expectFail) { + serverException = e; + } } finally { serverReady = true; } From 63217bef37d32c1e3889c19f4168efcfacfe10db Mon Sep 17 00:00:00 2001 From: Prem Balakrishnan Date: Thu, 1 Sep 2016 16:18:14 +0530 Subject: [PATCH 113/296] 8144735: [hidpi] javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java fails Reviewed-by: psadhukhan, vadim --- .../classes/sun/awt/windows/TranslucentWindowPainter.java | 6 +++--- .../TranslucentPerPixelTranslucentGradient.java | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java index e57ce205a74..05043bd7525 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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 @@ -303,10 +303,10 @@ abstract class TranslucentWindowPainter { if (bb instanceof DestSurfaceProvider) { Surface s = ((DestSurfaceProvider)bb).getDestSurface(); if (s instanceof AccelSurface) { - final int w = bb.getWidth(null); - final int h = bb.getHeight(null); final boolean arr[] = { false }; final AccelSurface as = (AccelSurface)s; + final int w = as.getBounds().width; + final int h = as.getBounds().height; RenderQueue rq = as.getContext().getRenderQueue(); rq.lock(); try { diff --git a/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java index 2137217b142..8022e8fff0b 100644 --- a/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java +++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java @@ -25,6 +25,7 @@ import java.awt.*; /* * @test + * @bug 8144735 * @key headful * @summary Check if a per-pixel translucent and translucent window is dragged * and resized by mouse correctly From 76f0a705fcf3a7fef24ed533787b929623ff6ed1 Mon Sep 17 00:00:00 2001 From: Aleksei Efimov Date: Thu, 1 Sep 2016 17:12:12 +0300 Subject: [PATCH 114/296] 8150145: javax/xml/jaxp/unittest/common/TransformationWarningsTest.java and ValidationWarningsTest.java failed intermittently without any error message Reviewed-by: joehw, clanger --- jaxp/test/ProblemList.txt | 4 -- .../common/TransformationWarningsTest.java | 10 ++++- .../common/ValidationWarningsTest.java | 1 + .../unittest/common/WarningsTestBase.java | 39 +++++++++++++++---- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/jaxp/test/ProblemList.txt b/jaxp/test/ProblemList.txt index 27337ae935c..ce63d06ff47 100644 --- a/jaxp/test/ProblemList.txt +++ b/jaxp/test/ProblemList.txt @@ -24,7 +24,3 @@ ########################################################################### javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh 8147431 generic-all - -javax/xml/jaxp/unittest/common/TransformationWarningsTest.java 8150145 generic-all - -javax/xml/jaxp/unittest/common/ValidationWarningsTest.java 8150145 generic-all diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java b/jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java index 310d1a4b4de..bffaa4afe5e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java @@ -42,12 +42,13 @@ import org.testng.annotations.Test; * @test * @bug 8144593 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @compile -XDignore.symbol.file TestSAXDriver.java * @run testng/othervm -DrunSecMngr=true common.TransformationWarningsTest * @run testng/othervm common.TransformationWarningsTest * @summary Check that warnings about unsupported properties from parsers * are suppressed during the transformation process. */ -@Listeners({jaxp.library.BasePolicy.class}) +@Listeners({jaxp.library.BasePolicy.class, jaxp.library.InternalAPIPolicy.class}) public class TransformationWarningsTest extends WarningsTestBase { @BeforeClass @@ -80,7 +81,12 @@ public class TransformationWarningsTest extends WarningsTestBase { Source xslsrc = new StreamSource(new StringReader(xsl)); // Create factory and transformer - TransformerFactory tf = TransformerFactory.newInstance(); + TransformerFactory tf; + // newTransformer() method doc states that different transformer + // factories can be used concurrently by different Threads. + synchronized (TransformerFactory.class) { + tf = TransformerFactory.newInstance(); + } Transformer t = tf.newTransformer(xslsrc); // Set URI Resolver to return the newly constructed xml diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java b/jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java index 3b4a945a254..c1f4989a770 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java @@ -46,6 +46,7 @@ import org.xml.sax.InputSource; * @bug 8144593 * @key intermittent * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @compile -XDignore.symbol.file TestSAXDriver.java * @run testng/othervm -DrunSecMngr=true common.ValidationWarningsTest * @run testng/othervm common.ValidationWarningsTest * @summary Check that warnings about unsupported properties from SAX diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/WarningsTestBase.java b/jaxp/test/javax/xml/jaxp/unittest/common/WarningsTestBase.java index 9a7ce2d8f7b..3fde8d1f725 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/WarningsTestBase.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/WarningsTestBase.java @@ -23,11 +23,15 @@ package common; +import static jaxp.library.JAXPTestUtilities.runWithAllPerm; + import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.lang.Thread.UncaughtExceptionHandler; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -58,25 +62,27 @@ public abstract class WarningsTestBase { PrintStream defStdErr = System.err; //Set new byte array stream as standard error stream ByteArrayOutputStream byteStream = new ByteArrayOutputStream(5000); - System.setErr(new PrintStream(byteStream)); + runWithAllPerm(() -> System.setErr(new PrintStream(byteStream))); //Execute multiple TestWorker tasks for (int id = 0; id < THREADS_COUNT; id++) { EXECUTOR.execute(new TestWorker(id)); } //Initiate shutdown of previously submitted task - EXECUTOR.shutdown(); + runWithAllPerm(EXECUTOR::shutdown); //Wait for termination of submitted tasks if (!EXECUTOR.awaitTermination(THREADS_COUNT, TimeUnit.SECONDS)) { //If not all tasks terminates during the time out force them to shutdown - EXECUTOR.shutdownNow(); + runWithAllPerm(EXECUTOR::shutdownNow); } //Restore default standard error stream - System.setErr(defStdErr); + runWithAllPerm(() -> System.setErr(defStdErr)); //Print tasks stderr output String errContent = byteStream.toString(); System.out.println("Standard error output content:"); System.out.println(errContent); - //Check tasks stderr output for quatity of warning messages + //Check if uncaught exceptions were observed by one or more threads + Assert.assertFalse(uncaughtExceptions); + //Check tasks stderr output for quantity of warning messages Assert.assertTrue(warningPrintedOnce(XMLConstants.ACCESS_EXTERNAL_DTD, errContent)); Assert.assertTrue(warningPrintedOnce(ENT_EXP_PROPERTY, errContent)); Assert.assertTrue(warningPrintedOnce(XMLConstants.FEATURE_SECURE_PROCESSING, errContent)); @@ -123,6 +129,25 @@ public abstract class WarningsTestBase { } } + // Thread factory that handles uncaughtExceptions and prints them + // to stdout instead of stderr. + private static class TestThreadFactory implements ThreadFactory { + + public Thread newThread(final Runnable r) { + Thread t = Executors.defaultThreadFactory().newThread(r); + t.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable thr) { + thr.printStackTrace(System.out); + uncaughtExceptions = true; + } + }); + return t; + } + } + + //Flag that indicates if one or more threads from thread pool caught unhandled exception + private static boolean uncaughtExceptions = false; //Entity expansion limit property name private static final String ENT_EXP_PROPERTY = "http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit"; //Number of simultaneous test threads @@ -130,7 +155,7 @@ public abstract class WarningsTestBase { //Number of iterations per one thread private static final int ITERATIONS_PER_THREAD = 4; //Test thread pool - private static final ExecutorService EXECUTOR = Executors.newCachedThreadPool(); - //Cyclic barrier for threads startup synchronisation + private static final ExecutorService EXECUTOR = Executors.newCachedThreadPool(new TestThreadFactory()); + //Cyclic barrier for threads startup synchronization private static final CyclicBarrier BARRIER = new CyclicBarrier(THREADS_COUNT); } From 347a38c28ddacc90ea1721f2484a27598f7c62dd Mon Sep 17 00:00:00 2001 From: Li Jiang Date: Thu, 1 Sep 2016 08:59:47 -0700 Subject: [PATCH 115/296] 8159408: duplicated data in rmic's javac.properties Reviewed-by: alanb --- .../share/classes/sun/tools/javac/resources/javac.properties | 2 -- 1 file changed, 2 deletions(-) diff --git a/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties b/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties index 2caf03fd1ea..5b754bb5d74 100644 --- a/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties +++ b/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties @@ -265,8 +265,6 @@ javac.err.unmatched.constr=\ No constructor matching {0} found in {1}. javac.err.wrong.number.args=\ Wrong number of arguments in {0}. -javac.err.wrong.number.args=\ - Wrong number of arguments in {0}. javac.err.forward.ref=\ Can''t make forward reference to {0} in {1}. javac.err.array.dim.missing=\ From 6f12a4ff0df3224f3a472e38c1f8e55809064b6a Mon Sep 17 00:00:00 2001 From: Phil Race Date: Thu, 1 Sep 2016 11:29:20 -0700 Subject: [PATCH 116/296] 8144015: [PIT] failures of text layout font tests 8144023: [PIT] failure of text measurements in javax/swing/text/html/parser/Parser/6836089/bug6836089.java 8145542: The case failed automatically and thrown java.lang.ArrayIndexOutOfBoundsException exception 8151725: [macosx] ArrayIndexOOB exception when displaying Devanagari text in JEditorPane 8144240: [macosx][PIT] AIOOB in closed/javax/swing/text/GlyphPainter2/6427244/bug6427244.java 8152680: Regression in GlyphVector.getGlyphCharIndex behaviour 8158924: Incorrect i18n text document layout 8041480: ArrayIndexOutOfBoundsException when JTable contains certain string Reviewed-by: serb, srl --- .../sun/font/ExtendedTextSourceLabel.java | 231 +++++++--------- .../share/native/libfontmanager/HBShaper.c | 164 ++++++------ .../GlyphVector/GetGlyphCharIndexTest.java | 44 ++++ .../TestLineBreakWithFontSub.java | 143 ++++++++++ .../font/TextLayout/LigatureCaretTest.java | 167 ++++++++++++ .../font/TextLayout/TestJustification.html | 52 ++++ .../font/TextLayout/TestJustification.java | 249 ++++++++++++++++++ .../javax/swing/text/DevanagariEditor.java | 36 +++ .../GlyphPainter2/6427244/bug6427244.java | 153 +++++++++++ 9 files changed, 1024 insertions(+), 215 deletions(-) create mode 100644 jdk/test/java/awt/font/GlyphVector/GetGlyphCharIndexTest.java create mode 100644 jdk/test/java/awt/font/LineBreakMeasurer/TestLineBreakWithFontSub.java create mode 100644 jdk/test/java/awt/font/TextLayout/LigatureCaretTest.java create mode 100644 jdk/test/java/awt/font/TextLayout/TestJustification.html create mode 100644 jdk/test/java/awt/font/TextLayout/TestJustification.java create mode 100644 jdk/test/javax/swing/text/DevanagariEditor.java create mode 100644 jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java diff --git a/jdk/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java b/jdk/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java index 54c5382129c..67aee9e18db 100644 --- a/jdk/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java +++ b/jdk/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java @@ -550,13 +550,16 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La return charinfo; } + private static final boolean DEBUG = FontUtilities.debugFonts(); /* * This takes the glyph info record obtained from the glyph vector and converts it into a similar record * adjusted to represent character data instead. For economy we don't use glyph info records in this processing. * * Here are some constraints: * - there can be more glyphs than characters (glyph insertion, perhaps based on normalization, has taken place) -* - there can not be fewer glyphs than characters (0xffff glyphs are inserted for characters ligaturized away) +* - there can be fewer glyphs than characters +* Some layout engines may insert 0xffff glyphs for characters ligaturized away, but +* not all do, and it cannot be relied upon. * - each glyph maps to a single character, when multiple glyphs exist for a character they all map to it, but * no two characters map to the same glyph * - multiple glyphs mapping to the same character need not be in sequence (thai, tamil have split characters) @@ -578,7 +581,8 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La * * The algorithm works in the following way: * 1) we scan the glyphs ltr or rtl based on the bidi run direction -* 2) we can work in place, since we always consume a glyph for each char we write +* 2) Since the may be fewer glyphs than chars we cannot work in place. +* A new array is allocated for output. * a) if the line is ltr, we start writing at position 0 until we finish, there may be leftver space * b) if the line is rtl and 1-1, we start writing at position numChars/glyphs - 1 until we finish at 0 * c) otherwise if we don't finish at 0, we have to copy the data down @@ -594,7 +598,7 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La * iii) the x advance is the distance to the maximum x + adv of all glyphs whose advance is not zero * iv) the y advance is the baseline * v) vis x,y,w,h tightly encloses the vis x,y,w,h of all the glyphs with nonzero w and h -* 4) we can make some simple optimizations if we know some things: +* 4) In the future, we can make some simple optimizations to avoid copying if we know some things: * a) if the mapping is 1-1, unidirectional, and there are no zero-adv glyphs, we just return the glyphinfo * b) if the mapping is 1-1, unidirectional, we just adjust the remaining glyphs to originate at right/left of the base * c) if the mapping is 1-1, we compute the base position and advance as we go, then go back to adjust the remaining glyphs @@ -625,23 +629,20 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La System.out.println(source); } - /* - if ((gv.getDescriptionFlags() & 0x7) == 0) { - return glyphinfo; - } - */ - int numGlyphs = gv.getNumGlyphs(); if (numGlyphs == 0) { return glyphinfo; } int[] indices = gv.getGlyphCharIndices(0, numGlyphs, null); + float[] charInfo = new float[source.getLength() * numvals]; - boolean DEBUG = false; if (DEBUG) { System.err.println("number of glyphs: " + numGlyphs); + System.err.println("glyphinfo.len: " + glyphinfo.length); + System.err.println("indices.len: " + indices.length); for (int i = 0; i < numGlyphs; ++i) { System.err.println("g: " + i + + " v: " + gv.getGlyphCode(i) + ", x: " + glyphinfo[i*numvals+posx] + ", a: " + glyphinfo[i*numvals+advx] + ", n: " + indices[i]); @@ -650,22 +651,19 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La int minIndex = indices[0]; // smallest index seen this cluster int maxIndex = minIndex; // largest index seen this cluster - int nextMin = 0; // expected smallest index for this cluster int cp = 0; // character position - int cx = 0; // character index (logical) + int cc = 0; int gp = 0; // glyph position int gx = 0; // glyph index (visual) int gxlimit = numGlyphs; // limit of gx, when we reach this we're done int pdelta = numvals; // delta for incrementing positions int xdelta = 1; // delta for incrementing indices - boolean ltr = (source.getLayoutFlags() & 0x1) == 0; - if (!ltr) { + boolean rtl = (source.getLayoutFlags() & 0x1) == 1; + if (rtl) { minIndex = indices[numGlyphs - 1]; maxIndex = minIndex; - nextMin = 0; // still logical - cp = glyphinfo.length - numvals; - cx = 0; // still logical + cp = charInfo.length - numvals; gp = glyphinfo.length - numvals; gx = numGlyphs - 1; gxlimit = -1; @@ -693,47 +691,36 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La float cposl = 0, cposr = 0, cvisl = 0, cvist = 0, cvisr = 0, cvisb = 0; float baseline = 0; - // record if we have to copy data even when no cluster - boolean mustCopy = false; - while (gx != gxlimit) { // start of new cluster - boolean haveCopy = false; int clusterExtraGlyphs = 0; minIndex = indices[gx]; maxIndex = minIndex; + cposl = glyphinfo[gp + posx]; + cposr = cposl + glyphinfo[gp + advx]; + cvisl = glyphinfo[gp + visx]; + cvist = glyphinfo[gp + visy]; + cvisr = cvisl + glyphinfo[gp + visw]; + cvisb = cvist + glyphinfo[gp + vish]; + // advance to next glyph gx += xdelta; gp += pdelta; - /* - while (gx != gxlimit && (glyphinfo[gp + advx] == 0 || - minIndex != nextMin || indices[gx] <= maxIndex)) { - */ while (gx != gxlimit && ((glyphinfo[gp + advx] == 0) || - (minIndex != nextMin) || (indices[gx] <= maxIndex) || (maxIndex - minIndex > clusterExtraGlyphs))) { - // initialize base data first time through, using base glyph - if (!haveCopy) { - int gps = gp - pdelta; - cposl = glyphinfo[gps + posx]; - cposr = cposl + glyphinfo[gps + advx]; - cvisl = glyphinfo[gps + visx]; - cvist = glyphinfo[gps + visy]; - cvisr = cvisl + glyphinfo[gps + visw]; - cvisb = cvist + glyphinfo[gps + vish]; - - haveCopy = true; + ++clusterExtraGlyphs; // have an extra glyph in this cluster + if (DEBUG) { + System.err.println("gp=" +gp +" adv=" + glyphinfo[gp + advx] + + " gx="+ gx+ " i[gx]="+indices[gx] + + " clusterExtraGlyphs="+clusterExtraGlyphs); } - // have an extra glyph in this cluster - ++clusterExtraGlyphs; - // adjust advance only if new glyph has non-zero advance float radvx = glyphinfo[gp + advx]; if (radvx != 0) { @@ -764,110 +751,90 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La // done with cluster, gx and gp are set for next glyph if (DEBUG) { - System.out.println("minIndex = " + minIndex + ", maxIndex = " + maxIndex); + System.err.println("minIndex = " + minIndex + ", maxIndex = " + maxIndex); } - nextMin = maxIndex + 1; + // save adjustments to the base character and do common adjustments. + charInfo[cp + posx] = cposl; + charInfo[cp + posy] = baseline; + charInfo[cp + advx] = cposr - cposl; + charInfo[cp + advy] = 0; + charInfo[cp + visx] = cvisl; + charInfo[cp + visy] = cvist; + charInfo[cp + visw] = cvisr - cvisl; + charInfo[cp + vish] = cvisb - cvist; + cc++; - // do common character adjustments - glyphinfo[cp + posy] = baseline; - glyphinfo[cp + advy] = 0; - - if (haveCopy) { - // save adjustments to the base character - glyphinfo[cp + posx] = cposl; - glyphinfo[cp + advx] = cposr - cposl; - glyphinfo[cp + visx] = cvisl; - glyphinfo[cp + visy] = cvist; - glyphinfo[cp + visw] = cvisr - cvisl; - glyphinfo[cp + vish] = cvisb - cvist; - - // compare number of chars read with number of glyphs read. - // if more glyphs than chars, set mustCopy to true, as we'll always have - // to copy the data from here on out. - if (maxIndex - minIndex < clusterExtraGlyphs) { - mustCopy = true; - } - - // Fix the characters that follow the base character. - // New values are all the same. Note we fix the number of characters - // we saw, not the number of glyphs we saw. - if (minIndex < maxIndex) { - if (!ltr) { - // if rtl, characters to left of base, else to right. reuse cposr. - cposr = cposl; - } - cvisr -= cvisl; // reuse, convert to deltas. - cvisb -= cvist; - - int iMinIndex = minIndex, icp = cp / 8; - - while (minIndex < maxIndex) { - ++minIndex; - cx += xdelta; - cp += pdelta; - - if (cp < 0 || cp >= glyphinfo.length) { - if (DEBUG) System.out.println("minIndex = " + iMinIndex + ", maxIndex = " + maxIndex + ", cp = " + icp); - } - - glyphinfo[cp + posx] = cposr; - glyphinfo[cp + posy] = baseline; - glyphinfo[cp + advx] = 0; - glyphinfo[cp + advy] = 0; - glyphinfo[cp + visx] = cvisl; - glyphinfo[cp + visy] = cvist; - glyphinfo[cp + visw] = cvisr; - glyphinfo[cp + vish] = cvisb; - } - } - - // no longer using this copy - haveCopy = false; - } else if (mustCopy) { - // out of synch, so we have to copy all the time now - int gpr = gp - pdelta; - - glyphinfo[cp + posx] = glyphinfo[gpr + posx]; - glyphinfo[cp + advx] = glyphinfo[gpr + advx]; - glyphinfo[cp + visx] = glyphinfo[gpr + visx]; - glyphinfo[cp + visy] = glyphinfo[gpr + visy]; - glyphinfo[cp + visw] = glyphinfo[gpr + visw]; - glyphinfo[cp + vish] = glyphinfo[gpr + vish]; + /* We may have consumed multiple glyphs for this char position. + * Map those extra consumed glyphs to char positions that would follow + * up to the index prior to that which begins the next cluster. + * If we have reached the last glyph (reached gxlimit) then we need to + * map remaining unmapped chars to the same location as the last one. + */ + int tgt; + if (gx == gxlimit) { + tgt = charInfo.length / numvals; + } else { + tgt = indices[gx]-1; } - // else glyphinfo is already at the correct character position, and is unchanged, so just leave it + if (DEBUG) { + System.err.println("gx=" + gx + " gxlimit=" + gxlimit + + " charInfo.len=" + charInfo.length + + " tgt=" + tgt + " cc=" + cc + " cp=" + cp); + } + while (cc < tgt) { + if (rtl) { + // if rtl, characters to left of base, else to right. reuse cposr. + cposr = cposl; + } + cvisr -= cvisl; // reuse, convert to deltas. + cvisb -= cvist; - // reset for new cluster - cp += pdelta; - cx += xdelta; - } + cp += pdelta; - if (mustCopy && !ltr) { - // data written to wrong end of array, need to shift down + if (cp < 0 || cp >= charInfo.length) { + if (DEBUG) { + System.err.println("Error : cp=" + cp + + " charInfo.length=" + charInfo.length); + } + break; + } - cp -= pdelta; // undo last increment, get start of valid character data in array - System.arraycopy(glyphinfo, cp, glyphinfo, 0, glyphinfo.length - cp); + if (DEBUG) { + System.err.println("Insert charIndex " + cc + " at pos="+cp); + } + charInfo[cp + posx] = cposr; + charInfo[cp + posy] = baseline; + charInfo[cp + advx] = 0; + charInfo[cp + advy] = 0; + charInfo[cp + visx] = cvisl; + charInfo[cp + visy] = cvist; + charInfo[cp + visw] = cvisr; + charInfo[cp + vish] = cvisb; + cc++; + } + cp += pdelta; // reset for new cluster } if (DEBUG) { - char[] chars = source.getChars(); - int start = source.getStart(); - int length = source.getLength(); - System.out.println("char info for " + length + " characters"); - for(int i = 0; i < length * numvals;) { - System.out.println(" ch: " + Integer.toHexString(chars[start + v2l(i / numvals)]) + - " x: " + glyphinfo[i++] + - " y: " + glyphinfo[i++] + - " xa: " + glyphinfo[i++] + - " ya: " + glyphinfo[i++] + - " l: " + glyphinfo[i++] + - " t: " + glyphinfo[i++] + - " w: " + glyphinfo[i++] + - " h: " + glyphinfo[i++]); + char[] chars = source.getChars(); + int start = source.getStart(); + int length = source.getLength(); + System.err.println("char info for " + length + " characters"); + + for (int i = 0; i < length * numvals;) { + System.err.println(" ch: " + Integer.toHexString(chars[start + v2l(i / numvals)]) + + " x: " + charInfo[i++] + + " y: " + charInfo[i++] + + " xa: " + charInfo[i++] + + " ya: " + charInfo[i++] + + " l: " + charInfo[i++] + + " t: " + charInfo[i++] + + " w: " + charInfo[i++] + + " h: " + charInfo[i++]); } } - - return glyphinfo; + return charInfo; } /** diff --git a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c index 3b35e27efda..3b7a463ffdf 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c +++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c @@ -40,6 +40,7 @@ static jfieldID gvdFlagsFID = 0; static jfieldID gvdGlyphsFID = 0; static jfieldID gvdPositionsFID = 0; static jfieldID gvdIndicesFID = 0; +static jmethodID gvdGrowMID = 0; static int jniInited = 0; static void getFloat(JNIEnv* env, jobject pt, jfloat *x, jfloat *y) { @@ -63,73 +64,88 @@ static int init_JNI_IDs(JNIEnv *env) { CHECK_NULL_RETURN(gvdGlyphsFID = (*env)->GetFieldID(env, gvdClass, "_glyphs", "[I"), 0); CHECK_NULL_RETURN(gvdPositionsFID = (*env)->GetFieldID(env, gvdClass, "_positions", "[F"), 0); CHECK_NULL_RETURN(gvdIndicesFID = (*env)->GetFieldID(env, gvdClass, "_indices", "[I"), 0); + CHECK_NULL_RETURN(gvdGrowMID = (*env)->GetMethodID(env, gvdClass, "grow", "()V"), 0); jniInited = 1; return jniInited; } // gmask is the composite font slot mask // baseindex is to be added to the character (code point) index. -int storeGVData(JNIEnv* env, - jobject gvdata, jint slot, jint baseIndex, jobject startPt, - int glyphCount, hb_glyph_info_t *glyphInfo, - hb_glyph_position_t *glyphPos, hb_direction_t direction, - float devScale) { +jboolean storeGVData(JNIEnv* env, + jobject gvdata, jint slot, + jint baseIndex, int offset, jobject startPt, + int charCount, int glyphCount, hb_glyph_info_t *glyphInfo, + hb_glyph_position_t *glyphPos, float devScale) { - int i; + int i, needToGrow; float x=0, y=0; - float startX, startY; + float startX, startY, advX, advY; float scale = 1.0f / FloatToFixedScale / devScale; unsigned int* glyphs; float* positions; - int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv; + int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv, maxStore; unsigned int* indices; jarray glyphArray, posArray, inxArray; if (!init_JNI_IDs(env)) { - return 0; + return JNI_FALSE; } initialCount = (*env)->GetIntField(env, gvdata, gvdCountFID); - glyphArray = - (jarray)(*env)->GetObjectField(env, gvdata, gvdGlyphsFID); - posArray = - (jarray)(*env)->GetObjectField(env, gvdata, gvdPositionsFID); - - if (glyphArray == NULL || posArray == NULL) - { - JNU_ThrowArrayIndexOutOfBoundsException(env, ""); - return 0; - } - - // The Java code catches the IIOBE and expands the storage - // and re-invokes layout. I suppose this is expected to be rare - // because at least in a single threaded case there should be - // re-use of the same container, but it is a little wasteful/distateful. - glyphArrayLen = (*env)->GetArrayLength(env, glyphArray); - posArrayLen = (*env)->GetArrayLength(env, posArray); - maxGlyphs = glyphCount + initialCount; - if ((maxGlyphs > glyphArrayLen) || - (maxGlyphs * 2 + 2 > posArrayLen)) - { - JNU_ThrowArrayIndexOutOfBoundsException(env, ""); - return 0; - } + do { + glyphArray = (jarray)(*env)->GetObjectField(env, gvdata, gvdGlyphsFID); + posArray = (jarray)(*env)->GetObjectField(env, gvdata, gvdPositionsFID); + inxArray = (jarray)(*env)->GetObjectField(env, gvdata, gvdIndicesFID); + if (glyphArray == NULL || posArray == NULL || inxArray == NULL) { + JNU_ThrowArrayIndexOutOfBoundsException(env, ""); + return JNI_FALSE; + } + glyphArrayLen = (*env)->GetArrayLength(env, glyphArray); + posArrayLen = (*env)->GetArrayLength(env, posArray); + maxGlyphs = (charCount > glyphCount) ? charCount : glyphCount; + maxStore = maxGlyphs + initialCount; + needToGrow = (maxStore > glyphArrayLen) || + (maxStore * 2 + 2 > posArrayLen); + if (needToGrow) { + (*env)->CallVoidMethod(env, gvdata, gvdGrowMID); + if ((*env)->ExceptionCheck(env)) { + return JNI_FALSE; + } + } + } while (needToGrow); getFloat(env, startPt, &startX, &startY); glyphs = (unsigned int*)(*env)->GetPrimitiveArrayCritical(env, glyphArray, NULL); + if (glyphs == NULL) { + return JNI_FALSE; + } positions = (jfloat*)(*env)->GetPrimitiveArrayCritical(env, posArray, NULL); + if (positions == NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, glyphArray, glyphs, 0); + return JNI_FALSE; + } + indices = + (unsigned int*)(*env)->GetPrimitiveArrayCritical(env, inxArray, NULL); + if (indices == NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, glyphArray, glyphs, 0); + (*env)->ReleasePrimitiveArrayCritical(env, posArray, positions, 0); + return JNI_FALSE; + } + for (i = 0; i < glyphCount; i++) { int storei = i + initialCount; - int index = glyphInfo[i].codepoint | slot; - if (iReleasePrimitiveArrayCritical(env, glyphArray, glyphs, 0); (*env)->ReleasePrimitiveArrayCritical(env, posArray, positions, 0); - putFloat(env, startPt,positions[(storeadv*2)],positions[(storeadv*2)+1] ); - inxArray = - (jarray)(*env)->GetObjectField(env, gvdata, gvdIndicesFID); - indices = - (unsigned int*)(*env)->GetPrimitiveArrayCritical(env, inxArray, NULL); - for (i = 0; i < glyphCount; i++) { - int cluster = glyphInfo[i].cluster; - if (direction == HB_DIRECTION_LTR) { - // I need to understand what hb does when processing a substring - // I expected the cluster index to be from the start of the text - // to process. - // Instead it appears to be from the start of the whole thing. - indices[i+initialCount] = cluster; - } else { - indices[i+initialCount] = baseIndex + glyphCount -1 -i; - } - } (*env)->ReleasePrimitiveArrayCritical(env, inxArray, indices, 0); - (*env)->SetIntField(env, gvdata, gvdCountFID, initialCount+glyphCount); - return initialCount+glyphCount; + putFloat(env, startPt, advX, advY); + (*env)->SetIntField(env, gvdata, gvdCountFID, storeadv); + + return JNI_TRUE; } static float euclidianDistance(float a, float b) @@ -226,7 +229,9 @@ JDKFontInfo* } -#define TYPO_RTL 0x80000000 +#define TYPO_KERN 0x00000001 +#define TYPO_LIGA 0x00000002 +#define TYPO_RTL 0x80000000 JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape (JNIEnv *env, jclass cls, @@ -255,10 +260,11 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape hb_glyph_info_t *glyphInfo; hb_glyph_position_t *glyphPos; hb_direction_t direction = HB_DIRECTION_LTR; - hb_feature_t *features = NULL; + hb_feature_t *features = NULL; int featureCount = 0; - - int i; + char* kern = (flags & TYPO_KERN) ? "kern" : "-kern"; + char* liga = (flags & TYPO_LIGA) ? "liga" : "-liga"; + jboolean ret; unsigned int buflen; JDKFontInfo *jdkFontInfo = @@ -281,6 +287,8 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape direction = HB_DIRECTION_RTL; } hb_buffer_set_direction(buffer, direction); + hb_buffer_set_cluster_level(buffer, + HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS); chars = (*env)->GetCharArrayElements(env, text, NULL); if ((*env)->ExceptionCheck(env)) { @@ -293,36 +301,26 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape hb_buffer_add_utf16(buffer, chars, len, offset, limit-offset); + features = calloc(2, sizeof(hb_feature_t)); + if (features) { + hb_feature_from_string(kern, -1, &features[featureCount++]); + hb_feature_from_string(liga, -1, &features[featureCount++]); + } + hb_shape_full(hbfont, buffer, features, featureCount, 0); glyphCount = hb_buffer_get_length(buffer); glyphInfo = hb_buffer_get_glyph_infos(buffer, 0); glyphPos = hb_buffer_get_glyph_positions(buffer, &buflen); - for (i = 0; i < glyphCount; i++) { - int index = glyphInfo[i].codepoint; - int xadv = (glyphPos[i].x_advance); - int yadv = (glyphPos[i].y_advance); - } - // On "input" HB assigns a cluster index to each character in UTF-16. - // On output where a sequence of characters have been mapped to - // a glyph they are all mapped to the cluster index of the first character. - // The next cluster index will be that of the first character in the - // next cluster. So cluster indexes may 'skip' on output. - // This can also happen if there are supplementary code-points - // such that two UTF-16 characters are needed to make one codepoint. - // In RTL text you need to count down. - // So the following code tries to build the reverse map as expected - // by calling code. - storeGVData(env, gvdata, slot, baseIndex, startPt, - glyphCount, glyphInfo, glyphPos, direction, - jdkFontInfo->devScale); + ret = storeGVData(env, gvdata, slot, baseIndex, offset, startPt, + limit - offset, glyphCount, glyphInfo, glyphPos, + jdkFontInfo->devScale); hb_buffer_destroy (buffer); hb_font_destroy(hbfont); free((void*)jdkFontInfo); if (features != NULL) free(features); (*env)->ReleaseCharArrayElements(env, text, chars, JNI_ABORT); - - return JNI_TRUE; + return ret; } diff --git a/jdk/test/java/awt/font/GlyphVector/GetGlyphCharIndexTest.java b/jdk/test/java/awt/font/GlyphVector/GetGlyphCharIndexTest.java new file mode 100644 index 00000000000..1754e5f64cc --- /dev/null +++ b/jdk/test/java/awt/font/GlyphVector/GetGlyphCharIndexTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* @test + * @summary Test getGlyphCharIndex() results from layout + * @bug 8152680 + * + +import java.awt.Font; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; + +public class GetGlyphCharIndexTest { + public static void main(String[] args) { + Font font = new Font(Font.MONOSPACED, Font.PLAIN, 12); + FontRenderContext frc = new FontRenderContext(null, false, false); + GlyphVector gv = font.layoutGlyphVector(frc, "abc".toCharArray(), 1, 3, + Font.LAYOUT_LEFT_TO_RIGHT); + int idx0 = gv.getGlyphCharIndex(0); + if (idx0 != 0) { + throw new RuntimeException("Expected 0, got " + idx0); + } + } +} diff --git a/jdk/test/java/awt/font/LineBreakMeasurer/TestLineBreakWithFontSub.java b/jdk/test/java/awt/font/LineBreakMeasurer/TestLineBreakWithFontSub.java new file mode 100644 index 00000000000..472fca810a5 --- /dev/null +++ b/jdk/test/java/awt/font/LineBreakMeasurer/TestLineBreakWithFontSub.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 1999, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 4175418 8158924 + * @author John Raley + * @summary This insures that bug 4175418: Font substitution in TextLayout / + * LineBreakMeasurer is inconsistent has been fixed. The problem was + * that text was measured in one Font, but lines were produced + * in a different font. + */ + +/* + * (C) Copyright IBM Corp. 1999, All Rights Reserved + */ + +import java.text.AttributedString; +import java.awt.font.LineBreakMeasurer; +import java.awt.font.TextLayout; +import java.awt.font.FontRenderContext; +import java.awt.font.TextAttribute; + +/** + * This insures that bug 4175418: Font substitution in TextLayout / + * LineBreakMeasurer is inconsistent has been fixed. The problem was + * that text was measured in one Font, but lines were produced + * in a different font. One symptom of this problem is that lines are + * either too short or too long. This test line-breaks a paragraph + * and checks the line lengths to make sure breaks were chosen well. + * This can be checked because the paragraph is so simple. + */ +public class TestLineBreakWithFontSub { + + public static void main(String[] args) { + + new TestLineBreakWithFontSub().test(); + System.out.println("Line break / font substitution test PASSED"); + } + + private static final String WORD = "word"; + private static final String SPACING = " "; + // The Hebrew character in this string can trigger font substitution + private static final String MIXED = "A\u05D0"; + + private static final int NUM_WORDS = 12; + + private static final FontRenderContext DEFAULT_FRC = + new FontRenderContext(null, false, false); + + public void test() { + + // construct a paragraph as follows: MIXED + [SPACING + WORD] + ... + StringBuffer text = new StringBuffer(MIXED); + for (int i=0; i < NUM_WORDS; i++) { + text.append(SPACING); + text.append(WORD); + } + + AttributedString attrString = new AttributedString(text.toString()); + attrString.addAttribute(TextAttribute.SIZE, new Float(24.0)); + + LineBreakMeasurer measurer = new LineBreakMeasurer(attrString.getIterator(), + DEFAULT_FRC); + + // get width of a space-word sequence, in context + int sequenceLength = WORD.length()+SPACING.length(); + measurer.setPosition(text.length() - sequenceLength); + + TextLayout layout = measurer.nextLayout(10000.0f); + + if (layout.getCharacterCount() != sequenceLength) { + throw new Error("layout length is incorrect!"); + } + + final float sequenceAdvance = layout.getVisibleAdvance(); + + float wrappingWidth = sequenceAdvance * 2; + + // now run test with a variety of widths + while (wrappingWidth < (sequenceAdvance*NUM_WORDS)) { + measurer.setPosition(0); + checkMeasurer(measurer, + wrappingWidth, + sequenceAdvance, + text.length()); + wrappingWidth += sequenceAdvance / 5; + } + } + + /** + * Iterate through measurer and check that every line is + * not too long and not too short, but just right. + */ + private void checkMeasurer(LineBreakMeasurer measurer, + float wrappingWidth, + float sequenceAdvance, + int endPosition) { + + do { + TextLayout layout = measurer.nextLayout(wrappingWidth); + float visAdvance = layout.getVisibleAdvance(); + + // Check that wrappingWidth-sequenceAdvance < visAdvance + // Also, if we're not at the end of the paragraph, + // check that visAdvance <= wrappingWidth + + if (visAdvance > wrappingWidth) { + // line is too long for given wrapping width + throw new Error("layout is too long"); + } + + if (measurer.getPosition() < endPosition) { + if (visAdvance <= wrappingWidth - sequenceAdvance) { + // line is too short for given wrapping width; + // another word would have fit + throw new Error("room for more words on line. diff=" + + (wrappingWidth - sequenceAdvance - visAdvance)); + } + } + } while (measurer.getPosition() != endPosition); + } +} diff --git a/jdk/test/java/awt/font/TextLayout/LigatureCaretTest.java b/jdk/test/java/awt/font/TextLayout/LigatureCaretTest.java new file mode 100644 index 00000000000..e59bccac996 --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/LigatureCaretTest.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 1998, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/** + * @test + * @bug 4178145 8144015 +*/ + +/* + * Copyright 1998 IBM Corp. All Rights Reserved. + */ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.font.TextAttribute; +import java.awt.font.TextLayout; +import java.awt.font.TextHitInfo; +import java.awt.font.FontRenderContext; +import java.util.Hashtable; + +/** + * This test ensures that TextLayout will not place a caret within + * an Arabic lam-alef ligature, and will correctly caret through + * bidirectional text with numbers. + */ + +public class LigatureCaretTest { + + public static void main(String[] args) { + + //testBidiWithNumbers(); + testLamAlef(); + System.out.println("LigatureCaretTest PASSED"); + } + + // These values are for TextLayout constructors + private static final Hashtable map = new Hashtable(); + static { + map.put(TextAttribute.FONT, new Font("Lucida Sans", Font.PLAIN, 24)); + } + private static final FontRenderContext frc = + new FontRenderContext(null, false, false); + + /** + * Caret through text mixed-direction text and check the results. + * If the test fails an Error is thrown. + * @exception an Error is thrown if the test fails + */ + public static void testBidiWithNumbers() { + + String bidiWithNumbers = "abc\u05D0\u05D1\u05D2123abc"; + // visual order for the text: + // abc123abc + + int[] carets = { 0, 1, 2, 3, 7, 8, 6, 5, 4, 9, 10, 11, 12 }; + TextLayout layout = new TextLayout(bidiWithNumbers, map, frc); + + // Caret through TextLayout in both directions and check results. + for (int i=0; i < carets.length-1; i++) { + + TextHitInfo hit = layout.getNextRightHit(carets[i]); + if (hit.getInsertionIndex() != carets[i+1]) { + throw new Error("right hit failed within layout"); + } + } + + if (layout.getNextRightHit(carets[carets.length-1]) != null) { + throw new Error("right hit failed at end of layout"); + } + + for (int i=carets.length-1; i > 0; i--) { + + TextHitInfo hit = layout.getNextLeftHit(carets[i]); + if (hit.getInsertionIndex() != carets[i-1]) { + throw new Error("left hit failed within layout"); + } + } + + if (layout.getNextLeftHit(carets[0]) != null) { + throw new Error("left hit failed at end of layout"); + } + } + + /** + * Ensure proper careting and hit-testing behavior with + * a lam-alef ligature. + * If the test fails, an Error is thrown. + * @exception an Error is thrown if the test fails + */ + public static void testLamAlef() { + + // lam-alef form a mandantory ligature. + final String lamAlef = "\u0644\u0627"; + final String ltrText = "abcd"; + + // Create a TextLayout with just a lam-alef sequence. There + // should only be two valid caret positions: one at + // insertion offset 0 and the other at insertion offset 2. + TextLayout layout = new TextLayout(lamAlef, map, frc); + + TextHitInfo hit; + + hit = layout.getNextLeftHit(0); + if (hit.getInsertionIndex() != 2) { + throw new Error("Left hit failed. Hit:" + hit); + } + + hit = layout.getNextRightHit(2); + if (hit.getInsertionIndex() != 0) { + throw new Error("Right hit failed. Hit:" + hit); + } + + hit = layout.hitTestChar(layout.getAdvance()/2, 0); + if (hit.getInsertionIndex() != 0 && hit.getInsertionIndex() != 2) { + throw new Error("Hit-test allowed incorrect caret. Hit:" + hit); + } + + + // Create a TextLayout with some left-to-right text + // before the lam-alef sequence. There should not be + // a caret position between the lam and alef. + layout = new TextLayout(ltrText+lamAlef, map, frc); + + final int ltrLen = ltrText.length(); + final int layoutLen = layout.getCharacterCount(); + + for (int i=0; i < ltrLen; i++) { + hit = layout.getNextRightHit(i); + if (hit.getInsertionIndex() != i+1) { + throw new Error("Right hit failed in ltr text."); + } + } + + hit = layout.getNextRightHit(ltrLen); + if (layoutLen != hit.getInsertionIndex()) { + throw new Error("Right hit failed at direction boundary."); + } + + hit = layout.getNextLeftHit(layoutLen); + if (hit.getInsertionIndex() != ltrLen) { + throw new Error("Left hit failed at end of text."); + } + } +} diff --git a/jdk/test/java/awt/font/TextLayout/TestJustification.html b/jdk/test/java/awt/font/TextLayout/TestJustification.html new file mode 100644 index 00000000000..c9e79f44cb2 --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/TestJustification.html @@ -0,0 +1,52 @@ + + + + +Test Justification + + + +

    Test Justification

    +
    +

    Five lines of text should appear, all justified to the same width, +followed by a sixth line containing only roman characters and no spaces +which is not justified, and instead is centered. +Carets should appear between all characters. Pass the test if this is +true. +

    + +alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." +Your browser is completely ignoring the <APPLET> tag! + + + + diff --git a/jdk/test/java/awt/font/TextLayout/TestJustification.java b/jdk/test/java/awt/font/TextLayout/TestJustification.java new file mode 100644 index 00000000000..417ddd5adfc --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/TestJustification.java @@ -0,0 +1,249 @@ +/* + * Copyright (c) 1999, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * + * See TestJustification.html for main test. + */ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.font.*; +import java.awt.geom.*; +import java.text.*; + +public class TestJustification extends Applet { + JustificationPanel panel; + + public void init() { + setLayout(new BorderLayout()); + panel = new JustificationPanel("Bitstream Cyberbit"); + add("Center", panel); + } + + public void destroy() { + remove(panel); + } + + // calls system.exit, not for use in tests. + public static void main(String args[]) { + TestJustification justificationTest = new TestJustification(); + justificationTest.init(); + justificationTest.start(); + + Frame f = new Frame("Test Justification"); + f.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + f.add("Center", justificationTest); + f.setSize(500, 500); + f.show(); + } + + public String getAppletInfo() { + return "Test TextLayout.getJustifiedLayout()"; + } + + static class JustificationPanel extends Panel { + TextLayout[] layouts; + String fontname; + float height; + float oldfsize; + + AttributedCharacterIterator lineText; + TextLayout[] lines; + int linecount; + float oldwidth; + + JustificationPanel(String fontname) { + this.fontname = fontname; + } + + private static final String[] texts = { + "This is an english Highlighting demo.", "Highlighting", + "This is an arabic \u0627\u0628\u062a\u062c \u062e\u0644\u0627\u062e demo.", "arabic \u0627\u0628\u062a\u062c", + "This is a hebrew \u05d0\u05d1\u05d2 \u05d3\u05d4\u05d5 demo.", "hebrew \u05d0\u05d1\u05d2", + "This is a cjk \u4e00\u4e01\u4e02\uac00\uac01\uc4fa\uf900\uf901\uf902 demo.", "cjk", + "NoSpaceCJK:\u4e00\u4e01\u4e02and\uac00\uac01\uc4faand\uf900\uf901\uf902", "No", + "NoSpaceRoman", "Space" + }; + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D)g; + + Dimension d = getSize(); + Insets insets = getInsets(); + + float w = d.width - insets.left - insets.right; + float h = d.height - insets.top - insets.bottom; + int fsize = (int)w/25; + + FontRenderContext frc = g2d.getFontRenderContext(); + + if (layouts == null || fsize != oldfsize) { + oldfsize = fsize; + + Font f0 = new Font(fontname, Font.PLAIN, fsize); + Font f1 = new Font(fontname, Font.ITALIC, (int)(fsize * 1.5)); + + if (layouts == null) { + layouts = new TextLayout[texts.length / 2]; + } + + height = 0; + for (int i = 0; i < layouts.length; ++i) { + String text = texts[i*2]; + String target = texts[i*2+1]; + + AttributedString astr = new AttributedString(text); + astr.addAttribute(TextAttribute.FONT, f0, 0, text.length()); + + int start = text.indexOf(target); + int limit = start + target.length(); + astr.addAttribute(TextAttribute.FONT, f1, start, limit); + + TextLayout layout = new TextLayout(astr.getIterator(), frc); + + layout = layout.getJustifiedLayout(w - 20); + + layouts[i] = layout; + + height += layout.getAscent() + layout.getDescent() + layout.getLeading(); + } + } + + g2d.setColor(Color.white); + g2d.fill(new Rectangle.Float(insets.left, insets.top, w, h)); + + float basey = 20; + + for (int i = 0; i < layouts.length; ++i) { + TextLayout layout = layouts[i]; + + float la = layout.getAscent(); + float ld = layout.getDescent(); + float ll = layout.getLeading(); + float lw = layout.getAdvance(); + float lh = la + ld + ll; + float lx = (w - lw) / 2f; + float ly = basey + layout.getAscent(); + + g2d.setColor(Color.black); + g2d.translate(insets.left + lx, insets.top + ly); + + Rectangle2D bounds = new Rectangle2D.Float(0, -la, lw, lh); + g2d.draw(bounds); + + layout.draw(g2d, 0, 0); + + g2d.setColor(Color.red); + for (int j = 0, e = layout.getCharacterCount(); j <= e; ++j) { + Shape[] carets = layout.getCaretShapes(j, bounds); + g2d.draw(carets[0]); + } + + g2d.translate(-insets.left - lx, -insets.top - ly); + basey += layout.getAscent() + layout.getDescent() + layout.getLeading(); + } + + // add LineBreakMeasurer-generated layouts + + if (lineText == null) { + String text = "This is a long line of text that should be broken across multiple " + + "lines and then justified to fit the break width. This test should pass if " + + "these lines are justified to the same width, and fail otherwise. It should " + + "also format the hebrew (\u05d0\u05d1\u05d2 \u05d3\u05d4\u05d5) and arabic " + + "(\u0627\u0628\u062a\u062c \u062e\u0644\u0627\u062e) and CJK " + + "(\u4e00\u4e01\u4e02\uac00\uac01\uc4fa\u67b1\u67b2\u67b3\u67b4\u67b5\u67b6\u67b7" + + "\u67b8\u67b9) text correctly."; + + Float regular = new Float(16.0); + Float big = new Float(24.0); + AttributedString astr = new AttributedString(text); + astr.addAttribute(TextAttribute.SIZE, regular, 0, text.length()); + astr.addAttribute(TextAttribute.FAMILY, fontname, 0, text.length()); + + int ix = text.indexOf("broken"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 6); + ix = text.indexOf("hebrew"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 6); + ix = text.indexOf("arabic"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 6); + ix = text.indexOf("CJK"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 3); + + lineText = astr.getIterator(); + } + + float width = w - 20; + if (lines == null || width != oldwidth) { + oldwidth = width; + + lines = new TextLayout[10]; + linecount = 0; + + LineBreakMeasurer measurer = new LineBreakMeasurer(lineText, frc); + + for (;;) { + TextLayout layout = measurer.nextLayout(width); + if (layout == null) { + break; + } + + // justify all but last line + if (linecount > 0) { + lines[linecount - 1] = lines[linecount - 1].getJustifiedLayout(width); + } + + if (linecount == lines.length) { + TextLayout[] nlines = new TextLayout[lines.length * 2]; + System.arraycopy(lines, 0, nlines, 0, lines.length); + lines = nlines; + } + + lines[linecount++] = layout; + } + } + + float basex = insets.left + 10; + basey += 10; + g2d.setColor(Color.black); + + for (int i = 0; i < linecount; ++i) { + TextLayout layout = lines[i]; + + basey += layout.getAscent(); + float adv = layout.getAdvance(); + float dx = layout.isLeftToRight() ? 0 : width - adv; + + layout.draw(g2d, basex + dx, basey); + + basey += layout.getDescent() + layout.getLeading(); + } + } + } +} diff --git a/jdk/test/javax/swing/text/DevanagariEditor.java b/jdk/test/javax/swing/text/DevanagariEditor.java new file mode 100644 index 00000000000..3781a1beae7 --- /dev/null +++ b/jdk/test/javax/swing/text/DevanagariEditor.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8151725 + * @summary Tests no exception creating a JEditorPane with Devanagari + */ + +import javax.swing.JEditorPane; + +public class DevanagariEditor { + public static void main(String[] args) { + new JEditorPane().setText("\u0930\u093E\u0915\u094D\u0937\u0938"); + } +} diff --git a/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java new file mode 100644 index 00000000000..cc32aeb7690 --- /dev/null +++ b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2011, 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + * + */ + +/* @test + @bug 6427244 8144240 + @summary Test that pressing HOME correctly moves caret in I18N document. + @author Sergey Groznyh + @library ../../../regtesthelpers + @build JRobot Util TestCase + @run main bug6427244 +*/ + +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Shape; +import java.awt.event.KeyEvent; +import javax.swing.JFrame; +import javax.swing.JTextPane; +import javax.swing.SwingUtilities; +import javax.swing.text.Position; + +public class bug6427244 extends TestCase { + private static final JRobot ROBOT = JRobot.getRobot(); + + final static int TP_SIZE = 200; + final static String[] SPACES = new String[] { + "\u0020", // ASCII space + "\u2002", // EN space + "\u2003", // EM space + "\u2004", // THREE-PER-EM space + "\u2005", // ... etc. + "\u2006", + //"\u2007", + "\u2008", + "\u2009", + "\u200a", + "\u200b", + "\u205f", + "\u3000", + }; + final static String[] WORDS = new String[] { + "It", "is", "a", "long", "paragraph", "for", "testing", "GlyphPainter2\n\n", + }; + + public static void main(String[] args) { + bug6427244 t = new bug6427244(); + for (String space: SPACES) { + t.init(space); + t.runAllTests(); + } + + System.out.println("OK"); + } + + void init(final String space) { + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + String text = null; + for (String word: WORDS) { + if (text == null) { + text = ""; + } else { + text += space; + } + text += word; + } + tp = new JTextPane(); + tp.setText(text + + "Some arabic: \u062a\u0641\u0627\u062d and some not."); + if (jf == null) { + jf = new JFrame(); + jf.setTitle("bug6427244"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jf.setSize(TP_SIZE, TP_SIZE); + jf.setVisible(true); + } + Container c = jf.getContentPane(); + c.removeAll(); + c.add(tp); + c.invalidate(); + c.validate(); + dim = c.getSize(); + } + }); + Util.blockTillDisplayed(tp); + ROBOT.waitForIdle(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + public void testCaretPosition() { + Point p = tp.getLocationOnScreen(); + // the right-top corner position + p.x += (dim.width - 5); + p.y += 5; + ROBOT.mouseMove(p.x, p.y); + ROBOT.clickMouse(); + ROBOT.hitKey(KeyEvent.VK_HOME); + ROBOT.waitForIdle(); + // this will fail if caret moves out of the 1st line. + assertEquals(0, getCaretOrdinate()); + } + + int getCaretOrdinate() { + final int[] y = new int[1]; + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Shape s; + try { + s = tp.getUI().getRootView(tp).modelToView( + tp.getCaretPosition(), tp.getBounds(), + Position.Bias.Forward); + } catch (Exception e) { + throw new RuntimeException(e); + } + y[0] = s.getBounds().y; + } + }); + } catch (Exception e) { + throw new RuntimeException(e); + } + return y[0]; + } + + JFrame jf; + JTextPane tp; + Dimension dim; +} From 7a3d0498d3e54e106bd03756791552f0093a6ffd Mon Sep 17 00:00:00 2001 From: Robert Field Date: Thu, 1 Sep 2016 12:13:13 -0700 Subject: [PATCH 117/296] 8133507: JShell: StackTraceElement#getFileName of EvalException does not use custom id generator Reviewed-by: jlahoda --- .../share/classes/jdk/jshell/Eval.java | 19 ++++++++++++------- .../test/jdk/jshell/IdGeneratorTest.java | 5 ++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java index 87f8d5af44d..79b8b221db5 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java @@ -555,9 +555,11 @@ class Eval { : ""; } catch (ResolutionException ex) { DeclarationSnippet sn = (DeclarationSnippet) state.maps.getSnippetDeadOrAlive(ex.id()); - exception = new UnresolvedReferenceException(sn, ex.getStackTrace()); + exception = new UnresolvedReferenceException(sn, translateExceptionStack(ex)); } catch (UserException ex) { - exception = translateExecutionException(ex); + exception = new EvalException(translateExceptionMessage(ex), + ex.causeExceptionClass(), + translateExceptionStack(ex)); } catch (RunException ex) { // StopException - no-op } catch (InternalException ex) { @@ -732,7 +734,7 @@ class Eval { } } - private EvalException translateExecutionException(UserException ex) { + private StackTraceElement[] translateExceptionStack(Exception ex) { StackTraceElement[] raw = ex.getStackTrace(); int last = raw.length; do { @@ -759,11 +761,14 @@ class Eval { elems[i] = r; } } + return elems; + } + + private String translateExceptionMessage(Exception ex) { String msg = ex.getMessage(); - if (msg.equals("")) { - msg = null; - } - return new EvalException(msg, ex.causeExceptionClass(), elems); + return msg.equals("") + ? null + : msg; } private boolean isWrap(StackTraceElement ste) { diff --git a/langtools/test/jdk/jshell/IdGeneratorTest.java b/langtools/test/jdk/jshell/IdGeneratorTest.java index 1a3f167ba3c..38ccc1b3de5 100644 --- a/langtools/test/jdk/jshell/IdGeneratorTest.java +++ b/langtools/test/jdk/jshell/IdGeneratorTest.java @@ -99,19 +99,18 @@ public class IdGeneratorTest { } } - @Test(enabled = false) // TODO 8133507 public void testIdInException() { JShell.Builder builder = getBuilder().idGenerator(((snippet, id) -> "custom" + id)); try (JShell jShell = builder.build()) { EvalException evalException = (EvalException) jShell.eval("throw new Error();").get(0).exception(); for (StackTraceElement ste : evalException.getStackTrace()) { - assertTrue(ste.getFileName().startsWith("custom"), "Not started with \"custom\": " + assertTrue(ste.getFileName().startsWith("#custom"), "Not started with \"#custom\": " + ste.getFileName()); } jShell.eval("void f() { g(); }"); UnresolvedReferenceException unresolvedException = (UnresolvedReferenceException) jShell.eval("f();").get(0).exception(); for (StackTraceElement ste : unresolvedException.getStackTrace()) { - assertTrue(ste.getFileName().startsWith("custom"), "Not started with \"custom\": " + assertTrue(ste.getFileName().startsWith("#custom"), "Not started with \"#custom\": " + ste.getFileName()); } } From 49b420e58ae5ab896aadc8db2a71c50c13b97582 Mon Sep 17 00:00:00 2001 From: Dmitry Markov Date: Thu, 1 Sep 2016 22:17:48 +0300 Subject: [PATCH 118/296] 8050478: [macosx] Cursor not updating correctly after closing a modal dialog Reviewed-by: serb, alexsch --- .../sun/lwawt/macosx/CPlatformWindow.java | 8 ++ .../native/libawt_lwawt/awt/AWTWindow.m | 27 +++- .../ModalDialogEnterExitEventsTest.java | 129 ++++++++++++++++++ 3 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 jdk/test/java/awt/Mouse/EnterExitEvents/ModalDialogEnterExitEventsTest.java diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index 2842e02fd1e..cbbf3b193e9 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -63,6 +63,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename); private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled); private static native void nativeSynthesizeMouseEnteredExitedEvents(); + private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr, int eventType); private static native void nativeDispose(long nsWindowPtr); private static native void nativeEnterFullScreenMode(long nsWindowPtr); private static native void nativeExitFullScreenMode(long nsWindowPtr); @@ -825,6 +826,13 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo return; } + if (blocked) { + // We are going to show a modal window. Previously displayed window will be + // blocked/disabled. So we have to send mouse exited event to it now, since + // all mouse events are discarded for blocked/disabled windows. + nativeSynthesizeMouseEnteredExitedEvents(getNSWindowPtr(), CocoaConstants.NSMouseExited); + } + nativeSetEnabled(getNSWindowPtr(), !blocked); checkBlockingAndOrder(); } diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m index 682769ac2d2..211be30d895 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m @@ -1333,9 +1333,9 @@ JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetTopmostPlatformWindowUnde /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSynthesizeMouseEnteredExitedEvents - * Signature: (J)V + * Signature: ()V */ -JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents__ (JNIEnv *env, jclass clazz) { JNF_COCOA_ENTER(env); @@ -1347,6 +1347,29 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMou JNF_COCOA_EXIT(env); } +/* + * Class: sun_lwawt_macosx_CPlatformWindow + * Method: nativeSynthesizeMouseEnteredExitedEvents + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents__JI +(JNIEnv *env, jclass clazz, jlong windowPtr, jint eventType) +{ +JNF_COCOA_ENTER(env); + + if (eventType == NSMouseEntered || eventType == NSMouseExited) { + NSWindow *nsWindow = OBJC(windowPtr); + + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ + [AWTWindow synthesizeMouseEnteredExitedEvents:nsWindow withType:eventType]; + }]; + } else { + [JNFException raise:env as:kIllegalArgumentException reason:"unknown event type"]; + } + +JNF_COCOA_EXIT(env); +} + /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: _toggleFullScreenMode diff --git a/jdk/test/java/awt/Mouse/EnterExitEvents/ModalDialogEnterExitEventsTest.java b/jdk/test/java/awt/Mouse/EnterExitEvents/ModalDialogEnterExitEventsTest.java new file mode 100644 index 00000000000..147818d6db5 --- /dev/null +++ b/jdk/test/java/awt/Mouse/EnterExitEvents/ModalDialogEnterExitEventsTest.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @key headful + * @bug 8050478 + * @summary Cursor not updating correctly after closing a modal dialog. + * The root cause of the issue was the lack of a mouse exit event + * during displaying of a modal dialog. + * @author Dmitry Markov + * @library ../../regtesthelpers + * @build Util + * @run main ModalDialogEnterExitEventsTest + */ + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.concurrent.atomic.AtomicInteger; + +import test.java.awt.regtesthelpers.Util; + +public class ModalDialogEnterExitEventsTest { + private static volatile AtomicInteger mouseEnterCount = new AtomicInteger(); + private static volatile AtomicInteger mouseExitCount = new AtomicInteger(); + + private static JFrame frame; + private static JButton openButton; + private static JButton closeButton; + + public static void main(String[] args) { + Robot robot = Util.createRobot(); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + createAndShowGUI(); + } + }); + Util.waitForIdle(robot); + + Util.clickOnComp(frame, robot, 500); + Util.waitForIdle(robot); + + mouseEnterCount.set(0); + mouseExitCount.set(0); + + Util.clickOnComp(openButton, robot, 500); + Util.waitForIdle(robot); + if (mouseExitCount.get() != 1) { + throw new RuntimeException("Test FAILED. Wrong number of MouseExited events = " + mouseExitCount.get()); + } + + Util.clickOnComp(closeButton, robot, 500); + Util.waitForIdle(robot); + if (mouseEnterCount.get() != 1) { + throw new RuntimeException("Test FAILED. Wrong number of MouseEntered events = "+ mouseEnterCount.get()); + } + } + + private static void createAndShowGUI() { + frame = new JFrame("ModalDialogEnterExitEventsTest"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLayout(new FlowLayout()); + frame.addMouseListener(new MouseAdapter() { + @Override + public void mouseExited(MouseEvent e) { + mouseExitCount.getAndIncrement(); + } + + @Override + public void mouseEntered(MouseEvent e) { + mouseEnterCount.getAndIncrement(); + } + }); + openButton = new JButton("Open Dialog"); + openButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JDialog dialog = new JDialog(frame, "Modal Dialog", true); + dialog.setLayout(new FlowLayout()); + closeButton = new JButton("Close"); + closeButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + } + }); + dialog.add(closeButton); + dialog.setSize(200, 200); + dialog.setLocationRelativeTo(null); + dialog.setVisible(true); + } + }); + frame.add(openButton); + frame.setExtendedState(Frame.MAXIMIZED_BOTH); + frame.setVisible(true); + } +} + From 8302f64ee65268dc1a52a418e4683d44fc194a0d Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 1 Sep 2016 21:25:33 +0200 Subject: [PATCH 119/296] 8164952: JShell tests: jdk/jshell/CompletionSuggestionTest.testUncompletedDeclaration(): failure Avoiding conflict between the CompletionSuggestionTest.testUncompletedDeclaration test and ClassPathTest Reviewed-by: rfield --- langtools/test/jdk/jshell/CompletionSuggestionTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/langtools/test/jdk/jshell/CompletionSuggestionTest.java b/langtools/test/jdk/jshell/CompletionSuggestionTest.java index 93767169bed..8c2c723bc1e 100644 --- a/langtools/test/jdk/jshell/CompletionSuggestionTest.java +++ b/langtools/test/jdk/jshell/CompletionSuggestionTest.java @@ -419,9 +419,9 @@ public class CompletionSuggestionTest extends KullaTesting { public void testUncompletedDeclaration() { assertCompletion("class Clazz { Claz|", "Clazz"); assertCompletion("class Clazz { class A extends Claz|", "Clazz"); - assertCompletion("class Clazz { Clazz clazz; Object o = cla|", "clazz"); - assertCompletion("class Clazz { static Clazz clazz; Object o = cla|", "clazz"); - assertCompletion("class Clazz { Clazz clazz; static Object o = cla|", true); + assertCompletion("class Clazz { Clazz clazz; Object o = claz|", "clazz"); + assertCompletion("class Clazz { static Clazz clazz; Object o = claz|", "clazz"); + assertCompletion("class Clazz { Clazz clazz; static Object o = claz|", true); assertCompletion("class Clazz { void method(Claz|", "Clazz"); assertCompletion("class A { int method() { return 0; } int a = meth|", "method()"); assertCompletion("class A { int field = 0; int method() { return fiel|", "field"); From 4017bf5f7a6a0b103ce00c7919bc9cd3683d8a16 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Thu, 1 Sep 2016 13:21:52 -0700 Subject: [PATCH 120/296] 8165211: JShell: Fix completion analysis problems Reviewed-by: jlahoda --- .../jdk/jshell/CompletenessAnalyzer.java | 142 +++++++----------- .../test/jdk/jshell/CompletenessTest.java | 9 +- 2 files changed, 65 insertions(+), 86 deletions(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java index 10a00697231..c652b45b308 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java @@ -46,6 +46,8 @@ import com.sun.source.tree.Tree; import static jdk.jshell.CompletenessAnalyzer.TK.*; import jdk.jshell.TaskFactory.ParseTask; import java.util.List; +import java.util.function.Function; +import java.util.function.Supplier; /** * Low level scanner to determine completeness of input. @@ -81,13 +83,13 @@ class CompletenessAnalyzer { CaInfo scan(String s) { try { - Scanner scanner = scannerFactory.newScanner(s, false); - Matched in = new Matched(scanner); - Parser parser = new Parser(in, proc, s); + Parser parser = new Parser( + () -> new Matched(scannerFactory.newScanner(s, false)), + () -> proc.taskFactory.new ParseTask(s)); Completeness stat = parser.parseUnit(); int endPos = stat == Completeness.UNKNOWN ? s.length() - : in.prevCT.endPos; + : parser.endPos(); return new CaInfo(stat, endPos); } catch (SyntaxException ex) { return new CaInfo(error(), s.length()); @@ -188,7 +190,7 @@ class CompletenessAnalyzer { ERROR(TokenKind.ERROR, XERRO), // IDENTIFIER(TokenKind.IDENTIFIER, XEXPR1|XDECL1|XTERM), // UNDERSCORE(TokenKind.UNDERSCORE, XERRO), // _ - CLASS(TokenKind.CLASS, XEXPR|XDECL1|XTERM), // class decl and .class + CLASS(TokenKind.CLASS, XEXPR|XDECL1), // class decl (MAPPED: DOTCLASS) MONKEYS_AT(TokenKind.MONKEYS_AT, XEXPR|XDECL1), // @ IMPORT(TokenKind.IMPORT, XDECL1|XSTART), // import -- consider declaration SEMI(TokenKind.SEMI, XSTMT1|XTERM|XSTART), // ; @@ -206,15 +208,15 @@ class CompletenessAnalyzer { THROWS(TokenKind.THROWS, XDECL), // throws // Primarive type names - BOOLEAN(TokenKind.BOOLEAN, XEXPR|XDECL1), // boolean - BYTE(TokenKind.BYTE, XEXPR|XDECL1), // byte - CHAR(TokenKind.CHAR, XEXPR|XDECL1), // char - DOUBLE(TokenKind.DOUBLE, XEXPR|XDECL1), // double - FLOAT(TokenKind.FLOAT, XEXPR|XDECL1), // float - INT(TokenKind.INT, XEXPR|XDECL1), // int - LONG(TokenKind.LONG, XEXPR|XDECL1), // long - SHORT(TokenKind.SHORT, XEXPR|XDECL1), // short - VOID(TokenKind.VOID, XEXPR|XDECL1), // void + BOOLEAN(TokenKind.BOOLEAN, XEXPR1|XDECL1), // boolean + BYTE(TokenKind.BYTE, XEXPR1|XDECL1), // byte + CHAR(TokenKind.CHAR, XEXPR1|XDECL1), // char + DOUBLE(TokenKind.DOUBLE, XEXPR1|XDECL1), // double + FLOAT(TokenKind.FLOAT, XEXPR1|XDECL1), // float + INT(TokenKind.INT, XEXPR1|XDECL1), // int + LONG(TokenKind.LONG, XEXPR1|XDECL1), // long + SHORT(TokenKind.SHORT, XEXPR1|XDECL1), // short + VOID(TokenKind.VOID, XEXPR1|XDECL1), // void // Modifiers keywords ABSTRACT(TokenKind.ABSTRACT, XDECL1), // abstract @@ -230,7 +232,7 @@ class CompletenessAnalyzer { // Declarations and type parameters (thus expressions) EXTENDS(TokenKind.EXTENDS, XEXPR|XDECL), // extends - COMMA(TokenKind.COMMA, XEXPR|XDECL), // , + COMMA(TokenKind.COMMA, XEXPR|XDECL|XTERM), // , AMP(TokenKind.AMP, XEXPR|XDECL), // & GT(TokenKind.GT, XEXPR|XDECL), // > LT(TokenKind.LT, XEXPR|XDECL1), // < @@ -239,7 +241,7 @@ class CompletenessAnalyzer { GTGTGT(TokenKind.GTGTGT, XEXPR|XDECL), // >>> QUES(TokenKind.QUES, XEXPR|XDECL), // ? DOT(TokenKind.DOT, XEXPR|XDECL), // . - STAR(TokenKind.STAR, XEXPR|XDECL|XTERM), // * -- import foo.* //TODO handle these case separately, XTERM + STAR(TokenKind.STAR, XEXPR), // * (MAPPED: DOTSTAR) // Statement keywords ASSERT(TokenKind.ASSERT, XSTMT1|XSTART), // assert @@ -280,7 +282,7 @@ class CompletenessAnalyzer { // Expressions cannot terminate INSTANCEOF(TokenKind.INSTANCEOF, XEXPR), // instanceof - NEW(TokenKind.NEW, XEXPR1), // new + NEW(TokenKind.NEW, XEXPR1), // new (MAPPED: COLCOLNEW) SUPER(TokenKind.SUPER, XEXPR1|XDECL), // super -- shouldn't see as rec. But in type parameters ARROW(TokenKind.ARROW, XEXPR), // -> COLCOL(TokenKind.COLCOL, XEXPR), // :: @@ -323,24 +325,29 @@ class CompletenessAnalyzer { UNMATCHED(XERRO), PARENS(XEXPR1|XDECL|XSTMT|XTERM), BRACKETS(XEXPR|XDECL|XTERM), - BRACES(XSTMT1|XEXPR|XTERM); + BRACES(XSTMT1|XEXPR|XTERM), + DOTSTAR(XDECL|XTERM), // import foo.* + COLCOLNEW(XEXPR|XTERM), // :: new + DOTCLASS(XEXPR|XTERM), // class decl and .class + ; static final EnumMap tokenKindToTKMap = new EnumMap<>(TokenKind.class); final TokenKind tokenKind; final int belongs; + Function mapping; TK(int b) { - this.tokenKind = null; - this.belongs = b; + this(null, b); } TK(TokenKind tokenKind, int b) { this.tokenKind = tokenKind; this.belongs = b; + this.mapping = null; } - private static TK tokenKindToTK(TokenKind kind) { + private static TK tokenKindToTK(TK prev, TokenKind kind) { TK tk = tokenKindToTKMap.get(kind); if (tk == null) { System.err.printf("No corresponding %s for %s: %s\n", @@ -349,7 +356,9 @@ class CompletenessAnalyzer { kind); throw new InternalError("No corresponding TK for TokenKind: " + kind); } - return tk; + return tk.mapping != null + ? tk.mapping.apply(prev) + : tk; } boolean isOkToTerminate() { @@ -383,8 +392,12 @@ class CompletenessAnalyzer { } } for (TokenKind kind : TokenKind.values()) { - tokenKindToTK(kind); // assure they can be retrieved without error + tokenKindToTK(null, kind); // assure they can be retrieved without error } + // Mappings of disambiguated contexts + STAR.mapping = prev -> prev == DOT ? DOTSTAR : STAR; + NEW.mapping = prev -> prev == COLCOL ? COLCOLNEW : NEW; + CLASS.mapping = prev -> prev == DOT ? DOTCLASS : CLASS; } } @@ -520,7 +533,7 @@ class CompletenessAnalyzer { ct = match(BRACKETS, TokenKind.LBRACKET); break; default: - ct = new CT(TK.tokenKindToTK(current.kind), advance()); + ct = new CT(TK.tokenKindToTK(prevTK, current.kind), advance()); break; } if (ct.kind.isStart() && !prevTK.isOkToTerminate()) { @@ -539,21 +552,21 @@ class CompletenessAnalyzer { */ private static class Parser { - final Matched in; - CT token; - Completeness checkResult; + private final Supplier matchedFactory; + private final Supplier parseFactory; + private Matched in; + private CT token; + private Completeness checkResult; - final JShell proc; - final String scannedInput; + Parser(Supplier matchedFactory, Supplier parseFactory) { + this.matchedFactory = matchedFactory; + this.parseFactory = parseFactory; + resetInput(); + } - - - Parser(Matched in, JShell proc, String scannedInput) { - this.in = in; + final void resetInput() { + this.in = matchedFactory.get(); nextToken(); - - this.proc = proc; - this.scannedInput = scannedInput; } final void nextToken() { @@ -598,6 +611,10 @@ class CompletenessAnalyzer { return flags != Completeness.COMPLETE; } + public int endPos() { + return in.prevCT.endPos; + } + public Completeness parseUnit() { //System.err.printf("%s: belongs %o XANY1 %o\n", token.kind, token.kind.belongs, token.kind.belongs & XANY1); switch (token.kind.belongs & XANY1) { @@ -651,11 +668,11 @@ class CompletenessAnalyzer { case IDENTIFIER: case BRACKETS: return Completeness.COMPLETE_WITH_SEMI; - case STAR: + case DOTSTAR: if (isImport) { return Completeness.COMPLETE_WITH_SEMI; } else { - return Completeness.DEFINITELY_INCOMPLETE; + return Completeness.UNKNOWN; } default: return Completeness.DEFINITELY_INCOMPLETE; @@ -667,7 +684,7 @@ class CompletenessAnalyzer { public Completeness disambiguateDeclarationVsExpression() { // String folding messes up position information. - ParseTask pt = proc.taskFactory.new ParseTask(scannedInput); + ParseTask pt = parseFactory.get(); List units = pt.units(); if (units.isEmpty()) { return error(); @@ -679,7 +696,7 @@ class CompletenessAnalyzer { case LABELED_STATEMENT: if (shouldAbort(IDENTIFIER)) return checkResult; if (shouldAbort(COLON)) return checkResult; - return parseStatement(); + return parseStatement(); case VARIABLE: case IMPORT: case CLASS: @@ -693,51 +710,6 @@ class CompletenessAnalyzer { } } -// public Status parseExpressionOrDeclaration() { -// if (token.kind == IDENTIFIER) { -// nextToken(); -// switch (token.kind) { -// case IDENTIFIER: -// return parseDeclaration(); -// } -// } -// while (token.kind.isExpressionOrDeclaration()) { -// if (!token.kind.isExpression()) { -// return parseDeclaration(); -// } -// if (!token.kind.isDeclaration()) { -// // Expression not declaration -// if (token.kind == EQ) { -// // Check for array initializer -// nextToken(); -// if (token.kind == BRACES) { -// nextToken(); -// return lastly(SEMI); -// } -// } -// return parseExpressionStatement(); -// } -// nextToken(); -// } -// switch (token.kind) { -// case BRACES: -// case SEMI: -// nextToken(); -// return Status.COMPLETE; -// case UNMATCHED: -// nextToken(); -// return Status.DEFINITELY_INCOMPLETE; -// case EOF: -// if (in.prevCT.kind.isOkToTerminate()) { -// return Status.COMPLETE_WITH_SEMI; -// } else { -// return Status.DEFINITELY_INCOMPLETE; -// } -// default: -// return error(); -// } -// } - public Completeness parseExpressionStatement() { if (shouldAbort(parseExpression())) return checkResult; return lastly(SEMI); diff --git a/langtools/test/jdk/jshell/CompletenessTest.java b/langtools/test/jdk/jshell/CompletenessTest.java index bf95b51f311..b0e5a781036 100644 --- a/langtools/test/jdk/jshell/CompletenessTest.java +++ b/langtools/test/jdk/jshell/CompletenessTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8149524 8131024 + * @bug 8149524 8131024 8165211 8080071 8130454 * @summary Test SourceCodeAnalysis * @build KullaTesting TestingInputStream * @run testng CompletenessTest @@ -63,6 +63,7 @@ public class CompletenessTest extends KullaTesting { "foo: while (true) { printf(\"Innn\"); break foo; }", "class Case, E2 extends Enum, E3 extends Enum> {}", ";", + "enum Tt { FOO, BAR, BAZ,; }" }; static final String[] expression = new String[] { @@ -77,6 +78,8 @@ public class CompletenessTest extends KullaTesting { "new int[] {1, 2,3}", "new Foo() {}", "i >= 0 && Character.isWhitespace(s.charAt(i))", + "int.class", + "String.class", }; static final String[] complete_with_semi = new String[] { @@ -113,6 +116,7 @@ public class CompletenessTest extends KullaTesting { "BufferedReader br = new BufferedReader(new FileReader(path))", "bar: g()", "baz: while (true) if (t()) printf('-'); else break baz", + "java.util.function.IntFunction ggg = int[]::new", }; static final String[] considered_incomplete = new String[] { @@ -141,6 +145,8 @@ public class CompletenessTest extends KullaTesting { "if (match.kind == BRACES && (prevCT.kind == ARROW || prevCT.kind == NEW_MIDDLE)) {", "if (match.kind == BRACES && (prevCT.kind == ARROW || prevCT.kind == NEW_MIDDLE)) { new CT(UNMATCHED, current, \"Unmatched \" + unmatched);", "x +", + "x *", + "3 *", "int", "for (int i = 0; i < lines.length(); ++i) {", "new", @@ -156,6 +162,7 @@ public class CompletenessTest extends KullaTesting { "enum TK { EOF(TokenKind.EOF, 0),", "enum TK { EOF(TokenKind.EOF, 0), NEW_MIDDLE(XEXPR1|XTERM)", "enum TK { EOF(TokenKind.EOF, 0), NEW_MIDDLE(XEXPR1|XTERM); ", + "enum Tt { FOO, BAR, BAZ,;" }; static final String[] unknown = new String[] { From 0ed31a8ac8e617d337e6e513e135aa05f225e492 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 1 Sep 2016 23:20:09 +0000 Subject: [PATCH 121/296] Added tag jdk-9+134 for changeset d03967e81db7 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 9b00c6661fd..0c614608939 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -376,3 +376,4 @@ d94d54a3192fea79234c3ac55cd0b4052d45e954 jdk-9+130 8728756c2f70a79a90188f4019cfd6b9a275765c jdk-9+131 a24702d4d5ab0015a5c553ed57f66fce7d85155e jdk-9+132 be1218f792a450dfb5d4b1f82616b9d95a6a732e jdk-9+133 +065724348690eda41fc69112278d8da6dcde548c jdk-9+134 From f0e3ab92184a849045aafa83c5a0f436a95b64aa Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 1 Sep 2016 23:20:10 +0000 Subject: [PATCH 122/296] Added tag jdk-9+134 for changeset 6efb7e03e19c --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 8d8a2e6cf99..4cc7243b9ce 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -536,3 +536,4 @@ e96b34b76d863ed1fa04e0eeb3f297ac17b490fd jdk-9+129 943bf73b49c33c2d7cbd796f6a4ae3c7a00ae932 jdk-9+131 713951c08aa26813375175c2ab6cc99ff2a56903 jdk-9+132 a25e0fb6033245ab075136e744d362ce765464cd jdk-9+133 +b8b694c6b4d2ab0939aed7adaf0eec1ac321a085 jdk-9+134 From 7a36df6b44adfa1a1ae03a076a337c0eba13f6b5 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 1 Sep 2016 23:20:10 +0000 Subject: [PATCH 123/296] Added tag jdk-9+134 for changeset 6929cdb3e1c5 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index a959d0d2240..ee81ced5edd 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -376,3 +376,4 @@ c3e83ccab3bb1733ae903d681879a33f85ed465c jdk-9+129 f7e1d5337c2e550fe553df7a3886bbed80292ecd jdk-9+131 1ab4b9399c4cba584f66c1c088188f2f565fbf9c jdk-9+132 2021bfedf1c478a4808a7711a6090682a12f4c0e jdk-9+133 +1a497f5ca0cfd88115cc7daa8af8a62b8741caf2 jdk-9+134 From f3b9377906740acaf71b3bc7cdaa22ec9c7c5b3a Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 1 Sep 2016 23:20:11 +0000 Subject: [PATCH 124/296] Added tag jdk-9+134 for changeset 1dddef49982c --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index e81f2084cef..25362b9eae8 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -376,3 +376,4 @@ e66cdc2de6b02443911d386fc9217b0d824d0686 jdk-9+130 874082a9b565a7092a40bfa934a6e3e3c3455a60 jdk-9+131 907445d85e680ea410fe2c83c0ec64b5508e4f3e jdk-9+132 9490ba2e5e41685c858a0ca2a6ec87611eb011c6 jdk-9+133 +1c6c21d87aa459d82425e1fddc9ce8647aebde34 jdk-9+134 From 03d3f90a58fcb22f85e86e965730e3e54f44702f Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 1 Sep 2016 23:20:11 +0000 Subject: [PATCH 125/296] Added tag jdk-9+134 for changeset 219458339252 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 136f72fe00d..19675fb9b1a 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -379,3 +379,4 @@ fe4e11bd2423635dc0f5f5cb9a64eb2f2cce7f4c jdk-9+128 783e7e2c587f2c7e1b9998a46d90ec196ab2a195 jdk-9+131 9fff2477a4cadf2a9618a76f1f4fe0f20bb5ff3b jdk-9+132 05e99eefda2b58d1ed176e411302d9d6b35dca16 jdk-9+133 +ab1d78d395d4cb8be426ff181211da1a4085cf01 jdk-9+134 From 5823fdef292fb05954023810b41681ffde0b12b5 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 1 Sep 2016 23:20:13 +0000 Subject: [PATCH 126/296] Added tag jdk-9+134 for changeset eb2c81860c86 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 4fdf92ea61c..f4500a88ff0 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -376,3 +376,4 @@ e181909291981038b041ed4d22714c4760e049cd jdk-9+129 aebfafc43714d5a27d5064d8a0011eaccde633cf jdk-9+131 2c17b65a37a8d7afdb9f96d5f11b28a3f21c78f2 jdk-9+132 7efa4b3477b2b93edbdb4abf827b74c6391f056e jdk-9+133 +f08683786207a48b652266b3b7b908e6c863c3fc jdk-9+134 From 2fb04d0a420c624ac69cccb5a13346de2ea06670 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 1 Sep 2016 23:20:13 +0000 Subject: [PATCH 127/296] Added tag jdk-9+134 for changeset d48c4f63e546 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index f68987a568a..344e197c433 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -367,3 +367,4 @@ ff07be6106fa56b72c163244f45a3ecb4c995564 jdk-9+127 ee77c6b3713ab293e027ac3ea1cc16f86dac535f jdk-9+131 55a75af751dfe44039baef2b762ee7347021025b jdk-9+132 3a924b820d02b108cf57b51e145b5150d1eedcca jdk-9+133 +e05400ba935753c77697af936db24657eb811022 jdk-9+134 From 524cb00f824a0b0d00fb8607e656024964ae3fa0 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Thu, 1 Sep 2016 17:03:41 -0700 Subject: [PATCH 128/296] 8161454: Fails to Load external Java method from inside of a XSL stylesheet if SecurityManager is present Reviewed-by: aefimov, lancea, dfuchs --- .../jdk/xml/internal/JdkXmlFeatures.java | 40 +++++++++- .../unittest/transform/XSLTFunctionsTest.java | 80 ++++++++++++++++++- 2 files changed, 115 insertions(+), 5 deletions(-) diff --git a/jaxp/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java b/jaxp/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java index 868ad21535c..240c386bf56 100644 --- a/jaxp/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java +++ b/jaxp/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java @@ -42,6 +42,9 @@ public class JdkXmlFeatures { ORACLE_JAXP_PROPERTY_PREFIX + "enableExtensionFunctions"; public static final String SP_ENABLE_EXTENSION_FUNCTION = "javax.xml.enableExtensionFunctions"; + // This is the correct name by the spec + public static final String SP_ENABLE_EXTENSION_FUNCTION_SPEC = + "jdk.xml.enableExtensionFunctions"; public static final String CATALOG_FEATURES = "javax.xml.catalog.catalogFeatures"; public final static String PROPERTY_USE_CATALOG = XMLConstants.USE_CATALOG; @@ -49,11 +52,11 @@ public class JdkXmlFeatures { public static enum XmlFeature { /** * Feature enableExtensionFunctions - * FSP: extension function is enforced by FSP. When FSP is on, entension + * FSP: extension function is enforced by FSP. When FSP is on, extension * function is disabled. */ ENABLE_EXTENSION_FUNCTION(ORACLE_ENABLE_EXTENSION_FUNCTION, - SP_ENABLE_EXTENSION_FUNCTION, true, false, true, true), + SP_ENABLE_EXTENSION_FUNCTION_SPEC, true, false, true, true), /** * The {@link javax.xml.XMLConstants.USE_CATALOG} feature. * FSP: USE_CATALOG is not enforced by FSP. @@ -148,6 +151,30 @@ public class JdkXmlFeatures { } + /** + * Maps old property names with the new ones. This map is used to keep track of + * name changes so that old or incorrect names continue to be supported for compatibility. + */ + public static enum NameMap { + + ENABLE_EXTENSION_FUNCTION(SP_ENABLE_EXTENSION_FUNCTION_SPEC, SP_ENABLE_EXTENSION_FUNCTION); + + final String newName; + final String oldName; + + NameMap(String newName, String oldName) { + this.newName = newName; + this.oldName = oldName; + } + + String getOldName(String newName) { + if (newName.equals(this.newName)) { + return oldName; + } + return null; + } + } + /** * States of the settings of a property, in the order: default value, value * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system @@ -316,6 +343,15 @@ public class JdkXmlFeatures { private void readSystemProperties() { for (XmlFeature feature : XmlFeature.values()) { getSystemProperty(feature, feature.systemProperty()); + if (!getSystemProperty(feature, feature.systemProperty())) { + //if system property is not found, try the older form if any + for (NameMap nameMap : NameMap.values()) { + String oldName = nameMap.getOldName(feature.systemProperty()); + if (oldName != null) { + getSystemProperty(feature, oldName); + } + } + } } } diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java index 51df5915037..354accefa4a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java @@ -34,11 +34,16 @@ import javax.xml.transform.URIResolver; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; +import static jaxp.library.JAXPTestUtilities.runWithAllPerm; +import static jaxp.library.JAXPTestUtilities.clearSystemProperty; +import static jaxp.library.JAXPTestUtilities.setSystemProperty; +import static jaxp.library.JAXPTestUtilities.getSystemProperty; /* * @test @@ -49,9 +54,65 @@ import static org.testng.Assert.assertEquals; * @summary This class contains tests for XSLT functions. */ -//@Listeners({jaxp.library.BasePolicy.class}) //uncomment this line after 8161454 is resolved +@Listeners({jaxp.library.BasePolicy.class}) public class XSLTFunctionsTest { + /** + * @bug 8161454 + * Verifies that the new / correct name is supported, as is the old / incorrect + * one for compatibility + */ + @Test + public void testNameChange() { + + boolean feature; + TransformerFactory tf = TransformerFactory.newInstance(); + feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION); + System.out.println("Default setting: " + feature); + // The default: true if no SecurityManager, false otherwise + Assert.assertTrue(feature == getDefault()); + + setSystemProperty(SP_ENABLE_EXTENSION_FUNCTION, getDefaultOpposite()); + tf = TransformerFactory.newInstance(); + feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION); + System.out.println("After setting " + SP_ENABLE_EXTENSION_FUNCTION + ": " + feature); + clearSystemProperty(SP_ENABLE_EXTENSION_FUNCTION); + // old/incorrect name is still supported + Assert.assertTrue(feature != getDefault()); + + setSystemProperty(SP_ENABLE_EXTENSION_FUNCTION_SPEC, getDefaultOpposite()); + tf = TransformerFactory.newInstance(); + feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION); + System.out.println("After setting " + SP_ENABLE_EXTENSION_FUNCTION_SPEC + ": " + feature); + clearSystemProperty(SP_ENABLE_EXTENSION_FUNCTION_SPEC); + // new/correct name is effective + Assert.assertTrue(feature != getDefault()); + } + + final boolean isSecure; + { + String runSecMngr = getSystemProperty("runSecMngr"); + isSecure = runSecMngr != null && runSecMngr.equals("true"); + } + + // The default: true if no SecurityManager, false otherwise + private boolean getDefault() { + if (isSecure) { + return false; + } else { + return true; + } + } + + // Gets a String value that is opposite to the default value + private String getDefaultOpposite() { + if (isSecure) { + return "true"; + } else { + return "false"; + } + } + /** * @bug 8062518 8153082 * Verifies that a reference to the DTM created by XSLT document function is @@ -72,7 +133,9 @@ public class XSLTFunctionsTest { // Create factory and transformer TransformerFactory tf = TransformerFactory.newInstance(); - tf.setFeature("http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions", true); + tf.setFeature(ORACLE_ENABLE_EXTENSION_FUNCTION, true); + tf.setAttribute(EXTENSION_CLASS_LOADER, + runWithAllPerm(() -> Thread.currentThread().getContextClassLoader())); Transformer t = tf.newTransformer( xslsrc ); t.setErrorListener(tf.getErrorListener()); @@ -133,5 +196,16 @@ public class XSLTFunctionsTest { static final String documentTesteExpectedResult = "" + "[Test:Doc][Test:External Doc]"; -} + public static final String ORACLE_JAXP_PROPERTY_PREFIX = + "http://www.oracle.com/xml/jaxp/properties/"; + /** + * Feature enableExtensionFunctions + */ + public static final String ORACLE_ENABLE_EXTENSION_FUNCTION = + ORACLE_JAXP_PROPERTY_PREFIX + "enableExtensionFunctions"; + static final String SP_ENABLE_EXTENSION_FUNCTION = "javax.xml.enableExtensionFunctions"; + // This is the correct name by the spec + static final String SP_ENABLE_EXTENSION_FUNCTION_SPEC = "jdk.xml.enableExtensionFunctions"; + private static final String EXTENSION_CLASS_LOADER = "jdk.xml.transform.extensionClassLoader"; +} From 876bb73271f242d8f4ccd500a7059d71b477f6e5 Mon Sep 17 00:00:00 2001 From: Srikanth Adayapalam Date: Fri, 2 Sep 2016 07:49:15 +0530 Subject: [PATCH 129/296] 8164073: Javac should unconditionally warn if deprecated javadoc tag is used without @Deprecated annotation Reviewed-by: mcimadamore --- .../com/sun/tools/javac/code/Symbol.java | 13 +++++++ .../com/sun/tools/javac/comp/Check.java | 16 +++------ .../com/sun/tools/javac/util/Options.java | 14 +++++++- .../tools/javac/T4994049/DeprecatedYES.out | 5 +-- .../test/tools/javac/danglingDep/DepX.out | 2 ++ .../SuppressDepAnnWithSwitchTest.java | 34 +++++++++++++++++++ .../depDocComment/SuppressDeprecation.java | 3 +- .../depDocComment/SuppressDeprecation.out | 28 ++++++++++----- .../depDocComment/SuppressDeprecation8.out | 9 +++++ .../javac/depOverrides/doccomment/Test1.java | 6 ++-- .../javac/depOverrides/doccomment/Test1A.out | 8 ++++- .../javac/depOverrides/doccomment/Test1B.out | 8 ++++- .../javac/depOverrides/doccomment/Test1B2.out | 8 ++++- .../javac/depOverrides/doccomment/Test1B3.out | 8 +++++ .../javac/depOverrides/doccomment/Test1I.out | 9 +++++ .../javac/depOverrides/doccomment/Test2.java | 4 +-- .../javac/depOverrides/doccomment/Test2P.out | 10 ++++++ .../javac/depOverrides/doccomment/Test2Q.out | 8 ++++- .../javac/depOverrides/doccomment/Test2R.out | 8 ++++- .../javac/depOverrides/doccomment/Test3.out | 3 +- .../test/tools/javac/lint/Deprecation.out | 5 +-- 21 files changed, 172 insertions(+), 37 deletions(-) create mode 100644 langtools/test/tools/javac/depDocComment/SuppressDepAnnWithSwitchTest.java create mode 100644 langtools/test/tools/javac/depDocComment/SuppressDeprecation8.out create mode 100644 langtools/test/tools/javac/depOverrides/doccomment/Test1B3.out create mode 100644 langtools/test/tools/javac/depOverrides/doccomment/Test1I.out create mode 100644 langtools/test/tools/javac/depOverrides/doccomment/Test2P.out diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java index 959d3ac1a91..8757939f626 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java @@ -359,6 +359,19 @@ public abstract class Symbol extends AnnoConstruct implements Element { return (flags_field & DEPRECATED) != 0; } + public boolean isDeprecatableViaAnnotation() { + switch (getKind()) { + case LOCAL_VARIABLE: + case PACKAGE: + case PARAMETER: + case RESOURCE_VARIABLE: + case EXCEPTION_PARAMETER: + return false; + default: + return true; + } + } + public boolean isStatic() { return (flags() & STATIC) != 0 || diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index 7e2f823d3c9..5767f9c45e4 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -3192,7 +3192,7 @@ public class Check { } void checkDeprecatedAnnotation(DiagnosticPosition pos, Symbol s) { - if (lint.isEnabled(LintCategory.DEP_ANN) && + if (lint.isEnabled(LintCategory.DEP_ANN) && s.isDeprecatableViaAnnotation() && (s.flags() & DEPRECATED) != 0 && !syms.deprecatedType.isErroneous() && s.attribute(syms.deprecatedType.tsym) == null) { @@ -3200,18 +3200,10 @@ public class Check { pos, "missing.deprecated.annotation"); } // Note: @Deprecated has no effect on local variables, parameters and package decls. - if (lint.isEnabled(LintCategory.DEPRECATION)) { + if (lint.isEnabled(LintCategory.DEPRECATION) && !s.isDeprecatableViaAnnotation()) { if (!syms.deprecatedType.isErroneous() && s.attribute(syms.deprecatedType.tsym) != null) { - switch (s.getKind()) { - case LOCAL_VARIABLE: - case PACKAGE: - case PARAMETER: - case RESOURCE_VARIABLE: - case EXCEPTION_PARAMETER: - log.warning(LintCategory.DEPRECATION, pos, - "deprecated.annotation.has.no.effect", Kinds.kindName(s)); - break; - } + log.warning(LintCategory.DEPRECATION, pos, + "deprecated.annotation.has.no.effect", Kinds.kindName(s)); } } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java index 6cdb8fc7020..15481349fc0 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java @@ -26,6 +26,8 @@ package com.sun.tools.javac.util; import java.util.*; + +import com.sun.tools.javac.code.Source; import com.sun.tools.javac.main.Option; import static com.sun.tools.javac.main.Option.*; @@ -176,7 +178,17 @@ public class Options { // disabled return isSet(XLINT_CUSTOM, s) || - (isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) && + (isSet(XLINT) || isSet(XLINT_CUSTOM, "all") || (s.equals("dep-ann") && depAnnOnByDefault())) && isUnset(XLINT_CUSTOM, "-" + s); } + // where + private boolean depAnnOnByDefault() { + String sourceName = get(Option.SOURCE); + Source source = null; + if (sourceName != null) + source = Source.lookup(sourceName); + if (source == null) + source = Source.DEFAULT; + return source.compareTo(Source.JDK1_9) >= 0; + } } diff --git a/langtools/test/tools/javac/T4994049/DeprecatedYES.out b/langtools/test/tools/javac/T4994049/DeprecatedYES.out index 0750441a39c..3925e16ded9 100644 --- a/langtools/test/tools/javac/T4994049/DeprecatedYES.out +++ b/langtools/test/tools/javac/T4994049/DeprecatedYES.out @@ -1,4 +1,5 @@ -DeprecatedYES.java:18:10: compiler.warn.has.been.deprecated: foo(), A +DeprecatedYES.java:12:10: compiler.warn.missing.deprecated.annotation - compiler.err.warnings.and.werror +DeprecatedYES.java:18:10: compiler.warn.has.been.deprecated: foo(), A 1 error -1 warning +2 warnings diff --git a/langtools/test/tools/javac/danglingDep/DepX.out b/langtools/test/tools/javac/danglingDep/DepX.out index 7260f4c18a3..433e1871b92 100644 --- a/langtools/test/tools/javac/danglingDep/DepX.out +++ b/langtools/test/tools/javac/danglingDep/DepX.out @@ -1,2 +1,4 @@ +DepX.java:38:1: compiler.warn.missing.deprecated.annotation - compiler.note.deprecated.filename: RefX.java - compiler.note.deprecated.recompile +1 warning diff --git a/langtools/test/tools/javac/depDocComment/SuppressDepAnnWithSwitchTest.java b/langtools/test/tools/javac/depDocComment/SuppressDepAnnWithSwitchTest.java new file mode 100644 index 00000000000..dbfc6b55011 --- /dev/null +++ b/langtools/test/tools/javac/depDocComment/SuppressDepAnnWithSwitchTest.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8164073 + * @summary Verify that -Xlint:-dep-ann suppresses warnings. + * @compile -Xlint:-dep-ann -Werror SuppressDepAnnWithSwitchTest.java + */ + +public class SuppressDepAnnWithSwitchTest { + /** @deprecated */ + int f; +} diff --git a/langtools/test/tools/javac/depDocComment/SuppressDeprecation.java b/langtools/test/tools/javac/depDocComment/SuppressDeprecation.java index 4d8849cd579..7968487f129 100644 --- a/langtools/test/tools/javac/depDocComment/SuppressDeprecation.java +++ b/langtools/test/tools/javac/depDocComment/SuppressDeprecation.java @@ -1,10 +1,11 @@ /** * @test /nodynamiccopyright/ - * @bug 4216683 4346296 4656556 4785453 + * @bug 4216683 4346296 4656556 4785453 8164073 * @summary New rules for when deprecation messages are suppressed * @author gafter * * @compile/ref=SuppressDeprecation.out -Xlint:deprecation -XDrawDiagnostics SuppressDeprecation.java + * @compile/ref=SuppressDeprecation8.out -source 8 -Xlint:deprecation -XDrawDiagnostics SuppressDeprecation.java */ /* Test for the contexts in which deprecations warnings should diff --git a/langtools/test/tools/javac/depDocComment/SuppressDeprecation.out b/langtools/test/tools/javac/depDocComment/SuppressDeprecation.out index 4a8b15f33fd..ff1bc124eb0 100644 --- a/langtools/test/tools/javac/depDocComment/SuppressDeprecation.out +++ b/langtools/test/tools/javac/depDocComment/SuppressDeprecation.out @@ -1,8 +1,20 @@ -SuppressDeprecation.java:82:10: compiler.warn.has.been.deprecated: g(), T -SuppressDeprecation.java:83:14: compiler.warn.has.been.deprecated: g(), T -SuppressDeprecation.java:84:9: compiler.warn.has.been.deprecated: var, T -SuppressDeprecation.java:87:9: compiler.warn.has.been.deprecated: T(), T -SuppressDeprecation.java:90:9: compiler.warn.has.been.deprecated: T(int), T -SuppressDeprecation.java:98:1: compiler.warn.has.been.deprecated: T(), T -SuppressDeprecation.java:130:17: compiler.warn.has.been.deprecated: X, compiler.misc.unnamed.package -7 warnings +SuppressDeprecation.java:29:9: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:33:10: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:38:10: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:48:5: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:53:5: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:67:10: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:74:9: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:80:10: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:83:10: compiler.warn.has.been.deprecated: g(), T +SuppressDeprecation.java:84:14: compiler.warn.has.been.deprecated: g(), T +SuppressDeprecation.java:85:9: compiler.warn.has.been.deprecated: var, T +SuppressDeprecation.java:88:9: compiler.warn.has.been.deprecated: T(), T +SuppressDeprecation.java:91:9: compiler.warn.has.been.deprecated: T(int), T +SuppressDeprecation.java:99:1: compiler.warn.has.been.deprecated: T(), T +SuppressDeprecation.java:124:9: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:103:1: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:129:1: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:131:17: compiler.warn.has.been.deprecated: X, compiler.misc.unnamed.package +SuppressDeprecation.java:135:1: compiler.warn.missing.deprecated.annotation +19 warnings diff --git a/langtools/test/tools/javac/depDocComment/SuppressDeprecation8.out b/langtools/test/tools/javac/depDocComment/SuppressDeprecation8.out new file mode 100644 index 00000000000..7a12c45d637 --- /dev/null +++ b/langtools/test/tools/javac/depDocComment/SuppressDeprecation8.out @@ -0,0 +1,9 @@ +- compiler.warn.source.no.bootclasspath: 1.8 +SuppressDeprecation.java:83:10: compiler.warn.has.been.deprecated: g(), T +SuppressDeprecation.java:84:14: compiler.warn.has.been.deprecated: g(), T +SuppressDeprecation.java:85:9: compiler.warn.has.been.deprecated: var, T +SuppressDeprecation.java:88:9: compiler.warn.has.been.deprecated: T(), T +SuppressDeprecation.java:91:9: compiler.warn.has.been.deprecated: T(int), T +SuppressDeprecation.java:99:1: compiler.warn.has.been.deprecated: T(), T +SuppressDeprecation.java:131:17: compiler.warn.has.been.deprecated: X, compiler.misc.unnamed.package +8 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1.java b/langtools/test/tools/javac/depOverrides/doccomment/Test1.java index 563492d4d29..571f1ce02ea 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test1.java +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -26,11 +26,11 @@ * @bug 5086088 * @summary check warnings generated when overriding deprecated methods * - * @compile/ref=empty -XDrawDiagnostics -Xlint:deprecation I.java + * @compile/ref=Test1I.out -XDrawDiagnostics -Xlint:deprecation I.java * @compile/ref=Test1A.out -XDrawDiagnostics -Xlint:deprecation A.java * @compile/ref=Test1B.out -XDrawDiagnostics -Xlint:deprecation B.java * @compile/ref=Test1B2.out -XDrawDiagnostics -Xlint:deprecation B2.java - * @compile/ref=empty -XDrawDiagnostics -Xlint:deprecation B3.java + * @compile/ref=Test1B3.out -XDrawDiagnostics -Xlint:deprecation B3.java * @compile/ref=empty -XDrawDiagnostics -Xlint:deprecation Test1.java */ diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1A.out b/langtools/test/tools/javac/depOverrides/doccomment/Test1A.out index 0cbe50c23ae..ef477945691 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test1A.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1A.out @@ -1,4 +1,10 @@ A.java:13:36: compiler.warn.has.been.deprecated: iDep_aUnd_bInh(), I A.java:12:36: compiler.warn.has.been.deprecated: iDep_aUnd_bUnd(), I A.java:11:36: compiler.warn.has.been.deprecated: iDep_aUnd_bDep(), I -3 warnings +A.java:8:36: compiler.warn.missing.deprecated.annotation +A.java:9:36: compiler.warn.missing.deprecated.annotation +A.java:10:36: compiler.warn.missing.deprecated.annotation +A.java:17:36: compiler.warn.missing.deprecated.annotation +A.java:18:36: compiler.warn.missing.deprecated.annotation +A.java:19:36: compiler.warn.missing.deprecated.annotation +9 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1B.out b/langtools/test/tools/javac/depOverrides/doccomment/Test1B.out index a2681b91475..d59496b2961 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test1B.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1B.out @@ -1,4 +1,10 @@ B.java:15:36: compiler.warn.has.been.deprecated: iDep_aInh_bUnd(), I +B.java:8:36: compiler.warn.missing.deprecated.annotation B.java:9:36: compiler.warn.has.been.deprecated: iDep_aDep_bUnd(), A +B.java:11:36: compiler.warn.missing.deprecated.annotation +B.java:14:36: compiler.warn.missing.deprecated.annotation +B.java:17:36: compiler.warn.missing.deprecated.annotation B.java:18:36: compiler.warn.has.been.deprecated: iUnd_aDep_bUnd(), A -3 warnings +B.java:20:36: compiler.warn.missing.deprecated.annotation +B.java:23:36: compiler.warn.missing.deprecated.annotation +9 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1B2.out b/langtools/test/tools/javac/depOverrides/doccomment/Test1B2.out index 12c51462051..17efd646d1b 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test1B2.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1B2.out @@ -2,6 +2,12 @@ B2.java:15:36: compiler.warn.has.been.deprecated: iDep_aInh_bUnd(), I B2.java:7:10: compiler.warn.has.been.deprecated: iDep_aUnd_bInh(), I B2.java:12:36: compiler.warn.has.been.deprecated: iDep_aUnd_bUnd(), I B2.java:9:36: compiler.warn.has.been.deprecated: iDep_aDep_bUnd(), I +B2.java:8:36: compiler.warn.missing.deprecated.annotation B2.java:9:36: compiler.warn.has.been.deprecated: iDep_aDep_bUnd(), A +B2.java:11:36: compiler.warn.missing.deprecated.annotation +B2.java:14:36: compiler.warn.missing.deprecated.annotation +B2.java:17:36: compiler.warn.missing.deprecated.annotation B2.java:18:36: compiler.warn.has.been.deprecated: iUnd_aDep_bUnd(), A -6 warnings +B2.java:20:36: compiler.warn.missing.deprecated.annotation +B2.java:23:36: compiler.warn.missing.deprecated.annotation +12 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1B3.out b/langtools/test/tools/javac/depOverrides/doccomment/Test1B3.out new file mode 100644 index 00000000000..c1bb87237da --- /dev/null +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1B3.out @@ -0,0 +1,8 @@ +B3.java:32:36: compiler.warn.missing.deprecated.annotation +B3.java:35:36: compiler.warn.missing.deprecated.annotation +B3.java:38:36: compiler.warn.missing.deprecated.annotation +B3.java:41:36: compiler.warn.missing.deprecated.annotation +B3.java:44:36: compiler.warn.missing.deprecated.annotation +B3.java:47:36: compiler.warn.missing.deprecated.annotation +B3.java:31:10: compiler.warn.missing.deprecated.annotation +7 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1I.out b/langtools/test/tools/javac/depOverrides/doccomment/Test1I.out new file mode 100644 index 00000000000..67e135cdd7f --- /dev/null +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1I.out @@ -0,0 +1,9 @@ +I.java:30:36: compiler.warn.missing.deprecated.annotation +I.java:31:36: compiler.warn.missing.deprecated.annotation +I.java:32:36: compiler.warn.missing.deprecated.annotation +I.java:33:36: compiler.warn.missing.deprecated.annotation +I.java:34:36: compiler.warn.missing.deprecated.annotation +I.java:35:36: compiler.warn.missing.deprecated.annotation +I.java:36:36: compiler.warn.missing.deprecated.annotation +I.java:37:36: compiler.warn.missing.deprecated.annotation +8 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test2.java b/langtools/test/tools/javac/depOverrides/doccomment/Test2.java index 6595ca22de3..b4fb656a6aa 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test2.java +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -26,7 +26,7 @@ * @bug 5086088 * @summary check warnings generated when overriding deprecated methods * - * @compile/ref=empty -XDrawDiagnostics -Xlint:deprecation P.java + * @compile/ref=Test2P.out -XDrawDiagnostics -Xlint:deprecation P.java * @compile/ref=Test2Q.out -XDrawDiagnostics -Xlint:deprecation Q.java * @compile/ref=Test2R.out -XDrawDiagnostics -Xlint:deprecation R.java * @compile/ref=empty -XDrawDiagnostics -Xlint:deprecation Test2.java diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test2P.out b/langtools/test/tools/javac/depOverrides/doccomment/Test2P.out new file mode 100644 index 00000000000..89147214dce --- /dev/null +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test2P.out @@ -0,0 +1,10 @@ +P.java:30:36: compiler.warn.missing.deprecated.annotation +P.java:31:36: compiler.warn.missing.deprecated.annotation +P.java:32:36: compiler.warn.missing.deprecated.annotation +P.java:33:36: compiler.warn.missing.deprecated.annotation +P.java:34:36: compiler.warn.missing.deprecated.annotation +P.java:35:36: compiler.warn.missing.deprecated.annotation +P.java:36:36: compiler.warn.missing.deprecated.annotation +P.java:37:36: compiler.warn.missing.deprecated.annotation +P.java:38:36: compiler.warn.missing.deprecated.annotation +9 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test2Q.out b/langtools/test/tools/javac/depOverrides/doccomment/Test2Q.out index 3b6f8c487ac..f092f2f4c88 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test2Q.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test2Q.out @@ -1,4 +1,10 @@ +Q.java:8:36: compiler.warn.missing.deprecated.annotation +Q.java:9:36: compiler.warn.missing.deprecated.annotation +Q.java:10:36: compiler.warn.missing.deprecated.annotation Q.java:11:36: compiler.warn.has.been.deprecated: pDep_qUnd_rDep(), P Q.java:12:36: compiler.warn.has.been.deprecated: pDep_qUnd_rUnd(), P Q.java:13:36: compiler.warn.has.been.deprecated: pDep_qUnd_rInh(), P -3 warnings +Q.java:17:36: compiler.warn.missing.deprecated.annotation +Q.java:18:36: compiler.warn.missing.deprecated.annotation +Q.java:19:36: compiler.warn.missing.deprecated.annotation +9 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test2R.out b/langtools/test/tools/javac/depOverrides/doccomment/Test2R.out index 181c583fd82..d3f30728086 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test2R.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test2R.out @@ -1,4 +1,10 @@ +R.java:8:36: compiler.warn.missing.deprecated.annotation R.java:9:36: compiler.warn.has.been.deprecated: pDep_qDep_rUnd(), Q +R.java:11:36: compiler.warn.missing.deprecated.annotation +R.java:14:36: compiler.warn.missing.deprecated.annotation R.java:15:36: compiler.warn.has.been.deprecated: pDep_qInh_rUnd(), P +R.java:17:36: compiler.warn.missing.deprecated.annotation R.java:18:36: compiler.warn.has.been.deprecated: pUnd_qDep_rUnd(), Q -3 warnings +R.java:20:36: compiler.warn.missing.deprecated.annotation +R.java:23:36: compiler.warn.missing.deprecated.annotation +9 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test3.out b/langtools/test/tools/javac/depOverrides/doccomment/Test3.out index 6d939718fb5..491828e5247 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test3.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test3.out @@ -1,2 +1,3 @@ +Test3.java:11:14: compiler.warn.missing.deprecated.annotation Test3.java:18:1: compiler.warn.has.been.deprecated: m(), LibInterface -1 warning +2 warnings diff --git a/langtools/test/tools/javac/lint/Deprecation.out b/langtools/test/tools/javac/lint/Deprecation.out index c16983bc6c1..9ddc2dab48a 100644 --- a/langtools/test/tools/javac/lint/Deprecation.out +++ b/langtools/test/tools/javac/lint/Deprecation.out @@ -1,4 +1,5 @@ -Deprecation.java:14:17: compiler.warn.has.been.deprecated: A, compiler.misc.unnamed.package +Deprecation.java:11:1: compiler.warn.missing.deprecated.annotation - compiler.err.warnings.and.werror +Deprecation.java:14:17: compiler.warn.has.been.deprecated: A, compiler.misc.unnamed.package 1 error -1 warning +2 warnings From 84ec8b74f97ad4124334adc7253ce57baa3854e3 Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Fri, 2 Sep 2016 10:31:49 +0300 Subject: [PATCH 130/296] 8164937: Remove code from SortingFocusTraversalPolicy that hacks into non-public Arrays.legacyMergeSort Reviewed-by: alexsch, serb --- .../swing/SortingFocusTraversalPolicy.java | 98 +++++++++++-------- .../java/awt/Focus/SortingFPT/JDK8048887.java | 4 +- 2 files changed, 59 insertions(+), 43 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java b/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java index 9057e80faad..d7f1ebcf034 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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 @@ -26,15 +26,11 @@ package javax.swing; import java.awt.Component; import java.awt.Container; -import java.awt.Window; import java.util.*; import java.awt.FocusTraversalPolicy; import sun.util.logging.PlatformLogger; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import sun.security.action.GetPropertyAction; import java.security.AccessController; -import java.security.PrivilegedAction; /** * A FocusTraversalPolicy that determines traversal order by sorting the @@ -100,27 +96,10 @@ public class SortingFocusTraversalPolicy * See: JDK-8048887 */ private static final boolean legacySortingFTPEnabled; - private static final Method legacyMergeSortMethod; static { legacySortingFTPEnabled = "true".equals(AccessController.doPrivileged( new GetPropertyAction("swing.legacySortingFTPEnabled", "true"))); - legacyMergeSortMethod = legacySortingFTPEnabled ? - AccessController.doPrivileged(new PrivilegedAction() { - public Method run() { - try { - Method m = java.util.Arrays.class.getDeclaredMethod("legacyMergeSort", - new Class[]{Object[].class, - Comparator.class}); - m.setAccessible(true); - return m; - } catch (NoSuchMethodException e) { - // using default sorting algo - return null; - } - } - }) : - null; } /** @@ -169,30 +148,25 @@ public class SortingFocusTraversalPolicy private void enumerateAndSortCycle(Container focusCycleRoot, List cycle) { if (focusCycleRoot.isShowing()) { enumerateCycle(focusCycleRoot, cycle); - if (!legacySortingFTPEnabled || - !legacySort(cycle, comparator)) - { - Collections.sort(cycle, comparator); + if (legacySortingFTPEnabled) { + legacySort(cycle, comparator); + } else { + cycle.sort(comparator); } } } - private boolean legacySort(List l, Comparator c) { - if (legacyMergeSortMethod == null) - return false; - - Object[] a = l.toArray(); - try { - legacyMergeSortMethod.invoke(null, a, c); - } catch (IllegalAccessException | InvocationTargetException e) { - return false; + private void legacySort(List l, + Comparator c) { + if (c != null && l.size() > 1) { + Component[] a = l.toArray(new Component[l.size()]); + mergeSort(a.clone(), a, 0, a.length, 0, c); + ListIterator i = l.listIterator(); + for (Component e : a) { + i.next(); + i.set(e); + } } - ListIterator i = l.listIterator(); - for (Object e : a) { - i.next(); - i.set((Component)e); - } - return true; } @SuppressWarnings("deprecation") @@ -665,6 +639,48 @@ public class SortingFocusTraversalPolicy protected boolean accept(Component aComponent) { return fitnessTestPolicy.accept(aComponent); } + + // merge sort implementation copied from java.utils.Arrays + private void mergeSort(T[] src, T[] dest, + int low, int high, int off, + Comparator c) { + int length = high - low; + + // Insertion sort on smallest arrays + if (length < 7) { + for (int i=low; ilow && c.compare(dest[j-1], dest[j])>0; j--) { + T t = dest[j]; + dest[j] = dest[j-1]; + dest[j-1] = t; + } + return; + } + + // Recursively sort halves of dest into src + int destLow = low; + int destHigh = high; + low += off; + high += off; + int mid = (low + high) >>> 1; + mergeSort(dest, src, low, mid, -off, c); + mergeSort(dest, src, mid, high, -off, c); + + // If list is already sorted, just copy from src to dest. This is an + // optimization that results in faster sorts for nearly ordered lists. + if (c.compare(src[mid-1], src[mid]) <= 0) { + System.arraycopy(src, low, dest, destLow, length); + return; + } + + // Merge sorted halves (now in src) into dest + for(int i = destLow, p = low, q = mid; i < destHigh; i++) { + if (q >= high || p < mid && c.compare(src[p], src[q]) <= 0) + dest[i] = src[p++]; + else + dest[i] = src[q++]; + } + } } // Create our own subclass and change accept to public so that we can call diff --git a/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java b/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java index 01287068e8c..2cd3bdcd2ea 100644 --- a/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java +++ b/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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,7 @@ /* @test - @bug 8048887 + @bug 8048887 8164937 @summary Tests SortingFTP for an exception caused by the tim-sort algo. @author anton.tarasov: area=awt.focus @run main JDK8048887 From c8c8826688901830952e05f388b01897dd0f19c5 Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Fri, 2 Sep 2016 10:36:55 +0300 Subject: [PATCH 131/296] 8163100: [hidpi] Linux: display-wise scaling factor issues Reviewed-by: alexsch, serb --- jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java | 4 ++++ .../java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java | 3 ++- .../unix/native/common/awt/systemscale/systemScale.c | 2 +- .../unix/native/libawt_xawt/awt/awt_GraphicsEnv.c | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java index be362ae0781..77514760937 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java @@ -1570,6 +1570,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable { Integer.valueOf(getMultiClickTime())); desktopProperties.put("awt.mouse.numButtons", Integer.valueOf(getNumberOfButtons())); + if(SunGraphicsEnvironment.isUIScaleEnabled()) { + addPropertyChangeListener("gnome.Xft/DPI", evt -> + localEnv.displayChanged()); + } } } diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java index 0f81f4e911f..346622e9e09 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java @@ -63,7 +63,7 @@ public final class X11GraphicsDevice extends GraphicsDevice private SunDisplayChanger topLevels = new SunDisplayChanger(); private DisplayMode origDisplayMode; private boolean shutdownHookRegistered; - private final int scale; + private int scale; public X11GraphicsDevice(int screennum) { this.screen = screennum; @@ -488,6 +488,7 @@ public final class X11GraphicsDevice extends GraphicsDevice * X11GraphicsEnvironment when the display mode has been changed. */ public synchronized void displayChanged() { + scale = initScaleFactor(); // On X11 the visuals do not change, and therefore we don't need // to reset the defaultConfig, config, doubleBufferVisuals, // neither do we need to reset the native data. diff --git a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c index c8a5810370f..f7bea414e63 100644 --- a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c +++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c @@ -148,7 +148,7 @@ static double getDesktopScale(char *output_name) { void *scale = fp_g_variant_get_child_value(entry, 1); if (screen && scale) { char *name = fp_g_variant_get_string(screen, NULL); - if (name && strcmp(name, output_name)) { + if (name && !strcmp(name, output_name)) { result = fp_g_variant_get_int32(scale) / 8.; } fp_g_variant_unref(screen); diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c index 8339a195828..c1895cd29d7 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c @@ -2181,7 +2181,8 @@ static char *get_output_screen_name(JNIEnv *env, int screen) { JNIEXPORT jdouble JNICALL Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor (JNIEnv *env, jobject this, jint screen) { - char *name = get_output_screen_name(env, screen); + // in case of Xinerama individual screen scales are not supported + char *name = get_output_screen_name(env, usingXinerama ? 0 : screen); double scale = getNativeScaleFactor(name); if (name) { free(name); From 7e27dd569e6edfad3fd673cf0b820b9e0e3a45b2 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Fri, 2 Sep 2016 05:43:54 -0700 Subject: [PATCH 132/296] 8160454: JSR269 jigsaw update: javax.lang.model.element.ModuleElement.getDirectives() causes NPE on unnamed modules Reviewed-by: jjg --- .../com/sun/tools/javac/code/Symbol.java | 5 -- .../com/sun/tools/javac/code/Symtab.java | 12 ++++ .../T8160454/NPEGetDirectivesTest.java | 70 +++++++++++++++++++ 3 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 langtools/test/tools/javac/modules/T8160454/NPEGetDirectivesTest.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java index 8757939f626..d99fbeee26e 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java @@ -928,11 +928,6 @@ public abstract class Symbol extends AnnoConstruct implements Element { return msym; } - public ModuleSymbol() { - super(MDL, 0, null, null, null); - this.type = new ModuleType(this); - } - public ModuleSymbol(Name name, Symbol owner) { super(MDL, 0, name, null, owner); this.type = new ModuleType(this); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java index 034ffda0ad0..339fe486bea 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java @@ -27,6 +27,7 @@ package com.sun.tools.javac.code; import java.util.Collection; import java.util.Collections; +import java.util.EnumSet; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -363,6 +364,17 @@ public class Symtab { // create the basic builtin symbols unnamedModule = new ModuleSymbol(names.empty, null) { + { + directives = List.nil(); + exports = List.nil(); + provides = List.nil(); + uses = List.nil(); + ModuleSymbol java_base = enterModule(names.java_base); + com.sun.tools.javac.code.Directive.RequiresDirective d = + new com.sun.tools.javac.code.Directive.RequiresDirective(java_base, + EnumSet.of(com.sun.tools.javac.code.Directive.RequiresFlag.MANDATED)); + requires = List.of(d); + } @Override public String toString() { return messages.getLocalizedString("compiler.misc.unnamed.module"); diff --git a/langtools/test/tools/javac/modules/T8160454/NPEGetDirectivesTest.java b/langtools/test/tools/javac/modules/T8160454/NPEGetDirectivesTest.java new file mode 100644 index 00000000000..a2538834943 --- /dev/null +++ b/langtools/test/tools/javac/modules/T8160454/NPEGetDirectivesTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8160454 + * @summary JSR269 jigsaw update: javax.lang.model.element.ModuleElement.getDirectives() causes NPE on unnamed modules + * @modules + * jdk.compiler/com.sun.tools.javac.code + * jdk.compiler/com.sun.tools.javac.util + * @compile NPEGetDirectivesTest.java + * @compile -processor NPEGetDirectivesTest NPEGetDirectivesTest.java + */ + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.*; + +import java.util.Set; + +import com.sun.tools.javac.code.Directive.RequiresDirective; +import com.sun.tools.javac.code.Symbol.ModuleSymbol; +import com.sun.tools.javac.util.Assert; + +import static com.sun.tools.javac.code.Directive.RequiresFlag.MANDATED; + +@SupportedAnnotationTypes("*") +public class NPEGetDirectivesTest extends AbstractProcessor { + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + for (Element e: roundEnv.getRootElements()) { + Element m = e.getEnclosingElement(); + while (!(m instanceof ModuleElement)) { + m = m.getEnclosingElement(); + } + ((ModuleSymbol)m).getDirectives(); + RequiresDirective requiresDirective = ((ModuleSymbol)m).requires.head; + Assert.check(requiresDirective.getDependency().getQualifiedName().toString().equals("java.base")); + Assert.check(requiresDirective.flags.contains(MANDATED)); + } + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } +} From c271d835997242aede1f5a023034a0b7fe69ca37 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Wed, 7 Sep 2016 09:20:10 +0200 Subject: [PATCH 133/296] 8165292: The gc+task logging is repeated a lot, decreasing the usefulness of -Xlog:gc*=info Separate number of workers used debugging information from adaptive worker sizing log messages. Reviewed-by: ehelin, sjohanss, jmasa --- .../gc/cms/concurrentMarkSweepGeneration.cpp | 1 + .../src/share/vm/gc/cms/parNewGeneration.cpp | 2 + .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 2 + .../src/share/vm/gc/g1/g1ConcurrentMark.cpp | 2 + hotspot/src/share/vm/gc/shared/workgroup.hpp | 2 +- hotspot/test/gc/TestNumWorkerOutput.java | 103 ++++++++++++++++++ 6 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 hotspot/test/gc/TestNumWorkerOutput.java diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp index 6d78865ac43..2a1be1af777 100644 --- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp @@ -3511,6 +3511,7 @@ bool CMSCollector::do_marking_mt() { conc_workers()->active_workers(), Threads::number_of_non_daemon_threads()); num_workers = conc_workers()->update_active_workers(num_workers); + log_info(gc,task)("Using %u workers of %u for marking", num_workers, conc_workers()->total_workers()); CompactibleFreeListSpace* cms_space = _cmsGen->cmsSpace(); diff --git a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp index e8f606eecc8..ddc80ce3a76 100644 --- a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp +++ b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp @@ -899,6 +899,8 @@ void ParNewGeneration::collect(bool full, workers->active_workers(), Threads::number_of_non_daemon_threads()); active_workers = workers->update_active_workers(active_workers); + log_info(gc,task)("Using %u workers of %u for evacuation", active_workers, workers->total_workers()); + _old_gen = gch->old_gen(); // If the next generation is too full to accommodate worst-case promotion diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index 7b6974c4f58..4543ee3e021 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -1332,6 +1332,7 @@ bool G1CollectedHeap::do_full_collection(bool explicit_gc, workers()->active_workers(), Threads::number_of_non_daemon_threads()); workers()->update_active_workers(n_workers); + log_info(gc,task)("Using %u workers of %u to rebuild remembered set", n_workers, workers()->total_workers()); ParRebuildRSTask rebuild_rs_task(this); workers()->run_task(&rebuild_rs_task); @@ -3068,6 +3069,7 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { workers()->active_workers(), Threads::number_of_non_daemon_threads()); workers()->update_active_workers(active_workers); + log_info(gc,task)("Using %u workers of %u for evacuation", active_workers, workers()->total_workers()); TraceCollectorStats tcs(g1mm()->incremental_collection_counters()); TraceMemoryManagerStats tms(false /* fullGC */, gc_cause()); diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index 27f4071b7bf..2f14e088f3f 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -1035,6 +1035,8 @@ void G1ConcurrentMark::mark_from_roots() { // worker threads may currently exist and more may not be // available. active_workers = _parallel_workers->update_active_workers(active_workers); + log_info(gc, task)("Using %u workers of %u for marking", active_workers, _parallel_workers->total_workers()); + // Parallel task terminator is set in "set_concurrency_and_phase()" set_concurrency_and_phase(active_workers, true /* concurrent */); diff --git a/hotspot/src/share/vm/gc/shared/workgroup.hpp b/hotspot/src/share/vm/gc/shared/workgroup.hpp index 00eb705f683..20491b66536 100644 --- a/hotspot/src/share/vm/gc/shared/workgroup.hpp +++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp @@ -162,7 +162,7 @@ class AbstractWorkGang : public CHeapObj { _active_workers = MIN2(v, _total_workers); add_workers(false /* exit_on_failure */); assert(v != 0, "Trying to set active workers to 0"); - log_info(gc, task)("GC Workers: using %d out of %d", _active_workers, _total_workers); + log_trace(gc, task)("%s: using %d out of %d workers", name(), _active_workers, _total_workers); return _active_workers; } diff --git a/hotspot/test/gc/TestNumWorkerOutput.java b/hotspot/test/gc/TestNumWorkerOutput.java new file mode 100644 index 00000000000..0f69bd7fd81 --- /dev/null +++ b/hotspot/test/gc/TestNumWorkerOutput.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test TestNumWorkerOutput + * @bug 8165292 + * @summary Check that when PrintGCDetails is enabled, gc,task output is printed only once per collection. + * @key gc + * @requires vm.gc=="null" + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -XX:+UseConcMarkSweepGC TestNumWorkerOutput UseConcMarkSweepGC + * @run main/othervm -XX:+UseG1GC TestNumWorkerOutput UseG1GC + */ + +import sun.hotspot.WhiteBox; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jdk.test.lib.Platform; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import static jdk.test.lib.Asserts.*; + +public class TestNumWorkerOutput { + + public static void checkPatternOnce(String pattern, String what) throws Exception { + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(what); + + if (!m.find()) { + throw new RuntimeException("Could not find pattern " + pattern + " in output"); + } + if (m.find()) { + throw new RuntimeException("Could find pattern " + pattern + " in output more than once"); + } + } + + public static void runTest(String gcArg) throws Exception { + final String[] arguments = { + "-Xbootclasspath/a:.", + "-XX:+UnlockExperimentalVMOptions", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:+" + gcArg, + "-Xmx10M", + "-XX:+PrintGCDetails", + GCTest.class.getName() + }; + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + output.shouldHaveExitValue(0); + + System.out.println(output.getStdout()); + + String stdout = output.getStdout(); + + checkPatternOnce(".*[info.*].*[gc,task.*].*GC\\(0\\) .*Using \\d+ workers of \\d+ for evacuation.*", stdout); + } + + public static void main(String[] args) throws Exception { + runTest(args[0]); + } + + static class GCTest { + private static final WhiteBox WB = WhiteBox.getWhiteBox(); + + public static Object holder; + + public static void main(String [] args) { + holder = new byte[100]; + WB.youngGC(); + System.out.println(holder); + } + } +} + From e8e6415b7a526f6b3fd53e3b94a29b5169d6a2bf Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 7 Sep 2016 07:19:48 -0400 Subject: [PATCH 134/296] 8058575: IllegalAccessError trying to access package-private class from VM anonymous class Put anonymous classes in unnamed package into host class's package. Throw exception if host class's package differs from anonymous class. Reviewed-by: coleenp, acorn --- .../share/vm/classfile/classFileParser.cpp | 62 +++++++- .../share/vm/classfile/classFileParser.hpp | 9 +- .../src/share/vm/classfile/klassFactory.cpp | 2 +- .../src/share/vm/classfile/klassFactory.hpp | 2 +- .../share/vm/classfile/systemDictionary.cpp | 2 +- .../share/vm/classfile/systemDictionary.hpp | 2 +- hotspot/src/share/vm/classfile/verifier.cpp | 2 +- hotspot/src/share/vm/oops/instanceKlass.hpp | 14 +- hotspot/src/share/vm/prims/unsafe.cpp | 13 +- hotspot/src/share/vm/runtime/reflection.cpp | 10 +- .../jsr292/CallSiteDepContextTest.java | 14 +- .../runtime/defineAnonClass/DefineAnon.java | 134 ++++++++++++++++++ .../runtime/defineAnonClass/NestedUnsafe.java | 91 ++++++++++++ .../defineAnonClass/NestedUnsafe2.java | 90 ++++++++++++ 14 files changed, 416 insertions(+), 31 deletions(-) create mode 100644 hotspot/test/runtime/defineAnonClass/DefineAnon.java create mode 100644 hotspot/test/runtime/defineAnonClass/NestedUnsafe.java create mode 100644 hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index a08af5587bc..5f0b1ca442a 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -5407,6 +5407,59 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa debug_only(ik->verify();) } +// For an anonymous class that is in the unnamed package, move it to its host class's +// package by prepending its host class's package name to its class name and setting +// its _class_name field. +void ClassFileParser::prepend_host_package_name(const InstanceKlass* host_klass, TRAPS) { + ResourceMark rm(THREAD); + assert(strrchr(_class_name->as_C_string(), '/') == NULL, + "Anonymous class should not be in a package"); + const char* host_pkg_name = + ClassLoader::package_from_name(host_klass->name()->as_C_string(), NULL); + + if (host_pkg_name != NULL) { + size_t host_pkg_len = strlen(host_pkg_name); + int class_name_len = _class_name->utf8_length(); + char* new_anon_name = + NEW_RESOURCE_ARRAY(char, host_pkg_len + 1 + class_name_len); + // Copy host package name and trailing /. + strncpy(new_anon_name, host_pkg_name, host_pkg_len); + new_anon_name[host_pkg_len] = '/'; + // Append anonymous class name. The anonymous class name can contain odd + // characters. So, do a strncpy instead of using sprintf("%s..."). + strncpy(new_anon_name + host_pkg_len + 1, (char *)_class_name->base(), class_name_len); + + // Create a symbol and update the anonymous class name. + _class_name = SymbolTable::new_symbol(new_anon_name, + (int)host_pkg_len + 1 + class_name_len, + CHECK); + } +} + +// If the host class and the anonymous class are in the same package then do +// nothing. If the anonymous class is in the unnamed package then move it to its +// host's package. If the classes are in different packages then throw an IAE +// exception. +void ClassFileParser::fix_anonymous_class_name(TRAPS) { + assert(_host_klass != NULL, "Expected an anonymous class"); + + const jbyte* anon_last_slash = UTF8::strrchr(_class_name->base(), + _class_name->utf8_length(), '/'); + if (anon_last_slash == NULL) { // Unnamed package + prepend_host_package_name(_host_klass, CHECK); + } else { + if (!InstanceKlass::is_same_class_package(_host_klass->class_loader(), + _host_klass->name(), + _host_klass->class_loader(), + _class_name)) { + ResourceMark rm(THREAD); + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + err_msg("Host class %s and anonymous class %s are in different packages", + _host_klass->name()->as_C_string(), _class_name->as_C_string())); + } + } +} + static bool relax_format_check_for(ClassLoaderData* loader_data) { bool trusted = (loader_data->is_the_null_class_loader_data() || SystemDictionary::is_platform_class_loader(loader_data->class_loader())); @@ -5422,7 +5475,7 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, Publicity pub_level, TRAPS) : @@ -5697,6 +5750,13 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, return; } + // if this is an anonymous class fix up its name if it's in the unnamed + // package. Otherwise, throw IAE if it is in a different package than + // its host class. + if (_host_klass != NULL) { + fix_anonymous_class_name(CHECK); + } + // Verification prevents us from creating names with dots in them, this // asserts that that's the case. assert(is_internal_format(_class_name), "external class name format used internally"); diff --git a/hotspot/src/share/vm/classfile/classFileParser.hpp b/hotspot/src/share/vm/classfile/classFileParser.hpp index 4b6287588c3..8cc820a450a 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.hpp +++ b/hotspot/src/share/vm/classfile/classFileParser.hpp @@ -79,7 +79,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { const Symbol* _requested_name; Symbol* _class_name; mutable ClassLoaderData* _loader_data; - const Klass* _host_klass; + const InstanceKlass* _host_klass; GrowableArray* _cp_patches; // overrides for CP entries // Metadata created before the instance klass is created. Must be deallocated @@ -155,6 +155,9 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { ConstantPool* cp, TRAPS); + void prepend_host_package_name(const InstanceKlass* host_klass, TRAPS); + void fix_anonymous_class_name(TRAPS); + void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH, TRAPS); void set_klass(InstanceKlass* instance); @@ -474,7 +477,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, Publicity pub_level, TRAPS); @@ -500,7 +503,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { bool is_anonymous() const { return _host_klass != NULL; } bool is_interface() const { return _access_flags.is_interface(); } - const Klass* host_klass() const { return _host_klass; } + const InstanceKlass* host_klass() const { return _host_klass; } const GrowableArray* cp_patches() const { return _cp_patches; } ClassLoaderData* loader_data() const { return _loader_data; } const Symbol* class_name() const { return _class_name; } diff --git a/hotspot/src/share/vm/classfile/klassFactory.cpp b/hotspot/src/share/vm/classfile/klassFactory.cpp index 4d08ea3329c..dc5f3963d1a 100644 --- a/hotspot/src/share/vm/classfile/klassFactory.cpp +++ b/hotspot/src/share/vm/classfile/klassFactory.cpp @@ -94,7 +94,7 @@ instanceKlassHandle KlassFactory::create_from_stream(ClassFileStream* stream, Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, TRAPS) { diff --git a/hotspot/src/share/vm/classfile/klassFactory.hpp b/hotspot/src/share/vm/classfile/klassFactory.hpp index 6783f2753a3..72dcc0dd6e4 100644 --- a/hotspot/src/share/vm/classfile/klassFactory.hpp +++ b/hotspot/src/share/vm/classfile/klassFactory.hpp @@ -72,7 +72,7 @@ class KlassFactory : AllStatic { Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, TRAPS); }; diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 70f9e6a169f..f3b667eaf43 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -1027,7 +1027,7 @@ Klass* SystemDictionary::parse_stream(Symbol* class_name, Handle class_loader, Handle protection_domain, ClassFileStream* st, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, TRAPS) { diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index 6dd7d20e456..bf10995a578 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -299,7 +299,7 @@ public: Handle class_loader, Handle protection_domain, ClassFileStream* st, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, TRAPS); diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp index 440257b9e79..ba58b175305 100644 --- a/hotspot/src/share/vm/classfile/verifier.cpp +++ b/hotspot/src/share/vm/classfile/verifier.cpp @@ -2786,7 +2786,7 @@ void ClassVerifier::verify_invoke_instructions( // direct interface relative to the host class have_imr_indirect = (have_imr_indirect && !is_same_or_direct_interface( - InstanceKlass::cast(current_class()->host_klass()), + current_class()->host_klass(), host_klass_type, ref_class_type)); } if (!subtype) { diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index da36a1422b4..e4eb9b3e4fe 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -619,8 +619,8 @@ class InstanceKlass: public Klass { objArrayOop signers() const; // host class - Klass* host_klass() const { - Klass** hk = (Klass**)adr_host_klass(); + InstanceKlass* host_klass() const { + InstanceKlass** hk = adr_host_klass(); if (hk == NULL) { return NULL; } else { @@ -628,9 +628,9 @@ class InstanceKlass: public Klass { return *hk; } } - void set_host_klass(const Klass* host) { + void set_host_klass(const InstanceKlass* host) { assert(is_anonymous(), "not anonymous"); - const Klass** addr = (const Klass**)adr_host_klass(); + const InstanceKlass** addr = (const InstanceKlass **)adr_host_klass(); assert(addr != NULL, "no reversed space"); if (addr != NULL) { *addr = host; @@ -1057,13 +1057,13 @@ public: } }; - Klass** adr_host_klass() const { + InstanceKlass** adr_host_klass() const { if (is_anonymous()) { - Klass** adr_impl = adr_implementor(); + InstanceKlass** adr_impl = (InstanceKlass **)adr_implementor(); if (adr_impl != NULL) { return adr_impl + 1; } else { - return end_of_nonstatic_oop_maps(); + return (InstanceKlass **)end_of_nonstatic_oop_maps(); } } else { return NULL; diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 2d836ccc160..cdcdc7d80ee 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -783,6 +783,7 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na // define a class but do not make it known to the class loader or system dictionary // - host_class: supplies context for linkage, access control, protection domain, and class loader +// if host_class is itself anonymous then it is replaced with its host class. // - data: bytes of a class file, a raw memory address (length gives the number of bytes) // - cp_patches: where non-null entries exist, they replace corresponding CP entries in data @@ -791,8 +792,12 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na // link to any member of U. Just after U is loaded, the only way to use it is reflectively, // through java.lang.Class methods like Class.newInstance. +// The package of an anonymous class must either match its host's class's package or be in the +// unnamed package. If it is in the unnamed package then it will be put in its host class's +// package. +// + // Access checks for linkage sites within U continue to follow the same rules as for named classes. -// The package of an anonymous class is given by the package qualifier on the name under which it was loaded. // An anonymous class also has special privileges to access any member of its host class. // This is the main reason why this loading operation is unsafe. The purpose of this is to // allow language implementations to simulate "open classes"; a host class in effect gets @@ -874,9 +879,11 @@ Unsafe_DefineAnonymousClass_impl(JNIEnv *env, // Primitive types have NULL Klass* fields in their java.lang.Class instances. if (host_klass == NULL) { - THROW_0(vmSymbols::java_lang_IllegalArgumentException()); + THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Host class is null"); } + assert(host_klass->is_instance_klass(), "Host class must be an instance class"); + const char* host_source = host_klass->external_name(); Handle host_loader(THREAD, host_klass->class_loader()); Handle host_domain(THREAD, host_klass->protection_domain()); @@ -907,7 +914,7 @@ Unsafe_DefineAnonymousClass_impl(JNIEnv *env, host_loader, host_domain, &st, - host_klass, + InstanceKlass::cast(host_klass), cp_patches, CHECK_NULL); if (anonk == NULL) { diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp index ae574a4edbf..b2fc1018828 100644 --- a/hotspot/src/share/vm/runtime/reflection.cpp +++ b/hotspot/src/share/vm/runtime/reflection.cpp @@ -412,13 +412,13 @@ oop Reflection::array_component_type(oop mirror, TRAPS) { return result; } -static bool under_host_klass(const InstanceKlass* ik, const Klass* host_klass) { +static bool under_host_klass(const InstanceKlass* ik, const InstanceKlass* host_klass) { DEBUG_ONLY(int inf_loop_check = 1000 * 1000 * 1000); for (;;) { - const Klass* hc = (const Klass*)ik->host_klass(); + const InstanceKlass* hc = ik->host_klass(); if (hc == NULL) return false; if (hc == host_klass) return true; - ik = InstanceKlass::cast(hc); + ik = hc; // There's no way to make a host class loop short of patching memory. // Therefore there cannot be a loop here unless there's another bug. @@ -436,8 +436,8 @@ static bool can_relax_access_check_for(const Klass* accessor, // If either is on the other's host_klass chain, access is OK, // because one is inside the other. - if (under_host_klass(accessor_ik, accessee) || - under_host_klass(accessee_ik, accessor)) + if (under_host_klass(accessor_ik, accessee_ik) || + under_host_klass(accessee_ik, accessor_ik)) return true; if ((RelaxAccessControlCheck && diff --git a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java index 80650b97136..cc672bc124d 100644 --- a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java +++ b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java @@ -62,7 +62,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.IRETURN; public class CallSiteDepContextTest { static final Unsafe UNSAFE = Unsafe.getUnsafe(); static final MethodHandles.Lookup LOOKUP = MethodHandleHelper.IMPL_LOOKUP; - static final String CLASS_NAME = "java/lang/invoke/Test"; + static final String CLASS_NAME = "compiler/jsr292/Test"; static final String METHOD_NAME = "m"; static final MethodType TYPE = MethodType.methodType(int.class); @@ -129,8 +129,8 @@ public class CallSiteDepContextTest { } public static void testSharedCallSite() throws Throwable { - Class cls1 = UNSAFE.defineAnonymousClass(Object.class, getClassFile("CS_1"), null); - Class cls2 = UNSAFE.defineAnonymousClass(Object.class, getClassFile("CS_2"), null); + Class cls1 = UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("CS_1"), null); + Class cls2 = UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("CS_2"), null); MethodHandle[] mhs = new MethodHandle[] { LOOKUP.findStatic(cls1, METHOD_NAME, TYPE), @@ -151,7 +151,7 @@ public class CallSiteDepContextTest { execute(1, mh); // mcs.context == cls1 - Class cls1 = UNSAFE.defineAnonymousClass(Object.class, getClassFile("NonBound_1"), null); + Class cls1 = UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("NonBound_1"), null); MethodHandle mh1 = LOOKUP.findStatic(cls1, METHOD_NAME, TYPE); execute(1, mh1); @@ -170,8 +170,8 @@ public class CallSiteDepContextTest { mcs = new MutableCallSite(LOOKUP.findStatic(T.class, "f1", TYPE)); Class[] cls = new Class[] { - UNSAFE.defineAnonymousClass(Object.class, getClassFile("GC_1" + id), null), - UNSAFE.defineAnonymousClass(Object.class, getClassFile("GC_2" + id), null), + UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("GC_1" + id), null), + UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("GC_2" + id), null), }; MethodHandle[] mhs = new MethodHandle[] { @@ -185,7 +185,7 @@ public class CallSiteDepContextTest { execute(1, mhs); ref = new PhantomReference<>(cls[0], rq); - cls[0] = UNSAFE.defineAnonymousClass(Object.class, getClassFile("GC_3" + id), null); + cls[0] = UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("GC_3" + id), null); mhs[0] = LOOKUP.findStatic(cls[0], METHOD_NAME, TYPE); do { diff --git a/hotspot/test/runtime/defineAnonClass/DefineAnon.java b/hotspot/test/runtime/defineAnonClass/DefineAnon.java new file mode 100644 index 00000000000..f73b20dfc5f --- /dev/null +++ b/hotspot/test/runtime/defineAnonClass/DefineAnon.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test DefineAnon + * @bug 8058575 + * @library /testlibrary + * @modules java.base/jdk.internal.org.objectweb.asm + * java.management + * @compile -XDignore.symbol.file=true DefineAnon.java + * @run main/othervm p1.DefineAnon + */ + +package p1; + +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import sun.misc.Unsafe; + + +class T { + static protected void test0() { System.out.println("test0 (public)"); } + static protected void test1() { System.out.println("test1 (protected)"); } + static /*package-private*/ void test2() { System.out.println("test2 (package)"); } + static private void test3() { System.out.println("test3 (private)"); } +} + +public class DefineAnon { + + private static Unsafe getUnsafe() { + try { + java.lang.reflect.Field singleoneInstanceField = Unsafe.class.getDeclaredField("theUnsafe"); + singleoneInstanceField.setAccessible(true); + return (Unsafe) singleoneInstanceField.get(null); + } catch (Throwable ex) { + throw new RuntimeException("Was unable to get Unsafe instance."); + } + } + + static Unsafe UNSAFE = DefineAnon.getUnsafe(); + + static Class getAnonClass(Class hostClass, final String className) { + final String superName = "java/lang/Object"; + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); + cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, superName, null); + + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC, "test", "()V", null, null); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test0", "()V", false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test1", "()V", false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test2", "()V", false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test3", "()V", false); + mv.visitInsn(Opcodes.RETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + + final byte[] classBytes = cw.toByteArray(); + Class invokerClass = UNSAFE.defineAnonymousClass(hostClass, classBytes, new Object[0]); + UNSAFE.ensureClassInitialized(invokerClass); + return invokerClass; + } + + public static void main(String[] args) throws Throwable { + Throwable fail = null; + + // Anonymous class has the privileges of its host class, so test[0123] should all work. + System.out.println("Injecting from the same package (p1):"); + Class p1cls = getAnonClass(T.class, "p1/AnonClass"); + try { + p1cls.getMethod("test").invoke(null); + } catch (Throwable ex) { + ex.printStackTrace(); + fail = ex; // throw this to make test fail, since subtest failed + } + + // Anonymous class has different package name from host class. Should throw + // IllegalArgumentException. + System.out.println("Injecting from the wrong package (p2):"); + try { + Class p2cls = getAnonClass(DefineAnon.class, "p2/AnonClass"); + p2cls.getMethod("test").invoke(null); + System.out.println("Failed, did not get expected IllegalArgumentException"); + } catch (java.lang.IllegalArgumentException e) { + if (e.getMessage().contains("Host class p1/DefineAnon and anonymous class p2/AnonClass")) { + System.out.println("Got expected IllegalArgumentException: " + e.getMessage()); + } else { + throw new RuntimeException("Unexpected message: " + e.getMessage()); + } + } catch (Throwable ex) { + ex.printStackTrace(); + fail = ex; // throw this to make test fail, since subtest failed + } + + // Inject a class in the unnamed package into p1.T. It should be able + // to access all methods in p1.T. + System.out.println("Injecting unnamed package into correct host class:"); + try { + Class p3cls = getAnonClass(T.class, "AnonClass"); + p3cls.getMethod("test").invoke(null); + } catch (Throwable ex) { + ex.printStackTrace(); + fail = ex; // throw this to make test fail, since subtest failed + } + + // Try using an array class as the host class. This should throw IllegalArgumentException. + try { + Class p3cls = getAnonClass(String[].class, "AnonClass"); + throw new RuntimeException("Expected IllegalArgumentException not thrown"); + } catch (IllegalArgumentException ex) { + } + + if (fail != null) throw fail; // make test fail, since subtest failed + } +} diff --git a/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java b/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java new file mode 100644 index 00000000000..c25f29a0965 --- /dev/null +++ b/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8058575 + * @summary Creates an anonymous class inside of an anonymous class. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.compiler + * java.management + * @run main p.NestedUnsafe + */ + +package p; + +import java.security.ProtectionDomain; +import java.io.InputStream; +import java.lang.*; +import jdk.test.lib.*; +import jdk.internal.misc.Unsafe; +import jdk.test.lib.unsafe.UnsafeHelper; + + +// Test that an anonymous class in package 'p' cannot define its own anonymous class +// in another package. +public class NestedUnsafe { + // The String concatenation should create the nested anonymous class. + static byte klassbuf[] = InMemoryJavaCompiler.compile("q.TestClass", + "package q; " + + "public class TestClass { " + + " public static void concat(String one, String two) throws Throwable { " + + " System.out.println(one + two);" + + " } } "); + + public static void main(String args[]) throws Exception { + Unsafe unsafe = UnsafeHelper.getUnsafe(); + + // The anonymous class calls defineAnonymousClass creating a nested anonymous class. + byte klassbuf2[] = InMemoryJavaCompiler.compile("p.TestClass2", + "package p; " + + "import jdk.internal.misc.Unsafe; " + + "public class TestClass2 { " + + " public static void doit() throws Throwable { " + + " Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); " + + " Class klass2 = unsafe.defineAnonymousClass(TestClass2.class, p.NestedUnsafe.klassbuf, new Object[0]); " + + " unsafe.ensureClassInitialized(klass2); " + + " Class[] dArgs = new Class[2]; " + + " dArgs[0] = String.class; " + + " dArgs[1] = String.class; " + + " try { " + + " klass2.getMethod(\"concat\", dArgs).invoke(null, \"CC\", \"DD\"); " + + " } catch (Throwable ex) { " + + " throw new RuntimeException(\"Exception: \" + ex.toString()); " + + " } " + + "} } ", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED"); + + Class klass2 = unsafe.defineAnonymousClass(p.NestedUnsafe.class, klassbuf2, new Object[0]); + try { + klass2.getMethod("doit").invoke(null); + throw new RuntimeException("Expected exception not thrown"); + } catch (Throwable ex) { + Throwable iae = ex.getCause(); + if (!iae.toString().contains( + "IllegalArgumentException: Host class p/NestedUnsafe and anonymous class q/TestClass")) { + throw new RuntimeException("Exception: " + iae.toString()); + } + } + } +} diff --git a/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java b/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java new file mode 100644 index 00000000000..33ec95a1005 --- /dev/null +++ b/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8058575 + * @summary Creates an anonymous class inside of an anonymous class. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.compiler + * java.management + * @run main p.NestedUnsafe2 + */ + +package p; + +import java.security.ProtectionDomain; +import java.io.InputStream; +import java.lang.*; +import jdk.test.lib.*; +import jdk.internal.misc.Unsafe; +import jdk.test.lib.unsafe.UnsafeHelper; + + +// Test that an anonymous class that gets put in its host's package cannot define +// an anonymous class in another package. +public class NestedUnsafe2 { + // The String concatenation should create the nested anonymous class. + public static byte klassbuf[] = InMemoryJavaCompiler.compile("q.TestClass", + "package q; " + + "public class TestClass { " + + " public static void concat(String one, String two) throws Throwable { " + + " System.out.println(one + two);" + + " } } "); + + public static void main(String args[]) throws Exception { + Unsafe unsafe = UnsafeHelper.getUnsafe(); + + // The anonymous class calls defineAnonymousClass creating a nested anonymous class. + byte klassbuf2[] = InMemoryJavaCompiler.compile("TestClass2", + "import jdk.internal.misc.Unsafe; " + + "public class TestClass2 { " + + " public static void doit() throws Throwable { " + + " Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); " + + " Class klass2 = unsafe.defineAnonymousClass(TestClass2.class, p.NestedUnsafe2.klassbuf, new Object[0]); " + + " unsafe.ensureClassInitialized(klass2); " + + " Class[] dArgs = new Class[2]; " + + " dArgs[0] = String.class; " + + " dArgs[1] = String.class; " + + " try { " + + " klass2.getMethod(\"concat\", dArgs).invoke(null, \"CC\", \"DD\"); " + + " } catch (Throwable ex) { " + + " throw new RuntimeException(\"Exception: \" + ex.toString()); " + + " } " + + "} } ", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED"); + + Class klass2 = unsafe.defineAnonymousClass(p.NestedUnsafe2.class, klassbuf2, new Object[0]); + try { + klass2.getMethod("doit").invoke(null); + throw new RuntimeException("Expected exception not thrown"); + } catch (Throwable ex) { + Throwable iae = ex.getCause(); + if (!iae.toString().contains( + "IllegalArgumentException: Host class p/NestedUnsafe2 and anonymous class q/TestClass")) { + throw new RuntimeException("Exception: " + iae.toString()); + } + } + } +} From af30b263449bd7aac6ec7f9aa14325090e9e7a0e Mon Sep 17 00:00:00 2001 From: Marcus Larsson Date: Wed, 7 Sep 2016 14:36:44 +0200 Subject: [PATCH 135/296] 8165226: Bad -Xloggc: arguments crashes the VM Reviewed-by: dsamersoff, sjohanss --- hotspot/src/share/vm/logging/logConfiguration.cpp | 1 + hotspot/src/share/vm/prims/jvmtiEnv.cpp | 10 +++------- hotspot/src/share/vm/runtime/arguments.cpp | 8 ++++++-- .../src/share/vm/services/classLoadingService.cpp | 14 ++++---------- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp index 29a65cd3a1f..7842cbb34e2 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.cpp +++ b/hotspot/src/share/vm/logging/logConfiguration.cpp @@ -385,6 +385,7 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr, const char* decoratorstr, const char* output_options, outputStream* errstream) { + assert(errstream != NULL, "errstream can not be NULL"); if (outputstr == NULL || strlen(outputstr) == 0) { outputstr = "stdout"; } diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp index f1c5f962b17..25ad11871fe 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp @@ -649,18 +649,14 @@ JvmtiEnv::GetErrorName(jvmtiError error, char** name_ptr) { jvmtiError JvmtiEnv::SetVerboseFlag(jvmtiVerboseFlag flag, jboolean value) { + LogLevelType level = value == 0 ? LogLevel::Off : LogLevel::Info; switch (flag) { case JVMTI_VERBOSE_OTHER: // ignore break; case JVMTI_VERBOSE_CLASS: - if (value == 0) { - LogConfiguration::parse_log_arguments("stdout", "class+unload=off", NULL, NULL, NULL); - LogConfiguration::parse_log_arguments("stdout", "class+load=off", NULL, NULL, NULL); - } else { - LogConfiguration::parse_log_arguments("stdout", "class+load=info", NULL, NULL, NULL); - LogConfiguration::parse_log_arguments("stdout", "class+unload=info", NULL, NULL, NULL); - } + LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, unload)); + LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, load)); break; case JVMTI_VERBOSE_GC: if (value == 0) { diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 18cd2374e3f..e897e9cdf50 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -33,8 +33,9 @@ #include "gc/shared/referenceProcessor.hpp" #include "gc/shared/taskqueue.hpp" #include "logging/log.hpp" -#include "logging/logTag.hpp" #include "logging/logConfiguration.hpp" +#include "logging/logStream.hpp" +#include "logging/logTag.hpp" #include "memory/allocation.inline.hpp" #include "memory/universe.inline.hpp" #include "oops/oop.inline.hpp" @@ -4176,7 +4177,10 @@ bool Arguments::handle_deprecated_print_gc_flags() { if (_gc_log_filename != NULL) { // -Xloggc was used to specify a filename const char* gc_conf = PrintGCDetails ? "gc*" : "gc"; - return LogConfiguration::parse_log_arguments(_gc_log_filename, gc_conf, NULL, NULL, NULL); + + LogTarget(Error, logging) target; + LogStreamCHeap errstream(target); + return LogConfiguration::parse_log_arguments(_gc_log_filename, gc_conf, NULL, NULL, &errstream); } else if (PrintGC || PrintGCDetails) { LogConfiguration::configure_stdout(LogLevel::Info, !PrintGCDetails, LOG_TAGS(gc)); } diff --git a/hotspot/src/share/vm/services/classLoadingService.cpp b/hotspot/src/share/vm/services/classLoadingService.cpp index 6d1f0cdb36f..185c04eeafa 100644 --- a/hotspot/src/share/vm/services/classLoadingService.cpp +++ b/hotspot/src/share/vm/services/classLoadingService.cpp @@ -183,11 +183,8 @@ size_t ClassLoadingService::compute_class_size(InstanceKlass* k) { bool ClassLoadingService::set_verbose(bool verbose) { MutexLocker m(Management_lock); // verbose will be set to the previous value - if (verbose) { - LogConfiguration::parse_log_arguments("stdout", "class+load=info", NULL, NULL, NULL); - } else { - LogConfiguration::parse_log_arguments("stdout", "class+load=off", NULL, NULL, NULL); - } + LogLevelType level = verbose ? LogLevel::Info : LogLevel::Off; + LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, load)); reset_trace_class_unloading(); return verbose; } @@ -196,11 +193,8 @@ bool ClassLoadingService::set_verbose(bool verbose) { void ClassLoadingService::reset_trace_class_unloading() { assert(Management_lock->owned_by_self(), "Must own the Management_lock"); bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose(); - if (value) { - LogConfiguration::parse_log_arguments("stdout", "class+unload=info", NULL, NULL, NULL); - } else { - LogConfiguration::parse_log_arguments("stdout", "class+unload=off", NULL, NULL, NULL); - } + LogLevelType level = value ? LogLevel::Info : LogLevel::Off; + LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, unload)); } GrowableArray* LoadedClassesEnumerator::_loaded_classes = NULL; From a900715bbf7d4892302f5598e1d1cb1482e62adc Mon Sep 17 00:00:00 2001 From: Frederic Parain Date: Wed, 7 Sep 2016 12:52:20 -0400 Subject: [PATCH 136/296] 8137035: nsk/stress/stack/stack tests got EXCEPTION_STACK_OVERFLOW on Windows 64 bit Reviewed-by: dholmes, dcubed, coleenp --- hotspot/src/cpu/x86/vm/globals_x86.hpp | 4 ++-- hotspot/src/os/windows/vm/os_windows.cpp | 19 +++++++++++-------- .../src/share/vm/runtime/interfaceSupport.hpp | 7 +++++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/globals_x86.hpp b/hotspot/src/cpu/x86/vm/globals_x86.hpp index 93aea2a18d7..925ae225476 100644 --- a/hotspot/src/cpu/x86/vm/globals_x86.hpp +++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp @@ -65,10 +65,10 @@ define_pd_global(intx, InlineSmallCode, 1000); #ifdef AMD64 // Very large C++ stack frames using solaris-amd64 optimized builds // due to lack of optimization caused by C++ compiler bugs -#define DEFAULT_STACK_SHADOW_PAGES (NOT_WIN64(20) WIN64_ONLY(6) DEBUG_ONLY(+2)) +#define DEFAULT_STACK_SHADOW_PAGES (NOT_WIN64(20) WIN64_ONLY(7) DEBUG_ONLY(+2)) // For those clients that do not use write socket, we allow // the min range value to be below that of the default -#define MIN_STACK_SHADOW_PAGES (NOT_WIN64(10) WIN64_ONLY(6) DEBUG_ONLY(+2)) +#define MIN_STACK_SHADOW_PAGES (NOT_WIN64(10) WIN64_ONLY(7) DEBUG_ONLY(+2)) #else #define DEFAULT_STACK_SHADOW_PAGES (4 DEBUG_ONLY(+5)) #define MIN_STACK_SHADOW_PAGES DEFAULT_STACK_SHADOW_PAGES diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 24b39189e76..17231d81849 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -2504,13 +2504,15 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { // It write enables the page immediately after protecting it // so just return. if (exception_code == EXCEPTION_ACCESS_VIOLATION) { - JavaThread* thread = (JavaThread*) t; - PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; - address addr = (address) exceptionRecord->ExceptionInformation[1]; - if (os::is_memory_serialize_page(thread, addr)) { - // Block current thread until the memory serialize page permission restored. - os::block_on_serialize_page_trap(); - return EXCEPTION_CONTINUE_EXECUTION; + if (t != NULL && t->is_Java_thread()) { + JavaThread* thread = (JavaThread*) t; + PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; + address addr = (address) exceptionRecord->ExceptionInformation[1]; + if (os::is_memory_serialize_page(thread, addr)) { + // Block current thread until the memory serialize page permission restored. + os::block_on_serialize_page_trap(); + return EXCEPTION_CONTINUE_EXECUTION; + } } } @@ -2564,7 +2566,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { } #endif if (thread->stack_guards_enabled()) { - if (_thread_in_Java) { + if (in_java) { frame fr; PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; address addr = (address) exceptionRecord->ExceptionInformation[1]; @@ -2576,6 +2578,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { // Yellow zone violation. The o/s has unprotected the first yellow // zone page for us. Note: must call disable_stack_yellow_zone to // update the enabled status, even if the zone contains only one page. + assert(thread->thread_state() != _thread_in_vm, "Undersized StackShadowPages"); thread->disable_stack_yellow_reserved_zone(); // If not in java code, return and hope for the best. return in_java diff --git a/hotspot/src/share/vm/runtime/interfaceSupport.hpp b/hotspot/src/share/vm/runtime/interfaceSupport.hpp index 4d4d51b26a0..840d68e2444 100644 --- a/hotspot/src/share/vm/runtime/interfaceSupport.hpp +++ b/hotspot/src/share/vm/runtime/interfaceSupport.hpp @@ -219,6 +219,9 @@ class ThreadInVMfromJava : public ThreadStateTransition { trans_from_java(_thread_in_vm); } ~ThreadInVMfromJava() { + if (_thread->stack_yellow_reserved_zone_disabled()) { + _thread->enable_stack_yellow_reserved_zone(); + } trans(_thread_in_vm, _thread_in_Java); // Check for pending. async. exceptions or suspends. if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(); @@ -306,6 +309,9 @@ class ThreadInVMfromJavaNoAsyncException : public ThreadStateTransition { trans_from_java(_thread_in_vm); } ~ThreadInVMfromJavaNoAsyncException() { + if (_thread->stack_yellow_reserved_zone_disabled()) { + _thread->enable_stack_yellow_reserved_zone(); + } trans(_thread_in_vm, _thread_in_Java); // NOTE: We do not check for pending. async. exceptions. // If we did and moved the pending async exception over into the @@ -314,6 +320,7 @@ class ThreadInVMfromJavaNoAsyncException : public ThreadStateTransition { // to the _thread_in_vm state. Instead we postpone the handling of // the async exception. + // Check for pending. suspends only. if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(false); From 3c2621dbdd3e868cd81942e3041c214ff735dc8e Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 7 Sep 2016 15:25:21 -0400 Subject: [PATCH 137/296] 8165246: [REDO] InstanceKlass::_previous_version_count goes negative Make _has_previous_version a boolean that is set to true when previous version of a class is added or during class unloading call to purge_previous_versions Reviewed-by: gtriantafill, dcubed, sspitsyn --- .../share/vm/classfile/classLoaderData.cpp | 2 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 179 ++++++++++-------- hotspot/src/share/vm/oops/instanceKlass.hpp | 14 +- .../RedefinePreviousVersions.java | 120 ++++++++++++ 4 files changed, 235 insertions(+), 80 deletions(-) create mode 100644 hotspot/test/runtime/RedefineTests/RedefinePreviousVersions.java diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index ba1191614b1..9dea595e3aa 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -966,7 +966,7 @@ bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, // Klasses to delete. bool walk_all_metadata = clean_previous_versions && JvmtiExport::has_redefined_a_class() && - InstanceKlass::has_previous_versions(); + InstanceKlass::has_previous_versions_and_reset(); MetadataOnStackMark md_on_stack(walk_all_metadata); // Save previous _unloading pointer for CMS which may add to unloading list before diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 1385affc5df..aaebc235e9d 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -3365,88 +3365,119 @@ void InstanceKlass::set_init_state(ClassState state) { #if INCLUDE_JVMTI -// RedefineClasses() support for previous versions: -int InstanceKlass::_previous_version_count = 0; +// RedefineClasses() support for previous versions -// Purge previous versions before adding new previous versions of the class. -void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { - if (ik->previous_versions() != NULL) { - // This klass has previous versions so see what we can cleanup - // while it is safe to do so. +// Globally, there is at least one previous version of a class to walk +// during class unloading, which is saved because old methods in the class +// are still running. Otherwise the previous version list is cleaned up. +bool InstanceKlass::_has_previous_versions = false; - int deleted_count = 0; // leave debugging breadcrumbs - int live_count = 0; - ClassLoaderData* loader_data = ik->class_loader_data(); - assert(loader_data != NULL, "should never be null"); +// Returns true if there are previous versions of a class for class +// unloading only. Also resets the flag to false. purge_previous_version +// will set the flag to true if there are any left, i.e., if there's any +// work to do for next time. This is to avoid the expensive code cache +// walk in CLDG::do_unloading(). +bool InstanceKlass::has_previous_versions_and_reset() { + bool ret = _has_previous_versions; + log_trace(redefine, class, iklass, purge)("Class unloading: has_previous_versions = %s", + ret ? "true" : "false"); + _has_previous_versions = false; + return ret; +} - ResourceMark rm; - log_trace(redefine, class, iklass, purge)("%s: previous versions", ik->external_name()); +// Purge previous versions before adding new previous versions of the class and +// during class unloading. +void InstanceKlass::purge_previous_version_list() { + assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); + assert(has_been_redefined(), "Should only be called for main class"); - // previous versions are linked together through the InstanceKlass - InstanceKlass* pv_node = ik->previous_versions(); - InstanceKlass* last = ik; - int version = 0; + // Quick exit. + if (previous_versions() == NULL) { + return; + } - // check the previous versions list - for (; pv_node != NULL; ) { + // This klass has previous versions so see what we can cleanup + // while it is safe to do so. - ConstantPool* pvcp = pv_node->constants(); - assert(pvcp != NULL, "cp ref was unexpectedly cleared"); + int deleted_count = 0; // leave debugging breadcrumbs + int live_count = 0; + ClassLoaderData* loader_data = class_loader_data(); + assert(loader_data != NULL, "should never be null"); - if (!pvcp->on_stack()) { - // If the constant pool isn't on stack, none of the methods - // are executing. Unlink this previous_version. - // The previous version InstanceKlass is on the ClassLoaderData deallocate list - // so will be deallocated during the next phase of class unloading. - log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is dead", p2i(pv_node)); - // For debugging purposes. - pv_node->set_is_scratch_class(); - pv_node->class_loader_data()->add_to_deallocate_list(pv_node); - pv_node = pv_node->previous_versions(); - last->link_previous_versions(pv_node); - deleted_count++; - version++; - continue; - } else { - log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is alive", p2i(pv_node)); - assert(pvcp->pool_holder() != NULL, "Constant pool with no holder"); - guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack"); - live_count++; - } + ResourceMark rm; + log_trace(redefine, class, iklass, purge)("%s: previous versions", external_name()); - // At least one method is live in this previous version. - // Reset dead EMCP methods not to get breakpoints. - // All methods are deallocated when all of the methods for this class are no - // longer running. - Array* method_refs = pv_node->methods(); - if (method_refs != NULL) { - log_trace(redefine, class, iklass, purge)("previous methods length=%d", method_refs->length()); - for (int j = 0; j < method_refs->length(); j++) { - Method* method = method_refs->at(j); + // previous versions are linked together through the InstanceKlass + InstanceKlass* pv_node = previous_versions(); + InstanceKlass* last = this; + int version = 0; - if (!method->on_stack()) { - // no breakpoints for non-running methods - if (method->is_running_emcp()) { - method->set_running_emcp(false); - } - } else { - assert (method->is_obsolete() || method->is_running_emcp(), - "emcp method cannot run after emcp bit is cleared"); - log_trace(redefine, class, iklass, purge) - ("purge: %s(%s): prev method @%d in version @%d is alive", - method->name()->as_C_string(), method->signature()->as_C_string(), j, version); + // check the previous versions list + for (; pv_node != NULL; ) { + + ConstantPool* pvcp = pv_node->constants(); + assert(pvcp != NULL, "cp ref was unexpectedly cleared"); + + if (!pvcp->on_stack()) { + // If the constant pool isn't on stack, none of the methods + // are executing. Unlink this previous_version. + // The previous version InstanceKlass is on the ClassLoaderData deallocate list + // so will be deallocated during the next phase of class unloading. + log_trace(redefine, class, iklass, purge) + ("previous version " INTPTR_FORMAT " is dead.", p2i(pv_node)); + // For debugging purposes. + pv_node->set_is_scratch_class(); + // Unlink from previous version list. + assert(pv_node->class_loader_data() == loader_data, "wrong loader_data"); + InstanceKlass* next = pv_node->previous_versions(); + pv_node->link_previous_versions(NULL); // point next to NULL + last->link_previous_versions(next); + // Add to the deallocate list after unlinking + loader_data->add_to_deallocate_list(pv_node); + pv_node = next; + deleted_count++; + version++; + continue; + } else { + log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is alive", p2i(pv_node)); + assert(pvcp->pool_holder() != NULL, "Constant pool with no holder"); + guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack"); + live_count++; + // found a previous version for next time we do class unloading + _has_previous_versions = true; + } + + // At least one method is live in this previous version. + // Reset dead EMCP methods not to get breakpoints. + // All methods are deallocated when all of the methods for this class are no + // longer running. + Array* method_refs = pv_node->methods(); + if (method_refs != NULL) { + log_trace(redefine, class, iklass, purge)("previous methods length=%d", method_refs->length()); + for (int j = 0; j < method_refs->length(); j++) { + Method* method = method_refs->at(j); + + if (!method->on_stack()) { + // no breakpoints for non-running methods + if (method->is_running_emcp()) { + method->set_running_emcp(false); } + } else { + assert (method->is_obsolete() || method->is_running_emcp(), + "emcp method cannot run after emcp bit is cleared"); + log_trace(redefine, class, iklass, purge) + ("purge: %s(%s): prev method @%d in version @%d is alive", + method->name()->as_C_string(), method->signature()->as_C_string(), j, version); } } - // next previous version - last = pv_node; - pv_node = pv_node->previous_versions(); - version++; } - log_trace(redefine, class, iklass, purge) - ("previous version stats: live=%d, deleted=%d", - live_count, deleted_count); + // next previous version + last = pv_node; + pv_node = pv_node->previous_versions(); + version++; } + log_trace(redefine, class, iklass, purge) + ("previous version stats: live=%d, deleted=%d", live_count, deleted_count); } void InstanceKlass::mark_newly_obsolete_methods(Array* old_methods, @@ -3518,8 +3549,8 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, log_trace(redefine, class, iklass, add) ("adding previous version ref for %s, EMCP_cnt=%d", scratch_class->external_name(), emcp_method_count); - // Clean out old previous versions - purge_previous_versions(this); + // Clean out old previous versions for this class + purge_previous_version_list(); // Mark newly obsolete methods in remaining previous versions. An EMCP method from // a previous redefinition may be made obsolete by this redefinition. @@ -3536,8 +3567,6 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, // For debugging purposes. scratch_class->set_is_scratch_class(); scratch_class->class_loader_data()->add_to_deallocate_list(scratch_class()); - // Update count for class unloading. - _previous_version_count--; return; } @@ -3565,12 +3594,12 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, } // Add previous version if any methods are still running. - log_trace(redefine, class, iklass, add)("scratch class added; one of its methods is on_stack"); + // Set has_previous_version flag for processing during class unloading. + _has_previous_versions = true; + log_trace(redefine, class, iklass, add) ("scratch class added; one of its methods is on_stack."); assert(scratch_class->previous_versions() == NULL, "shouldn't have a previous version"); scratch_class->link_previous_versions(previous_versions()); link_previous_versions(scratch_class()); - // Update count for class unloading. - _previous_version_count++; } // end add_previous_version() #endif // INCLUDE_JVMTI diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index e4eb9b3e4fe..330f373f001 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -709,6 +709,7 @@ class InstanceKlass: public Klass { // RedefineClasses() support for previous versions: void add_previous_version(instanceKlassHandle ikh, int emcp_method_count); + void purge_previous_version_list(); InstanceKlass* previous_versions() const { return _previous_versions; } #else @@ -768,10 +769,15 @@ public: } private: - static int _previous_version_count; + static bool _has_previous_versions; public: - static void purge_previous_versions(InstanceKlass* ik); - static bool has_previous_versions() { return _previous_version_count > 0; } + static void purge_previous_versions(InstanceKlass* ik) { + if (ik->has_been_redefined()) { + ik->purge_previous_version_list(); + } + } + + static bool has_previous_versions_and_reset(); // JVMTI: Support for caching a class file before it is modified by an agent that can do retransformation void set_cached_class_file(JvmtiCachedClassFileData *data) { @@ -792,7 +798,7 @@ public: #else // INCLUDE_JVMTI static void purge_previous_versions(InstanceKlass* ik) { return; }; - static bool has_previous_versions() { return false; } + static bool has_previous_versions_and_reset() { return false; } void set_cached_class_file(JvmtiCachedClassFileData *data) { assert(data == NULL, "unexpected call with JVMTI disabled"); diff --git a/hotspot/test/runtime/RedefineTests/RedefinePreviousVersions.java b/hotspot/test/runtime/RedefineTests/RedefinePreviousVersions.java new file mode 100644 index 00000000000..45555dcf4ab --- /dev/null +++ b/hotspot/test/runtime/RedefineTests/RedefinePreviousVersions.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8165246 + * @summary Test has_previous_versions flag and processing during class unloading. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @modules java.compiler + * java.instrument + * jdk.jartool/sun.tools.jar + * @run main RedefineClassHelper + * @run main/othervm RedefinePreviousVersions test + */ + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class RedefinePreviousVersions { + + public static String newB = + "class RedefinePreviousVersions$B {" + + "}"; + + static class B { } + + public static String newRunning = + "class RedefinePreviousVersions$Running {" + + " public static volatile boolean stop = true;" + + " static void localSleep() { }" + + " public static void infinite() { }" + + "}"; + + static class Running { + public static volatile boolean stop = false; + static void localSleep() { + try{ + Thread.currentThread().sleep(10);//sleep for 10 ms + } catch(InterruptedException ie) { + } + } + + public static void infinite() { + while (!stop) { localSleep(); } + } + } + + public static void main(String[] args) throws Exception { + + if (args.length > 0) { + + String jarFile = System.getProperty("test.src") + "/testcase.jar"; + + // java -javaagent:redefineagent.jar -Xlog:stuff RedefinePreviousVersions + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-javaagent:redefineagent.jar", + "-Xlog:redefine+class+iklass+add=trace,redefine+class+iklass+purge=trace", + "RedefinePreviousVersions"); + new OutputAnalyzer(pb.start()) + .shouldContain("Class unloading: has_previous_versions = false") + .shouldContain("Class unloading: has_previous_versions = true") + .shouldHaveExitValue(0); + return; + } + + // Redefine a class and create some garbage + // Since there are no methods running, the previous version is never added to the + // previous_version_list and the flag _has_previous_versions should stay false + RedefineClassHelper.redefineClass(B.class, newB); + + for (int i = 0; i < 10 ; i++) { + String s = new String("some garbage"); + System.gc(); + } + + // Start a class that has a method running + new Thread() { + public void run() { + Running.infinite(); + } + }.start(); + + // Since a method of newRunning is running, this class should be added to the previous_version_list + // of Running, and _has_previous_versions should return true at class unloading. + RedefineClassHelper.redefineClass(Running.class, newRunning); + + for (int i = 0; i < 10 ; i++) { + String s = new String("some garbage"); + System.gc(); + } + + // purge should clean everything up, except Xcomp it might not. + Running.stop = true; + + for (int i = 0; i < 10 ; i++) { + String s = new String("some garbage"); + System.gc(); + } + } +} From 1a8f8e22f1877155e24fdc36991b73997246c616 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Wed, 7 Sep 2016 16:43:32 -0400 Subject: [PATCH 138/296] 8165153: Crash in rebuild_cpu_to_node_map Use processor_count(), not active_processor_count() to determine physical number of CPUs Reviewed-by: rehn, cjplummer --- hotspot/src/os/linux/vm/os_linux.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 9248eb72e35..5aafe4b8474 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -2875,7 +2875,7 @@ void os::Linux::rebuild_cpu_to_node_map() { // in the library. const size_t BitsPerCLong = sizeof(long) * CHAR_BIT; - size_t cpu_num = os::active_processor_count(); + size_t cpu_num = processor_count(); size_t cpu_map_size = NCPUS / BitsPerCLong; size_t cpu_map_valid_size = MIN2((cpu_num + BitsPerCLong - 1) / BitsPerCLong, cpu_map_size); From 50fb03349c8fc71cff46b525aa67e8b204e49f64 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Fri, 2 Sep 2016 16:45:16 +0200 Subject: [PATCH 139/296] 8161079: Default heap size causes native memory exhaustion on 32 bit Windows Reviewed-by: tschatzl, sjohanss --- hotspot/src/os/windows/vm/os_windows.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 17231d81849..d8034537e2d 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -3796,6 +3796,11 @@ void os::win32::initialize_system_info() { GlobalMemoryStatusEx(&ms); _physical_memory = ms.ullTotalPhys; + if (FLAG_IS_DEFAULT(MaxRAM)) { + // Adjust MaxRAM according to the maximum virtual address space available. + FLAG_SET_DEFAULT(MaxRAM, MIN2(MaxRAM, (uint64_t) ms.ullTotalVirtual)); + } + OSVERSIONINFOEX oi; oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); GetVersionEx((OSVERSIONINFO*)&oi); From 3d2958a96203805cb65dcfdd92fdc883ed5b8d21 Mon Sep 17 00:00:00 2001 From: George Triantafillou Date: Fri, 2 Sep 2016 11:20:33 -0400 Subject: [PATCH 140/296] 8165293: Remove ClassesByName2Test.java and RedefineCrossEvent.java from ProblemList.txt Reviewed-by: dcubed --- jdk/test/ProblemList.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index daeb0bccd89..2dc7a19cbb1 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -330,9 +330,6 @@ com/sun/jdi/GetLocalVariables4Test.sh 8067354 windows- com/sun/jdi/sde/SourceDebugExtensionTest.java 8158066 windows-all -com/sun/jdi/ClassesByName2Test.java 8160833 generic-all -com/sun/jdi/RedefineCrossEvent.java 8160833 generic-all - ############################################################################ # jdk_time From 6d3b1a78ad425a3ef22c00595bc7bf2d53675a0a Mon Sep 17 00:00:00 2001 From: Andrey Dyachkov Date: Fri, 2 Sep 2016 12:30:46 -0400 Subject: [PATCH 141/296] 8155102: (Process) Process.toString could include pid, isAlive, exitStatus Reviewed-by: rriggs --- .../unix/classes/java/lang/ProcessImpl.java | 13 +++++++++ .../classes/java/lang/ProcessImpl.java | 14 ++++++++++ jdk/test/java/lang/ProcessBuilder/Basic.java | 27 +++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java index 4b4441a7700..f26b0108fed 100644 --- a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java +++ b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java @@ -630,6 +630,19 @@ final class ProcessImpl extends Process { return !hasExited; } + /** + * The {@code toString} method returns a string consisting of + * the native process ID of the process and the exit value of the process. + * + * @return a string representation of the object. + */ + @Override + public String toString() { + return new StringBuilder("Process[pid=").append(pid) + .append(", exitValue=").append(hasExited ? exitcode : "\"not exited\"") + .append("]").toString(); + } + private static native void init(); static { diff --git a/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java b/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java index a59eba9dd3d..988234daf51 100644 --- a/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java +++ b/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java @@ -563,6 +563,20 @@ final class ProcessImpl extends Process { private static native boolean isProcessAlive(long handle); + /** + * The {@code toString} method returns a string consisting of + * the native process ID of the process and the exit value of the process. + * + * @return a string representation of the object. + */ + @Override + public String toString() { + int exitCode = getExitCodeProcess(handle); + return new StringBuilder("Process[pid=").append(getPid()) + .append(", exitValue=").append(exitCode == STILL_ACTIVE ? "\"not exited\"" : exitCode) + .append("]").toString(); + } + /** * Create a process using the win32 function CreateProcess. * The method is synchronized due to MS kb315939 problem. diff --git a/jdk/test/java/lang/ProcessBuilder/Basic.java b/jdk/test/java/lang/ProcessBuilder/Basic.java index 9a1d97647f7..e17e28865e4 100644 --- a/jdk/test/java/lang/ProcessBuilder/Basic.java +++ b/jdk/test/java/lang/ProcessBuilder/Basic.java @@ -2226,6 +2226,33 @@ public class Basic { reader.join(); } } + + //---------------------------------------------------------------- + // Check the Process toString() method + //---------------------------------------------------------------- + { + List childArgs = new ArrayList(javaChildArgs); + childArgs.add("testIO"); + ProcessBuilder pb = new ProcessBuilder(childArgs); + pb.redirectInput(Redirect.PIPE); + pb.redirectOutput(DISCARD); + pb.redirectError(DISCARD); + final Process p = pb.start(); + // Child process waits until it gets input + String s = p.toString(); + check(s.contains("not exited")); + check(s.contains("pid=" + p.getPid() + ",")); + + new PrintStream(p.getOutputStream()).print("standard input"); + p.getOutputStream().close(); + + // Check the toString after it exits + int exitValue = p.waitFor(); + s = p.toString(); + check(s.contains("pid=" + p.getPid() + ",")); + check(s.contains("exitValue=" + exitValue) && + !s.contains("not exited")); + } } catch (Throwable t) { unexpected(t); } //---------------------------------------------------------------- From f0535f417c42087deae61bb84ad797972094ef6b Mon Sep 17 00:00:00 2001 From: Iris Clark Date: Fri, 2 Sep 2016 10:48:35 -0700 Subject: [PATCH 142/296] 8165269: (doc) Toolkit.isDynamicLayoutActive(): orphan '0' in first sentence Reviewed-by: alexsch --- jdk/src/java.desktop/share/classes/java/awt/Toolkit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java index 76db7f06a30..9d00222ed2c 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java @@ -208,7 +208,7 @@ public abstract class Toolkit { /** * Returns whether dynamic layout of Containers on resize is currently - * enabled on the underlying operating system and/or window manager). If the + * enabled on the underlying operating system and/or window manager. If the * platform supports it, {@code setDynamicLayout(boolean)} may be used to * programmatically enable or disable platform dynamic layout. Regardless of * whether that toggling is supported, or whether {@code true} or {@code From 92cf16b425ffe4336f5c0879d27ccda3983e7658 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 2 Sep 2016 11:29:02 -0700 Subject: [PATCH 143/296] 8154075: [TIFF] AIOOB Exception from TIFFLZWDecompressor For banded images make sure the step in the horizontal differencing predictor calculations for Deflate and LZW compression is unity (1) instead of the number of samples per pixel. Reviewed-by: prr --- .../plugins/tiff/TIFFDeflateDecompressor.java | 12 ++++++++---- .../imageio/plugins/tiff/TIFFLZWDecompressor.java | 14 ++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDeflateDecompressor.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDeflateDecompressor.java index ecbd38a4d3a..1ce7d56c1c7 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDeflateDecompressor.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDeflateDecompressor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -101,13 +101,17 @@ public class TIFFDeflateDecompressor extends TIFFDecompressor { if (predictor == BaselineTIFFTagSet.PREDICTOR_HORIZONTAL_DIFFERENCING) { + int step = planar || samplesPerPixel == 1 ? 1 : samplesPerPixel; + int samplesPerRow = step * srcWidth; + int off = bufOffset + step; for (int j = 0; j < srcHeight; j++) { - int count = bufOffset + samplesPerPixel * (j * srcWidth + 1); - for (int i=samplesPerPixel; i Date: Fri, 2 Sep 2016 12:38:27 -0700 Subject: [PATCH 144/296] 8165000: Selector.select(timeout) throws IOException when timeout is a large long Clamp the timeout passed to kevent0 to the largest value that does not provoke the error. Reviewed-by: clanger, alanb --- .../native/libnio/ch/KQueueArrayWrapper.c | 12 ++- .../nio/channels/Selector/SelectTimeout.java | 83 +++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 jdk/test/java/nio/channels/Selector/SelectTimeout.java diff --git a/jdk/src/java.base/macosx/native/libnio/ch/KQueueArrayWrapper.c b/jdk/src/java.base/macosx/native/libnio/ch/KQueueArrayWrapper.c index 8fd84347da1..059d9a7badb 100644 --- a/jdk/src/java.base/macosx/native/libnio/ch/KQueueArrayWrapper.c +++ b/jdk/src/java.base/macosx/native/libnio/ch/KQueueArrayWrapper.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -123,7 +123,6 @@ Java_sun_nio_ch_KQueueArrayWrapper_register0(JNIEnv *env, jobject this, kevent(kq, changes, 2, errors, 2, &dontBlock); } - JNIEXPORT jint JNICALL Java_sun_nio_ch_KQueueArrayWrapper_kevent0(JNIEnv *env, jobject this, jint kq, jlong kevAddr, jint kevCount, @@ -138,6 +137,15 @@ Java_sun_nio_ch_KQueueArrayWrapper_kevent0(JNIEnv *env, jobject this, jint kq, // Java timeout == -1 : wait forever : timespec timeout of NULL // Java timeout == 0 : return immediately : timespec timeout of zero if (timeout >= 0) { + // For some indeterminate reason kevent(2) has been found to fail with + // an EINVAL error for timeout values greater than or equal to + // 100000001000L. To avoid this problem, clamp the timeout arbitrarily + // to the maximum value of a 32-bit signed integer which is + // approximately 25 days in milliseconds. + const jlong timeoutMax = 0x7fffffff; // java.lang.Integer.MAX_VALUE + if (timeout > timeoutMax) { + timeout = timeoutMax; + } ts.tv_sec = timeout / 1000; ts.tv_nsec = (timeout % 1000) * 1000000; //nanosec = 1 million millisec tsp = &ts; diff --git a/jdk/test/java/nio/channels/Selector/SelectTimeout.java b/jdk/test/java/nio/channels/Selector/SelectTimeout.java new file mode 100644 index 00000000000..aaeff367d84 --- /dev/null +++ b/jdk/test/java/nio/channels/Selector/SelectTimeout.java @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2016, 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. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* 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. +*/ + +/* + * @test + * @bug 8165000 + * @summary Verify no IOException on OS X for large timeout value in select(). + * @requires (os.family == "mac") + */ +import java.io.IOException; +import java.nio.channels.Selector; + +public class SelectTimeout { + private static final long HUGE_TIMEOUT = 100000001000L; + private static final long SLEEP_MILLIS = 10000; + + private static Exception theException; + + public static void main(String[] args) + throws IOException, InterruptedException { + int failures = 0; + long[] timeouts = + new long[] {0, HUGE_TIMEOUT/2, HUGE_TIMEOUT - 1, HUGE_TIMEOUT}; + for (long t : timeouts) { + if (!test(t)) { + failures++; + } + } + if (failures > 0) { + throw new RuntimeException("Test failed!"); + } else { + System.out.println("Test succeeded"); + } + } + + private static boolean test(final long timeout) + throws InterruptedException, IOException { + theException = null; + + Selector selector = Selector.open(); + + Thread t = new Thread(() -> { + try { + selector.select(timeout); + } catch (IOException ioe) { + theException = ioe; + } + }); + t.start(); + + Thread.currentThread().sleep(SLEEP_MILLIS); + t.interrupt(); + + if (theException == null) { + System.out.printf("Test succeeded with timeout %d%n", timeout); + return true; + } else { + System.err.printf("Test failed with timeout %d%n", timeout); + theException.printStackTrace(); + return false; + } + } +} From 164b17df5b8dd6ecafed975aee5cc938306bdeed Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Sat, 3 Sep 2016 13:43:01 +0300 Subject: [PATCH 145/296] 8165243: Base64.Encoder.wrap(os).write(byte[],int,int) with incorrect arguments should not produce output Reviewed-by: rriggs, alanb, sherman --- .../share/classes/java/util/Base64.java | 4 +- jdk/test/java/util/Base64/TestBase64.java | 169 +++++++++++++----- 2 files changed, 124 insertions(+), 49 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/Base64.java b/jdk/src/java.base/share/classes/java/util/Base64.java index 9a34f279ab3..99f5dc0d993 100644 --- a/jdk/src/java.base/share/classes/java/util/Base64.java +++ b/jdk/src/java.base/share/classes/java/util/Base64.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -788,7 +788,7 @@ public class Base64 { public void write(byte[] b, int off, int len) throws IOException { if (closed) throw new IOException("Stream is closed"); - if (off < 0 || len < 0 || off + len > b.length) + if (off < 0 || len < 0 || len > b.length - off) throw new ArrayIndexOutOfBoundsException(); if (len == 0) return; diff --git a/jdk/test/java/util/Base64/TestBase64.java b/jdk/test/java/util/Base64/TestBase64.java index 0c5e27fd9fd..d28f0d0f88a 100644 --- a/jdk/test/java/util/Base64/TestBase64.java +++ b/jdk/test/java/util/Base64/TestBase64.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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,8 +23,11 @@ /** * @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530 8007379 8008925 - * 8014217 8025003 8026330 8028397 8129544 + * 8014217 8025003 8026330 8028397 8129544 8165243 * @summary tests java.util.Base64 + * @library /lib/testlibrary + * @build jdk.testlibrary.* + * @run main TestBase64 * @key randomness */ @@ -35,11 +38,17 @@ import java.io.IOException; import java.io.OutputStream; import java.nio.ByteBuffer; import java.util.Arrays; +import java.util.ArrayList; import java.util.Base64; +import java.util.List; import java.util.Random; +import jdk.testlibrary.RandomFactory; + public class TestBase64 { + private static final Random rnd = RandomFactory.getRandom(); + public static void main(String args[]) throws Throwable { int numRuns = 10; int numBytes = 200; @@ -52,7 +61,6 @@ public class TestBase64 { test(Base64.getUrlEncoder(), Base64.getUrlDecoder(), numRuns, numBytes); test(Base64.getMimeEncoder(), Base64.getMimeDecoder(), numRuns, numBytes); - Random rnd = new java.util.Random(); byte[] nl_1 = new byte[] {'\n'}; byte[] nl_2 = new byte[] {'\n', '\r'}; byte[] nl_3 = new byte[] {'\n', '\r', '\n'}; @@ -76,7 +84,7 @@ public class TestBase64 { testNull(Base64.getDecoder()); testNull(Base64.getUrlDecoder()); testNull(Base64.getMimeDecoder()); - checkNull(new Runnable() { public void run() { Base64.getMimeEncoder(10, null); }}); + checkNull(() -> Base64.getMimeEncoder(10, null)); testIOE(Base64.getEncoder()); testIOE(Base64.getUrlEncoder()); @@ -84,26 +92,23 @@ public class TestBase64 { testIOE(Base64.getMimeEncoder(10, new byte[]{'\n'})); byte[] src = new byte[1024]; - new Random().nextBytes(src); + rnd.nextBytes(src); final byte[] decoded = Base64.getEncoder().encode(src); testIOE(Base64.getDecoder(), decoded); testIOE(Base64.getMimeDecoder(), decoded); testIOE(Base64.getUrlDecoder(), Base64.getUrlEncoder().encode(src)); // illegal line separator - checkIAE(new Runnable() { public void run() { Base64.getMimeEncoder(10, new byte[]{'\r', 'N'}); }}); + checkIAE(() -> Base64.getMimeEncoder(10, new byte[]{'\r', 'N'})); // malformed padding/ending testMalformedPadding(); // illegal base64 character decoded[2] = (byte)0xe0; - checkIAE(new Runnable() { - public void run() { Base64.getDecoder().decode(decoded); }}); - checkIAE(new Runnable() { - public void run() { Base64.getDecoder().decode(decoded, new byte[1024]); }}); - checkIAE(new Runnable() { public void run() { - Base64.getDecoder().decode(ByteBuffer.wrap(decoded)); }}); + checkIAE(() -> Base64.getDecoder().decode(decoded)); + checkIAE(() -> Base64.getDecoder().decode(decoded, new byte[1024])); + checkIAE(() -> Base64.getDecoder().decode(ByteBuffer.wrap(decoded))); // test single-non-base64 character for mime decoding testSingleNonBase64MimeDec(); @@ -113,12 +118,20 @@ public class TestBase64 { // test mime decoding with ignored character after padding testDecodeIgnoredAfterPadding(); + + // given invalid args, encoder should not produce output + testEncoderKeepsSilence(Base64.getEncoder()); + testEncoderKeepsSilence(Base64.getUrlEncoder()); + testEncoderKeepsSilence(Base64.getMimeEncoder()); + + // given invalid args, decoder should not consume input + testDecoderKeepsAbstinence(Base64.getDecoder()); + testDecoderKeepsAbstinence(Base64.getUrlDecoder()); + testDecoderKeepsAbstinence(Base64.getMimeDecoder()); } private static void test(Base64.Encoder enc, Base64.Decoder dec, int numRuns, int numBytes) throws Throwable { - Random rnd = new java.util.Random(); - enc.encode(new byte[0]); dec.decode(new byte[0]); @@ -258,48 +271,49 @@ public class TestBase64 { private static final String str_null = null; private static final ByteBuffer bb_null = null; - private static void testNull(final Base64.Encoder enc) { - checkNull(new Runnable() { public void run() { enc.encode(ba_null); }}); - checkNull(new Runnable() { public void run() { enc.encodeToString(ba_null); }}); - checkNull(new Runnable() { public void run() { enc.encode(ba_null, new byte[10]); }}); - checkNull(new Runnable() { public void run() { enc.encode(new byte[10], ba_null); }}); - checkNull(new Runnable() { public void run() { enc.encode(bb_null); }}); - checkNull(new Runnable() { public void run() { enc.wrap((OutputStream)null); }}); + private static void testNull(Base64.Encoder enc) { + checkNull(() -> enc.encode(ba_null)); + checkNull(() -> enc.encodeToString(ba_null)); + checkNull(() -> enc.encode(ba_null, new byte[10])); + checkNull(() -> enc.encode(new byte[10], ba_null)); + checkNull(() -> enc.encode(bb_null)); + checkNull(() -> enc.wrap((OutputStream)null)); } - private static void testNull(final Base64.Decoder dec) { - checkNull(new Runnable() { public void run() { dec.decode(ba_null); }}); - checkNull(new Runnable() { public void run() { dec.decode(str_null); }}); - checkNull(new Runnable() { public void run() { dec.decode(ba_null, new byte[10]); }}); - checkNull(new Runnable() { public void run() { dec.decode(new byte[10], ba_null); }}); - checkNull(new Runnable() { public void run() { dec.decode(bb_null); }}); - checkNull(new Runnable() { public void run() { dec.wrap((InputStream)null); }}); + private static void testNull(Base64.Decoder dec) { + checkNull(() -> dec.decode(ba_null)); + checkNull(() -> dec.decode(str_null)); + checkNull(() -> dec.decode(ba_null, new byte[10])); + checkNull(() -> dec.decode(new byte[10], ba_null)); + checkNull(() -> dec.decode(bb_null)); + checkNull(() -> dec.wrap((InputStream)null)); } + @FunctionalInterface private static interface Testable { public void test() throws Throwable; } - private static void testIOE(final Base64.Encoder enc) throws Throwable { + private static void testIOE(Base64.Encoder enc) throws Throwable { ByteArrayOutputStream baos = new ByteArrayOutputStream(8192); - final OutputStream os = enc.wrap(baos); + OutputStream os = enc.wrap(baos); os.write(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9}); os.close(); - checkIOE(new Testable() { public void test() throws Throwable { os.write(10); }}); - checkIOE(new Testable() { public void test() throws Throwable { os.write(new byte[] {10}); }}); - checkIOE(new Testable() { public void test() throws Throwable { os.write(new byte[] {10}, 1, 4); }}); + checkIOE(() -> os.write(10)); + checkIOE(() -> os.write(new byte[] {10})); + checkIOE(() -> os.write(new byte[] {10}, 1, 4)); } - private static void testIOE(final Base64.Decoder dec, byte[] decoded) throws Throwable { + private static void testIOE(Base64.Decoder dec, byte[] decoded) throws Throwable { ByteArrayInputStream bais = new ByteArrayInputStream(decoded); - final InputStream is = dec.wrap(bais); + InputStream is = dec.wrap(bais); is.read(new byte[10]); is.close(); - checkIOE(new Testable() { public void test() throws Throwable { is.read(); }}); - checkIOE(new Testable() { public void test() throws Throwable { is.read(new byte[] {10}); }}); - checkIOE(new Testable() { public void test() throws Throwable { is.read(new byte[] {10}, 1, 4); }}); - checkIOE(new Testable() { public void test() throws Throwable { is.available(); }}); - checkIOE(new Testable() { public void test() throws Throwable { is.skip(20); }}); + checkIOE(() -> is.read()); + checkIOE(() -> is.read(new byte[] {10})); + checkIOE(() -> is.read(new byte[] {10}, 1, 4)); + checkIOE(() -> is.available()); + checkIOE(() -> is.skip(20)); } private static final void checkNull(Runnable r) { @@ -391,13 +405,13 @@ public class TestBase64 { int pos = (Integer)data[i + 2]; // decode(byte[]) - checkIAE(new Runnable() { public void run() { dec.decode(srcBytes); }}); + checkIAE(() -> dec.decode(srcBytes)); // decode(String) - checkIAE(new Runnable() { public void run() { dec.decode(srcStr); }}); + checkIAE(() -> dec.decode(srcStr)); // decode(ByteBuffer) - checkIAE(new Runnable() { public void run() { dec.decode(srcBB); }}); + checkIAE(() -> dec.decode(srcBB)); // wrap stream checkIOE(new Testable() { @@ -412,10 +426,8 @@ public class TestBase64 { // anything left after padding is "invalid"/IAE, if // not MIME. In case of MIME, non-base64 character(s) // is ignored. - checkIAE(new Runnable() { public void run() { - Base64.getDecoder().decode("AA==\u00D2"); }}); - checkIAE(new Runnable() { public void run() { - Base64.getUrlDecoder().decode("AA==\u00D2"); }}); + checkIAE(() -> Base64.getDecoder().decode("AA==\u00D2")); + checkIAE(() -> Base64.getUrlDecoder().decode("AA==\u00D2")); Base64.getMimeDecoder().decode("AA==\u00D2"); } @@ -516,4 +528,67 @@ public class TestBase64 { } return ret; } + + private static void testEncoderKeepsSilence(Base64.Encoder enc) + throws Throwable { + List vals = new ArrayList<>(List.of(Integer.MIN_VALUE, + Integer.MIN_VALUE + 1, -1111, -2, -1, 0, 1, 2, 3, 1111, + Integer.MAX_VALUE - 1, Integer.MAX_VALUE)); + vals.addAll(List.of(rnd.nextInt(), rnd.nextInt(), rnd.nextInt(), + rnd.nextInt())); + byte[] buf = new byte[] {1, 0, 91}; + for (int off : vals) { + for (int len : vals) { + if (off >= 0 && len >= 0 && off <= buf.length - len) { + // valid args, skip them + continue; + } + // invalid args, test them + System.out.println("testing off=" + off + ", len=" + len); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(100); + try (OutputStream os = enc.wrap(baos)) { + os.write(buf, off, len); + throw new RuntimeException("Expected IOOBEx was not thrown"); + } catch (IndexOutOfBoundsException expected) { + } + if (baos.size() > 0) + throw new RuntimeException("No output was expected, but got " + + baos.size() + " bytes"); + } + } + } + + private static void testDecoderKeepsAbstinence(Base64.Decoder dec) + throws Throwable { + List vals = new ArrayList<>(List.of(Integer.MIN_VALUE, + Integer.MIN_VALUE + 1, -1111, -2, -1, 0, 1, 2, 3, 1111, + Integer.MAX_VALUE - 1, Integer.MAX_VALUE)); + vals.addAll(List.of(rnd.nextInt(), rnd.nextInt(), rnd.nextInt(), + rnd.nextInt())); + byte[] buf = new byte[3]; + for (int off : vals) { + for (int len : vals) { + if (off >= 0 && len >= 0 && off <= buf.length - len) { + // valid args, skip them + continue; + } + // invalid args, test them + System.out.println("testing off=" + off + ", len=" + len); + + String input = "AAAAAAAAAAAAAAAAAAAAAA"; + ByteArrayInputStream bais = + new ByteArrayInputStream(input.getBytes("Latin1")); + try (InputStream is = dec.wrap(bais)) { + is.read(buf, off, len); + throw new RuntimeException("Expected IOOBEx was not thrown"); + } catch (IndexOutOfBoundsException expected) { + } + if (bais.available() != input.length()) + throw new RuntimeException("No input should be consumed, " + + "but consumed " + (input.length() - bais.available()) + + " bytes"); + } + } + } } From 5044a0fdc4e29ea83e0f9a0faafdd59545483f82 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Mon, 5 Sep 2016 10:05:12 +0200 Subject: [PATCH 146/296] 8163181: Further improvements for Unix NetworkInterface native implementation Reviewed-by: chegar, msheppar --- .../unix/native/libnet/NetworkInterface.c | 391 +++++++++--------- 1 file changed, 199 insertions(+), 192 deletions(-) diff --git a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c index 3efde95813a..d5b1824b314 100644 --- a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c +++ b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c @@ -80,6 +80,12 @@ #define DEV_PREFIX "/dev/" #endif +#ifdef LIFNAMSIZ + #define IFNAMESIZE LIFNAMSIZ +#else + #define IFNAMESIZE IFNAMSIZ +#endif + #define CHECKED_MALLOC3(_pointer, _type, _size) \ do { \ _pointer = (_type)malloc(_size); \ @@ -158,7 +164,7 @@ static short translateIPv6AddressToPrefix(struct sockaddr_in6 *addr); static int getIndex(int sock, const char *ifname); static int getFlags(int sock, const char *ifname, int *flags); -static int getMacAddress(JNIEnv *env, int sock, const char *ifname, +static int getMacAddress(JNIEnv *env, const char *ifname, const struct in_addr *addr, unsigned char *buf); static int getMTU(JNIEnv *env, int sock, const char *ifname); @@ -237,20 +243,25 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0 const char* name_utf; jobject obj = NULL; + if (name != NULL) { + name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); + } else { + JNU_ThrowNullPointerException(env, "network interface name is NULL"); + return NULL; + } + + if (name_utf == NULL) { + if (!(*env)->ExceptionCheck(env)) + JNU_ThrowOutOfMemoryError(env, NULL); + return NULL; + } + ifs = enumInterfaces(env); if (ifs == NULL) { return NULL; } - name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); - if (name_utf == NULL) { - if (!(*env)->ExceptionCheck(env)) - JNU_ThrowOutOfMemoryError(env, NULL); - freeif(ifs); - return NULL; - } - - // Search the list of interface based on name + // search the list of interfaces based on name curr = ifs; while (curr != NULL) { if (strcmp(name_utf, curr->name) == 0) { @@ -285,12 +296,13 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0 if (index <= 0) { return NULL; } + ifs = enumInterfaces(env); if (ifs == NULL) { return NULL; } - // Search the list of interface based on index + // search the list of interfaces based on index curr = ifs; while (curr != NULL) { if (index == curr->index) { @@ -304,7 +316,9 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0 obj = createNetworkInterface(env, curr); } + // release the interface list freeif(ifs); + return obj; } @@ -317,13 +331,11 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0 (JNIEnv *env, jclass cls, jobject iaObj) { netif *ifs, *curr; - #if defined(AF_INET6) int family = (getInetAddress_family(env, iaObj) == IPv4) ? AF_INET : AF_INET6; #else int family = AF_INET; #endif - jobject obj = NULL; jboolean match = JNI_FALSE; @@ -342,7 +354,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0 if (family == addrP->family) { if (family == AF_INET) { int address1 = htonl( - ((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr); + ((struct sockaddr_in *)addrP->addr)->sin_addr.s_addr); int address2 = getInetAddress_addr(env, iaObj); if (address1 == address2) { @@ -350,7 +362,6 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0 break; } } - #if defined(AF_INET6) if (family == AF_INET6) { jbyte *bytes = (jbyte *)&( @@ -390,7 +401,9 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0 obj = createNetworkInterface(env, curr); } + // release the interface list freeif(ifs); + return obj; } @@ -411,7 +424,7 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll return NULL; } - // count the interface + // count the interfaces ifCount = 0; curr = ifs; while (curr != NULL) { @@ -426,8 +439,8 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll return NULL; } - // Iterate through the interfaces, create a NetworkInterface instance - // for each array element and populate the object. + // iterate through the interfaces, create a NetworkInterface instance + // for each array element and populate the object curr = ifs; arr_index = 0; while (curr != NULL) { @@ -445,7 +458,9 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll curr = curr->next; } + // release the interface list freeif(ifs); + return netIFArr; } @@ -511,46 +526,45 @@ JNIEXPORT jbyteArray JNICALL Java_java_net_NetworkInterface_getMacAddr0 jbyteArray ret = NULL; unsigned char mac[16]; int len; - int sock; jboolean isCopy; - const char* name_utf; + const char *name_utf; - name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); - if (name_utf == NULL) { - if (!(*env)->ExceptionCheck(env)) - JNU_ThrowOutOfMemoryError(env, NULL); - return NULL; + if (name != NULL) { + name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); + } else { + JNU_ThrowNullPointerException(env, "network interface name is NULL"); + return NULL; } - if ((sock = openSocketWithFallback(env, name_utf)) < 0) { - (*env)->ReleaseStringUTFChars(env, name, name_utf); - return NULL; + + if (name_utf == NULL) { + if (!(*env)->ExceptionCheck(env)) + JNU_ThrowOutOfMemoryError(env, NULL); + return NULL; } if (!IS_NULL(addrArray)) { - (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr); - addr = ((caddr[0]<<24) & 0xff000000); - addr |= ((caddr[1] <<16) & 0xff0000); - addr |= ((caddr[2] <<8) & 0xff00); - addr |= (caddr[3] & 0xff); - iaddr.s_addr = htonl(addr); - len = getMacAddress(env, sock, name_utf, &iaddr, mac); + (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr); + addr = ((caddr[0]<<24) & 0xff000000); + addr |= ((caddr[1] <<16) & 0xff0000); + addr |= ((caddr[2] <<8) & 0xff00); + addr |= (caddr[3] & 0xff); + iaddr.s_addr = htonl(addr); + len = getMacAddress(env, name_utf, &iaddr, mac); } else { - len = getMacAddress(env, sock, name_utf, NULL, mac); + len = getMacAddress(env, name_utf, NULL, mac); } - if (len > 0) { - ret = (*env)->NewByteArray(env, len); - if (IS_NULL(ret)) { - /* we may have memory to free at the end of this */ - goto fexit; - } - (*env)->SetByteArrayRegion(env, ret, 0, len, (jbyte *)(mac)); - } - fexit: - // release the UTF string and interface list - (*env)->ReleaseStringUTFChars(env, name, name_utf); - close(sock); - return ret; + if (len > 0) { + ret = (*env)->NewByteArray(env, len); + if (!IS_NULL(ret)) { + (*env)->SetByteArrayRegion(env, ret, 0, len, (jbyte *)(mac)); + } + } + + // release the UTF string and interface list + (*env)->ReleaseStringUTFChars(env, name, name_utf); + + return ret; } /* @@ -562,8 +576,7 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0 (JNIEnv *env, jclass cls, jstring name, jint index) { jboolean isCopy; - int ret = -1; - int sock; + int sock, ret = -1; const char* name_utf = NULL; if (name != NULL) { @@ -572,15 +585,16 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0 JNU_ThrowNullPointerException(env, "network interface name is NULL"); return ret; } + if (name_utf == NULL) { - if (!(*env)->ExceptionCheck(env)) - JNU_ThrowOutOfMemoryError(env, NULL); - return ret; + if (!(*env)->ExceptionCheck(env)) + JNU_ThrowOutOfMemoryError(env, NULL); + return ret; } if ((sock = openSocketWithFallback(env, name_utf)) < 0) { - (*env)->ReleaseStringUTFChars(env, name, name_utf); - return JNI_FALSE; + (*env)->ReleaseStringUTFChars(env, name, name_utf); + return JNI_FALSE; } ret = getMTU(env, sock, name_utf); @@ -595,9 +609,8 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0 static int getFlags0(JNIEnv *env, jstring name) { jboolean isCopy; - int ret, sock; - const char* name_utf; - int flags = 0; + int ret, sock, flags = 0; + const char *name_utf; if (name != NULL) { name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); @@ -607,9 +620,9 @@ static int getFlags0(JNIEnv *env, jstring name) { } if (name_utf == NULL) { - if (!(*env)->ExceptionCheck(env)) - JNU_ThrowOutOfMemoryError(env, NULL); - return -1; + if (!(*env)->ExceptionCheck(env)) + JNU_ThrowOutOfMemoryError(env, NULL); + return -1; } if ((sock = openSocketWithFallback(env, name_utf)) < 0) { (*env)->ReleaseStringUTFChars(env, name, name_utf); @@ -648,7 +661,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { netif *childP; jobject tmp; - // Create a NetworkInterface object and populate it + // create a NetworkInterface object and populate it netifObj = (*env)->NewObject(env, ni_class, ni_ctrID); CHECK_NULL_RETURN(netifObj, NULL); name = (*env)->NewStringUTF(env, ifs->name); @@ -659,7 +672,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { (*env)->SetBooleanField(env, netifObj, ni_virutalID, ifs->virtual ? JNI_TRUE : JNI_FALSE); - //Count the number of address on this interface + // count the number of addresses on this interface addr_count = 0; addrP = ifs->addr; while (addrP != NULL) { @@ -667,7 +680,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { addrP = addrP->next; } - // Create the array of InetAddresses + // create the array of InetAddresses addrArr = (*env)->NewObjectArray(env, addr_count, ia_class, NULL); if (addrArr == NULL) { return NULL; @@ -687,32 +700,31 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { if (addrP->family == AF_INET) { iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (iaObj) { - setInetAddress_addr(env, iaObj, htonl( - ((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr)); + setInetAddress_addr(env, iaObj, htonl( + ((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr)); } else { return NULL; } ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID); if (ibObj) { - (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj); - if (addrP->brdcast) { + (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj); + if (addrP->brdcast) { jobject ia2Obj = NULL; ia2Obj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (ia2Obj) { - setInetAddress_addr(env, ia2Obj, htonl( - ((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr)); - (*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj); + setInetAddress_addr(env, ia2Obj, htonl( + ((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr)); + (*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj); } else { return NULL; } - } - (*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask); - (*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj); + } + (*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask); + (*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj); } else { return NULL; } } - #if defined(AF_INET6) if (addrP->family == AF_INET6) { int scope=0; @@ -748,7 +760,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { addrP = addrP->next; } - // See if there is any virtual interface attached to this one. + // see if there is any virtual interface attached to this one. child_count = 0; childP = ifs->childs; while (childP) { @@ -761,17 +773,17 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { return NULL; } - // Create the NetworkInterface instances for the sub-interfaces as well. + // create the NetworkInterface instances for the sub-interfaces as well child_index = 0; childP = ifs->childs; while(childP) { - tmp = createNetworkInterface(env, childP); - if (tmp == NULL) { - return NULL; - } - (*env)->SetObjectField(env, tmp, ni_parentID, netifObj); - (*env)->SetObjectArrayElement(env, childArr, child_index++, tmp); - childP = childP->next; + tmp = createNetworkInterface(env, childP); + if (tmp == NULL) { + return NULL; + } + (*env)->SetObjectField(env, tmp, ni_parentID, netifObj); + (*env)->SetObjectArrayElement(env, childArr, child_index++, tmp); + childP = childP->next; } (*env)->SetObjectField(env, netifObj, ni_addrsID, addrArr); (*env)->SetObjectField(env, netifObj, ni_bindsID, bindArr); @@ -785,46 +797,42 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { * Enumerates all interfaces */ static netif *enumInterfaces(JNIEnv *env) { - netif *ifs; + netif *ifs = NULL; int sock; - // Enumerate IPv4 addresses sock = openSocket(env, AF_INET); if (sock < 0 && (*env)->ExceptionOccurred(env)) { return NULL; } + // enumerate IPv4 addresses ifs = enumIPv4Interfaces(env, sock, NULL); close(sock); + // return partial list if an exception occurs in the middle of process ??? if (ifs == NULL && (*env)->ExceptionOccurred(env)) { return NULL; } - // return partial list if an exception occurs in the middle of process ??? - // If IPv6 is available then enumerate IPv6 addresses. #if defined(AF_INET6) - // User can disable ipv6 explicitly by -Djava.net.preferIPv4Stack=true, // so we have to call ipv6_available() if (ipv6_available()) { + sock = openSocket(env, AF_INET6); + if (sock < 0 && (*env)->ExceptionOccurred(env)) { + freeif(ifs); + return NULL; + } - sock = openSocket(env, AF_INET6); - if (sock < 0 && (*env)->ExceptionOccurred(env)) { - freeif(ifs); - return NULL; - } + ifs = enumIPv6Interfaces(env, sock, ifs); + close(sock); - ifs = enumIPv6Interfaces(env, sock, ifs); - close(sock); - - if ((*env)->ExceptionOccurred(env)) { - freeif(ifs); - return NULL; - } - - } + if ((*env)->ExceptionOccurred(env)) { + freeif(ifs); + return NULL; + } + } #endif return ifs; @@ -845,7 +853,7 @@ static void freeif(netif *ifs) { addrP = next; } - // Don't forget to free the sub-interfaces. + // don't forget to free the sub-interfaces if (currif->childs != NULL) { freeif(currif->childs); } @@ -863,26 +871,17 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs, { netif *currif = ifs, *parent; netaddr *addrP; - -#ifdef LIFNAMSIZ - int ifnam_size = LIFNAMSIZ; - char name[LIFNAMSIZ], vname[LIFNAMSIZ]; -#else - int ifnam_size = IFNAMSIZ; - char name[IFNAMSIZ], vname[IFNAMSIZ]; -#endif - + char name[IFNAMESIZE], vname[IFNAMESIZE]; char *name_colonP; int isVirtual = 0; int addr_size; - int flags = 0; // If the interface name is a logical interface then we remove the unit // number so that we have the physical interface (eg: hme0:1 -> hme0). // NetworkInterface currently doesn't have any concept of physical vs. // logical interfaces. - strncpy(name, if_name, ifnam_size); - name[ifnam_size - 1] = '\0'; + strncpy(name, if_name, IFNAMESIZE); + name[IFNAMESIZE - 1] = '\0'; *vname = 0; // Create and populate the netaddr node. If allocation fails @@ -917,20 +916,21 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs, // Deal with virtual interface with colon notation e.g. eth0:1 name_colonP = strchr(name, ':'); if (name_colonP != NULL) { + int flags = 0; // This is a virtual interface. If we are able to access the parent // we need to create a new entry if it doesn't exist yet *and* update // the 'parent' interface with the new records. *name_colonP = 0; if (getFlags(sock, name, &flags) < 0 || flags < 0) { - // failed to access parent interface do not create parent. - // We are a virtual interface with no parent. - isVirtual = 1; - *name_colonP = ':'; + // failed to access parent interface do not create parent. + // We are a virtual interface with no parent. + isVirtual = 1; + *name_colonP = ':'; } else { - // Got access to parent, so create it if necessary. - // Save original name to vname and truncate name by ':' - memcpy(vname, name, sizeof(vname) ); - vname[name_colonP - name] = ':'; + // Got access to parent, so create it if necessary. + // Save original name to vname and truncate name by ':' + memcpy(vname, name, sizeof(vname)); + vname[name_colonP - name] = ':'; } } @@ -943,12 +943,12 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs, currif = currif->next; } - // If "new" then create an netif structure and insert it into the list. + // If "new" then create a netif structure and insert it into the list. if (currif == NULL) { - CHECKED_MALLOC3(currif, netif *, sizeof(netif) + ifnam_size); + CHECKED_MALLOC3(currif, netif *, sizeof(netif) + IFNAMESIZE); currif->name = (char *)currif + sizeof(netif); - strncpy(currif->name, name, ifnam_size); - currif->name[ifnam_size - 1] = '\0'; + strncpy(currif->name, name, IFNAMESIZE); + currif->name[IFNAMESIZE - 1] = '\0'; currif->index = getIndex(sock, name); currif->addr = NULL; currif->childs = NULL; @@ -977,13 +977,12 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs, } if (currif == NULL) { - CHECKED_MALLOC3(currif, netif *, sizeof(netif) + ifnam_size); + CHECKED_MALLOC3(currif, netif *, sizeof(netif) + IFNAMESIZE); currif->name = (char *)currif + sizeof(netif); - strncpy(currif->name, vname, ifnam_size); - currif->name[ifnam_size - 1] = '\0'; + strncpy(currif->name, vname, IFNAMESIZE); + currif->name[IFNAMESIZE - 1] = '\0'; currif->index = getIndex(sock, vname); - currif->addr = NULL; - // Need to duplicate the addr entry? + currif->addr = NULL; // Need to duplicate the addr entry? currif->virtual = 1; currif->childs = NULL; currif->next = parent->childs; @@ -1150,7 +1149,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { struct sockaddr addr, broadaddr, *broadaddrP = NULL; short prefix = 0; - // ignore non IPv4 interfaces + // ignore non IPv4 addresses if (ifreqP->ifr_addr.sa_family != AF_INET) { continue; } @@ -1264,19 +1263,26 @@ static int getIndex(int sock, const char *name) { * MAC address. Returns -1 if there is no hardware address on that interface. */ static int getMacAddress - (JNIEnv *env, int sock, const char *ifname, const struct in_addr *addr, + (JNIEnv *env, const char *ifname, const struct in_addr *addr, unsigned char *buf) { static struct ifreq ifr; - int i; + int i, sock; + + if ((sock = openSocketWithFallback(env, ifname)) < 0) { + return -1; + } + memset((char *)&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFHWADDR) failed"); + close(sock); return -1; } + close(sock); memcpy(buf, &ifr.ifr_hwaddr.sa_data, IFHWADDRLEN); // all bytes to 0 means no hardware address @@ -1388,7 +1394,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { struct sockaddr addr, broadaddr, *broadaddrP = NULL; short prefix = 0; - // ignore non IPv4 interfaces + // ignore non IPv4 addresses if (ifreqP->ifr_addr.sa_family != AF_INET) { continue; } @@ -1444,7 +1450,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { struct ifconf ifc; struct ifreq *ifreqP; - char *buf; + char *buf, *cp, *cplimit; // call SIOCGSIZIFCONF to get size for SIOCGIFCONF buffer if (ioctl(sock, SIOCGSIZIFCONF, &(ifc.ifc_len)) < 0) { @@ -1464,8 +1470,9 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { } // iterate through each interface - char *cp = (char *)ifc.ifc_req; - char *cplimit = cp + ifc.ifc_len; + ifreqP = ifc.ifc_req; + cp = (char *)ifc.ifc_req; + cplimit = cp + ifc.ifc_len; for (; cp < cplimit; cp += (sizeof(ifreqP->ifr_name) + @@ -1474,7 +1481,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { ifreqP = (struct ifreq *)cp; short prefix = 0; - // ignore non IPv6 interfaces + // ignore non IPv6 addresses if (ifreqP->ifr_addr.sa_family != AF_INET6) { continue; } @@ -1527,7 +1534,7 @@ static int getIndex(int sock, const char *name) { * MAC address. Returns -1 if there is no hardware address on that interface. */ static int getMacAddress - (JNIEnv *env, int sock, const char *ifname, const struct in_addr *addr, + (JNIEnv *env, const char *ifname, const struct in_addr *addr, unsigned char *buf) { int size; @@ -1586,20 +1593,20 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) { } static int getFlags(int sock, const char *ifname, int *flags) { - struct ifreq if2; - memset((char *)&if2, 0, sizeof(if2)); - strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1); + struct ifreq if2; + memset((char *)&if2, 0, sizeof(if2)); + strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1); - if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) { - return -1; - } + if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) { + return -1; + } - if (sizeof(if2.ifr_flags) == sizeof(short)) { - *flags = (if2.ifr_flags & 0xffff); - } else { - *flags = if2.ifr_flags; - } - return 0; + if (sizeof(if2.ifr_flags) == sizeof(short)) { + *flags = (if2.ifr_flags & 0xffff); + } else { + *flags = if2.ifr_flags; + } + return 0; } #endif /* _AIX */ @@ -1668,7 +1675,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { char *buf = NULL; unsigned i; - // call SIOCGLIFNUM to get the size of SIOCGIFCONF buffer + // call SIOCGLIFNUM to get the interface count numifs.lifn_family = AF_INET; numifs.lifn_flags = 0; if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) { @@ -1695,7 +1702,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { for (i = 0; i < numifs.lifn_count; i++, ifreqP++) { struct sockaddr addr, *broadaddrP = NULL; - // ignore non IPv4 interfaces + // ignore non IPv4 addresses if (ifreqP->lifr_addr.ss_family != AF_INET) { continue; } @@ -1744,7 +1751,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { char *buf = NULL; unsigned i; - // call SIOCGLIFNUM to get the size of SIOCGLIFCONF buffer + // call SIOCGLIFNUM to get the interface count numifs.lifn_family = AF_INET6; numifs.lifn_flags = 0; if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) { @@ -1770,7 +1777,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { ifreqP = ifc.lifc_req; for (i = 0; i < numifs.lifn_count; i++, ifreqP++) { - // ignore non IPv6 interfaces + // ignore non IPv6 addresses if (ifreqP->lifr_addr.ss_family != AF_INET6) { continue; } @@ -1789,7 +1796,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { free(buf); return ifs; } - } + } // free buffer free(buf); @@ -1834,9 +1841,9 @@ static int getMacFromDevice strcpy(style1dev, DEV_PREFIX); strcat(style1dev, ifname); if ((fd = open(style1dev, O_RDWR)) < 0) { - // Can't open it. We probably are missing the privilege. - // We'll have to try something else - return 0; + // Can't open it. We probably are missing the privilege. + // We'll have to try something else + return 0; } dlpareq.dl_primitive = DL_PHYS_ADDR_REQ; @@ -1878,11 +1885,15 @@ static int getMacFromDevice * MAC address. Returns -1 if there is no hardware address on that interface. */ static int getMacAddress - (JNIEnv *env, int sock, const char *ifname, const struct in_addr *addr, + (JNIEnv *env, const char *ifname, const struct in_addr *addr, unsigned char *buf) { struct lifreq if2; - int len, i; + int len, i, sock; + + if ((sock = openSocketWithFallback(env, ifname)) < 0) { + return -1; + } // First, try the new (S11) SIOCGLIFHWADDR ioctl(). If that fails // try the old way. @@ -1893,40 +1904,36 @@ static int getMacAddress struct sockaddr_dl *sp; sp = (struct sockaddr_dl *)&if2.lifr_addr; memcpy(buf, &sp->sdl_data[0], sp->sdl_alen); + close(sock); return sp->sdl_alen; } // On Solaris we have to use DLPI, but it will only work if we have // privileged access (i.e. root). If that fails, we try a lookup // in the ARP table, which requires an IPv4 address. - if ((len = getMacFromDevice(env, ifname, buf)) == 0) { - // DLPI failed - trying to do arp lookup - + if (((len = getMacFromDevice(env, ifname, buf)) == 0) && (addr != NULL)) { struct arpreq arpreq; struct sockaddr_in *sin; struct sockaddr_in ipAddr; - if (addr == NULL) { - // No IPv4 address for that interface, so can't do an ARP lookup. - return -1; - } + len = 6; //??? - len = 6; //??? + sin = (struct sockaddr_in *)&arpreq.arp_pa; + memset((char *)&arpreq, 0, sizeof(struct arpreq)); + ipAddr.sin_port = 0; + ipAddr.sin_family = AF_INET; + memcpy(&ipAddr.sin_addr, addr, sizeof(struct in_addr)); + memcpy(&arpreq.arp_pa, &ipAddr, sizeof(struct sockaddr_in)); + arpreq.arp_flags= ATF_PUBL; - sin = (struct sockaddr_in *)&arpreq.arp_pa; - memset((char *)&arpreq, 0, sizeof(struct arpreq)); - ipAddr.sin_port = 0; - ipAddr.sin_family = AF_INET; - memcpy(&ipAddr.sin_addr, addr, sizeof(struct in_addr)); - memcpy(&arpreq.arp_pa, &ipAddr, sizeof(struct sockaddr_in)); - arpreq.arp_flags= ATF_PUBL; + if (ioctl(sock, SIOCGARP, &arpreq) < 0) { + close(sock); + return -1; + } - if (ioctl(sock, SIOCGARP, &arpreq) < 0) { - return -1; - } - - memcpy(buf, &arpreq.arp_ha.sa_data[0], len); + memcpy(buf, &arpreq.arp_ha.sa_data[0], len); } + close(sock); // all bytes to 0 means no hardware address for (i = 0; i < len; i++) { @@ -2014,7 +2021,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { for (ifa = origifa; ifa != NULL; ifa = ifa->ifa_next) { struct sockaddr *broadaddrP = NULL; - // ignore non IPv4 interfaces + // ignore non IPv4 addresses if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_INET) continue; @@ -2058,7 +2065,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { } for (ifa = origifa; ifa != NULL; ifa = ifa->ifa_next) { - // ignore non IPv6 interfaces + // ignore non IPv6 addresses if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -2113,22 +2120,22 @@ static int getIndex(int sock, const char *name) { * MAC address. Returns -1 if there is no hardware address on that interface. */ static int getMacAddress - (JNIEnv *env, int sock, const char *ifname, const struct in_addr *addr, + (JNIEnv *env, const char *ifname, const struct in_addr *addr, unsigned char *buf) { struct ifaddrs *ifa0, *ifa; struct sockaddr *saddr; int i; - // Grab the interface list + // grab the interface list if (!getifaddrs(&ifa0)) { - // Cycle through the interfaces + // cycle through the interfaces for (i = 0, ifa = ifa0; ifa != NULL; ifa = ifa->ifa_next, i++) { saddr = ifa->ifa_addr; - // Link layer contains the MAC address + // link layer contains the MAC address if (saddr->sa_family == AF_LINK && !strcmp(ifname, ifa->ifa_name)) { struct sockaddr_dl *sadl = (struct sockaddr_dl *) saddr; - // Check the address is the correct length + // check the address has the correct length if (sadl->sdl_alen == ETHER_ADDR_LEN) { memcpy(buf, (sadl->sdl_data + sadl->sdl_nlen), ETHER_ADDR_LEN); freeifaddrs(ifa0); From da68b22b6a65458ca17b6ee2b51bb911a4bb72d4 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Mon, 5 Sep 2016 10:10:29 +0200 Subject: [PATCH 147/296] 8165314: Javac server process left running if build fails on Windows Reviewed-by: tbell, wetmore --- make/Init.gmk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/make/Init.gmk b/make/Init.gmk index 6ed612b28a2..15ae487555c 100644 --- a/make/Init.gmk +++ b/make/Init.gmk @@ -314,6 +314,9 @@ else # HAS_SPEC=true endif on-failure: + $(call CleanupSmartJavac) + $(call StopGlobalTimer) + $(call ReportBuildTimes) $(call PrintFailureReports) $(call PrintBuildLogFailures) $(PRINTF) "Hint: If caused by a warning, try configure --disable-warnings-as-errors.\n\n" From 02654e7d3dafbe748aed20808502d9b72adeebcc Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Mon, 5 Sep 2016 20:40:08 -0400 Subject: [PATCH 148/296] 8165018: Missing memory barrier for PPC64 in Unsafe_GetObjectVolatile Reviewed-by: kbarrett, dholmes --- hotspot/src/share/vm/prims/unsafe.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 55a968170a5..2d836ccc160 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -324,6 +324,10 @@ UNSAFE_ENTRY(jobject, Unsafe_GetObjectVolatile(JNIEnv *env, jobject unsafe, jobj volatile oop v; + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + OrderAccess::fence(); + } + if (UseCompressedOops) { volatile narrowOop n = *(volatile narrowOop*) addr; (void)const_cast(v = oopDesc::decode_heap_oop(n)); From fec04dd065caaa870880687ddbdb77be60db8d5a Mon Sep 17 00:00:00 2001 From: Sharath Ballal Date: Tue, 6 Sep 2016 09:37:55 +0300 Subject: [PATCH 149/296] 8164943: sun/tools/jhsdb/HeapDumpTest failed with Can't find library: /test/lib/share/classes Change /test/lib/share/classes to /test/lib in HeapDumpTest.java Reviewed-by: dsamersoff, ctornqvi --- jdk/test/sun/tools/jhsdb/HeapDumpTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jdk/test/sun/tools/jhsdb/HeapDumpTest.java b/jdk/test/sun/tools/jhsdb/HeapDumpTest.java index 2c57252f76b..59772a3c421 100644 --- a/jdk/test/sun/tools/jhsdb/HeapDumpTest.java +++ b/jdk/test/sun/tools/jhsdb/HeapDumpTest.java @@ -25,10 +25,8 @@ * @test * @bug 8163346 * @summary Test hashing of extended characters in Serviceability Agent. - * @library /test/lib/share/classes + * @library /test/lib * @library /lib/testlibrary - * @build jdk.testlibrary.* - * @build jdk.test.lib.apps.* * @compile -encoding utf8 HeapDumpTest.java * @run main/timeout=240 HeapDumpTest */ From 848db998d9633625374c4a420f8c269a03c57591 Mon Sep 17 00:00:00 2001 From: Sharath Ballal Date: Tue, 6 Sep 2016 09:54:45 +0300 Subject: [PATCH 150/296] 8165114: stale reference to hotspot test Test8028623.java Remove Test8028623.java from hotspot/test/TEST.groups Reviewed-by: sla, dholmes --- hotspot/test/TEST.groups | 1 - 1 file changed, 1 deletion(-) diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups index 2fdda388eea..fc1eae68feb 100644 --- a/hotspot/test/TEST.groups +++ b/hotspot/test/TEST.groups @@ -168,7 +168,6 @@ needs_compact3 = \ runtime/InternalApi/ThreadCpuTimesDeadlock.java \ runtime/NMT/JcmdSummaryDiff.java \ runtime/RedefineTests/RedefineAnnotations.java \ - serviceability/sa/jmap-hashcode/Test8028623.java \ serviceability/threads/TestFalseDeadLock.java \ compiler/codecache/jmx \ compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java \ From d356b8d0850647010912ee7cf685916024626f94 Mon Sep 17 00:00:00 2001 From: Amit Sapre Date: Tue, 6 Sep 2016 13:57:03 +0530 Subject: [PATCH 151/296] 8164730: Make it clear that 'cl' parameter passed to RMIConnector.OISWL is never null Added checks inside constructor of ObjectInputStreamWithLoader inner class. Test case added. Reviewed-by: dfuchs, alanb --- .../management/remote/rmi/RMIConnector.java | 10 ++- ...ectInputStreamWithLoaderNullCheckTest.java | 84 +++++++++++++++++++ 2 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 jdk/test/javax/management/remote/mandatory/connection/ObjectInputStreamWithLoaderNullCheckTest.java diff --git a/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java b/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java index cbf32ee5834..93a5c7cbdd1 100644 --- a/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java +++ b/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -64,6 +64,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Hashtable; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.WeakHashMap; import java.util.stream.Collectors; @@ -1851,8 +1852,11 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable private static final class ObjectInputStreamWithLoader extends ObjectInputStream { ObjectInputStreamWithLoader(InputStream in, ClassLoader cl) - throws IOException { + throws IOException, IllegalArgumentException { super(in); + if (cl == null ) { + throw new IllegalArgumentException("class loader is null"); + } this.loader = cl; } @@ -1861,7 +1865,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable throws IOException, ClassNotFoundException { String name = classDesc.getName(); ReflectUtil.checkPackageAccess(name); - return Class.forName(name, false, loader); + return Class.forName(name, false, Objects.requireNonNull(loader)); } private final ClassLoader loader; diff --git a/jdk/test/javax/management/remote/mandatory/connection/ObjectInputStreamWithLoaderNullCheckTest.java b/jdk/test/javax/management/remote/mandatory/connection/ObjectInputStreamWithLoaderNullCheckTest.java new file mode 100644 index 00000000000..44a59113732 --- /dev/null +++ b/jdk/test/javax/management/remote/mandatory/connection/ObjectInputStreamWithLoaderNullCheckTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8009560 + * @summary Test RMIConnector.ObjectInputStreamWithLoader constructor with + * null Class loader. The test expects a IllegalArgumentException + * thrown when constructor is invoked with null class loader as + * an argument. + * @author Amit Sapre + * @modules java.management + * @run clean ObjectInputStreamWithLoaderNullCheckTest + * @run build ObjectInputStreamWithLoaderNullCheckTest + * @run main ObjectInputStreamWithLoaderNullCheckTest + */ + +import java.lang.reflect.*; +import javax.management.remote.*; +import javax.management.remote.rmi.*; +import java.io.*; + +public class ObjectInputStreamWithLoaderNullCheckTest { + + private static Class innerClass; + + public static void main(String[] args) throws Exception { + + System.out.println(">> == ObjectInputStreamWithLoaderNullCheckTest started..."); + + try { + innerClass = Class.forName("javax.management.remote.rmi.RMIConnector$ObjectInputStreamWithLoader"); + Constructor ctor = innerClass.getDeclaredConstructor(InputStream.class,ClassLoader.class); + ctor.setAccessible(true); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutput objOut = new ObjectOutputStream(baos); + objOut.writeObject(new String("Serialize")); + objOut.close(); + baos.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + + System.out.println(">> == Testing constructor with null class loader."); + Object obj = ctor.newInstance(bais,null); + + System.out.println(">> == Test case failed. No error occured"); + System.exit(1); + } catch (InvocationTargetException ex) { + Throwable cause = ex.getCause(); + System.out.println(">> == InvocationTargetException Cause message : " + cause.toString()); + if (cause instanceof IllegalArgumentException) { + System.out.println(">> == Test case Passed."); + } else { + System.out.println(">> == Test case Failed."); + ex.printStackTrace(); + System.exit(1); + } + } catch (Exception ex) { + System.out.println(">>> == Test case failed with error " + ex.getCause().getMessage()); + ex.printStackTrace(); + System.exit(1); + } + } +} From 09e25d0d1f577e1106fe43d26eea1e65326d2581 Mon Sep 17 00:00:00 2001 From: Vyom Tewari Date: Tue, 6 Sep 2016 14:11:12 +0530 Subject: [PATCH 152/296] 8131061: Use of -Dcom.sun.management.snmp needs to be examined for modules Reviewed-by: mchung, dfuchs --- .../share/classes/module-info.java | 3 +- .../share/classes/sun/management/Agent.java | 53 ++++++----- .../sun/management/spi/AgentProvider.java | 92 +++++++++++++++++++ 3 files changed, 120 insertions(+), 28 deletions(-) create mode 100644 jdk/src/java.management/share/classes/sun/management/spi/AgentProvider.java diff --git a/jdk/src/java.management/share/classes/module-info.java b/jdk/src/java.management/share/classes/module-info.java index 6772da9d8ee..54ccb16107a 100644 --- a/jdk/src/java.management/share/classes/module-info.java +++ b/jdk/src/java.management/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -50,6 +50,7 @@ module java.management { uses javax.management.remote.JMXConnectorProvider; uses javax.management.remote.JMXConnectorServerProvider; uses sun.management.spi.PlatformMBeanProvider; + uses sun.management.spi.AgentProvider; provides javax.security.auth.spi.LoginModule with com.sun.jmx.remote.security.FileLoginModule; diff --git a/jdk/src/java.management/share/classes/sun/management/Agent.java b/jdk/src/java.management/share/classes/sun/management/Agent.java index be68601ce0e..fbc80433793 100644 --- a/jdk/src/java.management/share/classes/sun/management/Agent.java +++ b/jdk/src/java.management/share/classes/sun/management/Agent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -31,17 +31,19 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.lang.management.ManagementFactory; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.UnknownHostException; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; import java.util.MissingResourceException; import java.util.Properties; import java.util.ResourceBundle; +import java.util.ServiceLoader; import java.util.function.Function; import java.util.function.Predicate; @@ -53,6 +55,7 @@ import sun.management.jmxremote.ConnectorBootstrap; import sun.management.jdp.JdpController; import sun.management.jdp.JdpException; import jdk.internal.vm.VMSupport; +import sun.management.spi.AgentProvider; /** * This Agent is started by the VM when -Dcom.sun.management.snmp or @@ -248,8 +251,8 @@ public class Agent { "com.sun.management.enableThreadContentionMonitoring"; private static final String LOCAL_CONNECTOR_ADDRESS_PROP = "com.sun.management.jmxremote.localConnectorAddress"; - private static final String SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME = - "sun.management.snmp.AdaptorBootstrap"; + private static final String SNMP_AGENT_NAME = + "SnmpAgent"; private static final String JDP_DEFAULT_ADDRESS = "224.0.23.178"; private static final int JDP_DEFAULT_PORT = 7095; @@ -429,7 +432,7 @@ public class Agent { try { if (snmpPort != null) { - loadSnmpAgent(snmpPort, props); + loadSnmpAgent(props); } /* @@ -554,28 +557,24 @@ public class Agent { return mgmtProps; } - private static void loadSnmpAgent(String snmpPort, Properties props) { - try { - // invoke the following through reflection: - // AdaptorBootstrap.initialize(snmpPort, props); - final Class adaptorClass = - Class.forName(SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME, true, null); - final Method initializeMethod = - adaptorClass.getMethod("initialize", - String.class, Properties.class); - initializeMethod.invoke(null, snmpPort, props); - } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException x) { - // snmp runtime doesn't exist - initialization fails - throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT, x); - } catch (InvocationTargetException x) { - final Throwable cause = x.getCause(); - if (cause instanceof RuntimeException) { - throw (RuntimeException) cause; - } else if (cause instanceof Error) { - throw (Error) cause; - } - // should not happen... - throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT, cause); + private static void loadSnmpAgent(Properties props) { + /* + * Load the jdk.snmp service + */ + AgentProvider provider = AccessController.doPrivileged( + (PrivilegedAction) () -> { + for(AgentProvider aProvider : ServiceLoader.loadInstalled(AgentProvider.class)) { + if(aProvider.getName().equals(SNMP_AGENT_NAME)) + return aProvider; + } + return null; + }, null + ); + + if (provider != null) { + provider.startAgent(props); + } else { // snmp runtime doesn't exist - initialization fails + throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT); } } diff --git a/jdk/src/java.management/share/classes/sun/management/spi/AgentProvider.java b/jdk/src/java.management/share/classes/sun/management/spi/AgentProvider.java new file mode 100644 index 00000000000..f68343acacb --- /dev/null +++ b/jdk/src/java.management/share/classes/sun/management/spi/AgentProvider.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ +package sun.management.spi; + +import java.util.Properties; + +/** + * Service interface for management agent + */ +public abstract class AgentProvider { + + /** + * Instantiates a new AgentProvider. + * + * @throws SecurityException if the subclass (and calling code) does not + * have + * {@code RuntimePermission("sun.management.spi.AgentProvider.subclass")} + */ + protected AgentProvider() { + this(checkSubclassPermission()); + } + + private AgentProvider(Void unused) { + } + + private static Void checkSubclassPermission() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission(AgentProvider.class.getName() + ".subclass")); + } + return null; + } + + /** + * Gets the name of the agent provider. + * + * @return name of agent provider + */ + public abstract String getName(); + + /** + * Initializes and starts the agent. + * + * @throws IllegalStateException if this agent has already been started. + */ + public abstract void startAgent(); + + /** + * Initializes and starts the agent at given port and with given properties + * + * @param props environment variables for agent + * + * @throws IllegalStateException if this agent has already been started. + */ + public abstract void startAgent(Properties props); + + /** + * Checks if agent is started and not terminated. + * + * @return true if agent is running, false otherwise. + */ + public abstract boolean isActive(); + + /** + * Stops this agent. + * + * @throws IllegalStateException if this agent is not started. + */ + public abstract void stopAgent(); +} From 539151b477ed698193b208b223b713db69d8ca79 Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Tue, 6 Sep 2016 13:03:00 +0300 Subject: [PATCH 153/296] 8155083: On Windows, usage of USER_ATTENTION_WINDOW depends on state setting order Reviewed-by: serb, ssadetsky --- jdk/src/java.desktop/share/classes/java/awt/Taskbar.java | 4 +--- .../java.desktop/share/classes/java/awt/peer/TaskbarPeer.java | 4 +--- .../windows/native/libawt/windows/awt_Taskbar.cpp | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java index 393d8a32ba2..22710085e83 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java @@ -273,9 +273,7 @@ public class Taskbar { } /** - * Requests user attention to the specified window until it is activated. - * - * On an already active window requesting attention does nothing. + * Requests user attention to the specified window. * * @param w window * @throws SecurityException if a security manager exists and it denies the diff --git a/jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java b/jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java index 934a1c01538..bf31082fe92 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java +++ b/jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java @@ -49,9 +49,7 @@ public interface TaskbarPeer { default void requestUserAttention(boolean enabled, final boolean critical) {} /** - * Requests user attention to the specified window until it is activated. - * - * On an already active window requesting attention does nothing. + * Requests user attention to the specified window. * * @param w window */ diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp index 50c1ba85c2a..ebb07187322 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp @@ -108,7 +108,7 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setProgressState JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_flashWindow (JNIEnv *, jobject, jlong window) { - AwtWindow::FlashWindowEx((HWND) window, 3, 0, FLASHW_TIMERNOFG); + ::FlashWindow((HWND) window, TRUE); } /* From 4814f397b23a5f2fb34593faf7bbd46e598f94aa Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 6 Sep 2016 12:51:40 +0200 Subject: [PATCH 154/296] 8161376: Introduce -Xlint:exports Adding -Xlint:exports, currently not doing anything. Functionality will be added separatelly under JDK-8153362. Reviewed-by: jjg --- .../share/classes/com/sun/tools/javac/code/Lint.java | 5 +++++ .../classes/com/sun/tools/javac/resources/javac.properties | 3 +++ 2 files changed, 8 insertions(+) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java index d5480816c34..ddd61d65615 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java @@ -165,6 +165,11 @@ public class Lint */ EMPTY("empty"), + /** + * Warn about issues regarding module exports. + */ + EXPORTS("exports"), + /** * Warn about falling through from one case of a switch statement to the next. */ diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties index 05874ad9087..44634e703e0 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties @@ -192,6 +192,9 @@ javac.opt.Xlint.desc.divzero=\ javac.opt.Xlint.desc.empty=\ Warn about empty statement after if. +javac.opt.Xlint.desc.exports=\ + Warn about issues regarding module exports. + javac.opt.Xlint.desc.fallthrough=\ Warn about falling through from one case of a switch statement to the next. From 0f792063c19c848b7b9eec3f0f753eed84f57758 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 6 Sep 2016 18:16:56 +0530 Subject: [PATCH 155/296] 8163952: jlink exclude VM plugin does not support static libraries Reviewed-by: jlaskey --- .../internal/plugins/ExcludeVMPlugin.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java index df824856282..549b6abfd54 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java @@ -99,9 +99,13 @@ public final class ExcludeVMPlugin implements Plugin { * e.g.: /java.base/native/amd64/server/libjvm.so * /java.base/native/server/libjvm.dylib */ - private List getVMs(ResourcePoolModule javaBase, String jvmlib) { + private List getVMs(ResourcePoolModule javaBase, String[] jvmlibs) { List ret = javaBase.entries().filter((t) -> { - return t.path().endsWith("/" + jvmlib); + String path = t.path(); + for (String jvmlib : jvmlibs) { + return t.path().endsWith("/" + jvmlib); + } + return false; }).collect(Collectors.toList()); return ret; } @@ -109,18 +113,21 @@ public final class ExcludeVMPlugin implements Plugin { @Override public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) { ResourcePoolModule javaBase = in.moduleView().findModule("java.base").get(); - String jvmlib = jvmlib(javaBase.descriptor().osName().get()); + String[] jvmlibs = jvmlibs(javaBase.descriptor().osName().get()); TreeSet existing = new TreeSet<>(new JvmComparator()); TreeSet removed = new TreeSet<>(new JvmComparator()); if (!keepAll) { // First retrieve all available VM names and removed VM - List jvms = getVMs(javaBase, jvmlib); + List jvms = getVMs(javaBase, jvmlibs); for (Jvm jvm : Jvm.values()) { for (ResourcePoolEntry md : jvms) { - if (md.path().endsWith("/" + jvm.getName() + "/" + jvmlib)) { - existing.add(jvm); - if (isRemoved(md)) { - removed.add(jvm); + String mdPath = md.path(); + for (String jvmlib : jvmlibs) { + if (mdPath.endsWith("/" + jvm.getName() + "/" + jvmlib)) { + existing.add(jvm); + if (isRemoved(md)) { + removed.add(jvm); + } } } } @@ -248,14 +255,14 @@ public final class ExcludeVMPlugin implements Plugin { return orig.copyWithContent(content); } - private static String jvmlib(String osName) { - String lib = "libjvm.so"; + private static String[] jvmlibs(String osName) { if (isWindows(osName)) { - lib = "jvm.dll"; + return new String[] { "jvm.dll" }; } else if (isMac(osName)) { - lib = "libjvm.dylib"; + return new String[] { "libjvm.dylib", "libjvm.a" }; + } else { + return new String[] { "libjvm.so", "libjvm.a" }; } - return lib; } private static boolean isWindows(String osName) { From 2aac4c1f387418d69dc34f9b4fe6a7ef07f990f3 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 6 Sep 2016 08:32:50 -0700 Subject: [PATCH 156/296] 8165345: JDK macro definition re-defined by MacOS core framework Reviewed-by: serb --- .../share/native/libfontmanager/HBShaper.c | 2 +- .../share/native/libfontmanager/hb-jdk-font.cc | 16 ++++++++-------- .../share/native/libfontmanager/hb-jdk.h | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c index 3b7a463ffdf..95a92f221ad 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c +++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c @@ -80,7 +80,7 @@ jboolean storeGVData(JNIEnv* env, int i, needToGrow; float x=0, y=0; float startX, startY, advX, advY; - float scale = 1.0f / FloatToFixedScale / devScale; + float scale = 1.0f / HBFloatToFixedScale / devScale; unsigned int* glyphs; float* positions; int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv, maxStore; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc index c65c673e4ae..2e41293a08f 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc @@ -80,7 +80,7 @@ hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, fadv *= jdkFontInfo->devScale; env->DeleteLocalRef(pt); - return FloatToFixed(fadv); + return HBFloatToFixed(fadv); } static hb_position_t @@ -107,7 +107,7 @@ hb_jdk_get_glyph_v_advance (hb_font_t *font HB_UNUSED, fadv = env->GetFloatField(pt, sunFontIDs.yFID); env->DeleteLocalRef(pt); - return FloatToFixed(fadv); + return HBFloatToFixed(fadv); } @@ -201,8 +201,8 @@ hb_jdk_get_glyph_contour_point (hb_font_t *font HB_UNUSED, *x = 0; *y = 0; return true; } - *x = FloatToFixed(env->GetFloatField(pt, sunFontIDs.xFID)); - *y = FloatToFixed(env->GetFloatField(pt, sunFontIDs.yFID)); + *x = HBFloatToFixed(env->GetFloatField(pt, sunFontIDs.xFID)); + *y = HBFloatToFixed(env->GetFloatField(pt, sunFontIDs.yFID)); env->DeleteLocalRef(pt); return true; @@ -321,8 +321,8 @@ static hb_font_t* _hb_jdk_font_create(JDKFontInfo *jdkFontInfo, _hb_jdk_get_font_funcs (), jdkFontInfo, (hb_destroy_func_t) _do_nothing); hb_font_set_scale (font, - FloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale), - FloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale)); + HBFloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale), + HBFloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale)); return font; } @@ -339,8 +339,8 @@ static hb_font_t* _hb_jdk_ct_font_create(JDKFontInfo *jdkFontInfo) { hb_face_destroy(face); hb_font_set_scale(font, - FloatToFixed(jdkFontInfo->ptSize), - FloatToFixed(jdkFontInfo->ptSize)); + HBFloatToFixed(jdkFontInfo->ptSize), + HBFloatToFixed(jdkFontInfo->ptSize)); return font; } #endif diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h index 8c08fb036ed..b62c8b1553b 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h @@ -49,8 +49,8 @@ typedef struct JDKFontInfo_Struct { // Use 16.16 for better precision than 26.6 -#define FloatToFixedScale ((float)(1 << 16)) -#define FloatToFixed(f) ((unsigned int)((f) * FloatToFixedScale)) +#define HBFloatToFixedScale ((float)(1 << 16)) +#define HBFloatToFixed(f) ((unsigned int)((f) * HBFloatToFixedScale)) /* * Note: From 3228ea809cd2da0570615920583d40392f71fdb9 Mon Sep 17 00:00:00 2001 From: Alan Burlison Date: Tue, 6 Sep 2016 13:09:29 -0400 Subject: [PATCH 157/296] 8161360: Deprecated vfork() should not be used on Solaris Reviewed-by: rriggs, dsamersoff --- jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c b/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c index 3408bdd9762..27230858253 100644 --- a/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c +++ b/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c @@ -349,6 +349,8 @@ static int copystrings(char *buf, int offset, const char * const *arg) { __attribute_noinline__ #endif +/* vfork(2) is deprecated on Solaris */ +#ifndef __solaris__ static pid_t vforkChild(ChildStuff *c) { volatile pid_t resultPid; @@ -367,6 +369,7 @@ vforkChild(ChildStuff *c) { assert(resultPid != 0); /* childProcess never returns */ return resultPid; } +#endif static pid_t forkChild(ChildStuff *c) { @@ -479,8 +482,11 @@ spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) static pid_t startChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) { switch (c->mode) { +/* vfork(2) is deprecated on Solaris */ +#ifndef __solaris__ case MODE_VFORK: return vforkChild(c); +#endif case MODE_FORK: return forkChild(c); #if defined(__solaris__) || defined(_ALLBSD_SOURCE) || defined(_AIX) From ed5befdde8e160bb904a2c2376c88fc9bcba2576 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 6 Sep 2016 11:08:59 -0700 Subject: [PATCH 158/296] 8164899: Provide package access to setComponentMixingCutoutShape Reviewed-by: serb --- .../classes/com/sun/awt/AWTUtilities.java | 1 + .../share/classes/java/awt/Component.java | 92 +++++++++++++------ 2 files changed, 67 insertions(+), 26 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java b/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java index 1957fba5b8e..1ba10acd72f 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java +++ b/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java @@ -447,6 +447,7 @@ public final class AWTUtilities { * @param shape the new 'mixing-cutout' shape * @throws NullPointerException if the component argument is {@code null} */ + @Deprecated(since = "9") public static void setComponentMixingCutoutShape(Component component, Shape shape) { diff --git a/jdk/src/java.desktop/share/classes/java/awt/Component.java b/jdk/src/java.desktop/share/classes/java/awt/Component.java index 25c6ee2b1aa..228e14c93d2 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Component.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java @@ -843,32 +843,7 @@ public abstract class Component implements ImageObserver, MenuContainer, return new Rectangle(comp.x, comp.y, comp.width, comp.height); } public void setMixingCutoutShape(Component comp, Shape shape) { - Region region = shape == null ? null : - Region.getInstance(shape, null); - - synchronized (comp.getTreeLock()) { - boolean needShowing = false; - boolean needHiding = false; - - if (!comp.isNonOpaqueForMixing()) { - needHiding = true; - } - - comp.mixingCutoutRegion = region; - - if (!comp.isNonOpaqueForMixing()) { - needShowing = true; - } - - if (comp.isMixingNeeded()) { - if (needHiding) { - comp.mixOnHiding(comp.isLightweight()); - } - if (needShowing) { - comp.mixOnShowing(); - } - } - } + comp.setMixingCutoutShape(shape); } public void setGraphicsConfiguration(Component comp, @@ -10238,6 +10213,71 @@ public abstract class Component implements ImageObserver, MenuContainer, return true; } + /** + * Sets a 'mixing-cutout' shape for the given component. + * + * By default a lightweight component is treated as an opaque rectangle for + * the purposes of the Heavyweight/Lightweight Components Mixing feature. + * This method enables developers to set an arbitrary shape to be cut out + * from heavyweight components positioned underneath the lightweight + * component in the z-order. + *

    + * The {@code shape} argument may have the following values: + *

      + *
    • {@code null} - reverts the default cutout shape (the rectangle equal + * to the component's {@code getBounds()}) + *
    • empty-shape - does not cut out anything from heavyweight + * components. This makes the given lightweight component effectively + * transparent. Note that descendants of the lightweight component still + * affect the shapes of heavyweight components. An example of an + * empty-shape is {@code new Rectangle()}. + *
    • non-empty-shape - the given shape will be cut out from + * heavyweight components. + *
    + *

    + * The most common example when the 'mixing-cutout' shape is needed is a + * glass pane component. The {@link JRootPane#setGlassPane()} method + * automatically sets the empty-shape as the 'mixing-cutout' shape + * for the given glass pane component. If a developer needs some other + * 'mixing-cutout' shape for the glass pane (which is rare), this must be + * changed manually after installing the glass pane to the root pane. + *

    + * Note that the 'mixing-cutout' shape neither affects painting, nor the + * mouse events handling for the given component. It is used exclusively + * for the purposes of the Heavyweight/Lightweight Components Mixing + * feature. + * + * @param shape the new 'mixing-cutout' shape + * @since 9 + */ + void setMixingCutoutShape(Shape shape) { + Region region = shape == null ? null : Region.getInstance(shape, null); + + synchronized (getTreeLock()) { + boolean needShowing = false; + boolean needHiding = false; + + if (!isNonOpaqueForMixing()) { + needHiding = true; + } + + mixingCutoutRegion = region; + + if (!isNonOpaqueForMixing()) { + needShowing = true; + } + + if (isMixingNeeded()) { + if (needHiding) { + mixOnHiding(isLightweight()); + } + if (needShowing) { + mixOnShowing(); + } + } + } + } + // ****************** END OF MIXING CODE ******************************** // Note that the method is overriden in the Window class, From a8147854b704570e301c1993b7db775101c11383 Mon Sep 17 00:00:00 2001 From: Rachel Protacio Date: Tue, 6 Sep 2016 16:29:32 -0400 Subject: [PATCH 159/296] 8161224: CONSTANT_NameAndType_info permits references to illegal names and descriptors Enforces proper format checking for NameAndType string content, and that the checking occurs even when not referenced in classfile Reviewed-by: coleenp, hseigel, ddmitriev --- .../share/vm/classfile/classFileParser.cpp | 85 ++++++++++--------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 30262696a8c..f53b428c046 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -95,7 +95,6 @@ #define JAVA_6_VERSION 50 // Used for backward compatibility reasons: -// - to check NameAndType_info signatures more aggressively // - to disallow argument and require ACC_STATIC for methods #define JAVA_7_VERSION 51 @@ -564,7 +563,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream, break; } case JVM_CONSTANT_NameAndType: { - if (_need_verify && _major_version >= JAVA_7_VERSION) { + if (_need_verify) { const int sig_index = cp->signature_ref_index_at(index); const int name_index = cp->name_ref_index_at(index); const Symbol* const name = cp->symbol_at(name_index); @@ -572,9 +571,17 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream, guarantee_property(sig->utf8_length() != 0, "Illegal zero length constant pool entry at %d in class %s", sig_index, CHECK); + guarantee_property(name->utf8_length() != 0, + "Illegal zero length constant pool entry at %d in class %s", + name_index, CHECK); + if (sig->byte_at(0) == JVM_SIGNATURE_FUNC) { + // Format check method name and signature + verify_legal_method_name(name, CHECK); verify_legal_method_signature(name, sig, CHECK); } else { + // Format check field name and signature + verify_legal_field_name(name, CHECK); verify_legal_field_signature(name, sig, CHECK); } } @@ -595,42 +602,32 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream, const Symbol* const name = cp->symbol_at(name_ref_index); const Symbol* const signature = cp->symbol_at(signature_ref_index); if (tag == JVM_CONSTANT_Fieldref) { - verify_legal_field_name(name, CHECK); - if (_need_verify && _major_version >= JAVA_7_VERSION) { - // Signature is verified above, when iterating NameAndType_info. - // Need only to be sure it's non-zero length and the right type. + if (_need_verify) { + // Field name and signature are verified above, when iterating NameAndType_info. + // Need only to be sure signature is non-zero length and the right type. if (signature->utf8_length() == 0 || signature->byte_at(0) == JVM_SIGNATURE_FUNC) { - throwIllegalSignature( - "Field", name, signature, CHECK); + throwIllegalSignature("Field", name, signature, CHECK); } - } else { - verify_legal_field_signature(name, signature, CHECK); } } else { - verify_legal_method_name(name, CHECK); - if (_need_verify && _major_version >= JAVA_7_VERSION) { - // Signature is verified above, when iterating NameAndType_info. - // Need only to be sure it's non-zero length and the right type. + if (_need_verify) { + // Method name and signature are verified above, when iterating NameAndType_info. + // Need only to be sure signature is non-zero length and the right type. if (signature->utf8_length() == 0 || signature->byte_at(0) != JVM_SIGNATURE_FUNC) { - throwIllegalSignature( - "Method", name, signature, CHECK); + throwIllegalSignature("Method", name, signature, CHECK); } - } else { - verify_legal_method_signature(name, signature, CHECK); } - if (tag == JVM_CONSTANT_Methodref) { - // 4509014: If a class method name begins with '<', it must be "". - assert(name != NULL, "method name in constant pool is null"); - const unsigned int name_len = name->utf8_length(); - if (name_len != 0 && name->byte_at(0) == '<') { - if (name != vmSymbols::object_initializer_name()) { - classfile_parse_error( - "Bad method name at constant pool index %u in class file %s", - name_ref_index, CHECK); - } - } + // 4509014: If a class method name begins with '<', it must be "" + const unsigned int name_len = name->utf8_length(); + if (tag == JVM_CONSTANT_Methodref && + name_len != 0 && + name->byte_at(0) == '<' && + name != vmSymbols::object_initializer_name()) { + classfile_parse_error( + "Bad method name at constant pool index %u in class file %s", + name_ref_index, CHECK); } } break; @@ -4843,19 +4840,28 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature, } } else { - // 4900761: For class version > 48, any unicode is allowed in class name. + // Skip leading 'L' and ignore first appearance of ';' length--; signature++; - while (length > 0 && signature[0] != ';') { - if (signature[0] == '.') { - classfile_parse_error("Class name contains illegal character '.' in descriptor in class file %s", CHECK_0); - } - length--; - signature++; - } - if (signature[0] == ';') { return signature + 1; } - } + char* c = strchr((char*) signature, ';'); + // Format check signature + if (c != NULL) { + ResourceMark rm(THREAD); + int newlen = c - (char*) signature; + char* sig = NEW_RESOURCE_ARRAY(char, newlen + 1); + strncpy(sig, signature, newlen); + sig[newlen] = '\0'; + bool legal = verify_unqualified_name(sig, newlen, LegalClass); + if (!legal) { + classfile_parse_error("Class name contains illegal character " + "in descriptor in class file %s", + CHECK_0); + return NULL; + } + return signature + newlen + 1; + } + } return NULL; } case JVM_SIGNATURE_ARRAY: @@ -4869,7 +4875,6 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature, length--; void_ok = false; break; - default: return NULL; } From 9aa36236bebb5db7fb95293a4c4eec8f6f4611dc Mon Sep 17 00:00:00 2001 From: Alexandre Iline Date: Tue, 6 Sep 2016 17:07:06 -0400 Subject: [PATCH 160/296] 8148859: Fix module dependences for java/time tests Reviewed-by: alanb, rriggs --- jdk/test/java/time/TEST.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/test/java/time/TEST.properties b/jdk/test/java/time/TEST.properties index f480a511913..82224020e8e 100644 --- a/jdk/test/java/time/TEST.properties +++ b/jdk/test/java/time/TEST.properties @@ -1,4 +1,6 @@ # Threeten test uses TestNG TestNG.dirs = . othervm.dirs = tck/java/time/chrono test/java/time/chrono test/java/time/format +modules = jdk.localedata lib.dirs = ../../lib/testlibrary +lib.build = jdk.testlibrary.RandomFactory From 97fa8cd04e629e51aaf66ff26465ad1543d30724 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Tue, 6 Sep 2016 16:08:54 -0700 Subject: [PATCH 161/296] 8159404: throw UnsupportedOperationException unconditionally for mutator methods Reviewed-by: martin, psandoz --- .../java/util/ImmutableCollections.java | 68 +++++++++-- .../share/classes/java/util/List.java | 3 +- .../share/classes/java/util/Map.java | 3 +- .../share/classes/java/util/Set.java | 3 +- jdk/test/java/util/Collection/MOAT.java | 111 +++++++++++++++++- 5 files changed, 173 insertions(+), 15 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java b/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java index 8414311e425..494dce83a89 100644 --- a/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java +++ b/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java @@ -31,6 +31,10 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamException; import java.io.Serializable; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; /** * Container class for immutable collections. Not part of the public API. @@ -61,9 +65,25 @@ class ImmutableCollections { */ static final double EXPAND_FACTOR = 2.0; + static UnsupportedOperationException uoe() { return new UnsupportedOperationException(); } + // ---------- List Implementations ---------- - static final class List0 extends AbstractList implements RandomAccess, Serializable { + abstract static class AbstractImmutableList extends AbstractList + implements RandomAccess, Serializable { + @Override public boolean add(E e) { throw uoe(); } + @Override public boolean addAll(Collection c) { throw uoe(); } + @Override public boolean addAll(int index, Collection c) { throw uoe(); } + @Override public void clear() { throw uoe(); } + @Override public boolean remove(Object o) { throw uoe(); } + @Override public boolean removeAll(Collection c) { throw uoe(); } + @Override public boolean removeIf(Predicate filter) { throw uoe(); } + @Override public void replaceAll(UnaryOperator operator) { throw uoe(); } + @Override public boolean retainAll(Collection c) { throw uoe(); } + @Override public void sort(Comparator c) { throw uoe(); } + } + + static final class List0 extends AbstractImmutableList { List0() { } @Override @@ -86,7 +106,7 @@ class ImmutableCollections { } } - static final class List1 extends AbstractList implements RandomAccess, Serializable { + static final class List1 extends AbstractImmutableList { private final E e0; List1(E e0) { @@ -114,7 +134,7 @@ class ImmutableCollections { } } - static final class List2 extends AbstractList implements RandomAccess, Serializable { + static final class List2 extends AbstractImmutableList { private final E e0; private final E e1; @@ -147,7 +167,7 @@ class ImmutableCollections { } } - static final class ListN extends AbstractList implements RandomAccess, Serializable { + static final class ListN extends AbstractImmutableList { private final E[] elements; @SafeVarargs @@ -183,7 +203,17 @@ class ImmutableCollections { // ---------- Set Implementations ---------- - static final class Set0 extends AbstractSet implements Serializable { + abstract static class AbstractImmutableSet extends AbstractSet implements Serializable { + @Override public boolean add(E e) { throw uoe(); } + @Override public boolean addAll(Collection c) { throw uoe(); } + @Override public void clear() { throw uoe(); } + @Override public boolean remove(Object o) { throw uoe(); } + @Override public boolean removeAll(Collection c) { throw uoe(); } + @Override public boolean removeIf(Predicate filter) { throw uoe(); } + @Override public boolean retainAll(Collection c) { throw uoe(); } + } + + static final class Set0 extends AbstractImmutableSet { Set0() { } @Override @@ -210,7 +240,7 @@ class ImmutableCollections { } } - static final class Set1 extends AbstractSet implements Serializable { + static final class Set1 extends AbstractImmutableSet { private final E e0; Set1(E e0) { @@ -241,7 +271,7 @@ class ImmutableCollections { } } - static final class Set2 extends AbstractSet implements Serializable { + static final class Set2 extends AbstractImmutableSet { private final E e0; private final E e1; @@ -312,7 +342,7 @@ class ImmutableCollections { * least one null is always present. * @param the element type */ - static final class SetN extends AbstractSet implements Serializable { + static final class SetN extends AbstractImmutableSet { private final E[] elements; private final int size; @@ -403,7 +433,23 @@ class ImmutableCollections { // ---------- Map Implementations ---------- - static final class Map0 extends AbstractMap implements Serializable { + abstract static class AbstractImmutableMap extends AbstractMap implements Serializable { + @Override public void clear() { throw uoe(); } + @Override public V compute(K key, BiFunction rf) { throw uoe(); } + @Override public V computeIfAbsent(K key, Function mf) { throw uoe(); } + @Override public V computeIfPresent(K key, BiFunction rf) { throw uoe(); } + @Override public V merge(K key, V value, BiFunction rf) { throw uoe(); } + @Override public V put(K key, V value) { throw uoe(); } + @Override public void putAll(Map m) { throw uoe(); } + @Override public V putIfAbsent(K key, V value) { throw uoe(); } + @Override public V remove(Object key) { throw uoe(); } + @Override public boolean remove(Object key, Object value) { throw uoe(); } + @Override public V replace(K key, V value) { throw uoe(); } + @Override public boolean replace(K key, V oldValue, V newValue) { throw uoe(); } + @Override public void replaceAll(BiFunction f) { throw uoe(); } + } + + static final class Map0 extends AbstractImmutableMap { Map0() { } @Override @@ -430,7 +476,7 @@ class ImmutableCollections { } } - static final class Map1 extends AbstractMap implements Serializable { + static final class Map1 extends AbstractImmutableMap { private final K k0; private final V v0; @@ -472,7 +518,7 @@ class ImmutableCollections { * @param the key type * @param the value type */ - static final class MapN extends AbstractMap implements Serializable { + static final class MapN extends AbstractImmutableMap { private final Object[] table; // pairs of key, value private final int size; // number of pairs diff --git a/jdk/src/java.base/share/classes/java/util/List.java b/jdk/src/java.base/share/classes/java/util/List.java index 3819d94e831..8e97c2ea259 100644 --- a/jdk/src/java.base/share/classes/java/util/List.java +++ b/jdk/src/java.base/share/classes/java/util/List.java @@ -94,7 +94,8 @@ import java.util.function.UnaryOperator; * *