This commit is contained in:
Lana Steuck 2010-12-20 21:09:57 -08:00
commit 0abd11c293
316 changed files with 11922 additions and 5058 deletions

View File

@ -466,12 +466,14 @@ else
# On X86, make sure tail call optimization is off
# The z and y are the tail call optimizations.
ifeq ($(ARCH_FAMILY), i586)
ifeq ($(shell $(EXPR) $(CC_VER) \> 5.8), 1)
# Somehow, tail call optimization is creeping in.
# Make sure it is off.
# WARNING: These may cause compiler warnings about duplicate -O options
CC_XKEEPFRAME_OPTIONS += -Wu,-O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
CXX_XKEEPFRAME_OPTIONS += -Qoption ube -O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
ifeq ($(shell $(EXPR) $(CC_MAJORVER) \>= 5), 1)
ifeq ($(shell $(EXPR) $(CC_MINORVER) \> 8), 1)
# Somehow, tail call optimization is creeping in.
# Make sure it is off.
# WARNING: These may cause compiler warnings about duplicate -O options
CC_XKEEPFRAME_OPTIONS += -Wu,-O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
CXX_XKEEPFRAME_OPTIONS += -Qoption ube -O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
endif
endif
endif
@ -487,12 +489,15 @@ else
CC_XKEEPFRAME_OPTIONS += -Wu,-Z~B
CXX_XKEEPFRAME_OPTIONS += -Qoption ube -Z~B
endif
ifeq ($(shell $(EXPR) $(CC_VER) \> 5.6), 1)
# Do NOT use frame pointer register as a general purpose opt register
CC_OPT/NONE += -xregs=no%frameptr
CXX_OPT/NONE += -xregs=no%frameptr
CC_XKEEPFRAME_OPTIONS += -xregs=no%frameptr
CXX_XKEEPFRAME_OPTIONS += -xregs=no%frameptr
ifeq ($(shell $(EXPR) $(CC_MAJORVER) \>= 5), 1)
ifeq ($(shell $(EXPR) $(CC_MINORVER) \> 6), 1)
# Do NOT use frame pointer register as a general purpose opt register
CC_OPT/NONE += -xregs=no%frameptr
CXX_OPT/NONE += -xregs=no%frameptr
CC_XKEEPFRAME_OPTIONS += -xregs=no%frameptr
CXX_XKEEPFRAME_OPTIONS += -xregs=no%frameptr
endif
endif
endif

View File

@ -61,6 +61,7 @@ endif
# Get compiler version
_CC_VER :=$(shell $(CC) -V 2>&1 | $(HEAD) -n 1)
CC_VER :=$(call GetVersion,"$(_CC_VER)")
CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
CC_MINORVER :=$(call MinorVersion,$(CC_VER))
# Name of compilers being used

View File

@ -123,7 +123,7 @@ LIBM=-lm
# GCC29_COMPILER_PATH: is the path to where the gcc 2.9 compiler is installed
# NOTE: Must end with / so that it could be empty, allowing PATH usage.
ifneq "$(origin ALT_GCC29_COMPILER_PATH)" "undefined"
ifdef ALT_GCC29_COMPILER_PATH
GCC29_COMPILER_PATH :=$(call PrefixPath,$(ALT_GCC29_COMPILER_PATH))
else
GCC29_COMPILER_PATH = $(JDK_DEVTOOLS_DIR)/$(PLATFORM)/gcc29/usr/

View File

@ -65,7 +65,7 @@
# If we are using freetype, the freetype version expected.
#
# REQUIRED_GCC_VER
# Solaris and Linux only. The required version of gcc/g++ for the plugin.
# Solaris and Linux only. The required version of gcc/g++ for the legacy OJI plugin.
#
# REQUIRED_LINK_VER
# Windows only: The version of link.exe expected.

View File

@ -99,12 +99,16 @@ ifeq ($(PLATFORM), linux)
echo "RedHat"; \
elif [ -f /etc/SuSE-release ] ; then \
echo "SuSE"; \
elif [ -f /etc/lsb-release ] ; then \
$(EGREP) DISTRIB_ID /etc/lsb-release | $(SED) -e 's@.*DISTRIB_ID=\(.*\)@\1@'; \
else \
echo "Unknown"; \
fi)
OS_VARIANT_VERSION := $(shell \
if [ "$(OS_VARIANT_NAME)" = "Fedora" ] ; then \
$(CAT) /etc/fedora-release | $(HEAD) -1 | $(NAWK) '{ print $$3; }' ; \
elif [ -f /etc/lsb-release ] ; then \
$(EGREP) DISTRIB_RELEASE /etc/lsb-release | $(SED) -e 's@.*DISTRIB_RELEASE=\(.*\)@\1@'; \
fi)
ALSA_INCLUDE=/usr/include/alsa/version.h
ALSA_LIBRARY=/usr/lib/libasound.so
@ -279,7 +283,7 @@ sane-arch_data_model:
fi
######################################################
# Check the OS version (windows and linus have release name checks)
# Check the OS version (windows and linux have release name checks)
# NOTE: OPENJDK explicitly does not check for OS release information.
# Unless we know for sure that it will not build somewhere, we cannot
# generate a fatal sanity error, and a warning about the official
@ -1477,20 +1481,20 @@ ifeq ($(PLATFORM), windows)
endif
######################################################
# Check the Solaris GNU c++ compiler for solaris plugin
# Check the GNU C++ compiler for OJI plugin
######################################################
sane-gcc-compiler:
ifeq ($(PLATFORM), solaris)
ifndef OPENJDK
@if [ -r $(GCC_COMPILER_PATH) ]; then \
if [ ! "$(GCC_VER)" = $(REQUIRED_GCC_VERSION) ]; then \
$(ECHO) "ERROR: The Solaris GCC compiler version must be $(REQUIRED_GCC_VERSION). \n" \
ifndef OPENJDK
ifeq ($(PLATFORM), solaris)
@if [ -r $(GCC_COMPILER_PATH) ]; then \
if [ ! "$(GCC_VER)" = $(REQUIRED_GCC_VER) ]; then \
$(ECHO) "ERROR: The Solaris GCC compiler version must be $(REQUIRED_GCC_VER). \n" \
" You are using the following compiler version: $(GCC_VER) \n" \
" The compiler was obtained from the following location: \n" \
" $(GCC_COMPILER_PATH) \n" \
" Please change your compiler. \n" \
"" >> $(ERROR_FILE) ; \
fi \
fi \
else \
$(ECHO) "ERROR: You do not have a valid GCC_COMPILER_PATH setting. \n" \
" Please check your access to \n" \
@ -1502,15 +1506,16 @@ ifeq ($(PLATFORM), solaris)
endif
ifeq ($(PLATFORM), linux)
ifeq ($(ARCH_DATA_MODEL), 32)
ifdef ALT_GCC29_COMPILER_PATH
@if [ ! -x $(ALT_GCC29_COMPILER_PATH)/bin/gcc ]; then \
$(ECHO) "ERROR: You do not have a valid ALT_GCC29_COMPILER_PATH setting. \n" \
$(ECHO) "ERROR: You do not have a valid ALT_GCC29_COMPILER_PATH setting. \n" \
" Please check your access to \n" \
" $(ALT_GCC29_COMPILER_PATH)/bin/gcc \n" \
" This will affect you if you build the plugin target. \n" \
"" >> $(ERROR_FILE) ; \
fi
endif
else
ifdef ALT_GCC29_PLUGIN_LIB_PATH
@if [ ! -r $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so ]; then \
$(ECHO) "Error: You do not have a valid ALT_GCC29_PLUGIN_LIB_PATH setting. \n" \
@ -1524,13 +1529,15 @@ ifeq ($(PLATFORM), solaris)
$(ECHO) "ERROR: You do not have a valid GCC29_COMPILER_PATH setting. \n" \
" Please check your access to \n" \
" $(GCC29_COMPILER_PATH) \n" \
" and/or check your value of ALT_GCC29_COMPILER_PATH. \n" \
" and/or check your value of ALT_GCC29_COMPILER_PATH or ALT_GCC29_PLUGIN_LIB_PATH \n" \
" This will affect you if you build the plugin target. \n" \
"" >> $(ERROR_FILE) ; \
fi
endif
endif
endif
endif # ALT_GCC29_PLUGIN_LIB_PATH
endif # ALT_GCC29_COMPILER_PATH
endif # ARCH_DATA_MODEL, 32
endif # LINUX
endif # OPEN_JDK
######################################################

View File

@ -190,7 +190,6 @@ $(call CopyrightLine,$(COPYRIGHT_URL),$(FIRST_COPYRIGHT_YEAR),)\
# Common javadoc options used by all
COMMON_JAVADOCFLAGS = \
$(NO_PROPRIETARY_API_WARNINGS) \
-source 1.5 \
-quiet \
-use \
-keywords \

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -137,6 +137,7 @@ JAVA_JAVA_java = \
java/lang/Comparable.java \
java/lang/Readable.java \
java/lang/Override.java \
java/lang/SafeVarargs.java \
java/lang/SuppressWarnings.java \
java/lang/ref/Reference.java \
java/lang/ref/SoftReference.java \

View File

@ -33,8 +33,8 @@ DEMONAME = zipfs
include $(BUILDDIR)/common/Defs.gmk
DEMO_ROOT = $(SHARE_SRC)/demo/nio/$(DEMONAME)
DEMO_TOPFILES = ./README.txt
DEMO_SRCDIR = $(DEMO_ROOT)
DEMO_TOPFILES = README.txt Demo.java
DEMO_SRCDIR = $(DEMO_ROOT)/src
DEMO_DESTDIR = $(DEMODIR)/nio/$(DEMONAME)
#
@ -42,10 +42,10 @@ DEMO_DESTDIR = $(DEMODIR)/nio/$(DEMONAME)
#
include $(BUILDDIR)/common/Demo.gmk
#EXTJAR = $(EXTDIR)/$(DEMONAME).jar
#
#all : build $(EXTJAR)
#
#$(EXTJAR) : $(DEMO_JAR)
# $(prep-target)
# $(CP) $(DEMO_JAR) $(EXTJAR)
EXTJAR = $(EXTDIR)/$(DEMONAME).jar
all : build $(EXTJAR)
$(EXTJAR) : $(DEMO_JAR)
$(prep-target)
$(CP) $(DEMO_JAR) $(EXTJAR)

View File

@ -18,11 +18,15 @@ MEDIA_SRC = $(SUN_SRC)/awt/medialib
J2D_SRC = $(SUN_SRC)/java2d
J2D_FONT_SRC = $(SUN_SRC)/font
J2D_WINDOWS_SRC = $(WINDOWS_SRC)/native/sun/java2d
AWT_WINDOWS_SRC = $(WINDOWS_SRC)/native/sun/awt
LOOP_SRC = $(SUN_SRC)/java2d/loops
PIPE_SRC = $(SUN_SRC)/java2d/pipe
WINDOWS_SRC = $(TOPDIR)/src/windows
SRC = $(WINDOWS_SRC)/native/sun/windows
# ensure consistent sort order
LC_ALL:= C
SRCDIRS = \
$(COMP_SRC) \
$(DEBUG_SRC) \
@ -61,6 +65,7 @@ INCLUDES = \
-I$(J2D_WINDOWS_SRC)/windows \
-I$(J2D_WINDOWS_SRC)/d3d \
-I$(J2D_WINDOWS_SRC)/opengl \
-I$(AWT_WINDOWS_SRC) \
-I$(LOOP_SRC) \
-I$(PIPE_SRC) \
-I$(SRC)
@ -68,22 +73,29 @@ INCLUDES = \
STUBFILES = \
$(STUBDIR)/ddraw.h \
$(STUBDIR)/d3d.h \
$(STUBDIR)/d3d9.h \
$(STUBDIR)/Ole2.h \
$(STUBDIR)/Zmouse.h \
$(STUBDIR)/cderr.h \
$(STUBDIR)/comdef.h \
$(STUBDIR)/commctrl.h \
$(STUBDIR)/commdlg.h \
$(STUBDIR)/comutil.h \
$(STUBDIR)/direct.h \
$(STUBDIR)/d3dcom.h \
$(STUBDIR)/imm.h \
$(STUBDIR)/ime.h \
$(STUBDIR)/io.h \
$(STUBDIR)/map \
$(STUBDIR)/mmsystem.h \
$(STUBDIR)/new.h \
$(STUBDIR)/new \
$(STUBDIR)/ole2.h \
$(STUBDIR)/process.h \
$(STUBDIR)/richole.h \
$(STUBDIR)/richedit.h \
$(STUBDIR)/shellapi.h \
$(STUBDIR)/shlwapi.h \
$(STUBDIR)/shlobj.h \
$(STUBDIR)/tchar.h \
$(STUBDIR)/winbase.h \
@ -135,6 +147,9 @@ dependencies:
include FILES_export_windows.gmk
EXTRAFILES_java = \
sun/java2d/opengl/OGLContext/OGLContextCaps.java \
sun/java2d/d3d/D3DPaints/MultiGradient.java \
sun/java2d/d3d/D3DContext/D3DContextCaps.java \
java/lang/Integer.java
FILES_java = $(FILES_export) $(FILES_export2) $(FILES_export3) \

View File

@ -85,6 +85,8 @@ FILES_2D_c = \
ScaledBlit.c \
FillRect.c \
FillSpans.c \
FillParallelogram.c \
DrawParallelogram.c \
DrawLine.c \
DrawRect.c \
DrawPolygons.c \

View File

@ -30,6 +30,8 @@ FILES_c = \
ScaledBlit.c \
FillRect.c \
FillSpans.c \
FillParallelogram.c \
DrawParallelogram.c \
DrawLine.c \
DrawRect.c \
DrawPolygons.c \

View File

@ -36,6 +36,8 @@ FILES_export = \
sun/java2d/loops/TransformBlit.java \
sun/java2d/loops/FillRect.java \
sun/java2d/loops/FillSpans.java \
sun/java2d/loops/FillParallelogram.java \
sun/java2d/loops/DrawParallelogram.java \
sun/java2d/loops/DrawGlyphList.java \
sun/java2d/loops/DrawGlyphListAA.java \
sun/java2d/loops/DrawGlyphListLCD.java \

View File

@ -135,6 +135,8 @@ FILES_export2 = \
sun/java2d/loops/ScaledBlit.java \
sun/java2d/loops/FillRect.java \
sun/java2d/loops/FillSpans.java \
sun/java2d/loops/FillParallelogram.java \
sun/java2d/loops/DrawParallelogram.java \
sun/java2d/loops/DrawGlyphList.java \
sun/java2d/loops/DrawGlyphListAA.java \
sun/java2d/loops/DrawGlyphListLCD.java \

View File

@ -366,11 +366,12 @@ _FONTCONFIGS = \
fontconfig.properties \
fontconfig.RedHat.properties \
fontconfig.RedHat.2.1.properties \
fontconfig.RedHat.3.properties \
fontconfig.RedHat.3.properties \
fontconfig.RedHat.4.properties \
fontconfig.Sun.properties \
fontconfig.Turbo.properties \
fontconfig.SuSE.properties
fontconfig.SuSE.10.properties \
fontconfig.SuSE.11.properties
endif
FONTCONFIGS_SRC_PREFIX = $(PLATFORM).

File diff suppressed because one or more lines are too long

View File

