mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
Merge remote-tracking branch 'origin/master' into JDK-object-monitor-experiments-reconcile-enter-reenter-attempt5
This commit is contained in:
commit
9e326306a8
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -115,7 +115,11 @@ AC_DEFUN([FLAGS_SETUP_ASFLAGS],
|
||||
# Force preprocessor to run, just to make sure
|
||||
BASIC_ASFLAGS="-x assembler-with-cpp"
|
||||
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
||||
BASIC_ASFLAGS="-nologo -c"
|
||||
if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
|
||||
BASIC_ASFLAGS="-nologo"
|
||||
else
|
||||
BASIC_ASFLAGS="-nologo -c"
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(BASIC_ASFLAGS)
|
||||
|
||||
|
||||
@ -655,8 +655,11 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE],
|
||||
if test "x$TOOLCHAIN_TYPE" != xmicrosoft; then
|
||||
AS="$CC -c"
|
||||
else
|
||||
if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
|
||||
# On 64 bit windows, the assembler is "ml64.exe"
|
||||
if test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
|
||||
# On Windows aarch64, the assembler is "armasm64.exe"
|
||||
UTIL_LOOKUP_TOOLCHAIN_PROGS(AS, armasm64)
|
||||
elif test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
|
||||
# On Windows x64, the assembler is "ml64.exe"
|
||||
UTIL_LOOKUP_TOOLCHAIN_PROGS(AS, ml64)
|
||||
else
|
||||
# otherwise, the assembler is "ml.exe"
|
||||
|
||||
@ -155,6 +155,12 @@ define CreateCompiledNativeFileBody
|
||||
endif
|
||||
$1_FLAGS := $$($1_FLAGS) -DASSEMBLY_SRC_FILE='"$$($1_REL_ASM_SRC)"' \
|
||||
-include $(TOPDIR)/make/data/autoheaders/assemblyprefix.h
|
||||
else ifeq ($(TOOLCHAIN_TYPE), microsoft)
|
||||
ifeq ($(OPENJDK_TARGET_CPU), aarch64)
|
||||
$1_NON_ASM_EXTENSION_FLAG :=
|
||||
else
|
||||
$1_NON_ASM_EXTENSION_FLAG := "-Ta"
|
||||
endif
|
||||
endif
|
||||
else ifneq ($$(filter %.cpp %.cc %.mm, $$($1_FILENAME)), )
|
||||
# Compile as a C++ or Objective-C++ file
|
||||
@ -236,7 +242,7 @@ define CreateCompiledNativeFileBody
|
||||
# For assembler calls just create empty dependency lists
|
||||
$$(call ExecuteWithLog, $$@, $$(call MakeCommandRelative, \
|
||||
$$($1_COMPILER) $$($1_FLAGS) \
|
||||
$(CC_OUT_OPTION)$$($1_OBJ) -Ta $$($1_SRC_FILE))) \
|
||||
$(CC_OUT_OPTION)$$($1_OBJ) $$($1_NON_ASM_EXTENSION_FLAG) $$($1_SRC_FILE))) \
|
||||
| $(TR) -d '\r' | $(GREP) -v -e "Assembling:" || test "$$$$?" = "1" ; \
|
||||
$(ECHO) > $$($1_DEPS_FILE) ; \
|
||||
$(ECHO) > $$($1_DEPS_TARGETS_FILE)
|
||||
|
||||
@ -922,8 +922,10 @@ public class GenerateJfrFiles {
|
||||
}
|
||||
out.write(" using JfrEvent<Event" + event.name
|
||||
+ ">::commit; // else commit() is hidden by overloaded versions in this class");
|
||||
printConstructor2(out, event, empty);
|
||||
printCommitMethod(out, event, empty);
|
||||
if (!event.fields.isEmpty()) {
|
||||
printConstructor2(out, event, empty);
|
||||
printCommitMethod(out, event, empty);
|
||||
}
|
||||
if (!empty) {
|
||||
printVerify(out, event.fields);
|
||||
}
|
||||
|
||||
@ -1099,8 +1099,12 @@ void VM_Version::get_processor_features() {
|
||||
}
|
||||
|
||||
stringStream ss(2048);
|
||||
ss.print("(%u cores per cpu, %u threads per core) family %d model %d stepping %d microcode 0x%x",
|
||||
cores_per_cpu(), threads_per_core(),
|
||||
if (supports_hybrid()) {
|
||||
ss.print("(hybrid)");
|
||||
} else {
|
||||
ss.print("(%u cores per cpu, %u threads per core)", cores_per_cpu(), threads_per_core());
|
||||
}
|
||||
ss.print(" family %d model %d stepping %d microcode 0x%x",
|
||||
cpu_family(), _model, _stepping, os::cpu_microcode_revision());
|
||||
ss.print(", ");
|
||||
int features_offset = (int)ss.size();
|
||||
@ -3043,6 +3047,8 @@ VM_Version::VM_Features VM_Version::CpuidInfo::feature_flags() const {
|
||||
if (is_intel()) {
|
||||
if (sef_cpuid7_edx.bits.serialize != 0)
|
||||
vm_features.set_feature(CPU_SERIALIZE);
|
||||
if (sef_cpuid7_edx.bits.hybrid != 0)
|
||||
vm_features.set_feature(CPU_HYBRID);
|
||||
if (_cpuid_info.sef_cpuid7_edx.bits.avx512_fp16 != 0)
|
||||
vm_features.set_feature(CPU_AVX512_FP16);
|
||||
}
|
||||
|
||||
@ -276,7 +276,8 @@ class VM_Version : public Abstract_VM_Version {
|
||||
fast_short_rep_mov : 1,
|
||||
: 9,
|
||||
serialize : 1,
|
||||
: 5,
|
||||
hybrid: 1,
|
||||
: 4,
|
||||
cet_ibt : 1,
|
||||
: 2,
|
||||
avx512_fp16 : 1,
|
||||
@ -444,7 +445,8 @@ protected:
|
||||
decl(SHA512, "sha512", 61) /* SHA512 instructions*/ \
|
||||
decl(AVX512_FP16, "avx512_fp16", 62) /* AVX512 FP16 ISA support*/ \
|
||||
decl(AVX10_1, "avx10_1", 63) /* AVX10 512 bit vector ISA Version 1 support*/ \
|
||||
decl(AVX10_2, "avx10_2", 64) /* AVX10 512 bit vector ISA Version 2 support*/
|
||||
decl(AVX10_2, "avx10_2", 64) /* AVX10 512 bit vector ISA Version 2 support*/ \
|
||||
decl(HYBRID, "hybrid", 65) /* Hybrid architecture */
|
||||
|
||||
#define DECLARE_CPU_FEATURE_FLAG(id, name, bit) CPU_##id = (bit),
|
||||
CPU_FEATURE_FLAGS(DECLARE_CPU_FEATURE_FLAG)
|
||||
@ -877,6 +879,7 @@ public:
|
||||
static bool supports_avx512_fp16() { return _features.supports_feature(CPU_AVX512_FP16); }
|
||||
static bool supports_hv() { return _features.supports_feature(CPU_HV); }
|
||||
static bool supports_serialize() { return _features.supports_feature(CPU_SERIALIZE); }
|
||||
static bool supports_hybrid() { return _features.supports_feature(CPU_HYBRID); }
|
||||
static bool supports_f16c() { return _features.supports_feature(CPU_F16C); }
|
||||
static bool supports_pku() { return _features.supports_feature(CPU_PKU); }
|
||||
static bool supports_ospke() { return _features.supports_feature(CPU_OSPKE); }
|
||||
|
||||
@ -105,7 +105,7 @@ void G1CollectionSet::abandon_all_candidates() {
|
||||
}
|
||||
|
||||
void G1CollectionSet::prepare_for_scan () {
|
||||
groups()->prepare_for_scan();
|
||||
_groups.prepare_for_scan();
|
||||
}
|
||||
|
||||
void G1CollectionSet::add_old_region(G1HeapRegion* hr) {
|
||||
|
||||
@ -233,9 +233,6 @@ public:
|
||||
G1CollectionSetCandidates* candidates() { return &_candidates; }
|
||||
const G1CollectionSetCandidates* candidates() const { return &_candidates; }
|
||||
|
||||
G1CSetCandidateGroupList* groups() { return &_groups; }
|
||||
const G1CSetCandidateGroupList* groups() const { return &_groups; }
|
||||
|
||||
void prepare_for_scan();
|
||||
|
||||
void init_region_lengths(uint eden_cset_region_length,
|
||||
|
||||
@ -41,7 +41,7 @@ inline void G1CollectionSet::merge_cardsets_for_collection_groups(CardOrRangeVis
|
||||
uint cur_pos = start_pos;
|
||||
uint count = 0;
|
||||
do {
|
||||
G1HeapRegionRemSet::iterate_for_merge(groups()->at(offset + cur_pos)->card_set(), cl);
|
||||
G1HeapRegionRemSet::iterate_for_merge(_groups.at(offset + cur_pos)->card_set(), cl);
|
||||
cur_pos++;
|
||||
count++;
|
||||
if (cur_pos == length) {
|
||||
|
||||
@ -59,6 +59,7 @@ void G1CSetCandidateGroup::calculate_efficiency() {
|
||||
}
|
||||
|
||||
double G1CSetCandidateGroup::liveness_percent() const {
|
||||
assert(length() > 0, "must be");
|
||||
size_t capacity = length() * G1HeapRegion::GrainBytes;
|
||||
return ((capacity - _reclaimable_bytes) * 100.0) / capacity;
|
||||
}
|
||||
|
||||
@ -3121,8 +3121,8 @@ void G1PrintRegionLivenessInfoClosure::log_cset_candidate_group_add_total(G1CSet
|
||||
G1PPRL_TYPE_H_FORMAT,
|
||||
group->group_id(),
|
||||
group->length(),
|
||||
group->gc_efficiency(),
|
||||
group->liveness_percent(),
|
||||
group->length() > 0 ? group->gc_efficiency() : 0.0,
|
||||
group->length() > 0 ? group->liveness_percent() : 0.0,
|
||||
group->card_set()->mem_size(),
|
||||
type);
|
||||
_total_remset_bytes += group->card_set()->mem_size();
|
||||
|
||||
@ -40,16 +40,39 @@
|
||||
event.commit();
|
||||
}
|
||||
|
||||
void baz(char* text) {
|
||||
EventText event;
|
||||
event.set_text(text);
|
||||
event.commit();
|
||||
}
|
||||
|
||||
$ make images
|
||||
$ java -XX:StartFlightRecording:settings=none,filename=dump.jfr ...
|
||||
$ jfr view Text dump.jfr
|
||||
Time Event Thread Text
|
||||
======== ======================================== ==========================
|
||||
21:54:29 Attach Listener hello
|
||||
21:54:29 Attach Listener world
|
||||
...
|
||||
$ jfr print dump.jfr
|
||||
$ jfr query 'SELECT text, COUNT(text) FROM Text GROUP BY text ORDER BY text ASC' dump.jfr
|
||||
|
||||
Text Count
|
||||
=================== ===================
|
||||
hello 622
|
||||
world 37
|
||||
|
||||
$ jfr query 'SELECT COUNT(duration), AVG(duration), MEDIAN(duration), P90(duration),
|
||||
P99(duration), P999(duration) FROM Duration' dump.jfr
|
||||
|
||||
The 'jfr query' command is only available in debug builds, but recordings with internal
|
||||
events can be generated by product builds.
|
||||
|
||||
Programmatic access:
|
||||
try (var rf = new RecordingFile(Path.of("dump.jfr"))) {
|
||||
while (rf.hasMoreEvents()) {
|
||||
RecordedEvent e = rf.readEvent();
|
||||
System.out.println(e.getName() + " " + e.getDuration());
|
||||
EventType et = e.getEventType();
|
||||
System.out.println(et.getName() + " " + e.getDuration() + " " + e.getValue("text"));
|
||||
}
|
||||
};
|
||||
!-->
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -210,7 +210,7 @@ import sun.text.SupplementaryCharacterData;
|
||||
* </blockquote>
|
||||
*
|
||||
* <p>For a more complete explanation, see <a
|
||||
* href="http://www.ibm.com/java/education/boundaries/boundaries.html">http://www.ibm.com/java/education/boundaries/boundaries.html</a>.
|
||||
* href="https://icu-project.org/docs/papers/text_boundary_analysis_in_java/">Text Boundary Analysis in Java</a> by Richard Gillam.
|
||||
* For examples, see the resource data (which is annotated).</p>
|
||||
*
|
||||
* @author Richard Gillam
|
||||
|
||||
@ -141,8 +141,6 @@ public final class LWCToolkit extends LWToolkit {
|
||||
private static CInputMethodDescriptor sInputMethodDescriptor;
|
||||
|
||||
static {
|
||||
System.err.flush();
|
||||
|
||||
ResourceBundle platformResources = null;
|
||||
try {
|
||||
platformResources = ResourceBundle.getBundle("sun.awt.resources.awtosx");
|
||||
|
||||
@ -44,7 +44,6 @@ import com.sun.imageio.plugins.wbmp.WBMPImageReaderSpi;
|
||||
import com.sun.imageio.plugins.wbmp.WBMPImageWriterSpi;
|
||||
import com.sun.imageio.plugins.tiff.TIFFImageReaderSpi;
|
||||
import com.sun.imageio.plugins.tiff.TIFFImageWriterSpi;
|
||||
import sun.awt.AppContext;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.ServiceConfigurationError;
|
||||
@ -105,25 +104,15 @@ public final class IIORegistry extends ServiceRegistry {
|
||||
registerApplicationClasspathSpis();
|
||||
}
|
||||
|
||||
private static final IIORegistry registry = new IIORegistry();
|
||||
|
||||
/**
|
||||
* Returns the default {@code IIORegistry} instance used by
|
||||
* the Image I/O API. This instance should be used for all
|
||||
* registry functions.
|
||||
*
|
||||
* <p> Each {@code ThreadGroup} will receive its own instance.
|
||||
*
|
||||
* @return the default registry for the current
|
||||
* {@code ThreadGroup}.
|
||||
* @return the default registry for the Image I/O API
|
||||
*/
|
||||
public static IIORegistry getDefaultInstance() {
|
||||
AppContext context = AppContext.getAppContext();
|
||||
IIORegistry registry =
|
||||
(IIORegistry)context.get(IIORegistry.class);
|
||||
if (registry == null) {
|
||||
// Create an instance for this AppContext
|
||||
registry = new IIORegistry();
|
||||
context.put(IIORegistry.class, registry);
|
||||
}
|
||||
return registry;
|
||||
}
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ import java.util.ServiceLoader;
|
||||
* proxy for the heavyweight service.
|
||||
*
|
||||
* <p> An application may customize the contents of a registry as it
|
||||
* sees fit, so long as it has the appropriate runtime permission.
|
||||
* sees fit.
|
||||
*
|
||||
* <p> For information on how to create and deploy service providers,
|
||||
* refer to the documentation on {@link java.util.ServiceLoader ServiceLoader}
|
||||
@ -283,8 +283,7 @@ public class ServiceRegistry {
|
||||
* {@code onRegistration} method will be called once for each
|
||||
* category it is registered under. Its
|
||||
* {@code onDeregistration} method will be called each time
|
||||
* it is deregistered from a category or when the registry is
|
||||
* finalized.
|
||||
* it is deregistered from a category.
|
||||
*
|
||||
* @param provider the service provider object to be registered.
|
||||
*
|
||||
@ -313,8 +312,7 @@ public class ServiceRegistry {
|
||||
* {@code onRegistration} method will be called once for each
|
||||
* category it is registered under. Its
|
||||
* {@code onDeregistration} method will be called each time
|
||||
* it is deregistered from a category or when the registry is
|
||||
* finalized.
|
||||
* it is deregistered from a category.
|
||||
*
|
||||
* @param providers an Iterator containing service provider
|
||||
* objects to be registered.
|
||||
@ -660,6 +658,12 @@ public class ServiceRegistry {
|
||||
/**
|
||||
* Deregisters all currently registered service providers from all
|
||||
* categories.
|
||||
* <p>
|
||||
* If an application creates a new {@code ServiceRegistry} instance and registers providers,
|
||||
* and at some point no longer needs the instance, it should call this method to ensure
|
||||
* that all providers which are instances of {@link RegisterableService}
|
||||
* receive a {@link RegisterableService#onDeregistration(ServiceRegistry, Class<?>)} call back,
|
||||
* before allowing the instance to be garbage collected.
|
||||
*/
|
||||
public void deregisterAll() {
|
||||
for (SubRegistry reg : categoryMap.values()) {
|
||||
@ -667,26 +671,6 @@ public class ServiceRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes this object prior to garbage collection. The
|
||||
* {@code deregisterAll} method is called to deregister all
|
||||
* currently registered service providers. This method should not
|
||||
* be called from application code.
|
||||
*
|
||||
* @throws Throwable if an error occurs during superclass
|
||||
* finalization.
|
||||
*
|
||||
* @deprecated Finalization has been deprecated for removal. See
|
||||
* {@link java.lang.Object#finalize} for background information and details
|
||||
* about migration options.
|
||||
*/
|
||||
@Deprecated(since="9", forRemoval=true)
|
||||
@SuppressWarnings("removal")
|
||||
public void finalize() throws Throwable {
|
||||
deregisterAll();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the provided class is one of the allowed
|
||||
* ImageIO service provider classes. If it is, returns normally.
|
||||
@ -821,10 +805,6 @@ class SubRegistry {
|
||||
poset.clear();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public synchronized void finalize() {
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -63,6 +63,14 @@ import sun.awt.AppContext;
|
||||
* of the image.
|
||||
*
|
||||
* <p>
|
||||
* If the image source parameter to a constructor or method is non-null,
|
||||
* but does not reference valid accessible image data,
|
||||
* no exceptions will be thrown but no image will be rendered
|
||||
* even though {@link #getImage()} will return a non-null value,
|
||||
* as the image will have no dimensions
|
||||
* and {@link #getImageLoadStatus()} will report {@code MediaTracker.ERRORED}.
|
||||
*
|
||||
* <p>
|
||||
* For further information and examples of using image icons, see
|
||||
* <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/icon.html">How to Use Icons</a>
|
||||
* in <em>The Java Tutorial.</em>
|
||||
@ -178,6 +186,7 @@ public class ImageIcon implements Icon, Serializable, Accessible {
|
||||
* of the image.
|
||||
* @param location the URL for the image
|
||||
* @param description a brief textual description of the image
|
||||
* @throws NullPointerException if {@code location} is {@code null}
|
||||
* @see #ImageIcon(String)
|
||||
*/
|
||||
public ImageIcon(URL location, String description) {
|
||||
@ -197,6 +206,7 @@ public class ImageIcon implements Icon, Serializable, Accessible {
|
||||
* The icon's description is initialized to be
|
||||
* a string representation of the URL.
|
||||
* @param location the URL for the image
|
||||
* @throws NullPointerException if {@code location} is {@code null}
|
||||
* @see #getDescription
|
||||
*/
|
||||
public ImageIcon (URL location) {
|
||||
@ -207,10 +217,13 @@ public class ImageIcon implements Icon, Serializable, Accessible {
|
||||
* Creates an ImageIcon from the image.
|
||||
* @param image the image
|
||||
* @param description a brief textual description of the image
|
||||
* @throws NullPointerException if {@code image} is {@code null}
|
||||
*/
|
||||
public ImageIcon(Image image, String description) {
|
||||
this(image);
|
||||
this.image = image;
|
||||
this.description = description;
|
||||
|
||||
loadImage(image);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,16 +231,22 @@ public class ImageIcon implements Icon, Serializable, Accessible {
|
||||
* If the image has a "comment" property that is a string,
|
||||
* then the string is used as the description of this icon.
|
||||
* @param image the image
|
||||
* @throws NullPointerException if {@code image} is {@code null}
|
||||
* @see #getDescription
|
||||
* @see java.awt.Image#getProperty
|
||||
*/
|
||||
public ImageIcon (Image image) {
|
||||
this.image = image;
|
||||
Object o = image.getProperty("comment", imageObserver);
|
||||
if (o instanceof String) {
|
||||
description = (String) o;
|
||||
}
|
||||
loadImage(image);
|
||||
this(image, getImageComment(image));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@code "comment"} property of the image
|
||||
* if the value of the property is a sting}
|
||||
* @param image the image to get the {@code "comment"} property
|
||||
*/
|
||||
private static String getImageComment(Image image) {
|
||||
Object o = image.getProperty("comment", null);
|
||||
return (o instanceof String) ? (String) o : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,6 +260,7 @@ public class ImageIcon implements Icon, Serializable, Accessible {
|
||||
* @param imageData an array of pixels in an image format supported
|
||||
* by the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
|
||||
* @param description a brief textual description of the image
|
||||
* @throws NullPointerException if {@code imageData} is {@code null}
|
||||
* @see java.awt.Toolkit#createImage
|
||||
*/
|
||||
public ImageIcon (byte[] imageData, String description) {
|
||||
@ -264,6 +284,7 @@ public class ImageIcon implements Icon, Serializable, Accessible {
|
||||
*
|
||||
* @param imageData an array of pixels in an image format supported by
|
||||
* the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
|
||||
* @throws NullPointerException if {@code imageData} is {@code null}
|
||||
* @see java.awt.Toolkit#createImage
|
||||
* @see #getDescription
|
||||
* @see java.awt.Image#getProperty
|
||||
@ -368,6 +389,7 @@ public class ImageIcon implements Icon, Serializable, Accessible {
|
||||
/**
|
||||
* Sets the image displayed by this icon.
|
||||
* @param image the image
|
||||
* @throws NullPointerException if {@code image} is {@code null}
|
||||
*/
|
||||
public void setImage(Image image) {
|
||||
this.image = image;
|
||||
|
||||
@ -1164,7 +1164,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
|
||||
* @see #setShowHorizontalLines
|
||||
*/
|
||||
@BeanProperty(description
|
||||
= "The color used to draw the grid lines.")
|
||||
= "Whether grid lines are drawn around the cells.")
|
||||
public void setShowGrid(boolean showGrid) {
|
||||
setShowHorizontalLines(showGrid);
|
||||
setShowVerticalLines(showGrid);
|
||||
|
||||
@ -172,13 +172,6 @@ public abstract class X11InputMethodBase extends InputMethodAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected void finalize() throws Throwable {
|
||||
dispose();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes openIM() that invokes XOpenIM() if it's not opened yet.
|
||||
* @return true if openXIM() is successful or it's already been opened.
|
||||
|
||||
@ -287,7 +287,8 @@ public class AMD64 extends Architecture {
|
||||
SHA512,
|
||||
AVX512_FP16,
|
||||
AVX10_1,
|
||||
AVX10_2
|
||||
AVX10_2,
|
||||
HYBRID
|
||||
}
|
||||
|
||||
private final EnumSet<CPUFeature> features;
|
||||
|
||||
@ -317,10 +317,11 @@ public class HtmlDoclet extends AbstractDoclet {
|
||||
copyResource(DocPaths.HIGHLIGHT_JS, DocPaths.SCRIPT_FILES.resolve(DocPaths.HIGHLIGHT_JS), true);
|
||||
}
|
||||
|
||||
// If a stylesheet file is not specified, copy the default stylesheet
|
||||
// and replace newline with platform-specific newline.
|
||||
// If a stylesheet file is not specified, copy the default stylesheet,
|
||||
// replace newline with platform-specific newline,
|
||||
// and remove the reference to fonts if --no-fonts is used.
|
||||
if (options.stylesheetFile().isEmpty()) {
|
||||
copyResource(DocPaths.STYLESHEET, DocPaths.RESOURCE_FILES.resolve(DocPaths.STYLESHEET), true);
|
||||
copyStylesheet(options);
|
||||
}
|
||||
copyResource(DocPaths.SCRIPT_JS_TEMPLATE, DocPaths.SCRIPT_FILES.resolve(DocPaths.SCRIPT_JS), true);
|
||||
copyResource(DocPaths.LEFT_SVG, DocPaths.RESOURCE_FILES.resolve(DocPaths.LEFT_SVG), true);
|
||||
@ -463,18 +464,13 @@ public class HtmlDoclet extends AbstractDoclet {
|
||||
|
||||
private void copyResource(DocPath sourcePath, DocPath targetPath, boolean replaceNewLine)
|
||||
throws DocletException {
|
||||
DocPath resourcePath = DocPaths.RESOURCES.resolve(sourcePath);
|
||||
// Resolve resources against doclets.formats.html package
|
||||
URL resourceURL = HtmlConfiguration.class.getResource(resourcePath.getPath());
|
||||
if (resourceURL == null) {
|
||||
throw new ResourceIOException(sourcePath, new FileNotFoundException(resourcePath.getPath()));
|
||||
}
|
||||
ReadableResource resource = resolveResource(sourcePath);
|
||||
DocFile f = DocFile.createFileForOutput(configuration, targetPath);
|
||||
|
||||
if (sourcePath.getPath().toLowerCase(Locale.ROOT).endsWith(".template")) {
|
||||
f.copyResource(resourcePath, resourceURL, configuration.docResources);
|
||||
f.copyResource(resource.path(), resource.url(), configuration.docResources);
|
||||
} else {
|
||||
f.copyResource(resourcePath, resourceURL, replaceNewLine);
|
||||
f.copyResource(resource.path(), resource.url(), replaceNewLine);
|
||||
}
|
||||
}
|
||||
|
||||
@ -503,6 +499,23 @@ public class HtmlDoclet extends AbstractDoclet {
|
||||
}
|
||||
}
|
||||
|
||||
private void copyStylesheet(HtmlOptions options) throws DocletException {
|
||||
ReadableResource resource = resolveResource(DocPaths.STYLESHEET);
|
||||
var targetPath = DocPaths.RESOURCE_FILES.resolve(DocPaths.STYLESHEET);
|
||||
DocFile f = DocFile.createFileForOutput(configuration, targetPath);
|
||||
|
||||
if (options.noFonts()) {
|
||||
f.copyResource(resource.path(), resource.url(), line -> {
|
||||
if (line.startsWith("@import url('fonts")) {
|
||||
return null; // remove the line
|
||||
}
|
||||
return line;
|
||||
});
|
||||
} else {
|
||||
f.copyResource(resource.path(), resource.url(), true);
|
||||
}
|
||||
}
|
||||
|
||||
private void copyFile(String filename, DocPath targetPath) throws DocFileIOException {
|
||||
if (filename.isEmpty()) {
|
||||
return;
|
||||
@ -519,4 +532,17 @@ public class HtmlDoclet extends AbstractDoclet {
|
||||
fromfile.getPath(), path.getPath());
|
||||
toFile.copyFile(fromfile);
|
||||
}
|
||||
|
||||
private ReadableResource resolveResource(DocPath sourcePath) throws ResourceIOException {
|
||||
DocPath resolvedPath = DocPaths.RESOURCES.resolve(sourcePath);
|
||||
// Resolve resources against doclets.formats.html package
|
||||
URL resourceURL = HtmlConfiguration.class.getResource(resolvedPath.getPath());
|
||||
if (resourceURL == null) {
|
||||
throw new ResourceIOException(sourcePath, new FileNotFoundException(resolvedPath.getPath()));
|
||||
}
|
||||
return new ReadableResource(resolvedPath, resourceURL);
|
||||
}
|
||||
|
||||
private record ReadableResource(DocPath path, URL url) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -188,7 +189,7 @@ public abstract class DocFile {
|
||||
*/
|
||||
public void copyResource(DocPath resource, URL url, boolean replaceNewLine)
|
||||
throws DocFileIOException, ResourceIOException {
|
||||
copyResource(resource, url, replaceNewLine, null);
|
||||
copyResource(resource, url, replaceNewLine, UnaryOperator.identity());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,11 +203,27 @@ public abstract class DocFile {
|
||||
* @throws ResourceIOException if there is a problem while reading the resource
|
||||
*/
|
||||
public void copyResource(DocPath resource, URL url, Resources resources) throws DocFileIOException, ResourceIOException {
|
||||
copyResource(resource, url, true, resources);
|
||||
copyResource(resource, url, resources == null ? UnaryOperator.identity() : line -> localize(line, resources));
|
||||
}
|
||||
|
||||
private void copyResource(DocPath resource, URL url, boolean replaceNewLine, Resources resources)
|
||||
throws DocFileIOException, ResourceIOException {
|
||||
/**
|
||||
* Copy the contents of a resource file to this file while transforming and filtering its lines.
|
||||
*
|
||||
* @param resource the path of the resource
|
||||
* @param url the URL of the resource
|
||||
* @param lineTransformer the transforming function that is called for each line; may return
|
||||
* {@code null} to remove a line.
|
||||
*
|
||||
* @throws DocFileIOException if there is a problem while writing the copy
|
||||
* @throws ResourceIOException if there is a problem while reading the resource
|
||||
*/
|
||||
public void copyResource(DocPath resource, URL url, UnaryOperator<String> lineTransformer)
|
||||
throws DocFileIOException, ResourceIOException {
|
||||
copyResource(resource, url, true, lineTransformer);
|
||||
}
|
||||
|
||||
private void copyResource(DocPath resource, URL url, boolean replaceNewLine, UnaryOperator<String> lineTransformer)
|
||||
throws ResourceIOException, DocFileIOException {
|
||||
try {
|
||||
InputStream in = url.openStream();
|
||||
|
||||
@ -216,8 +233,11 @@ public abstract class DocFile {
|
||||
try (Writer writer = openWriter()) {
|
||||
String line;
|
||||
while ((line = readResourceLine(resource, reader)) != null) {
|
||||
write(this, writer, resources == null ? line : localize(line, resources));
|
||||
write(this, writer, PLATFORM_LINE_SEPARATOR);
|
||||
String transformedLine = lineTransformer.apply(line);
|
||||
if (transformedLine != null) {
|
||||
write(this, writer, transformedLine);
|
||||
write(this, writer, PLATFORM_LINE_SEPARATOR);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new DocFileIOException(this, DocFileIOException.Mode.WRITE, e);
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
* jdk.internal.jvmstat/sun.jvmstat.monitor
|
||||
* @run driver CreateCoredumpOnCrash
|
||||
* @requires vm.flagless
|
||||
* @requires !vm.asan
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
@ -750,11 +750,6 @@ java/util/zip/CloseInflaterDeflaterTest.java 8339216 linux-s390x
|
||||
|
||||
sun/tools/jstatd/TestJstatdRmiPort.java 8251259,8293577 generic-all
|
||||
|
||||
sun/tools/jstat/jstatLineCounts1.sh 8248691,8268211 linux-ppc64le,aix-ppc64,linux-aarch64
|
||||
sun/tools/jstat/jstatLineCounts2.sh 8248691,8268211 linux-ppc64le,aix-ppc64,linux-aarch64
|
||||
sun/tools/jstat/jstatLineCounts3.sh 8248691,8268211 linux-ppc64le,aix-ppc64,linux-aarch64
|
||||
sun/tools/jstat/jstatLineCounts4.sh 8248691,8268211 linux-ppc64le,aix-ppc64,linux-aarch64
|
||||
|
||||
############################################################################
|
||||
|
||||
# jdk_other
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,110 +22,120 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
@test
|
||||
@key headful
|
||||
@bug 6315717
|
||||
@summary verifies that drag events are coming for every button if the property is set to true
|
||||
@author Andrei Dmitriev : area=awt.mouse
|
||||
@run main ExtraButtonDrag
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6315717
|
||||
* @summary Verifies that the mouse drag events received for every button if the property is set to true
|
||||
* @run main ExtraButtonDrag
|
||||
*/
|
||||
|
||||
//events from standard should also come
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.MouseInfo;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
public class ExtraButtonDrag {
|
||||
|
||||
public class ExtraButtonDrag extends Frame {
|
||||
static String tk = Toolkit.getDefaultToolkit().getClass().getName();
|
||||
static Robot robot;
|
||||
static int [] buttonsPressed;
|
||||
static int [] buttonsReleased;
|
||||
static int [] buttonsClicked;
|
||||
volatile static boolean dragged = false;
|
||||
volatile static boolean moved = false;
|
||||
private static Frame frame;
|
||||
private static Robot robot;
|
||||
private static volatile boolean dragged = false;
|
||||
private static volatile boolean moved = false;
|
||||
private static volatile Point centerFrame;
|
||||
private static volatile Point outboundsFrame;
|
||||
private static final String OS_NAME = System.getProperty("os.name");
|
||||
private static MouseAdapter mAdapter = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
dragged = true;
|
||||
}
|
||||
|
||||
public ExtraButtonDrag(){
|
||||
super("ExtraButtonDrag");
|
||||
}
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
moved = true;
|
||||
}
|
||||
};
|
||||
|
||||
public static void main(String []s){
|
||||
Frame frame = new ExtraButtonDrag();
|
||||
|
||||
MouseAdapter ma = new MouseAdapter() {
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
System.out.println("Dragged "+e);// +" : "+ e.getButton() + " : " +e.getButtonState(e.getButton()));
|
||||
dragged = true;
|
||||
}
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
System.out.println("Moved "+e);
|
||||
moved = true;
|
||||
}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
System.out.println(">>> "+e);
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
System.out.println(">>> "+e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
frame.addMouseMotionListener(ma);
|
||||
frame.addMouseListener(ma);
|
||||
public static void initializeGUI() {
|
||||
frame = new Frame("ExtraButtonDrag");
|
||||
frame.addMouseMotionListener(mAdapter);
|
||||
frame.addMouseListener(mAdapter);
|
||||
|
||||
frame.setSize(300, 300);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
int [] buttonMask = new int [MouseInfo.getNumberOfButtons()]; //InputEvent.getButtonMasks();
|
||||
public static void doTest()
|
||||
throws InvocationTargetException, InterruptedException {
|
||||
|
||||
for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){
|
||||
buttonMask[i] = InputEvent.getMaskForButton(i+1);
|
||||
// System.out.println("TEST: "+tmp[i]);
|
||||
int[] buttonMask = new int[MouseInfo.getNumberOfButtons()];
|
||||
|
||||
for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++) {
|
||||
buttonMask[i] = InputEvent.getMaskForButton(i + 1);
|
||||
}
|
||||
|
||||
try {
|
||||
robot = new Robot();
|
||||
robot.delay(1000);
|
||||
Point centerFrame = new Point(frame.getLocationOnScreen().x + frame.getWidth()/2, frame.getLocationOnScreen().y + frame.getHeight()/2);
|
||||
Point outboundsFrame = new Point(frame.getLocationOnScreen().x + frame.getWidth()*3/2, frame.getLocationOnScreen().y + frame.getHeight()/2);
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
Point location = frame.getLocationOnScreen();
|
||||
Dimension size = frame.getSize();
|
||||
centerFrame = new Point(location.x + size.width / 2,
|
||||
location.y + size.height / 2);
|
||||
outboundsFrame = new Point(location.x + size.width * 3 / 2,
|
||||
location.y + size.height / 2);
|
||||
});
|
||||
|
||||
System.out.println("areExtraMouseButtonsEnabled() == " + Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() );
|
||||
System.out.println("areExtraMouseButtonsEnabled() == "
|
||||
+ Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled());
|
||||
|
||||
for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){
|
||||
System.out.println("button to drag = " +(i+1) + " : value passed to robot = " +buttonMask[i]);
|
||||
for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++) {
|
||||
System.out.println("button to drag = " + (i + 1)
|
||||
+ " : value passed to robot = " + buttonMask[i]);
|
||||
|
||||
try {
|
||||
dragMouse(buttonMask[i], centerFrame.x, centerFrame.y, outboundsFrame.x, outboundsFrame.y);
|
||||
} catch (IllegalArgumentException e){
|
||||
throw new RuntimeException("Test failed. Exception occured.", e);
|
||||
try {
|
||||
dragMouse(buttonMask[i], centerFrame.x, centerFrame.y,
|
||||
outboundsFrame.x, outboundsFrame.y);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new RuntimeException("Test failed. Exception occured.",
|
||||
e);
|
||||
}
|
||||
|
||||
// this is a choice-case for X protocol issue: native events from
|
||||
// extra buttons doesn't contain
|
||||
// the correct state so it's unable to decide if there is a drag or
|
||||
// move. By default we send MOVED event.
|
||||
// XToolkit: extra buttons should report MOVED events only
|
||||
// WToolkit: extra buttons should report DRAGGED events only
|
||||
if (i > 2) { // extra buttons only
|
||||
if (OS_NAME.equals("Linux")) {
|
||||
if (!moved || dragged) {
|
||||
throw new RuntimeException("Test failed." + OS_NAME
|
||||
+ " Button = " + (i + 1) + " moved = " + moved
|
||||
+ " : dragged = " + dragged);
|
||||
}
|
||||
} else { // WToolkit
|
||||
if (moved || !dragged) {
|
||||
throw new RuntimeException("Test failed." + OS_NAME
|
||||
+ " Button = " + (i + 1) + " moved = " + moved
|
||||
+ " : dragged = " + dragged);
|
||||
}
|
||||
}
|
||||
|
||||
robot.delay(500);
|
||||
//this is a choice-case for X protocol issue: native events from extra buttons doesn't contain
|
||||
// the correct state so it's unable to decide if there is a drag or move. By default we send MOVED event.
|
||||
//XToolkit: extra buttons should report MOVED events only
|
||||
//WToolkit: extra buttons should report DRAGGED events only
|
||||
if (i > 2){ //extra buttons only
|
||||
if (tk.equals("sun.awt.X11.XToolkit")) {
|
||||
if (!moved || dragged) {
|
||||
throw new RuntimeException("Test failed."+ tk +" Button = " +(i+1) + " moved = "+moved +" : dragged = " +dragged);
|
||||
}
|
||||
} else { //WToolkit
|
||||
if (moved || !dragged) {
|
||||
throw new RuntimeException("Test failed."+ tk +" Button = " +(i+1) + " moved = "+moved +" : dragged = " +dragged);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (moved || !dragged){
|
||||
throw new RuntimeException("Test failed. Button = " +(i+1) + " not dragged.");
|
||||
}
|
||||
} else {
|
||||
if (moved || !dragged) {
|
||||
throw new RuntimeException(
|
||||
"Test failed. Button = " + (i + 1) + " not dragged.");
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
throw new RuntimeException("", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void dragMouse(int button, int x0, int y0, int x1, int y1){
|
||||
public static void dragMouse(int button, int x0, int y0, int x1, int y1) {
|
||||
int curX = x0;
|
||||
int curY = y0;
|
||||
int dx = x0 < x1 ? 1 : -1;
|
||||
@ -138,12 +148,12 @@ public class ExtraButtonDrag extends Frame {
|
||||
|
||||
robot.mousePress(button);
|
||||
|
||||
while (curX != x1){
|
||||
while (curX != x1) {
|
||||
curX += dx;
|
||||
robot.mouseMove(curX, curY);
|
||||
robot.delay(5);
|
||||
}
|
||||
while (curY != y1 ){
|
||||
while (curY != y1) {
|
||||
curY += dy;
|
||||
robot.mouseMove(curX, curY);
|
||||
robot.delay(5);
|
||||
@ -151,4 +161,30 @@ public class ExtraButtonDrag extends Frame {
|
||||
robot.mouseRelease(button);
|
||||
}
|
||||
|
||||
public static void main(String[] s)
|
||||
throws InvocationTargetException, InterruptedException, AWTException {
|
||||
try {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
robot.setAutoWaitForIdle(true);
|
||||
|
||||
EventQueue.invokeAndWait(ExtraButtonDrag::initializeGUI);
|
||||
robot.waitForIdle();
|
||||
robot.delay(100);
|
||||
|
||||
doTest();
|
||||
|
||||
System.out.println("Test Passed");
|
||||
} finally {
|
||||
EventQueue.invokeAndWait(ExtraButtonDrag::disposeFrame);
|
||||
}
|
||||
}
|
||||
|
||||
public static void disposeFrame() {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
frame = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,141 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 4421190
|
||||
* @summary Tests that Image I/O statics may be referenced properly from
|
||||
* multiple AppContexts, as would be the case for multiple Applets in a
|
||||
* single VM. Each AppContext should get its own copy of the registry
|
||||
* and the caching parameters in the ImageIO class.
|
||||
* @modules java.desktop/sun.awt
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.spi.IIORegistry;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
class TestThread extends Thread {
|
||||
|
||||
IIORegistry registry;
|
||||
boolean useCache;
|
||||
File cacheDirectory;
|
||||
boolean cacheSettingsOK = false;
|
||||
String threadName;
|
||||
|
||||
boolean gotCrosstalk = false;
|
||||
|
||||
public TestThread(ThreadGroup tg,
|
||||
boolean useCache, File cacheDirectory,
|
||||
String threadName) {
|
||||
super(tg, threadName);
|
||||
this.useCache = useCache;
|
||||
this.cacheDirectory = cacheDirectory;
|
||||
this.threadName = threadName;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// System.out.println("Thread " + threadName + " in thread group " +
|
||||
// getThreadGroup().getName());
|
||||
|
||||
// Create a new AppContext as though we were an applet
|
||||
SunToolkit.createNewAppContext();
|
||||
|
||||
// Get default registry and store reference
|
||||
this.registry = IIORegistry.getDefaultInstance();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// System.out.println(threadName +
|
||||
// ": setting cache parameters to " +
|
||||
// useCache + ", " + cacheDirectory);
|
||||
ImageIO.setUseCache(useCache);
|
||||
ImageIO.setCacheDirectory(cacheDirectory);
|
||||
|
||||
try {
|
||||
sleep(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
// System.out.println(threadName + ": reading cache parameters");
|
||||
boolean newUseCache = ImageIO.getUseCache();
|
||||
File newCacheDirectory = ImageIO.getCacheDirectory();
|
||||
if (newUseCache != useCache ||
|
||||
newCacheDirectory != cacheDirectory) {
|
||||
// System.out.println(threadName + ": got " +
|
||||
// newUseCache + ", " +
|
||||
// newCacheDirectory);
|
||||
// System.out.println(threadName + ": crosstalk encountered!");
|
||||
gotCrosstalk = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IIORegistry getRegistry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
public boolean gotCrosstalk() {
|
||||
return gotCrosstalk;
|
||||
}
|
||||
}
|
||||
|
||||
public class AppContextTest {
|
||||
|
||||
public AppContextTest() {
|
||||
ThreadGroup tg0 = new ThreadGroup("ThreadGroup0");
|
||||
ThreadGroup tg1 = new ThreadGroup("ThreadGroup1");
|
||||
|
||||
TestThread t0 =
|
||||
new TestThread(tg0, false, null, "TestThread 0");
|
||||
TestThread t1 =
|
||||
new TestThread(tg1, true, new File("."), "TestThread 1");
|
||||
|
||||
t0.start();
|
||||
t1.start();
|
||||
|
||||
try {
|
||||
t0.join();
|
||||
} catch (InterruptedException ie0) {
|
||||
}
|
||||
try {
|
||||
t1.join();
|
||||
} catch (InterruptedException ie1) {
|
||||
}
|
||||
|
||||
if (t0.gotCrosstalk() || t1.gotCrosstalk()) {
|
||||
throw new RuntimeException("ImageIO methods had crosstalk!");
|
||||
}
|
||||
|
||||
if (t0.getRegistry() == t1.getRegistry()) {
|
||||
throw new RuntimeException("ThreadGroups had same IIORegistry!");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
new AppContextTest();
|
||||
}
|
||||
}
|
||||
150
test/jdk/javax/swing/ImageIcon/ImageIconTest.java
Normal file
150
test/jdk/javax/swing/ImageIcon/ImageIconTest.java
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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 8159055
|
||||
* @summary Verifies null parameter and invalid data handling of
|
||||
* ImageIcon constructors and setImage method
|
||||
* @run main ImageIconTest
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.Random;
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public class ImageIconTest {
|
||||
|
||||
static enum ArgType { FILE, URL, BYTE_ARRAY, IMAGE, SET_IMAGE };
|
||||
static enum ArgVal { NULL, INVALID_DATA };
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
String imgName = "invalid.gif";
|
||||
byte[] invalidData = new byte[100];
|
||||
new Random().nextBytes(invalidData);
|
||||
try (FileOutputStream fos = new FileOutputStream(imgName)) {
|
||||
fos.write(invalidData);
|
||||
}
|
||||
File file = new File(imgName);
|
||||
file.deleteOnExit();
|
||||
|
||||
for (ArgType a : ArgType.values()) {
|
||||
for (final ArgVal v : ArgVal.values()) {
|
||||
System.out.println("Testing for ArgType " + a + " for case " + v);
|
||||
boolean expected = true;
|
||||
boolean passed = false;
|
||||
try {
|
||||
switch (a) {
|
||||
|
||||
case FILE :
|
||||
|
||||
expected = false;
|
||||
String s = (v == ArgVal.NULL) ? null : imgName;
|
||||
new ImageIcon(s);
|
||||
passed = true; // no exception expected for this case
|
||||
break;
|
||||
|
||||
case URL :
|
||||
|
||||
if (v == ArgVal.NULL) {
|
||||
|
||||
new ImageIcon((URL)null);
|
||||
|
||||
} else if (v == ArgVal.INVALID_DATA) {
|
||||
expected = false;
|
||||
new ImageIcon(new URI("file://" + imgName).toURL());
|
||||
passed = true; // no exception expected for this case
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case BYTE_ARRAY :
|
||||
|
||||
if (v == ArgVal.NULL) {
|
||||
|
||||
byte[] bytes = null;
|
||||
new ImageIcon(bytes);
|
||||
|
||||
} else if (v == ArgVal.INVALID_DATA) {
|
||||
expected = false;
|
||||
|
||||
new ImageIcon(invalidData);
|
||||
|
||||
passed = true; // no exception expected for this case
|
||||
}
|
||||
break;
|
||||
|
||||
case IMAGE :
|
||||
|
||||
if (v == ArgVal.NULL) {
|
||||
|
||||
new ImageIcon((Image)null);
|
||||
|
||||
} else if (v == ArgVal.INVALID_DATA) {
|
||||
expected = false;
|
||||
|
||||
new ImageIcon((Image)Toolkit.getDefaultToolkit().createImage(imgName));
|
||||
|
||||
passed = true; // no exception expected for this case
|
||||
}
|
||||
break;
|
||||
|
||||
case SET_IMAGE :
|
||||
|
||||
ImageIcon ii = new ImageIcon();
|
||||
|
||||
if (v == ArgVal.NULL) {
|
||||
|
||||
ii.setImage((Image) null);
|
||||
|
||||
} else if (v == ArgVal.INVALID_DATA) {
|
||||
expected = false;
|
||||
|
||||
ii.setImage((Image)Toolkit.getDefaultToolkit().createImage(imgName));
|
||||
|
||||
passed = true; // no exception expected for this case
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
if (expected) {
|
||||
passed = true;
|
||||
}
|
||||
}
|
||||
if (expected && !passed) {
|
||||
throw new RuntimeException("Did not receive expected exception for : " + a);
|
||||
}
|
||||
if (!expected && !passed) {
|
||||
throw new RuntimeException("Received unexpected exception for : " + a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -64,6 +64,8 @@ public class TestFonts extends JavadocTester {
|
||||
javadoc("-d", base.resolve("out").toString(),
|
||||
src.resolve("Dummy.java").toString());
|
||||
checkExit(Exit.OK);
|
||||
checkOutput("resource-files/stylesheet.css", true,
|
||||
"@import url('fonts/dejavu.css');");
|
||||
checkOutput("resource-files/fonts/dejavu.css", true,
|
||||
"""
|
||||
/* DejaVu fonts v2.37 */""",
|
||||
@ -115,6 +117,8 @@ public class TestFonts extends JavadocTester {
|
||||
"resource-files/link.svg",
|
||||
"resource-files/stylesheet.css",
|
||||
"resource-files/x.svg");
|
||||
checkOutput("resource-files/stylesheet.css", false,
|
||||
"@import url('fonts/dejavu.css');");
|
||||
checkFiles(false, "resource-files/fonts");
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ public class TestStylesheet extends JavadocTester {
|
||||
|
||||
@Test
|
||||
public void test(Path base) {
|
||||
setUseDefaultOptions(false);
|
||||
javadoc("-d", base.resolve("out").toString(),
|
||||
"-sourcepath", testSrc,
|
||||
"pkg");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user