@ -112,6 +112,8 @@ SUNWprivate_1.1 {
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;

View File

@ -68,8 +68,7 @@ FILES_cpp_shared = \
GlyphPositioningTables.cpp \
GlyphSubstLookupProc.cpp \
GlyphSubstitutionTables.cpp \
HebrewLigatureData.cpp \
HebrewShaping.cpp \
HangulLayoutEngine.cpp \
IndicClassTables.cpp \
IndicReordering.cpp \
KernTable.cpp \
@ -95,6 +94,8 @@ FILES_cpp_shared = \
SubstitutionLookups.cpp \
ThaiShaping.cpp \
ThaiStateTables.cpp \
TibetanLayoutEngine.cpp \
TibetanReordering.cpp \
ValueRecords.cpp \
ArabicLayoutEngine.cpp \
ArabicShaping.cpp \

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -113,6 +113,6 @@ public class BasicControl implements Control {
* ASN.1 BER encoded value.
*/
public byte[] getEncodedValue() {
return value;
return value == null ? null : value.clone();
}
}

View File

@ -427,7 +427,10 @@ final class Filter {
}
} else {
// descriptor
if (filter[i] != '-' &&
// The underscore ("_") character is not allowed by
// the LDAP specification. We allow it here to
// tolerate the incorrect use in practice.
if (filter[i] != '-' && filter[i] != '_' &&
!(filter[i] >= '0' && filter[i] <= '9') &&
!(filter[i] >= 'A' && filter[i] <= 'Z') &&
!(filter[i] >= 'a' && filter[i] <= 'z')) {
@ -467,7 +470,10 @@ final class Filter {
break;
}
if (filter[i] != '-' &&
// The underscore ("_") character is not allowed by
// the LDAP specification. We allow it here to
// tolerate the incorrect use in practice.
if (filter[i] != '-' && filter[i] != '_' &&
!(filter[i] >= '0' && filter[i] <= '9') &&
!(filter[i] >= 'A' && filter[i] <= 'Z') &&
!(filter[i] >= 'a' && filter[i] <= 'z')) {
@ -515,7 +521,10 @@ final class Filter {
}
} else {
// descriptor
if (filter[j] != '-' &&
// The underscore ("_") character is not allowed by
// the LDAP specification. We allow it here to
// tolerate the incorrect use in practice.
if (filter[j] != '-' && filter[j] != '_' &&
!(filter[j] >= '0' && filter[j] <= '9') &&
!(filter[j] >= 'A' && filter[j] <= 'Z') &&
!(filter[j] >= 'a' && filter[j] <= 'z')) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
* 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,8 +25,6 @@
package com.sun.security.auth.module;
import javax.security.auth.login.LoginException;
/**
* <p> This class implementation retrieves and makes available NT
* security information for the current user.
@ -124,7 +122,7 @@ public class NTSystem {
* @return the group SIDs for the current NT user.
*/
public String[] getGroupIDs() {
return groupIDs;
return groupIDs == null ? null : groupIDs.clone();
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
* 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,9 +25,6 @@
package com.sun.security.auth.module;
import javax.security.auth.*;
import javax.security.auth.login.*;
/**
* <p> This class implementation retrieves and makes available Solaris
* UID/GID/groups information for the current user.
@ -92,6 +89,6 @@ public class SolarisSystem {
* @return the supplementary groups for the current Solaris user.
*/
public long[] getGroups() {
return groups;
return groups == null ? null : groups.clone();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
* 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,9 +25,6 @@
package com.sun.security.auth.module;
import javax.security.auth.*;
import javax.security.auth.login.*;
/**
* <p> This class implementation retrieves and makes available Unix
* UID/GID/groups information for the current user.
@ -92,6 +89,6 @@ public class UnixSystem {
* @return the supplementary groups for the current Unix user.
*/
public long[] getGroups() {
return groups;
return groups == null ? null : groups.clone();
}
}

View File

@ -565,7 +565,7 @@ public class Dialog extends Window {
* @since 1.6
*/
public Dialog(Window owner) {
this(owner, null, ModalityType.MODELESS);
this(owner, "", ModalityType.MODELESS);
}
/**
@ -624,7 +624,7 @@ public class Dialog extends Window {
* @since 1.6
*/
public Dialog(Window owner, ModalityType modalityType) {
this(owner, null, modalityType);
this(owner, "", modalityType);
}
/**

View File

@ -30,15 +30,15 @@ package java.awt;
* <p>
* Objects that implement this interface are created with the
* {@link EventQueue#createSecondaryLoop} method. The interface
* provides two methods, {@link enter} and {@link exit},
* provides two methods, {@link #enter} and {@link #exit},
* which can be used to start and stop the event loop.
* <p>
* When the {@link enter} method is called, the current
* When the {@link #enter} method is called, the current
* thread is blocked until the loop is terminated by the
* {@link exit} method. Also, a new event loop is started
* {@link #exit} method. Also, a new event loop is started
* on the event dispatch thread, which may or may not be
* the current thread. The loop can be terminated on any
* thread by calling its {@link exit} method. After the
* thread by calling its {@link #exit} method. After the
* loop is terminated, the {@code SecondaryLoop} object can
* be reused to run a new nested event loop.
* <p>
@ -102,7 +102,7 @@ public interface SecondaryLoop {
* <p>
* This method can be called by any thread including the event
* dispatch thread. This thread will be blocked until the {@link
* exit} method is called or the loop is terminated. A new
* #exit} method is called or the loop is terminated. A new
* secondary loop will be created on the event dispatch thread
* for dispatching events in either case.
* <p>
@ -123,23 +123,23 @@ public interface SecondaryLoop {
/**
* Unblocks the execution of the thread blocked by the {@link
* enter} method and exits the secondary loop.
* #enter} method and exits the secondary loop.
* <p>
* This method resumes the thread that called the {@link enter}
* This method resumes the thread that called the {@link #enter}
* method and exits the secondary loop that was created when
* the {@link enter} method was invoked.
* the {@link #enter} method was invoked.
* <p>
* Note that if any other secondary loop is started while this
* loop is running, the blocked thread will not resume execution
* until the nested loop is terminated.
* <p>
* If this secondary loop has not been started with the {@link
* enter} method, or this secondary loop has already finished
* with the {@link exit} method, this method returns {@code
* #enter} method, or this secondary loop has already finished
* with the {@link #exit} method, this method returns {@code
* false}, otherwise {@code true} is returned.
*
* @return {@code true} if this loop was previously started and
* has not yet been finished with the {@link exit} method,
* has not yet been finished with the {@link #exit} method,
* {@code false} otherwise
*/
public boolean exit();

View File

@ -56,7 +56,15 @@ class FileOutputStream extends OutputStream
*/
private final FileDescriptor fd;
private FileChannel channel= null;
/**
* True if the file is opened for append.
*/
private final boolean append;
/**
* The associated channel, initalized lazily.
*/
private FileChannel channel;
private final Object closeLock = new Object();
private volatile boolean closed = false;
@ -196,7 +204,9 @@ class FileOutputStream extends OutputStream
if (name == null) {
throw new NullPointerException();
}
fd = new FileDescriptor();
this.fd = new FileDescriptor();
this.append = append;
fd.incrementAndGetUseCount();
open(name, append);
}
@ -232,7 +242,8 @@ class FileOutputStream extends OutputStream
if (security != null) {
security.checkWrite(fdObj);
}
fd = fdObj;
this.fd = fdObj;
this.append = false;
/*
* FileDescriptor is being shared by streams.
@ -250,6 +261,15 @@ class FileOutputStream extends OutputStream
private native void open(String name, boolean append)
throws FileNotFoundException;
/**
* Writes the specified byte to this file output stream.
*
* @param b the byte to be written.
* @param append {@code true} if the write operation first
* advances the position to the end of file
*/
private native void write(int b, boolean append) throws IOException;
/**
* Writes the specified byte to this file output stream. Implements
* the <code>write</code> method of <code>OutputStream</code>.
@ -257,16 +277,21 @@ class FileOutputStream extends OutputStream
* @param b the byte to be written.
* @exception IOException if an I/O error occurs.
*/
public native void write(int b) throws IOException;
public void write(int b) throws IOException {
write(b, append);
}
/**
* Writes a sub array as a sequence of bytes.
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @param append {@code true} to first advance the position to the
* end of file
* @exception IOException If an I/O error has occurred.
*/
private native void writeBytes(byte b[], int off, int len) throws IOException;
private native void writeBytes(byte b[], int off, int len, boolean append)
throws IOException;
/**
* Writes <code>b.length</code> bytes from the specified byte array
@ -276,7 +301,7 @@ class FileOutputStream extends OutputStream
* @exception IOException if an I/O error occurs.
*/
public void write(byte b[]) throws IOException {
writeBytes(b, 0, b.length);
writeBytes(b, 0, b.length, append);
}
/**
@ -289,7 +314,7 @@ class FileOutputStream extends OutputStream
* @exception IOException if an I/O error occurs.
*/
public void write(byte b[], int off, int len) throws IOException {
writeBytes(b, off, len);
writeBytes(b, off, len, append);
}
/**
@ -372,7 +397,7 @@ class FileOutputStream extends OutputStream
public FileChannel getChannel() {
synchronized (this) {
if (channel == null) {
channel = FileChannelImpl.open(fd, false, true, this);
channel = FileChannelImpl.open(fd, false, true, append, this);
/*
* Increment fd's use count. Invoking the channel's close()

View File

@ -3498,8 +3498,8 @@ public class ObjectInputStream
return ((int[]) array).clone();
} else if (array instanceof long[]) {
return ((long[]) array).clone();
} else if (array instanceof double[]) {
return ((double[]) array).clone();
} else if (array instanceof short[]) {
return ((short[]) array).clone();
} else {
throw new AssertionError();
}

View File

@ -6371,15 +6371,15 @@ class Character implements java.io.Serializable, Comparable<Character> {
* This method returns <code>true</code> for the following five
* characters only:
* <table>
* <tr><td><code>'\t'</code></td> <td><code>'&#92;u0009'</code></td>
* <tr><td><code>'\t'</code></td> <td><code>U+0009</code></td>
* <td><code>HORIZONTAL TABULATION</code></td></tr>
* <tr><td><code>'\n'</code></td> <td><code>'&#92;u000A'</code></td>
* <tr><td><code>'\n'</code></td> <td><code>U+000A</code></td>
* <td><code>NEW LINE</code></td></tr>
* <tr><td><code>'\f'</code></td> <td><code>'&#92;u000C'</code></td>
* <tr><td><code>'\f'</code></td> <td><code>U+000C</code></td>
* <td><code>FORM FEED</code></td></tr>
* <tr><td><code>'\r'</code></td> <td><code>'&#92;u000D'</code></td>
* <tr><td><code>'\r'</code></td> <td><code>U+000D</code></td>
* <td><code>CARRIAGE RETURN</code></td></tr>
* <tr><td><code>'&nbsp;'</code></td> <td><code>'&#92;u0020'</code></td>
* <tr><td><code>'&nbsp;'</code></td> <td><code>U+0020</code></td>
* <td><code>SPACE</code></td></tr>
* </table>
*
@ -6463,15 +6463,15 @@ class Character implements java.io.Serializable, Comparable<Character> {
* <code>LINE_SEPARATOR</code>, or <code>PARAGRAPH_SEPARATOR</code>)
* but is not also a non-breaking space (<code>'&#92;u00A0'</code>,
* <code>'&#92;u2007'</code>, <code>'&#92;u202F'</code>).
* <li> It is <code>'&#92;u0009'</code>, HORIZONTAL TABULATION.
* <li> It is <code>'&#92;u000A'</code>, LINE FEED.
* <li> It is <code>'&#92;u000B'</code>, VERTICAL TABULATION.
* <li> It is <code>'&#92;u000C'</code>, FORM FEED.
* <li> It is <code>'&#92;u000D'</code>, CARRIAGE RETURN.
* <li> It is <code>'&#92;u001C'</code>, FILE SEPARATOR.
* <li> It is <code>'&#92;u001D'</code>, GROUP SEPARATOR.
* <li> It is <code>'&#92;u001E'</code>, RECORD SEPARATOR.
* <li> It is <code>'&#92;u001F'</code>, UNIT SEPARATOR.
* <li> It is <code>'&#92;t'</code>, U+0009 HORIZONTAL TABULATION.
* <li> It is <code>'&#92;n'</code>, U+000A LINE FEED.
* <li> It is <code>'&#92;u000B'</code>, U+000B VERTICAL TABULATION.
* <li> It is <code>'&#92;f'</code>, U+000C FORM FEED.
* <li> It is <code>'&#92;r'</code>, U+000D CARRIAGE RETURN.
* <li> It is <code>'&#92;u001C'</code>, U+001C FILE SEPARATOR.
* <li> It is <code>'&#92;u001D'</code>, U+001D GROUP SEPARATOR.
* <li> It is <code>'&#92;u001E'</code>, U+001E RECORD SEPARATOR.
* <li> It is <code>'&#92;u001F'</code>, U+001F UNIT SEPARATOR.
* </ul>
*
* <p><b>Note:</b> This method cannot handle <a
@ -6499,15 +6499,15 @@ class Character implements java.io.Serializable, Comparable<Character> {
* {@link #LINE_SEPARATOR}, or {@link #PARAGRAPH_SEPARATOR})
* but is not also a non-breaking space (<code>'&#92;u00A0'</code>,
* <code>'&#92;u2007'</code>, <code>'&#92;u202F'</code>).
* <li> It is <code>'&#92;u0009'</code>, HORIZONTAL TABULATION.
* <li> It is <code>'&#92;u000A'</code>, LINE FEED.
* <li> It is <code>'&#92;u000B'</code>, VERTICAL TABULATION.
* <li> It is <code>'&#92;u000C'</code>, FORM FEED.
* <li> It is <code>'&#92;u000D'</code>, CARRIAGE RETURN.
* <li> It is <code>'&#92;u001C'</code>, FILE SEPARATOR.
* <li> It is <code>'&#92;u001D'</code>, GROUP SEPARATOR.
* <li> It is <code>'&#92;u001E'</code>, RECORD SEPARATOR.
* <li> It is <code>'&#92;u001F'</code>, UNIT SEPARATOR.
* <li> It is <code>'&#92;t'</code>, U+0009 HORIZONTAL TABULATION.
* <li> It is <code>'&#92;n'</code>, U+000A LINE FEED.
* <li> It is <code>'&#92;u000B'</code>, U+000B VERTICAL TABULATION.
* <li> It is <code>'&#92;f'</code>, U+000C FORM FEED.
* <li> It is <code>'&#92;r'</code>, U+000D CARRIAGE RETURN.
* <li> It is <code>'&#92;u001C'</code>, U+001C FILE SEPARATOR.
* <li> It is <code>'&#92;u001D'</code>, U+001D GROUP SEPARATOR.
* <li> It is <code>'&#92;u001E'</code>, U+001E RECORD SEPARATOR.
* <li> It is <code>'&#92;u001F'</code>, U+001F UNIT SEPARATOR.
* </ul>
* <p>
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -973,7 +973,8 @@ public final class Double extends Number implements Comparable<Double> {
if (d1 > d2)
return 1; // Neither val is NaN, thisVal is larger
long thisBits = Double.doubleToLongBits(d1);
// Cannot use doubleToRawLongBits because of possibility of NaNs.
long thisBits = Double.doubleToLongBits(d1);
long anotherBits = Double.doubleToLongBits(d2);
return (thisBits == anotherBits ? 0 : // Values are equal

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -872,12 +872,13 @@ public final class Float extends Number implements Comparable<Float> {
* @since 1.4
*/
public static int compare(float f1, float f2) {
if (f1 < f2)
if (f1 < f2)
return -1; // Neither val is NaN, thisVal is smaller
if (f1 > f2)
return 1; // Neither val is NaN, thisVal is larger
int thisBits = Float.floatToIntBits(f1);
// Cannot use floatToRawIntBits because of possibility of NaNs.
int thisBits = Float.floatToIntBits(f1);
int anotherBits = Float.floatToIntBits(f2);
return (thisBits == anotherBits ? 0 : // Values are equal

View File

@ -537,7 +537,11 @@ public final class ProcessBuilder
*/
public File file() { return null; }
FileOutputStream toFileOutputStream() throws IOException {
/**
* When redirected to a destination file, indicates if the output
* is to be written to the end of the file.
*/
boolean append() {
throw new UnsupportedOperationException();
}
@ -588,9 +592,7 @@ public final class ProcessBuilder
public String toString() {
return "redirect to write to file \"" + file + "\"";
}
FileOutputStream toFileOutputStream() throws IOException {
return new FileOutputStream(file, false);
}
boolean append() { return false; }
};
}
@ -620,9 +622,7 @@ public final class ProcessBuilder
public String toString() {
return "redirect to append to file \"" + file + "\"";
}
FileOutputStream toFileOutputStream() throws IOException {
return new FileOutputStream(file, true);
}
boolean append() { return true; }
};
}

View File

@ -0,0 +1,79 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* 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 java.lang;
import java.lang.annotation.*;
/**
* A programmer assertion that the body of the annotated method or
* constructor does not perform potentially unsafe operations on its
* varargs parameter. Applying this annotation to a method or
* constructor suppresses unchecked warnings about a
* <i>non-reifiable</i> variable-arity (vararg) type and suppresses
* unchecked warnings about parameterized array creation at call
* sites.
*
* <p> In addition to the usage restrictions imposed by its {@link
* Target @Target} meta-annotation, compilers are required to implement
* additional usage restrictions on this annotation type; it is a
* compile-time error if a method or constructor declaration is
* annotated with a {@code @SafeVarargs} annotation, and either:
* <ul>
* <li> the declaration is a fixed-arity method or constructor
*
* <li> the declaration is a variable-arity method that is neither
* {@code static} nor {@code final}.
*
* </ul>
*
* <p> Compilers are encouraged to issue warnings when this annotation
* type is applied to a method or constructor declaration where:
*
* <ul>
*
* <li> The variable-arity parameter has a reifiable element type,
* which includes primitive types, {@code Object}, and {@code String}.
* (The unchecked warnings this annotation type suppresses already do
* not occur for a reifiable element type.)
*
* <li> The body of the method or constructor declaration performs
* potentially unsafe operations, such as an assignment to an element
* of the variable-arity parameter's array that generates an unchecked
* warning.
*
* <p>Future versions of the platform may mandate compiler errors for
* such unsafe operations.
*
* </ul>
*
* @jls3 4.7 Reifiable Types
* @jls3 8.4.1 Formal Parameters
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
public @interface SafeVarargs {}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -801,8 +801,9 @@ public final class StrictMath {
return (a >= b) ? a : b;
}
private static long negativeZeroFloatBits = Float.floatToIntBits(-0.0f);
private static long negativeZeroDoubleBits = Double.doubleToLongBits(-0.0d);
// Use raw bit-wise conversions on guaranteed non-NaN arguments.
private static long negativeZeroFloatBits = Float.floatToRawIntBits(-0.0f);
private static long negativeZeroDoubleBits = Double.doubleToRawLongBits(-0.0d);
/**
* Returns the greater of two {@code float} values. That is,
@ -819,9 +820,12 @@ public final class StrictMath {
* @return the larger of {@code a} and {@code b}.
*/
public static float max(float a, float b) {
if (a != a) return a; // a is NaN
if ((a == 0.0f) && (b == 0.0f)
&& (Float.floatToIntBits(a) == negativeZeroFloatBits)) {
if (a != a)
return a; // a is NaN
if ((a == 0.0f) &&
(b == 0.0f) &&
(Float.floatToRawIntBits(a) == negativeZeroFloatBits)) {
// Raw conversion ok since NaN can't map to -0.0.
return b;
}
return (a >= b) ? a : b;
@ -842,9 +846,12 @@ public final class StrictMath {
* @return the larger of {@code a} and {@code b}.
*/
public static double max(double a, double b) {
if (a != a) return a; // a is NaN
if ((a == 0.0d) && (b == 0.0d)
&& (Double.doubleToLongBits(a) == negativeZeroDoubleBits)) {
if (a != a)
return a; // a is NaN
if ((a == 0.0d) &&
(b == 0.0d) &&
(Double.doubleToRawLongBits(a) == negativeZeroDoubleBits)) {
// Raw conversion ok since NaN can't map to -0.0.
return b;
}
return (a >= b) ? a : b;
@ -893,9 +900,12 @@ public final class StrictMath {
* @return the smaller of {@code a} and {@code b.}
*/
public static float min(float a, float b) {
if (a != a) return a; // a is NaN
if ((a == 0.0f) && (b == 0.0f)
&& (Float.floatToIntBits(b) == negativeZeroFloatBits)) {
if (a != a)
return a; // a is NaN
if ((a == 0.0f) &&
(b == 0.0f) &&
(Float.floatToRawIntBits(b) == negativeZeroFloatBits)) {
// Raw conversion ok since NaN can't map to -0.0.
return b;
}
return (a <= b) ? a : b;
@ -916,9 +926,12 @@ public final class StrictMath {
* @return the smaller of {@code a} and {@code b}.
*/
public static double min(double a, double b) {
if (a != a) return a; // a is NaN
if ((a == 0.0d) && (b == 0.0d)
&& (Double.doubleToLongBits(b) == negativeZeroDoubleBits)) {
if (a != a)
return a; // a is NaN
if ((a == 0.0d) &&
(b == 0.0d) &&
(Double.doubleToRawLongBits(b) == negativeZeroDoubleBits)) {
// Raw conversion ok since NaN can't map to -0.0.
return b;
}
return (a <= b) ? a : b;

View File

@ -209,7 +209,7 @@ class Thread implements Runnable {
* initialized to indicate thread 'not yet started'
*/
private int threadStatus = 0;
private volatile int threadStatus = 0;
private static synchronized long nextThreadID() {

View File

@ -275,18 +275,17 @@ public abstract class Charset
/* -- Static methods -- */
private static String bugLevel = null;
private static volatile String bugLevel = null;
static boolean atBugLevel(String bl) { // package-private
if (bugLevel == null) {
String level = bugLevel;
if (level == null) {
if (!sun.misc.VM.isBooted())
return false;
bugLevel = AccessController.doPrivileged(
new GetPropertyAction("sun.nio.cs.bugLevel"));
if (bugLevel == null)
bugLevel = "";
bugLevel = level = AccessController.doPrivileged(
new GetPropertyAction("sun.nio.cs.bugLevel", ""));
}
return (bugLevel != null) && bugLevel.equals(bl);
return level.equals(bl);
}
/**

View File

@ -25,7 +25,7 @@
package java.security;
import java.io.Serializable;
import java.io.*;
import java.security.cert.CRL;
import java.security.cert.CertPath;
import sun.misc.JavaSecurityCodeSignerAccess;
@ -205,4 +205,10 @@ public final class CodeSigner implements Serializable {
});
}
// Explicitly reset hash code value to -1
private void readObject(ObjectInputStream ois)
throws IOException, ClassNotFoundException {
ois.defaultReadObject();
myhash = -1;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* 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,10 +25,12 @@
package java.security;
import java.io.Serializable;
import java.io.*;
import java.security.cert.Certificate;
import java.security.cert.CertPath;
import java.security.cert.X509Extension;
import java.util.Date;
import java.util.List;
/**
* This class encapsulates information about a signed timestamp.
@ -142,8 +144,20 @@ public final class Timestamp implements Serializable {
StringBuffer sb = new StringBuffer();
sb.append("(");
sb.append("timestamp: " + timestamp);
sb.append("TSA: " + signerCertPath.getCertificates().get(0));
List<? extends Certificate> certs = signerCertPath.getCertificates();
if (!certs.isEmpty()) {
sb.append("TSA: " + certs.get(0));
} else {
sb.append("TSA: <empty>");
}
sb.append(")");
return sb.toString();
}
// Explicitly reset hash code value to -1
private void readObject(ObjectInputStream ois)
throws IOException, ClassNotFoundException {
ois.defaultReadObject();
myhash = -1;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,7 +32,7 @@ import java.util.Map;
import java.util.Set;
/**
* An AttributedCharacterIterator allows iteration through both text and
* An {@code AttributedCharacterIterator} allows iteration through both text and
* related attribute information.
*
* <p>
@ -46,22 +46,28 @@ import java.util.Set;
* <p>A <em>run with respect to an attribute</em> is a maximum text range for
* which:
* <ul>
* <li>the attribute is undefined or null for the entire range, or
* <li>the attribute value is defined and has the same non-null value for the
* <li>the attribute is undefined or {@code null} for the entire range, or
* <li>the attribute value is defined and has the same non-{@code null} value for the
* entire range.
* </ul>
*
* <p>A <em>run with respect to a set of attributes</em> is a maximum text range for
* which this condition is met for each member attribute.
*
* <p>When getting a run with no explicit attributes specified (i.e.,
* calling {@link #getRunStart()} and {@link #getRunLimit()}), any
* contiguous text segments having the same attributes (the same set
* of attribute/value pairs) are treated as separate runs if the
* attributes have been given to those text segments separately.
*
* <p>The returned indexes are limited to the range of the iterator.
*
* <p>The returned attribute information is limited to runs that contain
* the current character.
*
* <p>
* Attribute keys are instances of AttributedCharacterIterator.Attribute and its
* subclasses, such as java.awt.font.TextAttribute.
* Attribute keys are instances of {@link AttributedCharacterIterator.Attribute} and its
* subclasses, such as {@link java.awt.font.TextAttribute}.
*
* @see AttributedCharacterIterator.Attribute
* @see java.awt.font.TextAttribute
@ -74,7 +80,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/**
* Defines attribute keys that are used to identify text attributes. These
* keys are used in AttributedCharacterIterator and AttributedString.
* keys are used in {@code AttributedCharacterIterator} and {@code AttributedString}.
* @see AttributedCharacterIterator
* @see AttributedString
* @since 1.2
@ -83,7 +89,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
public static class Attribute implements Serializable {
/**
* The name of this Attribute. The name is used primarily by readResolve
* The name of this {@code Attribute}. The name is used primarily by {@code readResolve}
* to look up the corresponding predefined instance when deserializing
* an instance.
* @serial
@ -94,7 +100,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
private static final Map instanceMap = new HashMap(7);
/**
* Constructs an Attribute with the given name.
* Constructs an {@code Attribute} with the given name.
*/
protected Attribute(String name) {
this.name = name;
@ -114,7 +120,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/**
* Returns a hash code value for the object. This version is identical to
* the one in Object, but is also final.
* the one in {@code Object}, but is also final.
*/
public final int hashCode() {
return super.hashCode();
@ -122,7 +128,8 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/**
* Returns a string representation of the object. This version returns the
* concatenation of class name, "(", a name identifying the attribute and ")".
* concatenation of class name, {@code "("}, a name identifying the attribute
* and {@code ")"}.
*/
public String toString() {
return getClass().getName() + "(" + name + ")";
@ -153,7 +160,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/**
* Attribute key for the language of some text.
* <p> Values are instances of Locale.
* <p> Values are instances of {@link java.util.Locale Locale}.
* @see java.util.Locale
*/
public static final Attribute LANGUAGE = new Attribute("language");
@ -163,7 +170,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
* and the pronunciation of a word are only loosely related (such as Japanese),
* it is often necessary to store the reading (pronunciation) along with the
* written form.
* <p>Values are instances of Annotation holding instances of String.
* <p>Values are instances of {@link Annotation} holding instances of {@link String}.
* @see Annotation
* @see java.lang.String
*/
@ -172,7 +179,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/**
* Attribute key for input method segments. Input methods often break
* up text into segments, which usually correspond to words.
* <p>Values are instances of Annotation holding a null reference.
* <p>Values are instances of {@link Annotation} holding a {@code null} reference.
* @see Annotation
*/
public static final Attribute INPUT_METHOD_SEGMENT = new Attribute("input_method_segment");
@ -185,36 +192,44 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/**
* Returns the index of the first character of the run
* with respect to all attributes containing the current character.
*
* <p>Any contiguous text segments having the same attributes (the
* same set of attribute/value pairs) are treated as separate runs
* if the attributes have been given to those text segments separately.
*/
public int getRunStart();
/**
* Returns the index of the first character of the run
* with respect to the given attribute containing the current character.
* with respect to the given {@code attribute} containing the current character.
*/
public int getRunStart(Attribute attribute);
/**
* Returns the index of the first character of the run
* with respect to the given attributes containing the current character.
* with respect to the given {@code attributes} containing the current character.
*/
public int getRunStart(Set<? extends Attribute> attributes);
/**
* Returns the index of the first character following the run
* with respect to all attributes containing the current character.
*
* <p>Any contiguous text segments having the same attributes (the
* same set of attribute/value pairs) are treated as separate runs
* if the attributes have been given to those text segments separately.
*/
public int getRunLimit();
/**
* Returns the index of the first character following the run
* with respect to the given attribute containing the current character.
* with respect to the given {@code attribute} containing the current character.
*/
public int getRunLimit(Attribute attribute);
/**
* Returns the index of the first character following the run
* with respect to the given attributes containing the current character.
* with respect to the given {@code attributes} containing the current character.
*/
public int getRunLimit(Set<? extends Attribute> attributes);
@ -225,9 +240,8 @@ public interface AttributedCharacterIterator extends CharacterIterator {
public Map<Attribute,Object> getAttributes();
/**
* Returns the value of the named attribute for the current character.
* Returns null if the attribute is not defined.
* @param attribute the key of the attribute whose value is requested.
* Returns the value of the named {@code attribute} for the current character.
* Returns {@code null} if the {@code attribute} is not defined.
*/
public Object getAttribute(Attribute attribute);

View File

@ -79,9 +79,13 @@ import sun.text.normalizer.NormalizerBase;
* <pre>
*
* String testString = "This is a test";
* RuleBasedCollator ruleBasedCollator = (RuleBasedCollator)Collator.getInstance();
* CollationElementIterator collationElementIterator = ruleBasedCollator.getCollationElementIterator(testString);
* int primaryOrder = CollationElementIterator.primaryOrder(collationElementIterator.next());
* Collator col = Collator.getInstance();
* if (col instanceof RuleBasedCollator) {
* RuleBasedCollator ruleBasedCollator = (RuleBasedCollator)col;
* CollationElementIterator collationElementIterator = ruleBasedCollator.getCollationElementIterator(testString);
* int primaryOrder = CollationElementIterator.primaryOrder(collationElementIterator.next());
* :
* }
* </pre>
* </blockquote>
*
@ -93,6 +97,10 @@ import sun.text.normalizer.NormalizerBase;
* is its primary order; the next 8 bits is the secondary order and the
* last 8 bits is the tertiary order.
*
* <p><b>Note:</b> <code>CollationElementIterator</code> is a part of
* <code>RuleBasedCollator</code> implementation. It is only usable
* with <code>RuleBasedCollator</code> instances.
*
* @see Collator
* @see RuleBasedCollator
* @author Helena Shih, Laura Werner, Richard Gillam

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -180,11 +180,15 @@ import java.util.Locale;
*
* <p><strong>Examples</strong>
* <p>Simple: "&lt; a &lt; b &lt; c &lt; d"
* <p>Norwegian: "&lt; a,A&lt; b,B&lt; c,C&lt; d,D&lt; e,E&lt; f,F&lt; g,G&lt; h,H&lt; i,I&lt; j,J
* &lt; k,K&lt; l,L&lt; m,M&lt; n,N&lt; o,O&lt; p,P&lt; q,Q&lt; r,R&lt; s,S&lt; t,T
* &lt; u,U&lt; v,V&lt; w,W&lt; x,X&lt; y,Y&lt; z,Z
* &lt; &#92;u00E5=a&#92;u030A,&#92;u00C5=A&#92;u030A
* ;aa,AA&lt; &#92;u00E6,&#92;u00C6&lt; &#92;u00F8,&#92;u00D8"
* <p>Norwegian: "&lt; a, A &lt; b, B &lt; c, C &lt; d, D &lt; e, E &lt; f, F
* &lt; g, G &lt; h, H &lt; i, I &lt; j, J &lt; k, K &lt; l, L
* &lt; m, M &lt; n, N &lt; o, O &lt; p, P &lt; q, Q &lt; r, R
* &lt; s, S &lt; t, T &lt; u, U &lt; v, V &lt; w, W &lt; x, X
* &lt; y, Y &lt; z, Z
* &lt; &#92;u00E6, &#92;u00C6
* &lt; &#92;u00F8, &#92;u00D8
* &lt; &#92;u00E5 = a&#92;u030A, &#92;u00C5 = A&#92;u030A;
* aa, AA"
*
* <p>
* To create a <code>RuleBasedCollator</code> object with specialized
@ -199,11 +203,14 @@ import java.util.Locale;
* Or:
* <blockquote>
* <pre>
* String Norwegian = "&lt; a,A&lt; b,B&lt; c,C&lt; d,D&lt; e,E&lt; f,F&lt; g,G&lt; h,H&lt; i,I&lt; j,J" +
* "&lt; k,K&lt; l,L&lt; m,M&lt; n,N&lt; o,O&lt; p,P&lt; q,Q&lt; r,R&lt; s,S&lt; t,T" +
* "&lt; u,U&lt; v,V&lt; w,W&lt; x,X&lt; y,Y&lt; z,Z" +
* "&lt; &#92;u00E5=a&#92;u030A,&#92;u00C5=A&#92;u030A" +
* ";aa,AA&lt; &#92;u00E6,&#92;u00C6&lt; &#92;u00F8,&#92;u00D8";
* String Norwegian = "&lt; a, A &lt; b, B &lt; c, C &lt; d, D &lt; e, E &lt; f, F &lt; g, G &lt; h, H &lt; i, I" +
* "&lt; j, J &lt; k, K &lt; l, L &lt; m, M &lt; n, N &lt; o, O &lt; p, P &lt; q, Q &lt; r, R" +
* "&lt; s, S &lt; t, T &lt; u, U &lt; v, V &lt; w, W &lt; x, X &lt; y, Y &lt; z, Z" +
* "&lt; &#92;u00E6, &#92;u00C6" + // Latin letter ae & AE
* "&lt; &#92;u00F8, &#92;u00D8" + // Latin letter o & O with stroke
* "&lt; &#92;u00E5 = a&#92;u030A," + // Latin letter a with ring above
* " &#92;u00C5 = A&#92;u030A;" + // Latin letter A with ring above
* " aa, AA";
* RuleBasedCollator myNorwegian = new RuleBasedCollator(Norwegian);
* </pre>
* </blockquote>

View File

@ -1839,8 +1839,15 @@ public class SimpleDateFormat extends DateFormat {
break parsing;
case PATTERN_HOUR_OF_DAY1: // 'k' 1-based. eg, 23:59 + 1 hour =>> 24:59
if (!isLenient()) {
// Validate the hour value in non-lenient
if (value < 1 || value > 24) {
break parsing;
}
}
// [We computed 'value' above.]
if (value == calendar.getMaximum(Calendar.HOUR_OF_DAY)+1) value = 0;
if (value == calendar.getMaximum(Calendar.HOUR_OF_DAY)+1)
value = 0;
calb.set(Calendar.HOUR_OF_DAY, value);
return pos.index;
@ -1886,8 +1893,15 @@ public class SimpleDateFormat extends DateFormat {
break parsing;
case PATTERN_HOUR1: // 'h' 1-based. eg, 11PM + 1 hour =>> 12 AM
if (!isLenient()) {
// Validate the hour value in non-lenient
if (value < 1 || value > 12) {
break parsing;
}
}
// [We computed 'value' above.]
if (value == calendar.getLeastMaximum(Calendar.HOUR)+1) value = 0;
if (value == calendar.getLeastMaximum(Calendar.HOUR)+1)
value = 0;
calb.set(Calendar.HOUR, value);
return pos.index;

View File

@ -96,14 +96,14 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @throws NullPointerException {@inheritDoc}
*/
public boolean contains(Object o) {
Iterator<E> e = iterator();
Iterator<E> it = iterator();
if (o==null) {
while (e.hasNext())
if (e.next()==null)
while (it.hasNext())
if (it.next()==null)
return true;
} else {
while (e.hasNext())
if (o.equals(e.next()))
while (it.hasNext())
if (o.equals(it.next()))
return true;
}
return false;
@ -269,18 +269,18 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @throws NullPointerException {@inheritDoc}
*/
public boolean remove(Object o) {
Iterator<E> e = iterator();
Iterator<E> it = iterator();
if (o==null) {
while (e.hasNext()) {
if (e.next()==null) {
e.remove();
while (it.hasNext()) {
if (it.next()==null) {
it.remove();
return true;
}
}
} else {
while (e.hasNext()) {
if (o.equals(e.next())) {
e.remove();
while (it.hasNext()) {
if (o.equals(it.next())) {
it.remove();
return true;
}
}
@ -304,9 +304,8 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @see #contains(Object)
*/
public boolean containsAll(Collection<?> c) {
Iterator<?> e = c.iterator();
while (e.hasNext())
if (!contains(e.next()))
for (Object e : c)
if (!contains(e))
return false;
return true;
}
@ -331,11 +330,9 @@ public abstract class AbstractCollection<E> implements Collection<E> {
*/
public boolean addAll(Collection<? extends E> c) {
boolean modified = false;
Iterator<? extends E> e = c.iterator();
while (e.hasNext()) {
if (add(e.next()))
for (E e : c)
if (add(e))
modified = true;
}
return modified;
}
@ -362,10 +359,10 @@ public abstract class AbstractCollection<E> implements Collection<E> {
*/
public boolean removeAll(Collection<?> c) {
boolean modified = false;
Iterator<?> e = iterator();
while (e.hasNext()) {
if (c.contains(e.next())) {
e.remove();
Iterator<?> it = iterator();
while (it.hasNext()) {
if (c.contains(it.next())) {
it.remove();
modified = true;
}
}
@ -395,10 +392,10 @@ public abstract class AbstractCollection<E> implements Collection<E> {
*/
public boolean retainAll(Collection<?> c) {
boolean modified = false;
Iterator<E> e = iterator();
while (e.hasNext()) {
if (!c.contains(e.next())) {
e.remove();
Iterator<E> it = iterator();
while (it.hasNext()) {
if (!c.contains(it.next())) {
it.remove();
modified = true;
}
}
@ -421,10 +418,10 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @throws UnsupportedOperationException {@inheritDoc}
*/
public void clear() {
Iterator<E> e = iterator();
while (e.hasNext()) {
e.next();
e.remove();
Iterator<E> it = iterator();
while (it.hasNext()) {
it.next();
it.remove();
}
}
@ -442,18 +439,18 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @return a string representation of this collection
*/
public String toString() {
Iterator<E> i = iterator();
if (! i.hasNext())
Iterator<E> it = iterator();
if (! it.hasNext())
return "[]";
StringBuilder sb = new StringBuilder();
sb.append('[');
for (;;) {
E e = i.next();
E e = it.next();
sb.append(e == this ? "(this Collection)" : e);
if (! i.hasNext())
if (! it.hasNext())
return sb.append(']').toString();
sb.append(", ");
sb.append(',').append(' ');
}
}

View File

@ -175,15 +175,15 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
* @throws NullPointerException {@inheritDoc}
*/
public int indexOf(Object o) {
ListIterator<E> e = listIterator();
ListIterator<E> it = listIterator();
if (o==null) {
while (e.hasNext())
if (e.next()==null)
return e.previousIndex();
while (it.hasNext())
if (it.next()==null)
return it.previousIndex();
} else {
while (e.hasNext())
if (o.equals(e.next()))
return e.previousIndex();
while (it.hasNext())
if (o.equals(it.next()))
return it.previousIndex();
}
return -1;
}
@ -200,15 +200,15 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
* @throws NullPointerException {@inheritDoc}
*/
public int lastIndexOf(Object o) {
ListIterator<E> e = listIterator(size());
ListIterator<E> it = listIterator(size());
if (o==null) {
while (e.hasPrevious())
if (e.previous()==null)
return e.nextIndex();
while (it.hasPrevious())
if (it.previous()==null)
return it.nextIndex();
} else {
while (e.hasPrevious())
if (o.equals(e.previous()))
return e.nextIndex();
while (it.hasPrevious())
if (o.equals(it.previous()))
return it.nextIndex();
}
return -1;
}
@ -517,7 +517,7 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
ListIterator<E> e1 = listIterator();
ListIterator e2 = ((List) o).listIterator();
while(e1.hasNext() && e2.hasNext()) {
while (e1.hasNext() && e2.hasNext()) {
E o1 = e1.next();
Object o2 = e2.next();
if (!(o1==null ? o2==null : o1.equals(o2)))

View File

@ -523,7 +523,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
sb.append(value == this ? "(this Map)" : value);
if (! i.hasNext())
return sb.append('}').toString();
sb.append(", ");
sb.append(',').append(' ');
}
}

View File

@ -120,9 +120,9 @@ public class ArrayList<E> extends AbstractList<E>
/**
* Constructs an empty list with the specified initial capacity.
*
* @param initialCapacity the initial capacity of the list
* @exception IllegalArgumentException if the specified initial capacity
* is negative
* @param initialCapacity the initial capacity of the list
* @throws IllegalArgumentException if the specified initial capacity
* is negative
*/
public ArrayList(int initialCapacity) {
super();
@ -173,7 +173,7 @@ public class ArrayList<E> extends AbstractList<E>
* necessary, to ensure that it can hold at least the number of elements
* specified by the minimum capacity argument.
*
* @param minCapacity the desired minimum capacity
* @param minCapacity the desired minimum capacity
*/
public void ensureCapacity(int minCapacity) {
if (minCapacity > 0)

View File

@ -124,7 +124,7 @@ public class Collections {
*
* <p>The implementation takes equal advantage of ascending and
* descending order in its input array, and can take advantage of
* ascending and descending order in different parts of the the same
* ascending and descending order in different parts of the same
* input array. It is well-suited to merging two or more sorted arrays:
* simply concatenate the arrays and sort the resulting array.
*
@ -184,7 +184,7 @@ public class Collections {
*
* <p>The implementation takes equal advantage of ascending and
* descending order in its input array, and can take advantage of
* ascending and descending order in different parts of the the same
* ascending and descending order in different parts of the same
* input array. It is well-suited to merging two or more sorted arrays:
* simply concatenate the arrays and sort the resulting array.
*
@ -823,7 +823,7 @@ public class Collections {
i -= size;
displaced = list.set(i, displaced);
nMoved ++;
} while(i != cycleStart);
} while (i != cycleStart);
}
}
@ -1452,9 +1452,9 @@ public class Collections {
* when o is a Map.Entry, and calls o.setValue.
*/
public boolean containsAll(Collection<?> coll) {
Iterator<?> e = coll.iterator();
while (e.hasNext())
if (!contains(e.next())) // Invokes safe contains() above
Iterator<?> it = coll.iterator();
while (it.hasNext())
if (!contains(it.next())) // Invokes safe contains() above
return false;
return true;
}
@ -1482,12 +1482,12 @@ public class Collections {
UnmodifiableEntry(Map.Entry<? extends K, ? extends V> e) {this.e = e;}
public K getKey() {return e.getKey();}
public V getValue() {return e.getValue();}
public K getKey() {return e.getKey();}
public V getValue() {return e.getValue();}
public V setValue(V value) {
throw new UnsupportedOperationException();
}
public int hashCode() {return e.hashCode();}
public int hashCode() {return e.hashCode();}
public boolean equals(Object o) {
if (!(o instanceof Map.Entry))
return false;
@ -1495,7 +1495,7 @@ public class Collections {
return eq(e.getKey(), t.getKey()) &&
eq(e.getValue(), t.getValue());
}
public String toString() {return e.toString();}
public String toString() {return e.toString();}
}
}
}
@ -1562,7 +1562,7 @@ public class Collections {
* <pre>
* Collection c = Collections.synchronizedCollection(myCollection);
* ...
* synchronized(c) {
* synchronized (c) {
* Iterator i = c.iterator(); // Must be in the synchronized block
* while (i.hasNext())
* foo(i.next());
@ -1611,19 +1611,19 @@ public class Collections {
}
public int size() {
synchronized(mutex) {return c.size();}
synchronized (mutex) {return c.size();}
}
public boolean isEmpty() {
synchronized(mutex) {return c.isEmpty();}
synchronized (mutex) {return c.isEmpty();}
}
public boolean contains(Object o) {
synchronized(mutex) {return c.contains(o);}
synchronized (mutex) {return c.contains(o);}
}
public Object[] toArray() {
synchronized(mutex) {return c.toArray();}
synchronized (mutex) {return c.toArray();}
}
public <T> T[] toArray(T[] a) {
synchronized(mutex) {return c.toArray(a);}
synchronized (mutex) {return c.toArray(a);}
}
public Iterator<E> iterator() {
@ -1631,32 +1631,32 @@ public class Collections {
}
public boolean add(E e) {
synchronized(mutex) {return c.add(e);}
synchronized (mutex) {return c.add(e);}
}
public boolean remove(Object o) {
synchronized(mutex) {return c.remove(o);}
synchronized (mutex) {return c.remove(o);}
}
public boolean containsAll(Collection<?> coll) {
synchronized(mutex) {return c.containsAll(coll);}
synchronized (mutex) {return c.containsAll(coll);}
}
public boolean addAll(Collection<? extends E> coll) {
synchronized(mutex) {return c.addAll(coll);}
synchronized (mutex) {return c.addAll(coll);}
}
public boolean removeAll(Collection<?> coll) {
synchronized(mutex) {return c.removeAll(coll);}
synchronized (mutex) {return c.removeAll(coll);}
}
public boolean retainAll(Collection<?> coll) {
synchronized(mutex) {return c.retainAll(coll);}
synchronized (mutex) {return c.retainAll(coll);}
}
public void clear() {
synchronized(mutex) {c.clear();}
synchronized (mutex) {c.clear();}
}
public String toString() {
synchronized(mutex) {return c.toString();}
synchronized (mutex) {return c.toString();}
}
private void writeObject(ObjectOutputStream s) throws IOException {
synchronized(mutex) {s.defaultWriteObject();}
synchronized (mutex) {s.defaultWriteObject();}
}
}
@ -1671,7 +1671,7 @@ public class Collections {
* <pre>
* Set s = Collections.synchronizedSet(new HashSet());
* ...
* synchronized(s) {
* synchronized (s) {
* Iterator i = s.iterator(); // Must be in the synchronized block
* while (i.hasNext())
* foo(i.next());
@ -1709,10 +1709,10 @@ public class Collections {
}
public boolean equals(Object o) {
synchronized(mutex) {return c.equals(o);}
synchronized (mutex) {return c.equals(o);}
}
public int hashCode() {
synchronized(mutex) {return c.hashCode();}
synchronized (mutex) {return c.hashCode();}
}
}
@ -1728,7 +1728,7 @@ public class Collections {
* <pre>
* SortedSet s = Collections.synchronizedSortedSet(new TreeSet());
* ...
* synchronized(s) {
* synchronized (s) {
* Iterator i = s.iterator(); // Must be in the synchronized block
* while (i.hasNext())
* foo(i.next());
@ -1739,7 +1739,7 @@ public class Collections {
* SortedSet s = Collections.synchronizedSortedSet(new TreeSet());
* SortedSet s2 = s.headSet(foo);
* ...
* synchronized(s) { // Note: s, not s2!!!
* synchronized (s) { // Note: s, not s2!!!
* Iterator i = s2.iterator(); // Must be in the synchronized block
* while (i.hasNext())
* foo(i.next());
@ -1766,7 +1766,7 @@ public class Collections {
{
private static final long serialVersionUID = 8695801310862127406L;
final private SortedSet<E> ss;
private final SortedSet<E> ss;
SynchronizedSortedSet(SortedSet<E> s) {
super(s);
@ -1778,31 +1778,31 @@ public class Collections {
}
public Comparator<? super E> comparator() {
synchronized(mutex) {return ss.comparator();}
synchronized (mutex) {return ss.comparator();}
}
public SortedSet<E> subSet(E fromElement, E toElement) {
synchronized(mutex) {
synchronized (mutex) {
return new SynchronizedSortedSet<E>(
ss.subSet(fromElement, toElement), mutex);
}
}
public SortedSet<E> headSet(E toElement) {
synchronized(mutex) {
synchronized (mutex) {
return new SynchronizedSortedSet<E>(ss.headSet(toElement), mutex);
}
}
public SortedSet<E> tailSet(E fromElement) {
synchronized(mutex) {
synchronized (mutex) {
return new SynchronizedSortedSet<E>(ss.tailSet(fromElement),mutex);
}
}
public E first() {
synchronized(mutex) {return ss.first();}
synchronized (mutex) {return ss.first();}
}
public E last() {
synchronized(mutex) {return ss.last();}
synchronized (mutex) {return ss.last();}
}
}
@ -1817,7 +1817,7 @@ public class Collections {
* <pre>
* List list = Collections.synchronizedList(new ArrayList());
* ...
* synchronized(list) {
* synchronized (list) {
* Iterator i = list.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
@ -1863,34 +1863,34 @@ public class Collections {
}
public boolean equals(Object o) {
synchronized(mutex) {return list.equals(o);}
synchronized (mutex) {return list.equals(o);}
}
public int hashCode() {
synchronized(mutex) {return list.hashCode();}
synchronized (mutex) {return list.hashCode();}
}
public E get(int index) {
synchronized(mutex) {return list.get(index);}
synchronized (mutex) {return list.get(index);}
}
public E set(int index, E element) {
synchronized(mutex) {return list.set(index, element);}
synchronized (mutex) {return list.set(index, element);}
}
public void add(int index, E element) {
synchronized(mutex) {list.add(index, element);}
synchronized (mutex) {list.add(index, element);}
}
public E remove(int index) {
synchronized(mutex) {return list.remove(index);}
synchronized (mutex) {return list.remove(index);}
}
public int indexOf(Object o) {
synchronized(mutex) {return list.indexOf(o);}
synchronized (mutex) {return list.indexOf(o);}
}
public int lastIndexOf(Object o) {
synchronized(mutex) {return list.lastIndexOf(o);}
synchronized (mutex) {return list.lastIndexOf(o);}
}
public boolean addAll(int index, Collection<? extends E> c) {
synchronized(mutex) {return list.addAll(index, c);}
synchronized (mutex) {return list.addAll(index, c);}
}
public ListIterator<E> listIterator() {
@ -1902,7 +1902,7 @@ public class Collections {
}
public List<E> subList(int fromIndex, int toIndex) {
synchronized(mutex) {
synchronized (mutex) {
return new SynchronizedList<E>(list.subList(fromIndex, toIndex),
mutex);
}
@ -1943,7 +1943,7 @@ public class Collections {
}
public List<E> subList(int fromIndex, int toIndex) {
synchronized(mutex) {
synchronized (mutex) {
return new SynchronizedRandomAccessList<E>(
list.subList(fromIndex, toIndex), mutex);
}
@ -1975,7 +1975,7 @@ public class Collections {
* ...
* Set s = m.keySet(); // Needn't be in synchronized block
* ...
* synchronized(m) { // Synchronizing on m, not s!
* synchronized (m) { // Synchronizing on m, not s!
* Iterator i = s.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
@ -2016,32 +2016,32 @@ public class Collections {
}
public int size() {
synchronized(mutex) {return m.size();}
synchronized (mutex) {return m.size();}
}
public boolean isEmpty() {
synchronized(mutex) {return m.isEmpty();}
synchronized (mutex) {return m.isEmpty();}
}
public boolean containsKey(Object key) {
synchronized(mutex) {return m.containsKey(key);}
synchronized (mutex) {return m.containsKey(key);}
}
public boolean containsValue(Object value) {
synchronized(mutex) {return m.containsValue(value);}
synchronized (mutex) {return m.containsValue(value);}
}
public V get(Object key) {
synchronized(mutex) {return m.get(key);}
synchronized (mutex) {return m.get(key);}
}
public V put(K key, V value) {
synchronized(mutex) {return m.put(key, value);}
synchronized (mutex) {return m.put(key, value);}
}
public V remove(Object key) {
synchronized(mutex) {return m.remove(key);}
synchronized (mutex) {return m.remove(key);}
}
public void putAll(Map<? extends K, ? extends V> map) {
synchronized(mutex) {m.putAll(map);}
synchronized (mutex) {m.putAll(map);}
}
public void clear() {
synchronized(mutex) {m.clear();}
synchronized (mutex) {m.clear();}
}
private transient Set<K> keySet = null;
@ -2049,7 +2049,7 @@ public class Collections {
private transient Collection<V> values = null;
public Set<K> keySet() {
synchronized(mutex) {
synchronized (mutex) {
if (keySet==null)
keySet = new SynchronizedSet<K>(m.keySet(), mutex);
return keySet;
@ -2057,7 +2057,7 @@ public class Collections {
}
public Set<Map.Entry<K,V>> entrySet() {
synchronized(mutex) {
synchronized (mutex) {
if (entrySet==null)
entrySet = new SynchronizedSet<Map.Entry<K,V>>(m.entrySet(), mutex);
return entrySet;
@ -2065,7 +2065,7 @@ public class Collections {
}
public Collection<V> values() {
synchronized(mutex) {
synchronized (mutex) {
if (values==null)
values = new SynchronizedCollection<V>(m.values(), mutex);
return values;
@ -2073,16 +2073,16 @@ public class Collections {
}
public boolean equals(Object o) {
synchronized(mutex) {return m.equals(o);}
synchronized (mutex) {return m.equals(o);}
}
public int hashCode() {
synchronized(mutex) {return m.hashCode();}
synchronized (mutex) {return m.hashCode();}
}
public String toString() {
synchronized(mutex) {return m.toString();}
synchronized (mutex) {return m.toString();}
}
private void writeObject(ObjectOutputStream s) throws IOException {
synchronized(mutex) {s.defaultWriteObject();}
synchronized (mutex) {s.defaultWriteObject();}
}
}
@ -2101,7 +2101,7 @@ public class Collections {
* ...
* Set s = m.keySet(); // Needn't be in synchronized block
* ...
* synchronized(m) { // Synchronizing on m, not s!
* synchronized (m) { // Synchronizing on m, not s!
* Iterator i = s.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
@ -2114,7 +2114,7 @@ public class Collections {
* ...
* Set s2 = m2.keySet(); // Needn't be in synchronized block
* ...
* synchronized(m) { // Synchronizing on m, not m2 or s2!
* synchronized (m) { // Synchronizing on m, not m2 or s2!
* Iterator i = s.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
@ -2154,31 +2154,31 @@ public class Collections {
}
public Comparator<? super K> comparator() {
synchronized(mutex) {return sm.comparator();}
synchronized (mutex) {return sm.comparator();}
}
public SortedMap<K,V> subMap(K fromKey, K toKey) {
synchronized(mutex) {
synchronized (mutex) {
return new SynchronizedSortedMap<K,V>(
sm.subMap(fromKey, toKey), mutex);
}
}
public SortedMap<K,V> headMap(K toKey) {
synchronized(mutex) {
synchronized (mutex) {
return new SynchronizedSortedMap<K,V>(sm.headMap(toKey), mutex);
}
}
public SortedMap<K,V> tailMap(K fromKey) {
synchronized(mutex) {
synchronized (mutex) {
return new SynchronizedSortedMap<K,V>(sm.tailMap(fromKey),mutex);
}
}
public K firstKey() {
synchronized(mutex) {return sm.firstKey();}
synchronized (mutex) {return sm.firstKey();}
}
public K lastKey() {
synchronized(mutex) {return sm.lastKey();}
synchronized (mutex) {return sm.lastKey();}
}
}
@ -3317,7 +3317,7 @@ public class Collections {
{
private static final long serialVersionUID = 3193687207550431679L;
final private E element;
private final E element;
SingletonSet(E e) {element = e;}
@ -3448,7 +3448,7 @@ public class Collections {
* @param o the element to appear repeatedly in the returned list.
* @return an immutable list consisting of <tt>n</tt> copies of the
* specified object.
* @throws IllegalArgumentException if n &lt; 0.
* @throws IllegalArgumentException if {@code n < 0}
* @see List#addAll(Collection)
* @see List#addAll(int, Collection)
*/

View File

@ -207,7 +207,7 @@ class ComparableTimSort {
* @param lo the index of the first element in the range to be sorted
* @param hi the index after the last element in the range to be sorted
* @param start the index of the first element in the range that is
* not already known to be sorted (@code lo <= start <= hi}
* not already known to be sorted ({@code lo <= start <= hi})
*/
@SuppressWarnings("fallthrough")
private static void binarySort(Object[] a, int lo, int hi, int start) {
@ -245,7 +245,7 @@ class ComparableTimSort {
*/
int n = start - left; // The number of elements to move
// Switch is just an optimization for arraycopy in default case
switch(n) {
switch (n) {
case 2: a[left + 2] = a[left + 1];
case 1: a[left + 1] = a[left];
break;
@ -275,7 +275,7 @@ class ComparableTimSort {
* @param a the array in which a run is to be counted and possibly reversed
* @param lo index of the first element in the run
* @param hi index after the last element that may be contained in the run.
It is required that @code{lo < hi}.
It is required that {@code lo < hi}.
* @return the length of the run beginning at the specified position in
* the specified array
*/
@ -288,7 +288,7 @@ class ComparableTimSort {
// Find end of run, and reverse range if descending
if (((Comparable) a[runHi++]).compareTo(a[lo]) < 0) { // Descending
while(runHi < hi && ((Comparable) a[runHi]).compareTo(a[runHi - 1]) < 0)
while (runHi < hi && ((Comparable) a[runHi]).compareTo(a[runHi - 1]) < 0)
runHi++;
reverseRange(a, lo, runHi);
} else { // Ascending

View File

@ -59,10 +59,10 @@ public class FormattableFlags {
* <pre>
* out.toUpperCase() </pre>
*
* <p> This flag corresponds to <tt>'^'</tt> (<tt>'&#92;u005e'</tt>) in
* <p> This flag corresponds to <tt>'S'</tt> (<tt>'&#92;u0053'</tt>) in
* the format specifier.
*/
public static final int UPPERCASE = 1<<1; // '^'
public static final int UPPERCASE = 1<<1; // 'S'
/**
* Requires the output to use an alternate form. The definition of the

View File

@ -72,7 +72,7 @@ import sun.util.ResourceBundleEnumeration;
*
* public class MyResources extends ListResourceBundle {
* protected Object[][] getContents() {
* return new Object[][] = {
* return new Object[][] {
* // LOCALIZE THIS
* {"s1", "The disk \"{1}\" contains {0}."}, // MessageFormat pattern
* {"s2", "1"}, // location of {0} in pattern

View File

@ -870,7 +870,7 @@ public final class Locale implements Cloneable, Serializable {
* @throws SecurityException - if a security manager exists and its
* checkPermission method doesn't allow the operation.
* @throws NullPointerException - if category and/or newLocale is null
* @see SecurityManager.checkPermission(java.security.Permission)
* @see SecurityManager#checkPermission(java.security.Permission)
* @see PropertyPermission
* @see #getDefault(Locale.Category)
* @since 1.7
@ -1232,20 +1232,18 @@ public final class Locale implements Cloneable, Serializable {
* "Solaris_isjustthecoolestthing" is emitted as
* "x-lvariant-Solaris", not as "solaris".</li></ul>
*
* <p><b>Compatibility special cases:</b><ul>
* <p><b>Special Conversions:</b> Java supports some old locale
* representations, including deprecated ISO language codes,
* for compatibility. This method performs the following
* conversions:
* <ul>
*
* <li>The language codes "iw", "ji", and "in" are handled
* specially. Java uses these deprecated codes for compatibility
* reasons. The <code>toLanguageTag</code> method converts these
* three codes (and only these three) to "he", "yi", and "id"
* respectively.
* <li>Deprecated ISO language codes "iw", "ji", and "in" are
* converted to "he", "yi", and "id", respectively.
*
* <li>A locale with language "no", country "NO", and variant
* "NY", representing Norwegian Nynorsk, will be represented as
* having language "nn", country "NO", and empty variant. This is
* because some JVMs used the deprecated form to represent the
* user's default locale, and for compatibility reasons that Take a has
* not been changed.</ul>
* "NY", representing Norwegian Nynorsk (Norway), is converted
* to a language tag "nn-NO".</li></ul>
*
* <p><b>Note:</b> Although the language tag created by this
* method is well-formed (satisfies the syntax requirements
@ -1327,7 +1325,7 @@ public final class Locale implements Cloneable, Serializable {
*
* <pre>
* Locale loc;
* loc = Locale.forLanguageTag("en-US-x-lvariant-POSIX);
* loc = Locale.forLanguageTag("en-US-x-lvariant-POSIX");
* loc.getVariant(); // returns "POSIX"
* loc.getExtension('x'); // returns null
*
@ -1355,10 +1353,10 @@ public final class Locale implements Cloneable, Serializable {
* extensions are added as though the constructor had been called:
*
* <pre>
* Locale.forLanguageTag("ja-JP-x-lvariant-JP).toLanguageTag();
* // returns ja-JP-u-ca-japanese-x-lvariant-JP
* Locale.forLanguageTag("th-TH-x-lvariant-TH).toLanguageTag();
* // returns th-TH-u-nu-thai-x-lvariant-TH
* Locale.forLanguageTag("ja-JP-x-lvariant-JP").toLanguageTag();
* // returns "ja-JP-u-ca-japanese-x-lvariant-JP"
* Locale.forLanguageTag("th-TH-x-lvariant-TH").toLanguageTag();
* // returns "th-TH-u-nu-thai-x-lvariant-TH"
* <pre></ul>
*
* <p>This implements the 'Language-Tag' production of BCP47, and
@ -1428,7 +1426,12 @@ public final class Locale implements Cloneable, Serializable {
LanguageTag tag = LanguageTag.parse(languageTag, null);
InternalLocaleBuilder bldr = new InternalLocaleBuilder();
bldr.setLanguageTag(tag);
return getInstance(bldr.getBaseLocale(), bldr.getLocaleExtensions());
BaseLocale base = bldr.getBaseLocale();
LocaleExtensions exts = bldr.getLocaleExtensions();
if (exts.isEmpty() && base.getVariant().length() > 0) {
exts = getCompatibilityExtensions(base.getLanguage(), base.getScript(), base.getRegion(), base.getVariant());
}
return getInstance(base, exts);
}
/**
@ -2487,6 +2490,10 @@ public final class Locale implements Cloneable, Serializable {
public Locale build() {
BaseLocale baseloc = _locbld.getBaseLocale();
LocaleExtensions extensions = _locbld.getLocaleExtensions();
if (extensions.isEmpty() && baseloc.getVariant().length() > 0) {
extensions = getCompatibilityExtensions(baseloc.getLanguage(), baseloc.getScript(),
baseloc.getRegion(), baseloc.getVariant());
}
return Locale.getInstance(baseloc, extensions);
}
}

View File

@ -77,9 +77,9 @@ class Random implements java.io.Serializable {
*/
private final AtomicLong seed;
private final static long multiplier = 0x5DEECE66DL;
private final static long addend = 0xBL;
private final static long mask = (1L << 48) - 1;
private static final long multiplier = 0x5DEECE66DL;
private static final long addend = 0xBL;
private static final long mask = (1L << 48) - 1;
/**
* Creates a new random number generator. This constructor sets
@ -285,7 +285,7 @@ class Random implements java.io.Serializable {
* @return the next pseudorandom, uniformly distributed {@code int}
* value between {@code 0} (inclusive) and {@code n} (exclusive)
* from this random number generator's sequence
* @exception IllegalArgumentException if n is not positive
* @throws IllegalArgumentException if n is not positive
* @since 1.2
*/

View File

@ -73,9 +73,9 @@ class Stack<E> extends Vector<E> {
* Removes the object at the top of this stack and returns that
* object as the value of this function.
*
* @return The object at the top of this stack (the last item
* of the <tt>Vector</tt> object).
* @exception EmptyStackException if this stack is empty.
* @return The object at the top of this stack (the last item
* of the <tt>Vector</tt> object).
* @throws EmptyStackException if this stack is empty.
*/
public synchronized E pop() {
E obj;
@ -91,9 +91,9 @@ class Stack<E> extends Vector<E> {
* Looks at the object at the top of this stack without removing it
* from the stack.
*
* @return the object at the top of this stack (the last item
* of the <tt>Vector</tt> object).
* @exception EmptyStackException if this stack is empty.
* @return the object at the top of this stack (the last item
* of the <tt>Vector</tt> object).
* @throws EmptyStackException if this stack is empty.
*/
public synchronized E peek() {
int len = size();

View File

@ -239,7 +239,7 @@ class TimSort<T> {
* @param lo the index of the first element in the range to be sorted
* @param hi the index after the last element in the range to be sorted
* @param start the index of the first element in the range that is
* not already known to be sorted (@code lo <= start <= hi}
* not already known to be sorted ({@code lo <= start <= hi})
* @param c comparator to used for the sort
*/
@SuppressWarnings("fallthrough")
@ -278,7 +278,7 @@ class TimSort<T> {
*/
int n = start - left; // The number of elements to move
// Switch is just an optimization for arraycopy in default case
switch(n) {
switch (n) {
case 2: a[left + 2] = a[left + 1];
case 1: a[left + 1] = a[left];
break;
@ -308,7 +308,7 @@ class TimSort<T> {
* @param a the array in which a run is to be counted and possibly reversed
* @param lo index of the first element in the run
* @param hi index after the last element that may be contained in the run.
It is required that @code{lo < hi}.
It is required that {@code lo < hi}.
* @param c the comparator to used for the sort
* @return the length of the run beginning at the specified position in
* the specified array
@ -322,7 +322,7 @@ class TimSort<T> {
// Find end of run, and reverse range if descending
if (c.compare(a[runHi++], a[lo]) < 0) { // Descending
while(runHi < hi && c.compare(a[runHi], a[runHi - 1]) < 0)
while (runHi < hi && c.compare(a[runHi], a[runHi - 1]) < 0)
runHi++;
reverseRange(a, lo, runHi);
} else { // Ascending

View File

@ -1056,11 +1056,11 @@ public class TreeMap<K,V>
public Comparator<? super E> comparator() { return m.comparator(); }
public E pollFirst() {
Map.Entry<E,Object> e = m.pollFirstEntry();
return e == null? null : e.getKey();
return (e == null) ? null : e.getKey();
}
public E pollLast() {
Map.Entry<E,Object> e = m.pollLastEntry();
return e == null? null : e.getKey();
return (e == null) ? null : e.getKey();
}
public boolean remove(Object o) {
int oldSize = size();
@ -1196,7 +1196,7 @@ public class TreeMap<K,V>
* Test two values for equality. Differs from o1.equals(o2) only in
* that it copes with {@code null} o1 properly.
*/
final static boolean valEquals(Object o1, Object o2) {
static final boolean valEquals(Object o1, Object o2) {
return (o1==null ? o2==null : o1.equals(o2));
}
@ -1204,7 +1204,7 @@ public class TreeMap<K,V>
* Return SimpleImmutableEntry for entry, or null if null
*/
static <K,V> Map.Entry<K,V> exportEntry(TreeMap.Entry<K,V> e) {
return e == null? null :
return (e == null) ? null :
new AbstractMap.SimpleImmutableEntry<K,V>(e);
}
@ -1212,7 +1212,7 @@ public class TreeMap<K,V>
* Return key for entry, or null if null
*/
static <K,V> K keyOrNull(TreeMap.Entry<K,V> e) {
return e == null? null : e.key;
return (e == null) ? null : e.key;
}
/**
@ -1237,7 +1237,7 @@ public class TreeMap<K,V>
/**
* @serial include
*/
static abstract class NavigableSubMap<K,V> extends AbstractMap<K,V>
abstract static class NavigableSubMap<K,V> extends AbstractMap<K,V>
implements NavigableMap<K,V>, java.io.Serializable {
/**
* The backing map.
@ -1412,11 +1412,11 @@ public class TreeMap<K,V>
}
public final V get(Object key) {
return !inRange(key)? null : m.get(key);
return !inRange(key) ? null : m.get(key);
}
public final V remove(Object key) {
return !inRange(key)? null : m.remove(key);
return !inRange(key) ? null : m.remove(key);
}
public final Map.Entry<K,V> ceilingEntry(K key) {
@ -1559,7 +1559,8 @@ public class TreeMap<K,V>
if (!inRange(key))
return false;
TreeMap.Entry<K,V> node = m.getEntry(key);
if (node!=null && valEquals(node.getValue(),entry.getValue())){
if (node!=null && valEquals(node.getValue(),
entry.getValue())) {
m.deleteEntry(node);
return true;
}
@ -1724,7 +1725,7 @@ public class TreeMap<K,V>
false, toKey, inclusive);
}
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive){
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive) {
if (!inRange(fromKey, inclusive))
throw new IllegalArgumentException("fromKey out of range");
return new AscendingSubMap(m,
@ -1805,7 +1806,7 @@ public class TreeMap<K,V>
toEnd, hi, hiInclusive);
}
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive){
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive) {
if (!inRange(fromKey, inclusive))
throw new IllegalArgumentException("fromKey out of range");
return new DescendingSubMap(m,
@ -2143,7 +2144,7 @@ public class TreeMap<K,V>
// If strictly internal, copy successor's element to p and then make p
// point to successor.
if (p.left != null && p.right != null) {
Entry<K,V> s = successor (p);
Entry<K,V> s = successor(p);
p.key = s.key;
p.value = s.value;
p = s;

View File

@ -452,7 +452,7 @@ public class TreeSet<E> extends AbstractSet<E>
*/
public E pollFirst() {
Map.Entry<E,?> e = m.pollFirstEntry();
return (e == null)? null : e.getKey();
return (e == null) ? null : e.getKey();
}
/**
@ -460,7 +460,7 @@ public class TreeSet<E> extends AbstractSet<E>
*/
public E pollLast() {
Map.Entry<E,?> e = m.pollLastEntry();
return (e == null)? null : e.getKey();
return (e == null) ? null : e.getKey();
}
/**

View File

@ -919,7 +919,7 @@ public class Vector<E>
* elements (optional), or if the specified collection is null
* @since 1.2
*/
public synchronized boolean retainAll(Collection<?> c) {
public synchronized boolean retainAll(Collection<?> c) {
return super.retainAll(c);
}

View File

@ -51,20 +51,20 @@ import java.util.*;
* <p> <b>Extension example</b>. Here is a sketch of a class
* that customizes {@link ThreadPoolExecutor} to use
* a <tt>CustomTask</tt> class instead of the default <tt>FutureTask</tt>:
* <pre>
* <pre> {@code
* public class CustomThreadPoolExecutor extends ThreadPoolExecutor {
*
* static class CustomTask&lt;V&gt; implements RunnableFuture&lt;V&gt; {...}
* static class CustomTask<V> implements RunnableFuture<V> {...}
*
* protected &lt;V&gt; RunnableFuture&lt;V&gt; newTaskFor(Callable&lt;V&gt; c) {
* return new CustomTask&lt;V&gt;(c);
* protected <V> RunnableFuture<V> newTaskFor(Callable<V> c) {
* return new CustomTask<V>(c);
* }
* protected &lt;V&gt; RunnableFuture&lt;V&gt; newTaskFor(Runnable r, V v) {
* return new CustomTask&lt;V&gt;(r, v);
* protected <V> RunnableFuture<V> newTaskFor(Runnable r, V v) {
* return new CustomTask<V>(r, v);
* }
* // ... add constructors, etc.
* }
* </pre>
* }}</pre>
*
* @since 1.5
* @author Doug Lea
*/
@ -106,7 +106,7 @@ public abstract class AbstractExecutorService implements ExecutorService {
*/
public Future<?> submit(Runnable task) {
if (task == null) throw new NullPointerException();
RunnableFuture<Object> ftask = newTaskFor(task, null);
RunnableFuture<Void> ftask = newTaskFor(task, null);
execute(ftask);
return ftask;
}
@ -158,7 +158,7 @@ public abstract class AbstractExecutorService implements ExecutorService {
// Record exceptions so that if we fail to obtain any
// result, we can throw the last exception we got.
ExecutionException ee = null;
long lastTime = (timed)? System.nanoTime() : 0;
long lastTime = timed ? System.nanoTime() : 0;
Iterator<? extends Callable<T>> it = tasks.iterator();
// Start one task for sure; the rest incrementally
@ -191,8 +191,6 @@ public abstract class AbstractExecutorService implements ExecutorService {
--active;
try {
return f.get();
} catch (InterruptedException ie) {
throw ie;
} catch (ExecutionException eex) {
ee = eex;
} catch (RuntimeException rex) {

View File

@ -1270,7 +1270,7 @@ public class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
* for each key-value mapping, followed by a null pair.
* The key-value mappings are emitted in no particular order.
*/
private void writeObject(java.io.ObjectOutputStream s) throws IOException {
private void writeObject(java.io.ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
for (int k = 0; k < segments.length; ++k) {
@ -1298,7 +1298,7 @@ public class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
* @param s the stream
*/
private void readObject(java.io.ObjectInputStream s)
throws IOException, ClassNotFoundException {
throws IOException, ClassNotFoundException {
s.defaultReadObject();
// Initialize each segment to be minimally sized, and let grow.

View File

@ -38,7 +38,6 @@ package java.util.concurrent;
import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Deque;
import java.util.Iterator;
import java.util.NoSuchElementException;
@ -212,7 +211,7 @@ public class ConcurrentLinkedDeque<E>
* The actual representation we use is that p.next == p means to
* goto the first node (which in turn is reached by following prev
* pointers from head), and p.next == null && p.prev == p means
* that the iteration is at an end and that p is a (final static)
* that the iteration is at an end and that p is a (static final)
* dummy node, NEXT_TERMINATOR, and not the last active node.
* Finishing the iteration when encountering such a TERMINATOR is
* good enough for read-only traversals, so such traversals can use
@ -271,7 +270,7 @@ public class ConcurrentLinkedDeque<E>
*/
private transient volatile Node<E> tail;
private final static Node<Object> PREV_TERMINATOR, NEXT_TERMINATOR;
private static final Node<Object> PREV_TERMINATOR, NEXT_TERMINATOR;
static {
PREV_TERMINATOR = new Node<Object>(null);
@ -401,7 +400,7 @@ public class ConcurrentLinkedDeque<E>
}
}
private final static int HOPS = 2;
private static final int HOPS = 2;
/**
* Unlinks non-null node x.
@ -871,7 +870,7 @@ public class ConcurrentLinkedDeque<E>
/**
* Inserts the specified element at the front of this deque.
*
* @throws NullPointerException {@inheritDoc}
* @throws NullPointerException if the specified element is null
*/
public void addFirst(E e) {
linkFirst(e);
@ -882,7 +881,7 @@ public class ConcurrentLinkedDeque<E>
*
* <p>This method is equivalent to {@link #add}.
*
* @throws NullPointerException {@inheritDoc}
* @throws NullPointerException if the specified element is null
*/
public void addLast(E e) {
linkLast(e);
@ -892,7 +891,7 @@ public class ConcurrentLinkedDeque<E>
* Inserts the specified element at the front of this deque.
*
* @return {@code true} always
* @throws NullPointerException {@inheritDoc}
* @throws NullPointerException if the specified element is null
*/
public boolean offerFirst(E e) {
linkFirst(e);
@ -905,7 +904,7 @@ public class ConcurrentLinkedDeque<E>
* <p>This method is equivalent to {@link #add}.
*
* @return {@code true} always
* @throws NullPointerException {@inheritDoc}
* @throws NullPointerException if the specified element is null
*/
public boolean offerLast(E e) {
linkLast(e);
@ -940,7 +939,7 @@ public class ConcurrentLinkedDeque<E>
/**
* @throws NoSuchElementException {@inheritDoc}
*/
public E getLast() {
public E getLast() {
return screenNullResult(peekLast());
}
@ -1016,7 +1015,7 @@ public class ConcurrentLinkedDeque<E>
*
* @param o element to be removed from this deque, if present
* @return {@code true} if the deque contained the specified element
* @throws NullPointerException if the specified element is {@code null}
* @throws NullPointerException if the specified element is null
*/
public boolean removeFirstOccurrence(Object o) {
checkNotNull(o);
@ -1037,7 +1036,7 @@ public class ConcurrentLinkedDeque<E>
*
* @param o element to be removed from this deque, if present
* @return {@code true} if the deque contained the specified element
* @throws NullPointerException if the specified element is {@code null}
* @throws NullPointerException if the specified element is null
*/
public boolean removeLastOccurrence(Object o) {
checkNotNull(o);
@ -1110,7 +1109,7 @@ public class ConcurrentLinkedDeque<E>
*
* @param o element to be removed from this deque, if present
* @return {@code true} if the deque contained the specified element
* @throws NullPointerException if the specified element is {@code null}
* @throws NullPointerException if the specified element is null
*/
public boolean remove(Object o) {
return removeFirstOccurrence(o);
@ -1165,7 +1164,7 @@ public class ConcurrentLinkedDeque<E>
beginningOfTheEnd.lazySetPrev(p); // CAS piggyback
if (p.casNext(null, beginningOfTheEnd)) {
// Successful CAS is the linearization point
// for all elements to be added to this queue.
// for all elements to be added to this deque.
if (!casTail(t, last)) {
// Try a little harder to update tail,
// since we may be adding many elements.
@ -1251,12 +1250,12 @@ public class ConcurrentLinkedDeque<E>
* Returns an iterator over the elements in this deque in proper sequence.
* The elements will be returned in order from first (head) to last (tail).
*
* <p>The returned {@code Iterator} is a "weakly consistent" iterator that
* <p>The returned iterator is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this deque in proper sequence
*/
@ -1269,12 +1268,12 @@ public class ConcurrentLinkedDeque<E>
* sequential order. The elements will be returned in order from
* last (tail) to first (head).
*
* <p>The returned {@code Iterator} is a "weakly consistent" iterator that
* <p>The returned iterator is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this deque in reverse order
*/

View File

@ -65,8 +65,8 @@ import java.util.Queue;
* <p>Iterators are <i>weakly consistent</i>, returning elements
* reflecting the state of the queue at some point at or since the
* creation of the iterator. They do <em>not</em> throw {@link
* ConcurrentModificationException}, and may proceed concurrently with
* other operations. Elements contained in the queue since the creation
* java.util.ConcurrentModificationException}, and may proceed concurrently
* with other operations. Elements contained in the queue since the creation
* of the iterator will be returned exactly once.
*
* <p>Beware that, unlike in most collections, the {@code size} method
@ -634,12 +634,12 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* Returns an iterator over the elements in this queue in proper sequence.
* The elements will be returned in order from first (head) to last (tail).
*
* <p>The returned {@code Iterator} is a "weakly consistent" iterator that
* <p>The returned iterator is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this queue in proper sequence
*/

View File

@ -362,12 +362,12 @@ public class ConcurrentSkipListSet<E>
public E pollFirst() {
Map.Entry<E,Object> e = m.pollFirstEntry();
return e == null? null : e.getKey();
return (e == null) ? null : e.getKey();
}
public E pollLast() {
Map.Entry<E,Object> e = m.pollLastEntry();
return e == null? null : e.getKey();
return (e == null) ? null : e.getKey();
}

View File

@ -547,7 +547,7 @@ public class CopyOnWriteArrayList<E>
* @param fromIndex index of first element to be removed
* @param toIndex index after last element to be removed
* @throws IndexOutOfBoundsException if fromIndex or toIndex out of range
* (@code{fromIndex < 0 || toIndex > size() || toIndex < fromIndex})
* ({@code{fromIndex < 0 || toIndex > size() || toIndex < fromIndex})
*/
private void removeRange(int fromIndex, int toIndex) {
final ReentrantLock lock = this.lock;
@ -989,7 +989,7 @@ public class CopyOnWriteArrayList<E>
}
private static class COWIterator<E> implements ListIterator<E> {
/** Snapshot of the array **/
/** Snapshot of the array */
private final Object[] snapshot;
/** Index of element to be returned by subsequent call to next. */
private int cursor;

View File

@ -59,24 +59,23 @@ import java.util.*;
* copy-on-write set to maintain a set of Handler objects that
* perform some action upon state updates.
*
* <pre>
* <pre> {@code
* class Handler { void handle(); ... }
*
* class X {
* private final CopyOnWriteArraySet&lt;Handler&gt; handlers
* = new CopyOnWriteArraySet&lt;Handler&gt;();
* public void addHandler(Handler h) { handlers.add(h); }
* private final CopyOnWriteArraySet<Handler> handlers
* = new CopyOnWriteArraySet<Handler>();
* public void addHandler(Handler h) { handlers.add(h); }
*
* private long internalState;
* private synchronized void changeState() { internalState = ...; }
* private long internalState;
* private synchronized void changeState() { internalState = ...; }
*
* public void update() {
* changeState();
* for (Handler handler : handlers)
* handler.handle();
* }
* }
* </pre>
* public void update() {
* changeState();
* for (Handler handler : handlers)
* handler.handle();
* }
* }}</pre>
*
* <p>This class is a member of the
* <a href="{@docRoot}/../technotes/guides/collections/index.html">

View File

@ -175,7 +175,7 @@ public class CountDownLatch {
}
protected int tryAcquireShared(int acquires) {
return getState() == 0? 1 : -1;
return (getState() == 0) ? 1 : -1;
}
protected boolean tryReleaseShared(int releases) {

View File

@ -482,12 +482,14 @@ public class DelayQueue<E extends Delayed> extends AbstractQueue<E>
/**
* Returns an iterator over all the elements (both expired and
* unexpired) in this queue. The iterator does not return the
* elements in any particular order. The returned
* <tt>Iterator</tt> is a "weakly consistent" iterator that will
* never throw {@link ConcurrentModificationException}, and
* guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed
* to) reflect any modifications subsequent to construction.
* elements in any particular order.
*
* <p>The returned iterator is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this queue
*/

View File

@ -355,7 +355,9 @@ public class Exchanger<V> {
else if (y == null && // Try to occupy
slot.compareAndSet(null, me)) {
if (index == 0) // Blocking wait for slot 0
return timed? awaitNanos(me, slot, nanos): await(me, slot);
return timed ?
awaitNanos(me, slot, nanos) :
await(me, slot);
Object v = spinWait(me, slot); // Spin wait for non-0
if (v != CANCEL)
return v;
@ -597,8 +599,8 @@ public class Exchanger<V> {
* dormant until one of two things happens:
* <ul>
* <li>Some other thread enters the exchange; or
* <li>Some other thread {@linkplain Thread#interrupt interrupts} the current
* thread.
* <li>Some other thread {@linkplain Thread#interrupt interrupts}
* the current thread.
* </ul>
* <p>If the current thread:
* <ul>
@ -616,7 +618,7 @@ public class Exchanger<V> {
*/
public V exchange(V x) throws InterruptedException {
if (!Thread.interrupted()) {
Object v = doExchange(x == null? NULL_ITEM : x, false, 0);
Object v = doExchange((x == null) ? NULL_ITEM : x, false, 0);
if (v == NULL_ITEM)
return null;
if (v != CANCEL)
@ -671,7 +673,7 @@ public class Exchanger<V> {
public V exchange(V x, long timeout, TimeUnit unit)
throws InterruptedException, TimeoutException {
if (!Thread.interrupted()) {
Object v = doExchange(x == null? NULL_ITEM : x,
Object v = doExchange((x == null) ? NULL_ITEM : x,
true, unit.toNanos(timeout));
if (v == NULL_ITEM)
return null;

View File

@ -79,37 +79,37 @@ package java.util.concurrent;
* serializes the submission of tasks to a second executor,
* illustrating a composite executor.
*
* <pre>
* <pre> {@code
* class SerialExecutor implements Executor {
* final Queue&lt;Runnable&gt; tasks = new ArrayDeque&lt;Runnable&gt;();
* final Executor executor;
* Runnable active;
* final Queue<Runnable> tasks = new ArrayDeque<Runnable>();
* final Executor executor;
* Runnable active;
*
* SerialExecutor(Executor executor) {
* this.executor = executor;
* }
* SerialExecutor(Executor executor) {
* this.executor = executor;
* }
*
* public synchronized void execute(final Runnable r) {
* tasks.offer(new Runnable() {
* public void run() {
* try {
* r.run();
* } finally {
* scheduleNext();
* }
* }
* });
* if (active == null) {
* scheduleNext();
* public synchronized void execute(final Runnable r) {
* tasks.offer(new Runnable() {
* public void run() {
* try {
* r.run();
* } finally {
* scheduleNext();
* }
* }
* });
* if (active == null) {
* scheduleNext();
* }
* }
*
* protected synchronized void scheduleNext() {
* if ((active = tasks.poll()) != null) {
* executor.execute(active);
* }
* protected synchronized void scheduleNext() {
* if ((active = tasks.poll()) != null) {
* executor.execute(active);
* }
* }</pre>
* }
* }}</pre>
*
* The <tt>Executor</tt> implementations provided in this package
* implement {@link ExecutorService}, which is a more extensive

View File

@ -197,7 +197,8 @@ public class ExecutorCompletionService<V> implements CompletionService<V> {
return completionQueue.poll();
}
public Future<V> poll(long timeout, TimeUnit unit) throws InterruptedException {
public Future<V> poll(long timeout, TimeUnit unit)
throws InterruptedException {
return completionQueue.poll(timeout, unit);
}

View File

@ -83,7 +83,7 @@ public class Executors {
*
* @param nThreads the number of threads in the pool
* @return the newly created thread pool
* @throws IllegalArgumentException if <tt>nThreads &lt;= 0</tt>
* @throws IllegalArgumentException if {@code nThreads <= 0}
*/
public static ExecutorService newFixedThreadPool(int nThreads) {
return new ThreadPoolExecutor(nThreads, nThreads,
@ -108,7 +108,7 @@ public class Executors {
* @param threadFactory the factory to use when creating new threads
* @return the newly created thread pool
* @throws NullPointerException if threadFactory is null
* @throws IllegalArgumentException if <tt>nThreads &lt;= 0</tt>
* @throws IllegalArgumentException if {@code nThreads <= 0}
*/
public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory) {
return new ThreadPoolExecutor(nThreads, nThreads,
@ -242,7 +242,7 @@ public class Executors {
* @param corePoolSize the number of threads to keep in the pool,
* even if they are idle.
* @return a newly created scheduled thread pool
* @throws IllegalArgumentException if <tt>corePoolSize &lt; 0</tt>
* @throws IllegalArgumentException if {@code corePoolSize < 0}
*/
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize) {
return new ScheduledThreadPoolExecutor(corePoolSize);
@ -256,7 +256,7 @@ public class Executors {
* @param threadFactory the factory to use when the executor
* creates a new thread.
* @return a newly created scheduled thread pool
* @throws IllegalArgumentException if <tt>corePoolSize &lt; 0</tt>
* @throws IllegalArgumentException if {@code corePoolSize < 0}
* @throws NullPointerException if threadFactory is null
*/
public static ScheduledExecutorService newScheduledThreadPool(
@ -562,8 +562,8 @@ public class Executors {
DefaultThreadFactory() {
SecurityManager s = System.getSecurityManager();
group = (s != null)? s.getThreadGroup() :
Thread.currentThread().getThreadGroup();
group = (s != null) ? s.getThreadGroup() :
Thread.currentThread().getThreadGroup();
namePrefix = "pool-" +
poolNumber.getAndIncrement() +
"-thread-";
@ -669,7 +669,7 @@ public class Executors {
FinalizableDelegatedExecutorService(ExecutorService executor) {
super(executor);
}
protected void finalize() {
protected void finalize() {
super.shutdown();
}
}

View File

@ -47,21 +47,21 @@ package java.util.concurrent;
* computation has completed, the computation cannot be cancelled.
* If you would like to use a <tt>Future</tt> for the sake
* of cancellability but not provide a usable result, you can
* declare types of the form <tt>Future&lt;?&gt;</tt> and
* declare types of the form {@code Future<?>} and
* return <tt>null</tt> as a result of the underlying task.
*
* <p>
* <b>Sample Usage</b> (Note that the following classes are all
* made-up.) <p>
* <pre>
* <pre> {@code
* interface ArchiveSearcher { String search(String target); }
* class App {
* ExecutorService executor = ...
* ArchiveSearcher searcher = ...
* void showSearch(final String target)
* throws InterruptedException {
* Future&lt;String&gt; future
* = executor.submit(new Callable&lt;String&gt;() {
* Future<String> future
* = executor.submit(new Callable<String>() {
* public String call() {
* return searcher.search(target);
* }});
@ -70,20 +70,18 @@ package java.util.concurrent;
* displayText(future.get()); // use future
* } catch (ExecutionException ex) { cleanup(); return; }
* }
* }
* </pre>
* }}</pre>
*
* The {@link FutureTask} class is an implementation of <tt>Future</tt> that
* implements <tt>Runnable</tt>, and so may be executed by an <tt>Executor</tt>.
* For example, the above construction with <tt>submit</tt> could be replaced by:
* <pre>
* FutureTask&lt;String&gt; future =
* new FutureTask&lt;String&gt;(new Callable&lt;String&gt;() {
* <pre> {@code
* FutureTask<String> future =
* new FutureTask<String>(new Callable<String>() {
* public String call() {
* return searcher.search(target);
* }});
* executor.execute(future);
* </pre>
* executor.execute(future);}</pre>
*
* <p>Memory consistency effects: Actions taken by the asynchronous computation
* <a href="package-summary.html#MemoryVisibility"> <i>happen-before</i></a>

View File

@ -85,7 +85,7 @@ public class FutureTask<V> implements RunnableFuture<V> {
* @param result the result to return on successful completion. If
* you don't need a particular result, consider using
* constructions of the form:
* <tt>Future&lt;?&gt; f = new FutureTask&lt;Object&gt;(runnable, null)</tt>
* {@code Future<?> f = new FutureTask<Void>(runnable, null)}
* @throws NullPointerException if runnable is null
*/
public FutureTask(Runnable runnable, V result) {

View File

@ -1004,12 +1004,13 @@ public class LinkedBlockingDeque<E>
/**
* Returns an iterator over the elements in this deque in proper sequence.
* The elements will be returned in order from first (head) to last (tail).
* The returned {@code Iterator} is a "weakly consistent" iterator that
*
* <p>The returned iterator is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this deque in proper sequence
*/
@ -1021,12 +1022,13 @@ public class LinkedBlockingDeque<E>
* Returns an iterator over the elements in this deque in reverse
* sequential order. The elements will be returned in order from
* last (tail) to first (head).
* The returned {@code Iterator} is a "weakly consistent" iterator that
*
* <p>The returned iterator is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*/
public Iterator<E> descendingIterator() {
return new DescendingItr();

View File

@ -159,7 +159,9 @@ public abstract class RecursiveAction extends ForkJoinTask<Void> {
protected abstract void compute();
/**
* Always returns null.
* Always returns {@code null}.
*
* @return {@code null} always
*/
public final Void getRawResult() { return null; }

View File

@ -72,24 +72,23 @@ import java.util.*;
* Here is a class with a method that sets up a ScheduledExecutorService
* to beep every ten seconds for an hour:
*
* <pre>
* <pre> {@code
* import static java.util.concurrent.TimeUnit.*;
* class BeeperControl {
* private final ScheduledExecutorService scheduler =
* Executors.newScheduledThreadPool(1);
* private final ScheduledExecutorService scheduler =
* Executors.newScheduledThreadPool(1);
*
* public void beepForAnHour() {
* final Runnable beeper = new Runnable() {
* public void run() { System.out.println("beep"); }
* };
* final ScheduledFuture&lt;?&gt; beeperHandle =
* scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);
* scheduler.schedule(new Runnable() {
* public void run() { beeperHandle.cancel(true); }
* }, 60 * 60, SECONDS);
* }
* }
* </pre>
* public void beepForAnHour() {
* final Runnable beeper = new Runnable() {
* public void run() { System.out.println("beep"); }
* };
* final ScheduledFuture<?> beeperHandle =
* scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);
* scheduler.schedule(new Runnable() {
* public void run() { beeperHandle.cancel(true); }
* }, 60 * 60, SECONDS);
* }
* }}</pre>
*
* @since 1.5
* @author Doug Lea

View File

@ -62,8 +62,8 @@ import java.util.*;
* time of cancellation.
*
* <p>Successive executions of a task scheduled via
* <code>scheduleAtFixedRate</code> or
* <code>scheduleWithFixedDelay</code> do not overlap. While different
* {@code scheduleAtFixedRate} or
* {@code scheduleWithFixedDelay} do not overlap. While different
* executions may be performed by different threads, the effects of
* prior executions <a
* href="package-summary.html#MemoryVisibility"><i>happen-before</i></a>
@ -436,7 +436,7 @@ public class ScheduledThreadPoolExecutor
* @throws NullPointerException if {@code threadFactory} is null
*/
public ScheduledThreadPoolExecutor(int corePoolSize,
ThreadFactory threadFactory) {
ThreadFactory threadFactory) {
super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS,
new DelayedWorkQueue(), threadFactory);
}
@ -453,7 +453,7 @@ public class ScheduledThreadPoolExecutor
* @throws NullPointerException if {@code handler} is null
*/
public ScheduledThreadPoolExecutor(int corePoolSize,
RejectedExecutionHandler handler) {
RejectedExecutionHandler handler) {
super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS,
new DelayedWorkQueue(), handler);
}
@ -473,8 +473,8 @@ public class ScheduledThreadPoolExecutor
* {@code handler} is null
*/
public ScheduledThreadPoolExecutor(int corePoolSize,
ThreadFactory threadFactory,
RejectedExecutionHandler handler) {
ThreadFactory threadFactory,
RejectedExecutionHandler handler) {
super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS,
new DelayedWorkQueue(), threadFactory, handler);
}

View File

@ -223,7 +223,7 @@ public class Semaphore implements java.io.Serializable {
/**
* NonFair version
*/
final static class NonfairSync extends Sync {
static final class NonfairSync extends Sync {
private static final long serialVersionUID = -2694183684443567898L;
NonfairSync(int permits) {
@ -238,7 +238,7 @@ public class Semaphore implements java.io.Serializable {
/**
* Fair version
*/
final static class FairSync extends Sync {
static final class FairSync extends Sync {
private static final long serialVersionUID = 2014338818796000944L;
FairSync(int permits) {
@ -282,7 +282,7 @@ public class Semaphore implements java.io.Serializable {
* else {@code false}
*/
public Semaphore(int permits, boolean fair) {
sync = (fair)? new FairSync(permits) : new NonfairSync(permits);
sync = fair ? new FairSync(permits) : new NonfairSync(permits);
}
/**

View File

@ -63,9 +63,9 @@ import java.util.Random;
*/
public class ThreadLocalRandom extends Random {
// same constants as Random, but must be redeclared because private
private final static long multiplier = 0x5DEECE66DL;
private final static long addend = 0xBL;
private final static long mask = (1L << 48) - 1;
private static final long multiplier = 0x5DEECE66DL;
private static final long addend = 0xBL;
private static final long mask = (1L << 48) - 1;
/**
* The random seed. We can't use super.seed.

View File

@ -53,12 +53,12 @@ package java.util.concurrent;
* java.util.concurrent.locks.Lock lock} is not available:
*
* <pre> Lock lock = ...;
* if ( lock.tryLock(50L, TimeUnit.MILLISECONDS) ) ...
* if (lock.tryLock(50L, TimeUnit.MILLISECONDS)) ...
* </pre>
* while this code will timeout in 50 seconds:
* <pre>
* Lock lock = ...;
* if ( lock.tryLock(50L, TimeUnit.SECONDS) ) ...
* if (lock.tryLock(50L, TimeUnit.SECONDS)) ...
* </pre>
*
* Note however, that there is no guarantee that a particular timeout
@ -291,7 +291,8 @@ public enum TimeUnit {
abstract int excessNanos(long d, long m);
/**
* Performs a timed <tt>Object.wait</tt> using this time unit.
* Performs a timed {@link Object#wait(long, int) Object.wait}
* using this time unit.
* This is a convenience method that converts timeout arguments
* into the form required by the <tt>Object.wait</tt> method.
*
@ -299,21 +300,22 @@ public enum TimeUnit {
* method (see {@link BlockingQueue#poll BlockingQueue.poll})
* using:
*
* <pre> public synchronized Object poll(long timeout, TimeUnit unit) throws InterruptedException {
* while (empty) {
* unit.timedWait(this, timeout);
* ...
* }
* }</pre>
* <pre> {@code
* public synchronized Object poll(long timeout, TimeUnit unit)
* throws InterruptedException {
* while (empty) {
* unit.timedWait(this, timeout);
* ...
* }
* }}</pre>
*
* @param obj the object to wait on
* @param timeout the maximum time to wait. If less than
* or equal to zero, do not wait at all.
* @throws InterruptedException if interrupted while waiting.
* @see Object#wait(long, int)
* @throws InterruptedException if interrupted while waiting
*/
public void timedWait(Object obj, long timeout)
throws InterruptedException {
throws InterruptedException {
if (timeout > 0) {
long ms = toMillis(timeout);
int ns = excessNanos(timeout, ms);
@ -322,17 +324,18 @@ public enum TimeUnit {
}
/**
* Performs a timed <tt>Thread.join</tt> using this time unit.
* Performs a timed {@link Thread#join(long, int) Thread.join}
* using this time unit.
* This is a convenience method that converts time arguments into the
* form required by the <tt>Thread.join</tt> method.
*
* @param thread the thread to wait for
* @param timeout the maximum time to wait. If less than
* or equal to zero, do not wait at all.
* @throws InterruptedException if interrupted while waiting.
* @see Thread#join(long, int)
* @throws InterruptedException if interrupted while waiting
*/
public void timedJoin(Thread thread, long timeout)
throws InterruptedException {
throws InterruptedException {
if (timeout > 0) {
long ms = toMillis(timeout);
int ns = excessNanos(timeout, ms);
@ -341,13 +344,14 @@ public enum TimeUnit {
}
/**
* Performs a <tt>Thread.sleep</tt> using this unit.
* Performs a {@link Thread#sleep(long, int) Thread.sleep} using
* this time unit.
* This is a convenience method that converts time arguments into the
* form required by the <tt>Thread.sleep</tt> method.
*
* @param timeout the minimum time to sleep. If less than
* or equal to zero, do not sleep at all.
* @throws InterruptedException if interrupted while sleeping.
* @see Thread#sleep
* @throws InterruptedException if interrupted while sleeping
*/
public void sleep(long timeout) throws InterruptedException {
if (timeout > 0) {

View File

@ -55,7 +55,7 @@ import java.lang.reflect.*;
* @author Doug Lea
* @param <T> The type of the object holding the updatable field
*/
public abstract class AtomicIntegerFieldUpdater<T> {
public abstract class AtomicIntegerFieldUpdater<T> {
/**
* Creates and returns an updater for objects with the given field.
* The Class argument is needed to check that reflective types and
@ -279,7 +279,7 @@ public abstract class AtomicIntegerFieldUpdater<T> {
sun.reflect.misc.ReflectUtil.ensureMemberAccess(
caller, tclass, null, modifiers);
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
} catch(Exception ex) {
} catch (Exception ex) {
throw new RuntimeException(ex);
}

View File

@ -55,7 +55,7 @@ import java.lang.reflect.*;
* @author Doug Lea
* @param <T> The type of the object holding the updatable field
*/
public abstract class AtomicLongFieldUpdater<T> {
public abstract class AtomicLongFieldUpdater<T> {
/**
* Creates and returns an updater for objects with the given field.
* The Class argument is needed to check that reflective types and
@ -278,7 +278,7 @@ public abstract class AtomicLongFieldUpdater<T> {
sun.reflect.misc.ReflectUtil.ensureMemberAccess(
caller, tclass, null, modifiers);
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
} catch(Exception ex) {
} catch (Exception ex) {
throw new RuntimeException(ex);
}
@ -331,7 +331,7 @@ public abstract class AtomicLongFieldUpdater<T> {
if (cclass.isInstance(obj)) {
return;
}
throw new RuntimeException (
throw new RuntimeException(
new IllegalAccessException("Class " +
cclass.getName() +
" can not access a protected member of class " +
@ -361,7 +361,7 @@ public abstract class AtomicLongFieldUpdater<T> {
sun.reflect.misc.ReflectUtil.ensureMemberAccess(
caller, tclass, null, modifiers);
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
} catch(Exception ex) {
} catch (Exception ex) {
throw new RuntimeException(ex);
}
@ -387,7 +387,7 @@ public abstract class AtomicLongFieldUpdater<T> {
public boolean compareAndSet(T obj, long expect, long update) {
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
synchronized(this) {
synchronized (this) {
long v = unsafe.getLong(obj, offset);
if (v != expect)
return false;
@ -402,7 +402,7 @@ public abstract class AtomicLongFieldUpdater<T> {
public void set(T obj, long newValue) {
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
synchronized(this) {
synchronized (this) {
unsafe.putLong(obj, offset, newValue);
}
}
@ -413,7 +413,7 @@ public abstract class AtomicLongFieldUpdater<T> {
public long get(T obj) {
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
synchronized(this) {
synchronized (this) {
return unsafe.getLong(obj, offset);
}
}
@ -422,7 +422,7 @@ public abstract class AtomicLongFieldUpdater<T> {
if (cclass.isInstance(obj)) {
return;
}
throw new RuntimeException (
throw new RuntimeException(
new IllegalAccessException("Class " +
cclass.getName() +
" can not access a protected member of class " +

View File

@ -45,13 +45,13 @@ import java.lang.reflect.*;
* independently subject to atomic updates. For example, a tree node
* might be declared as
*
* <pre>
* <pre> {@code
* class Node {
* private volatile Node left, right;
*
* private static final AtomicReferenceFieldUpdater&lt;Node, Node&gt; leftUpdater =
* private static final AtomicReferenceFieldUpdater<Node, Node> leftUpdater =
* AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "left");
* private static AtomicReferenceFieldUpdater&lt;Node, Node&gt; rightUpdater =
* private static AtomicReferenceFieldUpdater<Node, Node> rightUpdater =
* AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "right");
*
* Node getLeft() { return left; }
@ -59,8 +59,7 @@ import java.lang.reflect.*;
* return leftUpdater.compareAndSet(this, expect, update);
* }
* // ... and so on
* }
* </pre>
* }}</pre>
*
* <p>Note that the guarantees of the {@code compareAndSet}
* method in this class are weaker than in other atomic classes.
@ -74,7 +73,7 @@ import java.lang.reflect.*;
* @param <T> The type of the object holding the updatable field
* @param <V> The type of the field
*/
public abstract class AtomicReferenceFieldUpdater<T, V> {
public abstract class AtomicReferenceFieldUpdater<T, V> {
/**
* Creates and returns an updater for objects with the given field.
@ -291,7 +290,7 @@ public abstract class AtomicReferenceFieldUpdater<T, V> {
if (cclass.isInstance(obj)) {
return;
}
throw new RuntimeException (
throw new RuntimeException(
new IllegalAccessException("Class " +
cclass.getName() +
" can not access a protected member of class " +

View File

@ -990,7 +990,8 @@ public abstract class AbstractQueuedLongSynchronizer
* can represent anything you like.
* @throws InterruptedException if the current thread is interrupted
*/
public final void acquireInterruptibly(long arg) throws InterruptedException {
public final void acquireInterruptibly(long arg)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
if (!tryAcquire(arg))
@ -1014,7 +1015,8 @@ public abstract class AbstractQueuedLongSynchronizer
* @return {@code true} if acquired; {@code false} if timed out
* @throws InterruptedException if the current thread is interrupted
*/
public final boolean tryAcquireNanos(long arg, long nanosTimeout) throws InterruptedException {
public final boolean tryAcquireNanos(long arg, long nanosTimeout)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
return tryAcquire(arg) ||
@ -1070,7 +1072,8 @@ public abstract class AbstractQueuedLongSynchronizer
* you like.
* @throws InterruptedException if the current thread is interrupted
*/
public final void acquireSharedInterruptibly(long arg) throws InterruptedException {
public final void acquireSharedInterruptibly(long arg)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
if (tryAcquireShared(arg) < 0)
@ -1093,7 +1096,8 @@ public abstract class AbstractQueuedLongSynchronizer
* @return {@code true} if acquired; {@code false} if timed out
* @throws InterruptedException if the current thread is interrupted
*/
public final boolean tryAcquireSharedNanos(long arg, long nanosTimeout) throws InterruptedException {
public final boolean tryAcquireSharedNanos(long arg, long nanosTimeout)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
return tryAcquireShared(arg) >= 0 ||
@ -1841,7 +1845,8 @@ public abstract class AbstractQueuedLongSynchronizer
* <li> If interrupted while blocked in step 4, throw InterruptedException.
* </ol>
*/
public final long awaitNanos(long nanosTimeout) throws InterruptedException {
public final long awaitNanos(long nanosTimeout)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
Node node = addConditionWaiter();
@ -1885,7 +1890,8 @@ public abstract class AbstractQueuedLongSynchronizer
* <li> If timed out while blocked in step 4, return false, else true.
* </ol>
*/
public final boolean awaitUntil(Date deadline) throws InterruptedException {
public final boolean awaitUntil(Date deadline)
throws InterruptedException {
if (deadline == null)
throw new NullPointerException();
long abstime = deadline.getTime();
@ -1928,7 +1934,8 @@ public abstract class AbstractQueuedLongSynchronizer
* <li> If timed out while blocked in step 4, return false, else true.
* </ol>
*/
public final boolean await(long time, TimeUnit unit) throws InterruptedException {
public final boolean await(long time, TimeUnit unit)
throws InterruptedException {
if (unit == null)
throw new NullPointerException();
long nanosTimeout = unit.toNanos(time);
@ -2084,7 +2091,7 @@ public abstract class AbstractQueuedLongSynchronizer
/**
* CAS waitStatus field of a node.
*/
private final static boolean compareAndSetWaitStatus(Node node,
private static final boolean compareAndSetWaitStatus(Node node,
int expect,
int update) {
return unsafe.compareAndSwapInt(node, waitStatusOffset,
@ -2094,7 +2101,7 @@ public abstract class AbstractQueuedLongSynchronizer
/**
* CAS next field of a node.
*/
private final static boolean compareAndSetNext(Node node,
private static final boolean compareAndSetNext(Node node,
Node expect,
Node update) {
return unsafe.compareAndSwapObject(node, nextOffset, expect, update);

View File

@ -265,7 +265,7 @@ import sun.misc.Unsafe;
* boolean isSignalled() { return getState() != 0; }
*
* protected int tryAcquireShared(int ignore) {
* return isSignalled()? 1 : -1;
* return isSignalled() ? 1 : -1;
* }
*
* protected boolean tryReleaseShared(int ignore) {
@ -1213,7 +1213,8 @@ public abstract class AbstractQueuedSynchronizer
* can represent anything you like.
* @throws InterruptedException if the current thread is interrupted
*/
public final void acquireInterruptibly(int arg) throws InterruptedException {
public final void acquireInterruptibly(int arg)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
if (!tryAcquire(arg))
@ -1237,7 +1238,8 @@ public abstract class AbstractQueuedSynchronizer
* @return {@code true} if acquired; {@code false} if timed out
* @throws InterruptedException if the current thread is interrupted
*/
public final boolean tryAcquireNanos(int arg, long nanosTimeout) throws InterruptedException {
public final boolean tryAcquireNanos(int arg, long nanosTimeout)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
return tryAcquire(arg) ||
@ -1293,7 +1295,8 @@ public abstract class AbstractQueuedSynchronizer
* you like.
* @throws InterruptedException if the current thread is interrupted
*/
public final void acquireSharedInterruptibly(int arg) throws InterruptedException {
public final void acquireSharedInterruptibly(int arg)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
if (tryAcquireShared(arg) < 0)
@ -1316,7 +1319,8 @@ public abstract class AbstractQueuedSynchronizer
* @return {@code true} if acquired; {@code false} if timed out
* @throws InterruptedException if the current thread is interrupted
*/
public final boolean tryAcquireSharedNanos(int arg, long nanosTimeout) throws InterruptedException {
public final boolean tryAcquireSharedNanos(int arg, long nanosTimeout)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
return tryAcquireShared(arg) >= 0 ||
@ -2062,7 +2066,8 @@ public abstract class AbstractQueuedSynchronizer
* <li> If interrupted while blocked in step 4, throw InterruptedException.
* </ol>
*/
public final long awaitNanos(long nanosTimeout) throws InterruptedException {
public final long awaitNanos(long nanosTimeout)
throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException();
Node node = addConditionWaiter();
@ -2106,7 +2111,8 @@ public abstract class AbstractQueuedSynchronizer
* <li> If timed out while blocked in step 4, return false, else true.
* </ol>
*/
public final boolean awaitUntil(Date deadline) throws InterruptedException {
public final boolean awaitUntil(Date deadline)
throws InterruptedException {
if (deadline == null)
throw new NullPointerException();
long abstime = deadline.getTime();
@ -2149,7 +2155,8 @@ public abstract class AbstractQueuedSynchronizer
* <li> If timed out while blocked in step 4, return false, else true.
* </ol>
*/
public final boolean await(long time, TimeUnit unit) throws InterruptedException {
public final boolean await(long time, TimeUnit unit)
throws InterruptedException {
if (unit == null)
throw new NullPointerException();
long nanosTimeout = unit.toNanos(time);
@ -2305,7 +2312,7 @@ public abstract class AbstractQueuedSynchronizer
/**
* CAS waitStatus field of a node.
*/
private final static boolean compareAndSetWaitStatus(Node node,
private static final boolean compareAndSetWaitStatus(Node node,
int expect,
int update) {
return unsafe.compareAndSwapInt(node, waitStatusOffset,
@ -2315,7 +2322,7 @@ public abstract class AbstractQueuedSynchronizer
/**
* CAS next field of a node.
*/
private final static boolean compareAndSetNext(Node node,
private static final boolean compareAndSetNext(Node node,
Node expect,
Node update) {
return unsafe.compareAndSwapObject(node, nextOffset, expect, update);

View File

@ -200,8 +200,8 @@ public class LockSupport {
* <li>Some other thread invokes {@link #unpark unpark} with the
* current thread as the target; or
*
* <li>Some other thread {@linkplain Thread#interrupt interrupts} the current
* thread; or
* <li>Some other thread {@linkplain Thread#interrupt interrupts}
* the current thread; or
*
* <li>The specified waiting time elapses; or
*

View File

@ -116,7 +116,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
* into fair and nonfair versions below. Uses AQS state to
* represent the number of holds on the lock.
*/
static abstract class Sync extends AbstractQueuedSynchronizer {
abstract static class Sync extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = -5179523762034025860L;
/**
@ -200,7 +200,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
/**
* Sync object for non-fair locks
*/
final static class NonfairSync extends Sync {
static final class NonfairSync extends Sync {
private static final long serialVersionUID = 7316153563782823691L;
/**
@ -222,7 +222,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
/**
* Sync object for fair locks
*/
final static class FairSync extends Sync {
static final class FairSync extends Sync {
private static final long serialVersionUID = -3000897897090466540L;
final void lock() {
@ -269,7 +269,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
* @param fair {@code true} if this lock should use a fair ordering policy
*/
public ReentrantLock(boolean fair) {
sync = (fair)? new FairSync() : new NonfairSync();
sync = fair ? new FairSync() : new NonfairSync();
}
/**
@ -440,7 +440,8 @@ public class ReentrantLock implements Lock, java.io.Serializable {
* @throws NullPointerException if the time unit is null
*
*/
public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
public boolean tryLock(long timeout, TimeUnit unit)
throws InterruptedException {
return sync.tryAcquireNanos(1, unit.toNanos(timeout));
}

View File

@ -155,7 +155,7 @@ import java.util.*;
* }
* // Downgrade by acquiring read lock before releasing write lock
* rwl.readLock().lock();
* } finally {
* } finally {
* rwl.writeLock().unlock(); // Unlock write, still hold read
* }
* }
@ -215,7 +215,8 @@ import java.util.*;
* @author Doug Lea
*
*/
public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializable {
public class ReentrantReadWriteLock
implements ReadWriteLock, java.io.Serializable {
private static final long serialVersionUID = -6992448646407690164L;
/** Inner class providing readlock */
private final ReentrantReadWriteLock.ReadLock readerLock;
@ -251,7 +252,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
* Synchronization implementation for ReentrantReadWriteLock.
* Subclassed into fair and nonfair versions.
*/
static abstract class Sync extends AbstractQueuedSynchronizer {
abstract static class Sync extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 6317671515068378041L;
/*
@ -618,7 +619,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
final Thread getOwner() {
// Must read state before owner to ensure memory consistency
return ((exclusiveCount(getState()) == 0)?
return ((exclusiveCount(getState()) == 0) ?
null :
getExclusiveOwnerThread());
}
@ -669,7 +670,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
/**
* Nonfair version of Sync
*/
final static class NonfairSync extends Sync {
static final class NonfairSync extends Sync {
private static final long serialVersionUID = -8159625535654395037L;
final boolean writerShouldBlock() {
return false; // writers can always barge
@ -689,7 +690,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
/**
* Fair version of Sync
*/
final static class FairSync extends Sync {
static final class FairSync extends Sync {
private static final long serialVersionUID = -2274990926593161451L;
final boolean writerShouldBlock() {
return hasQueuedPredecessors();
@ -702,7 +703,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
/**
* The lock returned by method {@link ReentrantReadWriteLock#readLock}.
*/
public static class ReadLock implements Lock, java.io.Serializable {
public static class ReadLock implements Lock, java.io.Serializable {
private static final long serialVersionUID = -5992448646407690164L;
private final Sync sync;
@ -867,7 +868,8 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
* @throws NullPointerException if the time unit is null
*
*/
public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
public boolean tryLock(long timeout, TimeUnit unit)
throws InterruptedException {
return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
}
@ -908,7 +910,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
/**
* The lock returned by method {@link ReentrantReadWriteLock#writeLock}.
*/
public static class WriteLock implements Lock, java.io.Serializable {
public static class WriteLock implements Lock, java.io.Serializable {
private static final long serialVersionUID = -4992448646407690164L;
private final Sync sync;
@ -1108,7 +1110,8 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
* @throws NullPointerException if the time unit is null
*
*/
public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
public boolean tryLock(long timeout, TimeUnit unit)
throws InterruptedException {
return sync.tryAcquireNanos(1, unit.toNanos(timeout));
}

View File

@ -315,7 +315,7 @@ class ZipFile implements ZipConstants, Closeable {
private static native void freeEntry(long jzfile, long jzentry);
// the outstanding inputstreams that need to be closed.
private Set<ZipFileInputStream> streams = new HashSet<ZipFileInputStream>();
private Set<InputStream> streams = new HashSet<>();
/**
* Returns an input stream for reading the contents of the specified
@ -348,55 +348,58 @@ class ZipFile implements ZipConstants, Closeable {
return null;
}
in = new ZipFileInputStream(jzentry);
streams.add(in);
}
final ZipFileInputStream zfin = in;
switch (getEntryMethod(jzentry)) {
case STORED:
return zfin;
case DEFLATED:
// MORE: Compute good size for inflater stream:
long size = getEntrySize(jzentry) + 2; // Inflater likes a bit of slack
if (size > 65536) size = 8192;
if (size <= 0) size = 4096;
return new InflaterInputStream(zfin, getInflater(), (int)size) {
private boolean isClosed = false;
public void close() throws IOException {
if (!isClosed) {
releaseInflater(inf);
this.in.close();
isClosed = true;
}
}
// Override fill() method to provide an extra "dummy" byte
// at the end of the input stream. This is required when
// using the "nowrap" Inflater option.
protected void fill() throws IOException {
if (eof) {
throw new EOFException(
"Unexpected end of ZLIB input stream");
}
len = this.in.read(buf, 0, buf.length);
if (len == -1) {
buf[0] = 0;
len = 1;
eof = true;
}
inf.setInput(buf, 0, len);
}
private boolean eof;
switch (getEntryMethod(jzentry)) {
case STORED:
streams.add(in);
return in;
case DEFLATED:
final ZipFileInputStream zfin = in;
// MORE: Compute good size for inflater stream:
long size = getEntrySize(jzentry) + 2; // Inflater likes a bit of slack
if (size > 65536) size = 8192;
if (size <= 0) size = 4096;
InputStream is = new InflaterInputStream(zfin, getInflater(), (int)size) {
private boolean isClosed = false;
public int available() throws IOException {
if (isClosed)
return 0;
long avail = zfin.size() - inf.getBytesWritten();
return avail > (long) Integer.MAX_VALUE ?
Integer.MAX_VALUE : (int) avail;
}
};
default:
throw new ZipException("invalid compression method");
public void close() throws IOException {
if (!isClosed) {
super.close();
releaseInflater(inf);
isClosed = true;
}
}
// Override fill() method to provide an extra "dummy" byte
// at the end of the input stream. This is required when
// using the "nowrap" Inflater option.
protected void fill() throws IOException {
if (eof) {
throw new EOFException(
"Unexpected end of ZLIB input stream");
}
len = this.in.read(buf, 0, buf.length);
if (len == -1) {
buf[0] = 0;
len = 1;
eof = true;
}
inf.setInput(buf, 0, len);
}
private boolean eof;
public int available() throws IOException {
if (isClosed)
return 0;
long avail = zfin.size() - inf.getBytesWritten();
return avail > (long) Integer.MAX_VALUE ?
Integer.MAX_VALUE : (int) avail;
}
};
streams.add(is);
return is;
default:
throw new ZipException("invalid compression method");
}
}
}
@ -539,9 +542,9 @@ class ZipFile implements ZipConstants, Closeable {
closeRequested = true;
if (streams.size() !=0) {
Set<ZipFileInputStream> copy = streams;
streams = new HashSet<ZipFileInputStream>();
for (ZipFileInputStream is: copy)
Set<InputStream> copy = streams;
streams = new HashSet<InputStream>();
for (InputStream is: copy)
is.close();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -166,8 +166,9 @@ public class SerialBlob implements Blob, Serializable, Cloneable {
length = (int)len;
}
if (pos < 1 || length - pos < 0 ) {
throw new SerialException("Invalid arguments: position cannot be less that 1");
if (pos < 1 || len - pos < 0 ) {
throw new SerialException("Invalid arguments: position cannot be "
+ "less than 1 or greater than the length of the SerialBlob");
}
pos--; // correct pos to array index

View File

@ -154,8 +154,8 @@ public class JDialog extends Dialog implements WindowConstants,
}
/**
* Creates a modeless dialog without a title with the
* specified {@code Frame} as its owner. If {@code owner}
* Creates a modeless dialog with the specified {@code Frame}
* as its owner and an empty title. If {@code owner}
* is {@code null}, a shared, hidden frame will be set as the
* owner of the dialog.
* <p>
@ -179,8 +179,8 @@ public class JDialog extends Dialog implements WindowConstants,
}
/**
* Creates a dialog with the specified owner {@code Frame}, modality
* and an empty title. If {@code owner} is {@code null},
* Creates a dialog with an empty title and the specified modality and
* {@code Frame} as its owner. If {@code owner} is {@code null},
* a shared, hidden frame will be set as the owner of the dialog.
* <p>
* This constructor sets the component's locale property to the value
@ -202,7 +202,7 @@ public class JDialog extends Dialog implements WindowConstants,
* @see JComponent#getDefaultLocale
*/
public JDialog(Frame owner, boolean modal) {
this(owner, null, modal);
this(owner, "", modal);
}
/**
@ -330,8 +330,8 @@ public class JDialog extends Dialog implements WindowConstants,
}
/**
* Creates a modeless dialog without a title with the
* specified {@code Dialog} as its owner.
* Creates a modeless dialog with the specified {@code Dialog}
* as its owner and an empty title.
* <p>
* This constructor sets the component's locale property to the value
* returned by {@code JComponent.getDefaultLocale}.
@ -348,7 +348,8 @@ public class JDialog extends Dialog implements WindowConstants,
}
/**
* Creates a dialog with the specified owner {@code Dialog} and modality.
* Creates a dialog with an empty title and the specified modality and
* {@code Dialog} as its owner.
* <p>
* This constructor sets the component's locale property to the value
* returned by {@code JComponent.getDefaultLocale}.
@ -369,7 +370,7 @@ public class JDialog extends Dialog implements WindowConstants,
* @see JComponent#getDefaultLocale
*/
public JDialog(Dialog owner, boolean modal) {
this(owner, null, modal);
this(owner, "", modal);
}
/**
@ -461,8 +462,8 @@ public class JDialog extends Dialog implements WindowConstants,
}
/**
* Creates a modeless dialog with the specified owner {@code Window} and
* an empty title.
* Creates a modeless dialog with the specified {@code Window}
* as its owner and an empty title.
* <p>
* This constructor sets the component's locale property to the value
* returned by {@code JComponent.getDefaultLocale}.
@ -488,8 +489,8 @@ public class JDialog extends Dialog implements WindowConstants,
}
/**
* Creates a dialog with the specified owner {@code Window}, modality
* and an empty title.
* Creates a dialog with an empty title and the specified modality and
* {@code Window} as its owner.
* <p>
* This constructor sets the component's locale property to the value
* returned by {@code JComponent.getDefaultLocale}.
@ -520,7 +521,7 @@ public class JDialog extends Dialog implements WindowConstants,
* @since 1.6
*/
public JDialog(Window owner, ModalityType modalityType) {
this(owner, null, modalityType);
this(owner, "", modalityType);
}
/**

View File

@ -339,7 +339,7 @@ public class Main {
// Standard browser properties
avProps.put("browser", "sun.applet.AppletViewer");
avProps.put("browser.version", "1.06");
avProps.put("browser.vendor", "Sun Microsystems Inc.");
avProps.put("browser.vendor", "Oracle Corporation");
avProps.put("http.agent", "Java(tm) 2 SDK, Standard Edition v" + theVersion);
// Define which packages can be extended by applets

View File

@ -94,6 +94,11 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
protected int dropStatus = STATUS_NONE;
protected boolean dropComplete = false;
// The flag is used to monitor whether the drop action is
// handled by a user. That allows to distinct during
// which operation getTransferData() method is invoked.
boolean dropInProcess = false;
/*
* global lock
*/
@ -220,7 +225,7 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
SecurityManager sm = System.getSecurityManager();
try {
if (!dropComplete && sm != null) {
if (!dropInProcess && sm != null) {
sm.checkSystemClipboardAccess();
}
} catch (Exception e) {
@ -526,6 +531,8 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
setCurrentJVMLocalSourceTransferable(null);
}
dropInProcess = true;
try {
((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
hots,
@ -538,6 +545,7 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
} else if (dropComplete == false) {
dropComplete(false);
}
dropInProcess = false;
}
} else {
rejectDrop();

View File

@ -276,6 +276,18 @@ public final class FontUtilities {
// 0E00 - 0E7F if Thai, assume shaping for vowel, tone marks
return true;
}
else if (code < 0x0f00) {
return false;
}
else if (code <= 0x0fff) { // U+0F00 - U+0FFF Tibetan
return true;
}
else if (code < 0x1100) {
return false;
}
else if (code < 0x11ff) { // U+1100 - U+11FF Old Hangul
return true;
}
else if (code < 0x1780) {
return false;
}

View File

@ -46,11 +46,15 @@ import sun.java2d.loops.DrawPolygons;
import sun.java2d.loops.DrawPath;
import sun.java2d.loops.FillPath;
import sun.java2d.loops.FillSpans;
import sun.java2d.loops.FillParallelogram;
import sun.java2d.loops.DrawParallelogram;
import sun.java2d.loops.FontInfo;
import sun.java2d.loops.DrawGlyphList;
import sun.java2d.loops.DrawGlyphListAA;
import sun.java2d.loops.DrawGlyphListLCD;
import sun.java2d.pipe.LoopPipe;
import sun.java2d.pipe.ShapeDrawPipe;
import sun.java2d.pipe.ParallelogramPipe;
import sun.java2d.pipe.CompositePipe;
import sun.java2d.pipe.GeneralCompositePipe;
import sun.java2d.pipe.SpanClipRenderer;
@ -59,6 +63,7 @@ import sun.java2d.pipe.AAShapePipe;
import sun.java2d.pipe.AlphaPaintPipe;
import sun.java2d.pipe.AlphaColorPipe;
import sun.java2d.pipe.PixelToShapeConverter;
import sun.java2d.pipe.PixelToParallelogramConverter;
import sun.java2d.pipe.TextPipe;
import sun.java2d.pipe.TextRenderer;
import sun.java2d.pipe.AATextRenderer;
@ -364,6 +369,7 @@ public abstract class SurfaceData
protected static final CompositePipe colorPipe;
protected static final PixelToShapeConverter colorViaShape;
protected static final PixelToParallelogramConverter colorViaPgram;
protected static final TextPipe colorText;
protected static final CompositePipe clipColorPipe;
protected static final TextPipe clipColorText;
@ -396,6 +402,31 @@ public abstract class SurfaceData
protected static final DrawImagePipe imagepipe;
// Utility subclass to add the LoopBasedPipe tagging interface
static class PixelToShapeLoopConverter
extends PixelToShapeConverter
implements LoopBasedPipe
{
public PixelToShapeLoopConverter(ShapeDrawPipe pipe) {
super(pipe);
}
}
// Utility subclass to add the LoopBasedPipe tagging interface
static class PixelToPgramLoopConverter
extends PixelToParallelogramConverter
implements LoopBasedPipe
{
public PixelToPgramLoopConverter(ShapeDrawPipe shapepipe,
ParallelogramPipe pgrampipe,
double minPenSize,
double normPosition,
boolean adjustfill)
{
super(shapepipe, pgrampipe, minPenSize, normPosition, adjustfill);
}
}
static {
colorPrimitives = new LoopPipe();
@ -406,7 +437,10 @@ public abstract class SurfaceData
colorPipe = new AlphaColorPipe();
// colorShape = colorPrimitives;
colorViaShape = new PixelToShapeConverter(colorPrimitives);
colorViaShape = new PixelToShapeLoopConverter(colorPrimitives);
colorViaPgram = new PixelToPgramLoopConverter(colorPrimitives,
colorPrimitives,
1.0, 0.25, true);
colorText = new TextRenderer(colorPipe);
clipColorPipe = new SpanClipRenderer(colorPipe);
clipColorText = new TextRenderer(clipColorPipe);
@ -441,10 +475,12 @@ public abstract class SurfaceData
}
/* Not all surfaces and rendering mode combinations support LCD text. */
static final int LCDLOOP_UNKNOWN = 0;
static final int LCDLOOP_FOUND = 1;
static final int LCDLOOP_NOTFOUND = 2;
static final int LOOP_UNKNOWN = 0;
static final int LOOP_FOUND = 1;
static final int LOOP_NOTFOUND = 2;
int haveLCDLoop;
int havePgramXORLoop;
int havePgramSolidLoop;
public boolean canRenderLCDText(SunGraphics2D sg2d) {
// For now the answer can only be true in the following cases:
@ -453,18 +489,48 @@ public abstract class SurfaceData
sg2d.clipState <= SunGraphics2D.CLIP_RECTANGULAR &&
sg2d.surfaceData.getTransparency() == Transparency.OPAQUE)
{
if (haveLCDLoop == LCDLOOP_UNKNOWN) {
if (haveLCDLoop == LOOP_UNKNOWN) {
DrawGlyphListLCD loop =
DrawGlyphListLCD.locate(SurfaceType.AnyColor,
CompositeType.SrcNoEa,
getSurfaceType());
haveLCDLoop = (loop!= null) ? LCDLOOP_FOUND : LCDLOOP_NOTFOUND;
haveLCDLoop = (loop != null) ? LOOP_FOUND : LOOP_NOTFOUND;
}
return haveLCDLoop == LCDLOOP_FOUND;
return haveLCDLoop == LOOP_FOUND;
}
return false; /* for now - in the future we may want to search */
}
public boolean canRenderParallelograms(SunGraphics2D sg2d) {
if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
if (sg2d.compositeState == sg2d.COMP_XOR) {
if (havePgramXORLoop == LOOP_UNKNOWN) {
FillParallelogram loop =
FillParallelogram.locate(SurfaceType.AnyColor,
CompositeType.Xor,
getSurfaceType());
havePgramXORLoop =
(loop != null) ? LOOP_FOUND : LOOP_NOTFOUND;
}
return havePgramXORLoop == LOOP_FOUND;
} else if (sg2d.compositeState <= sg2d.COMP_ISCOPY &&
sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
sg2d.clipState != sg2d.CLIP_SHAPE)
{
if (havePgramSolidLoop == LOOP_UNKNOWN) {
FillParallelogram loop =
FillParallelogram.locate(SurfaceType.AnyColor,
CompositeType.SrcNoEa,
getSurfaceType());
havePgramSolidLoop =
(loop != null) ? LOOP_FOUND : LOOP_NOTFOUND;
}
return havePgramSolidLoop == LOOP_FOUND;
}
}
return false;
}
public void validatePipe(SunGraphics2D sg2d) {
sg2d.imagepipe = imagepipe;
if (sg2d.compositeState == sg2d.COMP_XOR) {
@ -480,9 +546,21 @@ public abstract class SurfaceData
// text drawn in XOR mode with a Paint object.
sg2d.textpipe = outlineTextRenderer;
} else {
PixelToShapeConverter converter;
if (canRenderParallelograms(sg2d)) {
converter = colorViaPgram;
// Note that we use the transforming pipe here because it
// will examine the shape and possibly perform an optimized
// operation if it can be simplified. The simplifications
// will be valid for all STROKE and TRANSFORM types.
sg2d.shapepipe = colorViaPgram;
} else {
converter = colorViaShape;
sg2d.shapepipe = colorPrimitives;
}
if (sg2d.clipState == sg2d.CLIP_SHAPE) {
sg2d.drawpipe = colorViaShape;
sg2d.fillpipe = colorViaShape;
sg2d.drawpipe = converter;
sg2d.fillpipe = converter;
// REMIND: We should not be changing text strategies
// between outline and glyph rendering based upon the
// presence of a complex clip as that could cause a
@ -494,11 +572,11 @@ public abstract class SurfaceData
sg2d.textpipe = outlineTextRenderer;
} else {
if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
sg2d.drawpipe = colorViaShape;
sg2d.fillpipe = colorViaShape;
sg2d.drawpipe = converter;
sg2d.fillpipe = converter;
} else {
if (sg2d.strokeState != sg2d.STROKE_THIN) {
sg2d.drawpipe = colorViaShape;
sg2d.drawpipe = converter;
} else {
sg2d.drawpipe = colorPrimitives;
}
@ -506,7 +584,6 @@ public abstract class SurfaceData
}
sg2d.textpipe = solidTextRenderer;
}
sg2d.shapepipe = colorPrimitives;
// assert(sg2d.surfaceData == this);
}
} else if (sg2d.compositeState == sg2d.COMP_CUSTOM) {
@ -589,12 +666,24 @@ public abstract class SurfaceData
}
}
} else {
PixelToShapeConverter converter;
if (canRenderParallelograms(sg2d)) {
converter = colorViaPgram;
// Note that we use the transforming pipe here because it
// will examine the shape and possibly perform an optimized
// operation if it can be simplified. The simplifications
// will be valid for all STROKE and TRANSFORM types.
sg2d.shapepipe = colorViaPgram;
} else {
converter = colorViaShape;
sg2d.shapepipe = colorPrimitives;
}
if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
sg2d.drawpipe = colorViaShape;
sg2d.fillpipe = colorViaShape;
sg2d.drawpipe = converter;
sg2d.fillpipe = converter;
} else {
if (sg2d.strokeState != sg2d.STROKE_THIN) {
sg2d.drawpipe = colorViaShape;
sg2d.drawpipe = converter;
} else {
sg2d.drawpipe = colorPrimitives;
}
@ -602,7 +691,6 @@ public abstract class SurfaceData
}
sg2d.textpipe = getTextPipe(sg2d, false /* AA==OFF */);
sg2d.shapepipe = colorPrimitives;
// assert(sg2d.surfaceData == this);
}
@ -761,6 +849,8 @@ public abstract class SurfaceData
loops.drawPathLoop = DrawPath.locate(src, comp, dst);
loops.fillPathLoop = FillPath.locate(src, comp, dst);
loops.fillSpansLoop = FillSpans.locate(src, comp, dst);
loops.fillParallelogramLoop = FillParallelogram.locate(src, comp, dst);
loops.drawParallelogramLoop = DrawParallelogram.locate(src, comp, dst);
loops.drawGlyphListLoop = DrawGlyphList.locate(src, comp, dst);
loops.drawGlyphListAALoop = DrawGlyphListAA.locate(src, comp, dst);
loops.drawGlyphListLCDLoop = DrawGlyphListLCD.locate(src, comp, dst);

View File

@ -0,0 +1,123 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* 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.
*/
/*
* @author Jim Graham
*/
package sun.java2d.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
/**
* DrawParallelogram
* 1) fill the area between the 4 edges of an outer parallelogram
* (as specified by an origin and 2 delta vectors)
* but also outside the 4 edges of an inner parallelogram
* (as specified by proportional amounts of the outer delta vectors)
*/
public class DrawParallelogram extends GraphicsPrimitive
{
public final static String methodSignature =
"DrawParallelogram(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static DrawParallelogram locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (DrawParallelogram)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected DrawParallelogram(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID,
srctype, comptype, dsttype);
}
public DrawParallelogram(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID,
srctype, comptype, dsttype);
}
/**
* All DrawParallelogram implementors must have this invoker method
*/
public native void DrawParallelogram(SunGraphics2D sg, SurfaceData dest,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2);
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
// REMIND: iterate with a FillRect primitive?
throw new InternalError("DrawParallelogram not implemented for "+
srctype+" with "+comptype);
}
public GraphicsPrimitive traceWrap() {
return new TraceDrawParallelogram(this);
}
private static class TraceDrawParallelogram extends DrawParallelogram {
DrawParallelogram target;
public TraceDrawParallelogram(DrawParallelogram target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void DrawParallelogram(SunGraphics2D sg2d, SurfaceData dest,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2)
{
tracePrimitive(target);
target.DrawParallelogram(sg2d, dest,
x, y, dx1, dy1, dx2, dy2, lw1, lw2);
}
}
}

View File

@ -0,0 +1,118 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* 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.
*/
/*
* @author Jim Graham
*/
package sun.java2d.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
/**
* FillParallelogram
* 1) fill the area between the 4 edges of a parallelogram
* (as specified by an origin and 2 delta vectors)
*/
public class FillParallelogram extends GraphicsPrimitive
{
public final static String methodSignature =
"FillParallelogram(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static FillParallelogram locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (FillParallelogram)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected FillParallelogram(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID,
srctype, comptype, dsttype);
}
public FillParallelogram(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID,
srctype, comptype, dsttype);
}
/**
* All FillParallelogram implementors must have this invoker method
*/
public native void FillParallelogram(SunGraphics2D sg2d, SurfaceData dest,
double x0, double y0,
double dx1, double dy1,
double dx2, double dy2);
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
// REMIND: iterate with a FillRect primitive?
throw new InternalError("FillParallelogram not implemented for "+
srctype+" with "+comptype);
}
public GraphicsPrimitive traceWrap() {
return new TraceFillParallelogram(this);
}
private static class TraceFillParallelogram extends FillParallelogram {
FillParallelogram target;
public TraceFillParallelogram(FillParallelogram target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void FillParallelogram(SunGraphics2D sg2d, SurfaceData dest,
double x0, double y0,
double dx1, double dy1,
double dx2, double dy2)
{
tracePrimitive(target);
target.FillParallelogram(sg2d, dest, x0, y0, dx1, dy1, dx2, dy2);
}
}
}

View File

@ -47,6 +47,8 @@ public class RenderLoops {
public DrawPath drawPathLoop;
public FillPath fillPathLoop;
public FillSpans fillSpansLoop;
public FillParallelogram fillParallelogramLoop;
public DrawParallelogram drawParallelogramLoop;
public DrawGlyphList drawGlyphListLoop;
public DrawGlyphListAA drawGlyphListAALoop;
public DrawGlyphListLCD drawGlyphListLCDLoop;

View File

@ -41,11 +41,14 @@ import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import sun.java2d.loops.FontInfo;
import sun.java2d.loops.DrawPolygons;
import sun.java2d.loops.FillParallelogram;
import sun.java2d.loops.DrawParallelogram;
import sun.awt.SunHints;
public class LoopPipe
implements PixelDrawPipe,
PixelFillPipe,
ParallelogramPipe,
ShapeDrawPipe,
LoopBasedPipe
{
@ -347,4 +350,25 @@ public class LoopPipe
sg2d.loops.fillRectLoop.FillRect(sg2d, sd, x, y, w, h);
}
}
public void fillParallelogram(SunGraphics2D sg2d,
double x, double y,
double dx1, double dy1,
double dx2, double dy2)
{
FillParallelogram fp = sg2d.loops.fillParallelogramLoop;
fp.FillParallelogram(sg2d, sg2d.getSurfaceData(),
x, y, dx1, dy1, dx2, dy2);
}
public void drawParallelogram(SunGraphics2D sg2d,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2)
{
DrawParallelogram dp = sg2d.loops.drawParallelogramLoop;
dp.DrawParallelogram(sg2d, sg2d.getSurfaceData(),
x, y, dx1, dy1, dx2, dy2, lw1, lw2);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2010 Oracle and/or its affiliates. All rights reserved.
* 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,9 +29,9 @@ import sun.misc.FloatConsts;
import sun.misc.DoubleConsts;
/**
* The class <code>FpUtils</code> contains static utility methods for
* manipulating and inspecting <code>float</code> and
* <code>double</code> floating-point numbers. These methods include
* The class {@code FpUtils} contains static utility methods for
* manipulating and inspecting {@code float} and
* {@code double} floating-point numbers. These methods include
* functionality recommended or required by the IEEE 754
* floating-point standard.
*
@ -136,7 +136,7 @@ public class FpUtils {
// tests for exception cases.
/**
* Returns unbiased exponent of a <code>double</code>.
* Returns unbiased exponent of a {@code double}.
*/
public static int getExponent(double d){
/*
@ -149,7 +149,7 @@ public class FpUtils {
}
/**
* Returns unbiased exponent of a <code>float</code>.
* Returns unbiased exponent of a {@code float}.
*/
public static int getExponent(float f){
/*
@ -185,15 +185,15 @@ public class FpUtils {
* Returns the first floating-point argument with the sign of the
* second floating-point argument. Note that unlike the {@link
* FpUtils#copySign(double, double) copySign} method, this method
* does not require NaN <code>sign</code> arguments to be treated
* does not require NaN {@code sign} arguments to be treated
* as positive values; implementations are permitted to treat some
* NaN arguments as positive and other NaN arguments as negative
* to allow greater performance.
*
* @param magnitude the parameter providing the magnitude of the result
* @param sign the parameter providing the sign of the result
* @return a value with the magnitude of <code>magnitude</code>
* and the sign of <code>sign</code>.
* @return a value with the magnitude of {@code magnitude}
* and the sign of {@code sign}.
* @author Joseph D. Darcy
*/
public static double rawCopySign(double magnitude, double sign) {
@ -208,15 +208,15 @@ public class FpUtils {
* Returns the first floating-point argument with the sign of the
* second floating-point argument. Note that unlike the {@link
* FpUtils#copySign(float, float) copySign} method, this method
* does not require NaN <code>sign</code> arguments to be treated
* does not require NaN {@code sign} arguments to be treated
* as positive values; implementations are permitted to treat some
* NaN arguments as positive and other NaN arguments as negative
* to allow greater performance.
*
* @param magnitude the parameter providing the magnitude of the result
* @param sign the parameter providing the sign of the result
* @return a value with the magnitude of <code>magnitude</code>
* and the sign of <code>sign</code>.
* @return a value with the magnitude of {@code magnitude}
* and the sign of {@code sign}.
* @author Joseph D. Darcy
*/
public static float rawCopySign(float magnitude, float sign) {
@ -230,129 +230,129 @@ public class FpUtils {
/* ***************************************************************** */
/**
* Returns <code>true</code> if the argument is a finite
* floating-point value; returns <code>false</code> otherwise (for
* Returns {@code true} if the argument is a finite
* floating-point value; returns {@code false} otherwise (for
* NaN and infinity arguments).
*
* @param d the <code>double</code> value to be tested
* @return <code>true</code> if the argument is a finite
* floating-point value, <code>false</code> otherwise.
* @param d the {@code double} value to be tested
* @return {@code true} if the argument is a finite
* floating-point value, {@code false} otherwise.
*/
public static boolean isFinite(double d) {
return Math.abs(d) <= DoubleConsts.MAX_VALUE;
}
/**
* Returns <code>true</code> if the argument is a finite
* floating-point value; returns <code>false</code> otherwise (for
* Returns {@code true} if the argument is a finite
* floating-point value; returns {@code false} otherwise (for
* NaN and infinity arguments).
*
* @param f the <code>float</code> value to be tested
* @return <code>true</code> if the argument is a finite
* floating-point value, <code>false</code> otherwise.
* @param f the {@code float} value to be tested
* @return {@code true} if the argument is a finite
* floating-point value, {@code false} otherwise.
*/
public static boolean isFinite(float f) {
return Math.abs(f) <= FloatConsts.MAX_VALUE;
}
/**
* Returns <code>true</code> if the specified number is infinitely
* large in magnitude, <code>false</code> otherwise.
* Returns {@code true} if the specified number is infinitely
* large in magnitude, {@code false} otherwise.
*
* <p>Note that this method is equivalent to the {@link
* Double#isInfinite(double) Double.isInfinite} method; the
* functionality is included in this class for convenience.
*
* @param d the value to be tested.
* @return <code>true</code> if the value of the argument is positive
* infinity or negative infinity; <code>false</code> otherwise.
* @return {@code true} if the value of the argument is positive
* infinity or negative infinity; {@code false} otherwise.
*/
public static boolean isInfinite(double d) {
return Double.isInfinite(d);
}
/**
* Returns <code>true</code> if the specified number is infinitely
* large in magnitude, <code>false</code> otherwise.
* Returns {@code true} if the specified number is infinitely
* large in magnitude, {@code false} otherwise.
*
* <p>Note that this method is equivalent to the {@link
* Float#isInfinite(float) Float.isInfinite} method; the
* functionality is included in this class for convenience.
*
* @param f the value to be tested.
* @return <code>true</code> if the argument is positive infinity or
* negative infinity; <code>false</code> otherwise.
* @return {@code true} if the argument is positive infinity or
* negative infinity; {@code false} otherwise.
*/
public static boolean isInfinite(float f) {
return Float.isInfinite(f);
}
/**
* Returns <code>true</code> if the specified number is a
* Not-a-Number (NaN) value, <code>false</code> otherwise.
* Returns {@code true} if the specified number is a
* Not-a-Number (NaN) value, {@code false} otherwise.
*
* <p>Note that this method is equivalent to the {@link
* Double#isNaN(double) Double.isNaN} method; the functionality is
* included in this class for convenience.
*
* @param d the value to be tested.
* @return <code>true</code> if the value of the argument is NaN;
* <code>false</code> otherwise.
* @return {@code true} if the value of the argument is NaN;
* {@code false} otherwise.
*/
public static boolean isNaN(double d) {
return Double.isNaN(d);
}
/**
* Returns <code>true</code> if the specified number is a
* Not-a-Number (NaN) value, <code>false</code> otherwise.
* Returns {@code true} if the specified number is a
* Not-a-Number (NaN) value, {@code false} otherwise.
*
* <p>Note that this method is equivalent to the {@link
* Float#isNaN(float) Float.isNaN} method; the functionality is
* included in this class for convenience.
*
* @param f the value to be tested.
* @return <code>true</code> if the argument is NaN;
* <code>false</code> otherwise.
* @return {@code true} if the argument is NaN;
* {@code false} otherwise.
*/
public static boolean isNaN(float f) {
return Float.isNaN(f);
}
/**
* Returns <code>true</code> if the unordered relation holds
* Returns {@code true} if the unordered relation holds
* between the two arguments. When two floating-point values are
* unordered, one value is neither less than, equal to, nor
* greater than the other. For the unordered relation to be true,
* at least one argument must be a <code>NaN</code>.
* at least one argument must be a {@code NaN}.
*
* @param arg1 the first argument
* @param arg2 the second argument
* @return <code>true</code> if at least one argument is a NaN,
* <code>false</code> otherwise.
* @return {@code true} if at least one argument is a NaN,
* {@code false} otherwise.
*/
public static boolean isUnordered(double arg1, double arg2) {
return isNaN(arg1) || isNaN(arg2);
}
/**
* Returns <code>true</code> if the unordered relation holds
* Returns {@code true} if the unordered relation holds
* between the two arguments. When two floating-point values are
* unordered, one value is neither less than, equal to, nor
* greater than the other. For the unordered relation to be true,
* at least one argument must be a <code>NaN</code>.
* at least one argument must be a {@code NaN}.
*
* @param arg1 the first argument
* @param arg2 the second argument
* @return <code>true</code> if at least one argument is a NaN,
* <code>false</code> otherwise.
* @return {@code true} if at least one argument is a NaN,
* {@code false} otherwise.
*/
public static boolean isUnordered(float arg1, float arg2) {
return isNaN(arg1) || isNaN(arg2);
}
/**
* Returns unbiased exponent of a <code>double</code>; for
* Returns unbiased exponent of a {@code double}; for
* subnormal values, the number is treated as if it were
* normalized. That is for all finite, non-zero, positive numbers
* <i>x</i>, <code>scalb(<i>x</i>, -ilogb(<i>x</i>))</code> is
@ -378,7 +378,6 @@ public class FpUtils {
return (1<<30); // 2^30
else // infinite value
return (1<<28); // 2^28
// break;
case DoubleConsts.MIN_EXPONENT-1: // zero or subnormal
if(d == 0.0) {
@ -414,18 +413,16 @@ public class FpUtils {
exponent < DoubleConsts.MIN_EXPONENT);
return exponent;
}
// break;
default:
assert( exponent >= DoubleConsts.MIN_EXPONENT &&
exponent <= DoubleConsts.MAX_EXPONENT);
return exponent;
// break;
}
}
/**
* Returns unbiased exponent of a <code>float</code>; for
* Returns unbiased exponent of a {@code float}; for
* subnormal values, the number is treated as if it were
* normalized. That is for all finite, non-zero, positive numbers
* <i>x</i>, <code>scalb(<i>x</i>, -ilogb(<i>x</i>))</code> is
@ -451,7 +448,6 @@ public class FpUtils {
return (1<<30); // 2^30
else // infinite value
return (1<<28); // 2^28
// break;
case FloatConsts.MIN_EXPONENT-1: // zero or subnormal
if(f == 0.0f) {
@ -487,13 +483,11 @@ public class FpUtils {
exponent < FloatConsts.MIN_EXPONENT);
return exponent;
}
// break;
default:
assert( exponent >= FloatConsts.MIN_EXPONENT &&
exponent <= FloatConsts.MAX_EXPONENT);
return exponent;
// break;
}
}
@ -534,22 +528,22 @@ public class FpUtils {
*/
/**
* Return <code>d</code> &times;
* 2<sup><code>scale_factor</code></sup> rounded as if performed
* Return {@code d} &times;
* 2<sup>{@code scale_factor}</sup> rounded as if performed
* by a single correctly rounded floating-point multiply to a
* member of the double value set. See <a
* href="http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html#9208">&sect;4.2.3</a>
* of the <a href="http://java.sun.com/docs/books/jls/html/">Java
* Language Specification</a> for a discussion of floating-point
* value sets. If the exponent of the result is between the
* <code>double</code>'s minimum exponent and maximum exponent,
* {@code double}'s minimum exponent and maximum exponent,
* the answer is calculated exactly. If the exponent of the
* result would be larger than <code>doubles</code>'s maximum
* result would be larger than {@code doubles}'s maximum
* exponent, an infinity is returned. Note that if the result is
* subnormal, precision may be lost; that is, when <code>scalb(x,
* n)</code> is subnormal, <code>scalb(scalb(x, n), -n)</code> may
* subnormal, precision may be lost; that is, when {@code scalb(x,
* n)} is subnormal, {@code scalb(scalb(x, n), -n)} may
* not equal <i>x</i>. When the result is non-NaN, the result has
* the same sign as <code>d</code>.
* the same sign as {@code d}.
*
*<p>
* Special cases:
@ -562,8 +556,8 @@ public class FpUtils {
* </ul>
*
* @param d number to be scaled by a power of two.
* @param scale_factor power of 2 used to scale <code>d</code>
* @return <code>d * </code>2<sup><code>scale_factor</code></sup>
* @param scale_factor power of 2 used to scale {@code d}
* @return {@code d * }2<sup>{@code scale_factor}</sup>
* @author Joseph D. Darcy
*/
public static double scalb(double d, int scale_factor) {
@ -644,22 +638,22 @@ public class FpUtils {
}
/**
* Return <code>f </code>&times;
* 2<sup><code>scale_factor</code></sup> rounded as if performed
* Return {@code f} &times;
* 2<sup>{@code scale_factor}</sup> rounded as if performed
* by a single correctly rounded floating-point multiply to a
* member of the float value set. See <a
* href="http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html#9208">&sect;4.2.3</a>
* of the <a href="http://java.sun.com/docs/books/jls/html/">Java
* Language Specification</a> for a discussion of floating-point
* value set. If the exponent of the result is between the
* <code>float</code>'s minimum exponent and maximum exponent, the
* {@code float}'s minimum exponent and maximum exponent, the
* answer is calculated exactly. If the exponent of the result
* would be larger than <code>float</code>'s maximum exponent, an
* would be larger than {@code float}'s maximum exponent, an
* infinity is returned. Note that if the result is subnormal,
* precision may be lost; that is, when <code>scalb(x, n)</code>
* is subnormal, <code>scalb(scalb(x, n), -n)</code> may not equal
* precision may be lost; that is, when {@code scalb(x, n)}
* is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
* <i>x</i>. When the result is non-NaN, the result has the same
* sign as <code>f</code>.
* sign as {@code f}.
*
*<p>
* Special cases:
@ -672,8 +666,8 @@ public class FpUtils {
* </ul>
*
* @param f number to be scaled by a power of two.
* @param scale_factor power of 2 used to scale <code>f</code>
* @return <code>f * </code>2<sup><code>scale_factor</code></sup>
* @param scale_factor power of 2 used to scale {@code f}
* @return {@code f * }2<sup>{@code scale_factor}</sup>
* @author Joseph D. Darcy
*/
public static float scalb(float f, int scale_factor) {
@ -709,34 +703,34 @@ public class FpUtils {
* <ul>
* <li> If either argument is a NaN, then NaN is returned.
*
* <li> If both arguments are signed zeros, <code>direction</code>
* <li> If both arguments are signed zeros, {@code direction}
* is returned unchanged (as implied by the requirement of
* returning the second argument if the arguments compare as
* equal).
*
* <li> If <code>start</code> is
* &plusmn;<code>Double.MIN_VALUE</code> and <code>direction</code>
* <li> If {@code start} is
* &plusmn;{@code Double.MIN_VALUE} and {@code direction}
* has a value such that the result should have a smaller
* magnitude, then a zero with the same sign as <code>start</code>
* magnitude, then a zero with the same sign as {@code start}
* is returned.
*
* <li> If <code>start</code> is infinite and
* <code>direction</code> has a value such that the result should
* have a smaller magnitude, <code>Double.MAX_VALUE</code> with the
* same sign as <code>start</code> is returned.
* <li> If {@code start} is infinite and
* {@code direction} has a value such that the result should
* have a smaller magnitude, {@code Double.MAX_VALUE} with the
* same sign as {@code start} is returned.
*
* <li> If <code>start</code> is equal to &plusmn;
* <code>Double.MAX_VALUE</code> and <code>direction</code> has a
* <li> If {@code start} is equal to &plusmn;
* {@code Double.MAX_VALUE} and {@code direction} has a
* value such that the result should have a larger magnitude, an
* infinity with same sign as <code>start</code> is returned.
* infinity with same sign as {@code start} is returned.
* </ul>
*
* @param start starting floating-point value
* @param direction value indicating which of
* <code>start</code>'s neighbors or <code>start</code> should
* {@code start}'s neighbors or {@code start} should
* be returned
* @return The floating-point number adjacent to <code>start</code> in the
* direction of <code>direction</code>.
* @return The floating-point number adjacent to {@code start} in the
* direction of {@code direction}.
* @author Joseph D. Darcy
*/
public static double nextAfter(double start, double direction) {
@ -809,34 +803,34 @@ public class FpUtils {
* <ul>
* <li> If either argument is a NaN, then NaN is returned.
*
* <li> If both arguments are signed zeros, a <code>float</code>
* zero with the same sign as <code>direction</code> is returned
* <li> If both arguments are signed zeros, a {@code float}
* zero with the same sign as {@code direction} is returned
* (as implied by the requirement of returning the second argument
* if the arguments compare as equal).
*
* <li> If <code>start</code> is
* &plusmn;<code>Float.MIN_VALUE</code> and <code>direction</code>
* <li> If {@code start} is
* &plusmn;{@code Float.MIN_VALUE} and {@code direction}
* has a value such that the result should have a smaller
* magnitude, then a zero with the same sign as <code>start</code>
* magnitude, then a zero with the same sign as {@code start}
* is returned.
*
* <li> If <code>start</code> is infinite and
* <code>direction</code> has a value such that the result should
* have a smaller magnitude, <code>Float.MAX_VALUE</code> with the
* same sign as <code>start</code> is returned.
* <li> If {@code start} is infinite and
* {@code direction} has a value such that the result should
* have a smaller magnitude, {@code Float.MAX_VALUE} with the
* same sign as {@code start} is returned.
*
* <li> If <code>start</code> is equal to &plusmn;
* <code>Float.MAX_VALUE</code> and <code>direction</code> has a
* <li> If {@code start} is equal to &plusmn;
* {@code Float.MAX_VALUE} and {@code direction} has a
* value such that the result should have a larger magnitude, an
* infinity with same sign as <code>start</code> is returned.
* infinity with same sign as {@code start} is returned.
* </ul>
*
* @param start starting floating-point value
* @param direction value indicating which of
* <code>start</code>'s neighbors or <code>start</code> should
* {@code start}'s neighbors or {@code start} should
* be returned
* @return The floating-point number adjacent to <code>start</code> in the
* direction of <code>direction</code>.
* @return The floating-point number adjacent to {@code start} in the
* direction of {@code direction}.
* @author Joseph D. Darcy
*/
public static float nextAfter(float start, double direction) {
@ -900,12 +894,12 @@ public class FpUtils {
}
/**
* Returns the floating-point value adjacent to <code>d</code> in
* Returns the floating-point value adjacent to {@code d} in
* the direction of positive infinity. This method is
* semantically equivalent to <code>nextAfter(d,
* Double.POSITIVE_INFINITY)</code>; however, a <code>nextUp</code>
* semantically equivalent to {@code nextAfter(d,
* Double.POSITIVE_INFINITY)}; however, a {@code nextUp}
* implementation may run faster than its equivalent
* <code>nextAfter</code> call.
* {@code nextAfter} call.
*
* <p>Special Cases:
* <ul>
@ -915,7 +909,7 @@ public class FpUtils {
* positive infinity.
*
* <li> If the argument is zero, the result is
* <code>Double.MIN_VALUE</code>
* {@code Double.MIN_VALUE}
*
* </ul>
*
@ -935,12 +929,12 @@ public class FpUtils {
}
/**
* Returns the floating-point value adjacent to <code>f</code> in
* Returns the floating-point value adjacent to {@code f} in
* the direction of positive infinity. This method is
* semantically equivalent to <code>nextAfter(f,
* Double.POSITIVE_INFINITY)</code>; however, a <code>nextUp</code>
* semantically equivalent to {@code nextAfter(f,
* Double.POSITIVE_INFINITY)}; however, a {@code nextUp}
* implementation may run faster than its equivalent
* <code>nextAfter</code> call.
* {@code nextAfter} call.
*
* <p>Special Cases:
* <ul>
@ -950,7 +944,7 @@ public class FpUtils {
* positive infinity.
*
* <li> If the argument is zero, the result is
* <code>Float.MIN_VALUE</code>
* {@code Float.MIN_VALUE}
*
* </ul>
*
@ -970,12 +964,12 @@ public class FpUtils {
}
/**
* Returns the floating-point value adjacent to <code>d</code> in
* Returns the floating-point value adjacent to {@code d} in
* the direction of negative infinity. This method is
* semantically equivalent to <code>nextAfter(d,
* Double.NEGATIVE_INFINITY)</code>; however, a
* <code>nextDown</code> implementation may run faster than its
* equivalent <code>nextAfter</code> call.
* semantically equivalent to {@code nextAfter(d,
* Double.NEGATIVE_INFINITY)}; however, a
* {@code nextDown} implementation may run faster than its
* equivalent {@code nextAfter} call.
*
* <p>Special Cases:
* <ul>
@ -985,7 +979,7 @@ public class FpUtils {
* negative infinity.
*
* <li> If the argument is zero, the result is
* <code>-Double.MIN_VALUE</code>
* {@code -Double.MIN_VALUE}
*
* </ul>
*
@ -1007,12 +1001,12 @@ public class FpUtils {
}
/**
* Returns the floating-point value adjacent to <code>f</code> in
* Returns the floating-point value adjacent to {@code f} in
* the direction of negative infinity. This method is
* semantically equivalent to <code>nextAfter(f,
* Float.NEGATIVE_INFINITY)</code>; however, a
* <code>nextDown</code> implementation may run faster than its
* equivalent <code>nextAfter</code> call.
* semantically equivalent to {@code nextAfter(f,
* Float.NEGATIVE_INFINITY)}; however, a
* {@code nextDown} implementation may run faster than its
* equivalent {@code nextAfter} call.
*
* <p>Special Cases:
* <ul>
@ -1022,7 +1016,7 @@ public class FpUtils {
* negative infinity.
*
* <li> If the argument is zero, the result is
* <code>-Float.MIN_VALUE</code>
* {@code -Float.MIN_VALUE}
*
* </ul>
*
@ -1046,13 +1040,13 @@ public class FpUtils {
/**
* Returns the first floating-point argument with the sign of the
* second floating-point argument. For this method, a NaN
* <code>sign</code> argument is always treated as if it were
* {@code sign} argument is always treated as if it were
* positive.
*
* @param magnitude the parameter providing the magnitude of the result
* @param sign the parameter providing the sign of the result
* @return a value with the magnitude of <code>magnitude</code>
* and the sign of <code>sign</code>.
* @return a value with the magnitude of {@code magnitude}
* and the sign of {@code sign}.
* @author Joseph D. Darcy
* @since 1.5
*/
@ -1063,13 +1057,13 @@ public class FpUtils {
/**
* Returns the first floating-point argument with the sign of the
* second floating-point argument. For this method, a NaN
* <code>sign</code> argument is always treated as if it were
* {@code sign} argument is always treated as if it were
* positive.
*
* @param magnitude the parameter providing the magnitude of the result
* @param sign the parameter providing the sign of the result
* @return a value with the magnitude of <code>magnitude</code>
* and the sign of <code>sign</code>.
* @return a value with the magnitude of {@code magnitude}
* and the sign of {@code sign}.
* @author Joseph D. Darcy
*/
public static float copySign(float magnitude, float sign) {
@ -1078,8 +1072,8 @@ public class FpUtils {
/**
* Returns the size of an ulp of the argument. An ulp of a
* <code>double</code> value is the positive distance between this
* floating-point value and the <code>double</code> value next
* {@code double} value is the positive distance between this
* floating-point value and the {@code double} value next
* larger in magnitude. Note that for non-NaN <i>x</i>,
* <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
*
@ -1089,8 +1083,8 @@ public class FpUtils {
* <li> If the argument is positive or negative infinity, then the
* result is positive infinity.
* <li> If the argument is positive or negative zero, then the result is
* <code>Double.MIN_VALUE</code>.
* <li> If the argument is &plusmn;<code>Double.MAX_VALUE</code>, then
* {@code Double.MIN_VALUE}.
* <li> If the argument is &plusmn;{@code Double.MAX_VALUE}, then
* the result is equal to 2<sup>971</sup>.
* </ul>
*
@ -1105,11 +1099,9 @@ public class FpUtils {
switch(exp) {
case DoubleConsts.MAX_EXPONENT+1: // NaN or infinity
return Math.abs(d);
// break;
case DoubleConsts.MIN_EXPONENT-1: // zero or subnormal
return Double.MIN_VALUE;
// break
default:
assert exp <= DoubleConsts.MAX_EXPONENT && exp >= DoubleConsts.MIN_EXPONENT;
@ -1126,14 +1118,13 @@ public class FpUtils {
return Double.longBitsToDouble(1L <<
(exp - (DoubleConsts.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1)) ));
}
// break
}
}
/**
* Returns the size of an ulp of the argument. An ulp of a
* <code>float</code> value is the positive distance between this
* floating-point value and the <code>float</code> value next
* {@code float} value is the positive distance between this
* floating-point value and the {@code float} value next
* larger in magnitude. Note that for non-NaN <i>x</i>,
* <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
*
@ -1143,8 +1134,8 @@ public class FpUtils {
* <li> If the argument is positive or negative infinity, then the
* result is positive infinity.
* <li> If the argument is positive or negative zero, then the result is
* <code>Float.MIN_VALUE</code>.
* <li> If the argument is &plusmn;<code>Float.MAX_VALUE</code>, then
* {@code Float.MIN_VALUE}.
* <li> If the argument is &plusmn;{@code Float.MAX_VALUE}, then
* the result is equal to 2<sup>104</sup>.
* </ul>
*
@ -1159,11 +1150,9 @@ public class FpUtils {
switch(exp) {
case FloatConsts.MAX_EXPONENT+1: // NaN or infinity
return Math.abs(f);
// break;
case FloatConsts.MIN_EXPONENT-1: // zero or subnormal
return FloatConsts.MIN_VALUE;
// break
default:
assert exp <= FloatConsts.MAX_EXPONENT && exp >= FloatConsts.MIN_EXPONENT;
@ -1180,7 +1169,6 @@ public class FpUtils {
return Float.intBitsToFloat(1 <<
(exp - (FloatConsts.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1)) ));
}
// break
}
}

View File

@ -25,6 +25,7 @@
package sun.misc;
import static java.lang.Thread.State.*;
import java.util.Properties;
import java.util.HashMap;
import java.util.Map;
@ -332,69 +333,37 @@ public class VM {
}
}
/**
* Returns Thread.State for the given threadStatus
*/
public static Thread.State toThreadState(int threadStatus) {
// Initialize the threadStateMap
initThreadStateMap();
Thread.State s = threadStateMap.get(threadStatus);
if (s == null) {
// default to RUNNABLE if the threadStatus value is unknown
s = Thread.State.RUNNABLE;
}
return s;
}
// a map of threadStatus values to the corresponding Thread.State
private static Map<Integer, Thread.State> threadStateMap = null;
private static Map<Integer, String> threadStateNames = null;
private synchronized static void initThreadStateMap() {
if (threadStateMap != null) {
return;
}
final Thread.State[] ts = Thread.State.values();
final int[][] vmThreadStateValues = new int[ts.length][];
final String[][] vmThreadStateNames = new String[ts.length][];
getThreadStateValues(vmThreadStateValues, vmThreadStateNames);
threadStateMap = new HashMap<Integer, Thread.State>();
threadStateNames = new HashMap<Integer, String>();
for (int i = 0; i < ts.length; i++) {
String state = ts[i].name();
int[] values = null;
String[] names = null;
for (int j = 0; j < ts.length; j++) {
if (vmThreadStateNames[j][0].startsWith(state)) {
values = vmThreadStateValues[j];
names = vmThreadStateNames[j];
}
}
if (values == null) {
throw new InternalError("No VM thread state mapped to " +
state);
}
if (values.length != names.length) {
throw new InternalError("VM thread state values and names " +
" mapped to " + state + ": length not matched" );
}
for (int k = 0; k < values.length; k++) {
threadStateMap.put(values[k], ts[i]);
threadStateNames.put(values[k], names[k]);
}
if ((threadStatus & JVMTI_THREAD_STATE_RUNNABLE) != 0) {
return RUNNABLE;
} else if ((threadStatus & JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) != 0) {
return BLOCKED;
} else if ((threadStatus & JVMTI_THREAD_STATE_WAITING_INDEFINITELY) != 0) {
return WAITING;
} else if ((threadStatus & JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT) != 0) {
return TIMED_WAITING;
} else if ((threadStatus & JVMTI_THREAD_STATE_TERMINATED) != 0) {
return TERMINATED;
} else if ((threadStatus & JVMTI_THREAD_STATE_ALIVE) == 0) {
return NEW;
} else {
return RUNNABLE;
}
}
// Fill in vmThreadStateValues with int arrays, each of which contains
// the threadStatus values mapping to the Thread.State enum constant.
// Fill in vmThreadStateNames with String arrays, each of which contains
// the name of each threadStatus value of the format:
// <Thread.State.name()>[.<Substate name>]
// e.g. WAITING.OBJECT_WAIT
//
private native static void getThreadStateValues(int[][] vmThreadStateValues,
String[][] vmThreadStateNames);
/* The threadStatus field is set by the VM at state transition
* in the hotspot implementation. Its value is set according to
* the JVM TI specification GetThreadState function.
*/
private final static int JVMTI_THREAD_STATE_ALIVE = 0x0001;
private final static int JVMTI_THREAD_STATE_TERMINATED = 0x0002;
private final static int JVMTI_THREAD_STATE_RUNNABLE = 0x0004;
private final static int JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400;
private final static int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010;
private final static int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020;
static {
initialize();

View File

@ -129,9 +129,22 @@ class Request {
hdrs = new Headers();
char s[] = new char[10];
int len = 0;
int firstc = is.read();
// check for empty headers
if (firstc == CR || firstc == LF) {
int c = is.read();
if (c == CR || c == LF) {
return hdrs;
}
s[0] = (char)firstc;
len = 1;
firstc = c;
}
while (firstc != LF && firstc != CR && firstc >= 0) {
int len = 0;
int keyend = -1;
int c;
boolean inKey = firstc > ' ';
@ -191,6 +204,7 @@ class Request {
else
v = String.copyValueOf(s, keyend, len - keyend);
hdrs.add (k,v);
len = 0;
}
return hdrs;
}

View File

@ -74,8 +74,8 @@ class SSLStreams {
private void configureEngine(HttpsConfigurator cfg, InetSocketAddress addr){
if (cfg != null) {
Parameters params = new Parameters (cfg, addr);
cfg.configure (params);
//BEGIN_TIGER_EXCLUDE
cfg.configure (params);
SSLParameters sslParams = params.getSSLParameters();
if (sslParams != null) {
engine.setSSLParameters (sslParams);

Some files were not shown because too many files have changed in this diff Show More