Merge
This commit is contained in:
commit
5973e18697
@ -40,6 +40,7 @@ allfonts.devanagari=Mangal
|
||||
allfonts.dingbats=Wingdings
|
||||
allfonts.lucida=Lucida Sans Regular
|
||||
allfonts.symbol=Symbol
|
||||
allfonts.symbols=Segoe UI Symbol
|
||||
allfonts.thai=Lucida Sans Regular
|
||||
allfonts.georgian=Sylfaen
|
||||
|
||||
@ -236,7 +237,7 @@ sequence.dialoginput.x-windows-949=alphabetic,korean,dingbats,symbol
|
||||
|
||||
sequence.allfonts.x-windows-874=alphabetic,thai,dingbats,symbol
|
||||
|
||||
sequence.fallback=lucida,\
|
||||
sequence.fallback=lucida,symbols,\
|
||||
chinese-ms950,chinese-hkscs,chinese-ms936,chinese-gb18030,\
|
||||
japanese,korean,chinese-ms950-extb,chinese-ms936-extb,georgian
|
||||
|
||||
@ -298,3 +299,4 @@ filename.Symbol=SYMBOL.TTF
|
||||
filename.Wingdings=WINGDING.TTF
|
||||
|
||||
filename.Sylfaen=sylfaen.ttf
|
||||
filename.Segoe_UI_Symbol=SEGUISYM.TTF
|
||||
|
@ -21,4 +21,4 @@
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
tzdata2015f
|
||||
tzdata2015g
|
||||
|
@ -154,7 +154,8 @@ Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2
|
||||
# Azerbaijan
|
||||
# From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23):
|
||||
# According to the resolution of Cabinet of Ministers, 1997
|
||||
# Resolution available at: http://aif.az/docs/daylight_res.pdf
|
||||
# From Paul Eggert (2015-09-17): It was Resolution No. 21 (1997-03-17).
|
||||
# http://code.az/files/daylight_res.pdf
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Azer 1997 max - Mar lastSun 4:00 1:00 S
|
||||
Rule Azer 1997 max - Oct lastSun 5:00 0 -
|
||||
@ -1740,11 +1741,12 @@ Rule ROK 1987 1988 - Oct Sun>=8 3:00 0 S
|
||||
# the 8:30 time zone on August 15, one example:
|
||||
# http://www.bbc.com/news/world-asia-33815049
|
||||
#
|
||||
# From Paul Eggert (2015-08-07):
|
||||
# No transition time is specified; assume 00:00.
|
||||
# From Paul Eggert (2015-08-15):
|
||||
# Bells rang out midnight (00:00) Friday as part of the celebrations. See:
|
||||
# Talmadge E. North Korea celebrates new time zone, 'Pyongyang Time'
|
||||
# http://news.yahoo.com/north-korea-celebrates-time-zone-pyongyang-time-164038128.html
|
||||
# There is no common English-language abbreviation for this time zone.
|
||||
# Use %z rather than invent one. We can't assume %z works everywhere yet,
|
||||
# so for now substitute its output manually.
|
||||
# Use KST, as that's what we already use for 1954-1961 in ROK.
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Asia/Seoul 8:27:52 - LMT 1908 Apr 1
|
||||
@ -1758,7 +1760,7 @@ Zone Asia/Pyongyang 8:23:00 - LMT 1908 Apr 1
|
||||
8:30 - KST 1912 Jan 1
|
||||
9:00 - JCST 1937 Oct 1
|
||||
9:00 - JST 1945 Aug 24
|
||||
9:00 - KST 2015 Aug 15
|
||||
9:00 - KST 2015 Aug 15 00:00
|
||||
8:30 - KST
|
||||
|
||||
###############################################################################
|
||||
|
@ -358,10 +358,17 @@ Zone Indian/Cocos 6:27:40 - LMT 1900
|
||||
# DST will start Nov. 2 this year.
|
||||
# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-NOVEMBER-2ND.aspx
|
||||
|
||||
# From Paul Eggert (2014-10-20):
|
||||
# From a government order dated 2015-08-26 and published as Legal Notice No. 77
|
||||
# in the Government of Fiji Gazette Supplement No. 24 (2015-08-28),
|
||||
# via Ken Rylander (2015-09-02):
|
||||
# the daylight saving period is 1 hour in advance of the standard time
|
||||
# commencing at 2.00 am on Sunday 1st November, 2015 and ending at
|
||||
# 3.00 am on Sunday 17th January, 2016.
|
||||
|
||||
# From Paul Eggert (2015-09-01):
|
||||
# For now, guess DST from 02:00 the first Sunday in November to
|
||||
# 03:00 the first Sunday on or after January 18. Although ad hoc, it
|
||||
# matches this year's plan and seems more likely to match future
|
||||
# 03:00 the third Sunday in January. Although ad hoc, it matches
|
||||
# transitions since late 2014 and seems more likely to match future
|
||||
# practice than guessing no DST.
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
@ -374,7 +381,7 @@ Rule Fiji 2011 only - Mar Sun>=1 3:00 0 -
|
||||
Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 -
|
||||
Rule Fiji 2014 only - Jan Sun>=18 2:00 0 -
|
||||
Rule Fiji 2014 max - Nov Sun>=1 2:00 1:00 S
|
||||
Rule Fiji 2015 max - Jan Sun>=18 3:00 0 -
|
||||
Rule Fiji 2015 max - Jan Sun>=15 3:00 0 -
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva
|
||||
12:00 Fiji FJ%sT # Fiji Time
|
||||
@ -533,7 +540,10 @@ Zone Pacific/Niue -11:19:40 - LMT 1901 # Alofi
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Pacific/Norfolk 11:11:52 - LMT 1901 # Kingston
|
||||
11:12 - NMT 1951 # Norfolk Mean Time
|
||||
11:30 - NFT # Norfolk Time
|
||||
11:30 - NFT 1974 Oct 27 02:00 # Norfolk T.
|
||||
11:30 1:00 NFST 1975 Mar 2 02:00
|
||||
11:30 - NFT 2015 Oct 4 02:00
|
||||
11:00 - NFT
|
||||
|
||||
# Palau (Belau)
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
@ -1573,6 +1583,20 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
|
||||
# started DST on June 3. Possibly DST was observed other years
|
||||
# in Midway, but we have no record of it.
|
||||
|
||||
# Norfolk
|
||||
|
||||
# From Alexander Krivenyshev (2015-09-23):
|
||||
# Norfolk Island will change ... from +1130 to +1100:
|
||||
# https://www.comlaw.gov.au/Details/F2015L01483/Explanatory%20Statement/Text
|
||||
# ... at 12.30 am (by legal time in New South Wales) on 4 October 2015.
|
||||
# http://www.norfolkisland.gov.nf/nia/MediaRelease/Media%20Release%20Norfolk%20Island%20Standard%20Time%20Change.pdf
|
||||
|
||||
# From Paul Eggert (2015-09-23):
|
||||
# Transitions before 2015 are from timeanddate.com, which consulted
|
||||
# the Norfolk Island Museum and the Australian Bureau of Meteorology's
|
||||
# Norfolk Island station, and found no record of Norfolk observing DST
|
||||
# other than in 1974/5. See:
|
||||
# http://www.timeanddate.com/time/australia/norfolk-island.html
|
||||
|
||||
# Pitcairn
|
||||
|
||||
|
@ -3173,6 +3173,11 @@ Zone Europe/Zurich 0:34:08 - LMT 1853 Jul 16 # See above comment.
|
||||
# http://www.balkaneu.com/eventful-elections-turkey/ 2014-03-30.
|
||||
# I guess the best we can do is document the official time.
|
||||
|
||||
# From Fatih (2015-09-29):
|
||||
# It's officially announced now by the Ministry of Energy.
|
||||
# Turkey delays winter time to 8th of November 04:00
|
||||
# http://www.aa.com.tr/tr/turkiye/yaz-saati-uygulamasi-8-kasimda-sona-erecek/362217
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Turkey 1916 only - May 1 0:00 1:00 S
|
||||
Rule Turkey 1916 only - Oct 1 0:00 0 -
|
||||
@ -3242,6 +3247,8 @@ Zone Europe/Istanbul 1:55:52 - LMT 1880
|
||||
2:00 - EET 2011 Mar 28 1:00u
|
||||
2:00 EU EE%sT 2014 Mar 30 1:00u
|
||||
2:00 - EET 2014 Mar 31 1:00u
|
||||
2:00 EU EE%sT 2015 Oct 25 1:00u
|
||||
2:00 1:00 EEST 2015 Nov 8 1:00u
|
||||
2:00 EU EE%sT
|
||||
Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents.
|
||||
|
||||
|
@ -1849,6 +1849,22 @@ Zone America/Edmonton -7:33:52 - LMT 1906 Sep
|
||||
|
||||
# The transition dates (and times) are guesses.
|
||||
|
||||
# From Matt Johnson (2015-09-21):
|
||||
# Fort Nelson, BC, Canada will cancel DST this year. So while previously they
|
||||
# were aligned with America/Vancouver, they're now aligned with
|
||||
# America/Dawson_Creek.
|
||||
# http://www.northernrockies.ca/EN/meta/news/archives/2015/northern-rockies-time-change.html
|
||||
#
|
||||
# From Tim Parenti (2015-09-23):
|
||||
# This requires a new zone for the Northern Rockies Regional Municipality,
|
||||
# America/Fort_Nelson. The resolution of 2014-12-08 was reached following a
|
||||
# 2014-11-15 poll with nearly 75% support. Effectively, the municipality has
|
||||
# been on MST (-0700) like Dawson Creek since it advanced its clocks on
|
||||
# 2015-03-08.
|
||||
#
|
||||
# From Paul Eggert (2015-09-23):
|
||||
# Shanks says Fort Nelson did not observe DST in 1946, unlike Vancouver.
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Vanc 1918 only - Apr 14 2:00 1:00 D
|
||||
Rule Vanc 1918 only - Oct 27 2:00 0 S
|
||||
@ -1867,6 +1883,12 @@ Zone America/Dawson_Creek -8:00:56 - LMT 1884
|
||||
-8:00 Canada P%sT 1947
|
||||
-8:00 Vanc P%sT 1972 Aug 30 2:00
|
||||
-7:00 - MST
|
||||
Zone America/Fort_Nelson -8:10:47 - LMT 1884
|
||||
-8:00 Vanc P%sT 1946
|
||||
-8:00 - PST 1947
|
||||
-8:00 Vanc P%sT 1987
|
||||
-8:00 Canada P%sT 2015 Mar 8 2:00
|
||||
-7:00 - MST
|
||||
Zone America/Creston -7:46:04 - LMT 1884
|
||||
-7:00 - MST 1916 Oct 1
|
||||
-8:00 - PST 1918 Jun 2
|
||||
|
@ -152,6 +152,7 @@ CA +6227-11421 America/Yellowknife Mountain Time - central Northwest Territories
|
||||
CA +682059-1334300 America/Inuvik Mountain Time - west Northwest Territories
|
||||
CA +4906-11631 America/Creston Mountain Standard Time - Creston, British Columbia
|
||||
CA +5946-12014 America/Dawson_Creek Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
|
||||
CA +5848-12242 America/Fort_Nelson Mountain Standard Time - Fort Nelson, British Columbia
|
||||
CA +4916-12307 America/Vancouver Pacific Time - west British Columbia
|
||||
CA +6043-13503 America/Whitehorse Pacific Time - south Yukon
|
||||
CA +6404-13925 America/Dawson Pacific Time - north Yukon
|
||||
|
@ -93,8 +93,7 @@ define SetupCompileProperties
|
||||
$$($1_TARGET): $$($1_SRCS) $$($1_JAVAS) $(BUILD_TOOLS_JDK)
|
||||
$(MKDIR) -p $$(@D) $$($1_DIRS)
|
||||
$(ECHO) Compiling $$(words $$($1_SRCS)) properties into resource bundles for $(MODULE)
|
||||
$(RM) $$($1_CMDLINE_FILE)
|
||||
$$(call ListPathsSafely,$1_CMDLINE,\n, >> $$($1_CMDLINE_FILE))
|
||||
$$(eval $$(call ListPathsSafely, $1_CMDLINE, $$($1_CMDLINE_FILE)))
|
||||
$(TOOL_COMPILEPROPERTIES) -quiet @$$($1_CMDLINE_FILE)
|
||||
$(TOUCH) $$@
|
||||
|
||||
|
@ -26,5 +26,6 @@
|
||||
include LauncherCommon.gmk
|
||||
|
||||
$(eval $(call SetupLauncher,jjs, \
|
||||
-DENABLE_ARG_FILES \
|
||||
-DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "jdk.nashorn.tools.jjs.Main"$(COMMA) }'))
|
||||
|
||||
|
@ -959,10 +959,9 @@ ifeq ($(OPENJDK_TARGET_OS), macosx)
|
||||
$(X_CFLAGS) \
|
||||
$(X_LIBS) \
|
||||
$(LIBAWT_LWAWT_CFLAGS), \
|
||||
DISABLED_WARNINGS_clang := incomplete-implementation \
|
||||
DISABLED_WARNINGS_clang := incomplete-implementation enum-conversion \
|
||||
deprecated-declarations objc-method-access bitwise-op-parentheses \
|
||||
incompatible-pointer-types parentheses-equality extra-tokens, \
|
||||
WARNINGS_AS_ERRORS_clang := false, \
|
||||
LDFLAGS := $(LDFLAGS_JDKLIB) \
|
||||
$(call SET_SHARED_LIBRARY_ORIGIN) \
|
||||
-L$(INSTALL_LIBRARIES_HERE), \
|
||||
|
@ -160,6 +160,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \
|
||||
-framework Security -framework SystemConfiguration, \
|
||||
LDFLAGS_SUFFIX_windows := -export:winFileHandleOpen -export:handleLseek \
|
||||
-export:getLastErrorString \
|
||||
-export:getErrorString \
|
||||
jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \
|
||||
shell32.lib delayimp.lib -DELAYLOAD:shell32.dll \
|
||||
advapi32.lib version.lib, \
|
||||
|
@ -282,8 +282,9 @@ SUNWprivate_1.1 {
|
||||
|
||||
# ZipFile.c needs this one
|
||||
throwFileNotFoundException;
|
||||
# zip_util.c needs this one
|
||||
# zip_util.c needs these
|
||||
getLastErrorString;
|
||||
getErrorString;
|
||||
|
||||
# Outcalls from libjvm done using dlsym().
|
||||
|
||||
|
@ -31,9 +31,9 @@ include RMICompilation.gmk
|
||||
|
||||
##########################################################################################
|
||||
|
||||
BTRMIC_CP := $(call PathList, $(INTERIM_CORBA_JAR) \
|
||||
BTRMIC_CP := $(call PathList, \
|
||||
$(BUILDTOOLS_OUTPUTDIR)/interim_rmic_classes $(INTERIM_LANGTOOLS_JAR))
|
||||
BTRMIC_ARGS := -Xbootclasspath/p:$(BTRMIC_CP) -cp $(BTRMIC_CP)
|
||||
BTRMIC_ARGS := -cp $(BTRMIC_CP)
|
||||
RMIC := $(JAVA) $(BTRMIC_ARGS) sun.rmi.rmic.Main
|
||||
|
||||
CLASSES_DIR := $(JDK_OUTPUTDIR)/modules
|
||||
|
@ -504,11 +504,11 @@ class Atom {
|
||||
|
||||
private static Applet applet;
|
||||
private static byte[] data;
|
||||
private final static int R = 40;
|
||||
private final static int hx = 15;
|
||||
private final static int hy = 15;
|
||||
private final static int bgGrey = 192;
|
||||
private final static int nBalls = 16;
|
||||
private static final int R = 40;
|
||||
private static final int hx = 15;
|
||||
private static final int hy = 15;
|
||||
private static final int bgGrey = 192;
|
||||
private static final int nBalls = 16;
|
||||
private static int maxr;
|
||||
private int Rl;
|
||||
private int Gl;
|
||||
|
@ -771,7 +771,7 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class ImageOpTests extends ImageTests {
|
||||
private abstract static class ImageOpTests extends ImageTests {
|
||||
ImageOpTests(Group parent, String nodeName, String desc) {
|
||||
super(parent, nodeName, desc,
|
||||
new Modifier.Filter() {
|
||||
|
@ -245,7 +245,7 @@ public abstract class PixelTests extends Test {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class BufImgTest extends PixelTests {
|
||||
public abstract static class BufImgTest extends PixelTests {
|
||||
public BufImgTest(String nodeName, String description) {
|
||||
super(bufimgtestroot, nodeName, description);
|
||||
}
|
||||
@ -281,7 +281,7 @@ public abstract class PixelTests extends Test {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class RasTest extends PixelTests {
|
||||
public abstract static class RasTest extends PixelTests {
|
||||
public RasTest(String nodeName, String description) {
|
||||
super(rastertestroot, nodeName, description);
|
||||
}
|
||||
@ -355,7 +355,7 @@ public abstract class PixelTests extends Test {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class DataBufTest extends PixelTests {
|
||||
public abstract static class DataBufTest extends PixelTests {
|
||||
public DataBufTest(String nodeName, String description) {
|
||||
super(dbtestroot, nodeName, description);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ abstract class InputTests extends IIOTests {
|
||||
}
|
||||
}
|
||||
|
||||
protected static abstract class Context {
|
||||
protected abstract static class Context {
|
||||
int size;
|
||||
Object input;
|
||||
int inputType;
|
||||
|
@ -156,7 +156,7 @@ abstract class OutputTests extends IIOTests {
|
||||
}
|
||||
}
|
||||
|
||||
protected static abstract class Context {
|
||||
protected abstract static class Context {
|
||||
int size;
|
||||
Object output;
|
||||
int outputType;
|
||||
|
@ -232,7 +232,7 @@ public abstract class TextMeasureTests extends TextTests {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class GVMeasureTest extends TextMeasureTests {
|
||||
public abstract static class GVMeasureTest extends TextMeasureTests {
|
||||
protected GVMeasureTest(Group parent, String nodeName, String description) {
|
||||
super(parent, nodeName, description);
|
||||
}
|
||||
@ -431,7 +431,7 @@ public abstract class TextMeasureTests extends TextTests {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class TLMeasureTest extends TextMeasureTests {
|
||||
public abstract static class TLMeasureTest extends TextMeasureTests {
|
||||
protected TLMeasureTest(Group parent, String nodeName, String description) {
|
||||
super(parent, nodeName, description);
|
||||
}
|
||||
@ -506,7 +506,7 @@ public abstract class TextMeasureTests extends TextTests {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class TLExtendedMeasureTest extends TLMeasureTest {
|
||||
public abstract static class TLExtendedMeasureTest extends TLMeasureTest {
|
||||
protected TLExtendedMeasureTest(Group parent, String nodeName, String description) {
|
||||
super(parent, nodeName, description);
|
||||
}
|
||||
|
@ -143,11 +143,11 @@ public class FileChooserDemo extends JPanel implements ActionListener {
|
||||
private JTextField customField;
|
||||
private final ExampleFileView fileView;
|
||||
private final ExampleFileSystemView fileSystemView;
|
||||
private final static Dimension hpad10 = new Dimension(10, 1);
|
||||
private final static Dimension vpad20 = new Dimension(1, 20);
|
||||
private final static Dimension vpad7 = new Dimension(1, 7);
|
||||
private final static Dimension vpad4 = new Dimension(1, 4);
|
||||
private final static Insets insets = new Insets(5, 10, 0, 10);
|
||||
private static final Dimension hpad10 = new Dimension(10, 1);
|
||||
private static final Dimension vpad20 = new Dimension(1, 20);
|
||||
private static final Dimension vpad7 = new Dimension(1, 7);
|
||||
private static final Dimension vpad4 = new Dimension(1, 4);
|
||||
private static final Insets insets = new Insets(5, 10, 0, 10);
|
||||
private final FilePreviewer previewer;
|
||||
private final JFileChooser chooser;
|
||||
|
||||
|
@ -64,7 +64,7 @@ class Notepad extends JPanel {
|
||||
|
||||
protected static Properties properties;
|
||||
private static ResourceBundle resources;
|
||||
private final static String EXIT_AFTER_PAINT = "-exit";
|
||||
private static final String EXIT_AFTER_PAINT = "-exit";
|
||||
private static boolean exitAfterFirstPaint;
|
||||
|
||||
private static final String[] MENUBAR_KEYS = {"file", "edit", "debug"};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -65,9 +65,23 @@ class EPollSelectorImpl
|
||||
long pipeFds = IOUtil.makePipe(false);
|
||||
fd0 = (int) (pipeFds >>> 32);
|
||||
fd1 = (int) pipeFds;
|
||||
pollWrapper = new EPollArrayWrapper();
|
||||
pollWrapper.initInterrupt(fd0, fd1);
|
||||
fdToKey = new HashMap<>();
|
||||
try {
|
||||
pollWrapper = new EPollArrayWrapper();
|
||||
pollWrapper.initInterrupt(fd0, fd1);
|
||||
fdToKey = new HashMap<>();
|
||||
} catch (Throwable t) {
|
||||
try {
|
||||
FileDispatcherImpl.closeIntFD(fd0);
|
||||
} catch (IOException ioe0) {
|
||||
t.addSuppressed(ioe0);
|
||||
}
|
||||
try {
|
||||
FileDispatcherImpl.closeIntFD(fd1);
|
||||
} catch (IOException ioe1) {
|
||||
t.addSuppressed(ioe1);
|
||||
}
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
protected int doSelect(long timeout) throws IOException {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -84,10 +84,24 @@ class KQueueSelectorImpl
|
||||
long fds = IOUtil.makePipe(false);
|
||||
fd0 = (int)(fds >>> 32);
|
||||
fd1 = (int)fds;
|
||||
kqueueWrapper = new KQueueArrayWrapper();
|
||||
kqueueWrapper.initInterrupt(fd0, fd1);
|
||||
fdMap = new HashMap<>();
|
||||
totalChannels = 1;
|
||||
try {
|
||||
kqueueWrapper = new KQueueArrayWrapper();
|
||||
kqueueWrapper.initInterrupt(fd0, fd1);
|
||||
fdMap = new HashMap<>();
|
||||
totalChannels = 1;
|
||||
} catch (Throwable t) {
|
||||
try {
|
||||
FileDispatcherImpl.closeIntFD(fd0);
|
||||
} catch (IOException ioe0) {
|
||||
t.addSuppressed(ioe0);
|
||||
}
|
||||
try {
|
||||
FileDispatcherImpl.closeIntFD(fd1);
|
||||
} catch (IOException ioe1) {
|
||||
t.addSuppressed(ioe1);
|
||||
}
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,6 +34,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -41,7 +42,6 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TimeZone;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarInputStream;
|
||||
@ -84,13 +84,8 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
|
||||
*/
|
||||
public synchronized void pack(JarFile in, OutputStream out) throws IOException {
|
||||
assert(Utils.currentInstance.get() == null);
|
||||
TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
|
||||
? null
|
||||
: TimeZone.getDefault();
|
||||
try {
|
||||
Utils.currentInstance.set(this);
|
||||
if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
|
||||
|
||||
if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
|
||||
Utils.copyJarFile(in, out);
|
||||
} else {
|
||||
@ -98,7 +93,6 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
|
||||
}
|
||||
} finally {
|
||||
Utils.currentInstance.set(null);
|
||||
if (tz != null) TimeZone.setDefault(tz);
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
@ -119,11 +113,8 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
|
||||
*/
|
||||
public synchronized void pack(JarInputStream in, OutputStream out) throws IOException {
|
||||
assert(Utils.currentInstance.get() == null);
|
||||
TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null :
|
||||
TimeZone.getDefault();
|
||||
try {
|
||||
Utils.currentInstance.set(this);
|
||||
if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
|
||||
if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
|
||||
Utils.copyJarFile(in, out);
|
||||
} else {
|
||||
@ -131,7 +122,6 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
|
||||
}
|
||||
} finally {
|
||||
Utils.currentInstance.set(null);
|
||||
if (tz != null) TimeZone.setDefault(tz);
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
@ -327,7 +317,9 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
|
||||
this.f = null;
|
||||
this.jf = jf;
|
||||
this.je = je;
|
||||
int timeSecs = getModtime(je.getTime());
|
||||
int timeSecs = (int) je.getTimeLocal()
|
||||
.atOffset(ZoneOffset.UTC)
|
||||
.toEpochSecond();
|
||||
if (keepModtime && timeSecs != Constants.NO_MODTIME) {
|
||||
this.modtime = timeSecs;
|
||||
} else if (latestModtime && timeSecs > pkg.default_modtime) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -69,10 +69,6 @@ final class PropMap implements SortedMap<String, String> {
|
||||
props.put(Utils.DEBUG_VERBOSE,
|
||||
String.valueOf(Integer.getInteger(Utils.DEBUG_VERBOSE,0)));
|
||||
|
||||
// Set the PACK_TIMEZONE_NO_UTC
|
||||
props.put(Utils.PACK_DEFAULT_TIMEZONE,
|
||||
String.valueOf(Boolean.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)));
|
||||
|
||||
// The segment size is unlimited
|
||||
props.put(Pack200.Packer.SEGMENT_LIMIT, "-1");
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,10 +32,11 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TimeZone;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
import java.util.jar.JarOutputStream;
|
||||
@ -95,13 +96,9 @@ public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker {
|
||||
throw new NullPointerException("null output");
|
||||
}
|
||||
assert(Utils.currentInstance.get() == null);
|
||||
TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
|
||||
? null
|
||||
: TimeZone.getDefault();
|
||||
|
||||
try {
|
||||
Utils.currentInstance.set(this);
|
||||
if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
|
||||
final int verbose = props.getInteger(Utils.DEBUG_VERBOSE);
|
||||
BufferedInputStream in0 = new BufferedInputStream(in);
|
||||
if (Utils.isJarMagic(Utils.readMagic(in0))) {
|
||||
@ -125,7 +122,6 @@ public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker {
|
||||
} finally {
|
||||
_nunp = null;
|
||||
Utils.currentInstance.set(null);
|
||||
if (tz != null) TimeZone.setDefault(tz);
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,9 +242,9 @@ public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker {
|
||||
je.setCrc(crc.getValue());
|
||||
}
|
||||
if (keepModtime) {
|
||||
je.setTime(file.modtime);
|
||||
// Convert back to milliseconds
|
||||
je.setTime((long)file.modtime * 1000);
|
||||
LocalDateTime ldt = LocalDateTime
|
||||
.ofEpochSecond(file.modtime, 0, ZoneOffset.UTC);
|
||||
je.setTimeLocal(ldt);
|
||||
} else {
|
||||
je.setTime((long)modtime * 1000);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -61,13 +61,6 @@ class Utils {
|
||||
*/
|
||||
static final String DEBUG_DISABLE_NATIVE = COM_PREFIX+"disable.native";
|
||||
|
||||
/*
|
||||
* Use the default working TimeZone instead of UTC.
|
||||
* Note: This has installer unpacker implications.
|
||||
* see: zip.cpp which uses gmtime vs. localtime.
|
||||
*/
|
||||
static final String PACK_DEFAULT_TIMEZONE = COM_PREFIX+"default.timezone";
|
||||
|
||||
/*
|
||||
* Property indicating that the unpacker should
|
||||
* ignore the transmitted PACK_MODIFICATION_TIME,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -56,7 +56,9 @@ class NTLM {
|
||||
private final Mac hmac;
|
||||
private final MessageDigest md5;
|
||||
private static final boolean DEBUG =
|
||||
System.getProperty("ntlm.debug") != null;
|
||||
java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetBooleanAction("ntlm.debug"))
|
||||
.booleanValue();
|
||||
|
||||
final Version v;
|
||||
|
||||
|
@ -27,6 +27,8 @@ package java.io;
|
||||
|
||||
import java.util.*;
|
||||
import java.nio.charset.Charset;
|
||||
import jdk.internal.misc.JavaIOAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.nio.cs.StreamDecoder;
|
||||
import sun.nio.cs.StreamEncoder;
|
||||
|
||||
@ -519,7 +521,7 @@ public final class Console implements Flushable
|
||||
try {
|
||||
// Add a shutdown hook to restore console's echo state should
|
||||
// it be necessary.
|
||||
sun.misc.SharedSecrets.getJavaLangAccess()
|
||||
SharedSecrets.getJavaLangAccess()
|
||||
.registerShutdownHook(0 /* shutdown hook invocation order */,
|
||||
false /* only register if shutdown is not in progress */,
|
||||
new Runnable() {
|
||||
@ -536,7 +538,7 @@ public final class Console implements Flushable
|
||||
// by a shutdown hook
|
||||
}
|
||||
|
||||
sun.misc.SharedSecrets.setJavaIOAccess(new sun.misc.JavaIOAccess() {
|
||||
SharedSecrets.setJavaIOAccess(new JavaIOAccess() {
|
||||
public Console console() {
|
||||
if (istty()) {
|
||||
if (cons == null)
|
||||
|
@ -26,6 +26,7 @@ package java.io;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
|
||||
/**
|
||||
* This class holds a set of filenames to be deleted on VM exit through a shutdown hook.
|
||||
@ -41,7 +42,7 @@ class DeleteOnExitHook {
|
||||
// delete on exit list and cause the DeleteOnExitHook to be
|
||||
// registered during shutdown in progress. So set the
|
||||
// registerShutdownInProgress parameter to true.
|
||||
sun.misc.SharedSecrets.getJavaLangAccess()
|
||||
SharedSecrets.getJavaLangAccess()
|
||||
.registerShutdownHook(2 /* Shutdown hook invocation order */,
|
||||
true /* register even if shutdown in progress */,
|
||||
new Runnable() {
|
||||
|
@ -27,8 +27,8 @@ package java.io;
|
||||
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import sun.misc.SharedSecrets;
|
||||
import sun.misc.JavaIOFileDescriptorAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaIOFileDescriptorAccess;
|
||||
import sun.nio.ch.FileChannelImpl;
|
||||
|
||||
|
||||
|
@ -352,15 +352,15 @@ class FdLibm {
|
||||
|
||||
double p_h, p_l, t1, t2;
|
||||
// |y| is huge
|
||||
if (y_abs > 0x1.0p31) { // if |y| > 2**31
|
||||
if (y_abs > 0x1.00000_ffff_ffffp31) { // if |y| > ~2**31
|
||||
final double INV_LN2 = 0x1.7154_7652_b82fep0; // 1.44269504088896338700e+00 = 1/ln2
|
||||
final double INV_LN2_H = 0x1.715476p0; // 1.44269502162933349609e+00 = 24 bits of 1/ln2
|
||||
final double INV_LN2_L = 0x1.4ae0_bf85_ddf44p-26; // 1.92596299112661746887e-08 = 1/ln2 tail
|
||||
|
||||
// Over/underflow if x is not close to one
|
||||
if (x_abs < 0x1.fffffp-1) // |x| < 0.9999995231628418
|
||||
if (x_abs < 0x1.fffff_0000_0000p-1) // |x| < ~0.9999995231628418
|
||||
return (y < 0.0) ? s * INFINITY : s * 0.0;
|
||||
if (x_abs > 1.0) // |x| > 1.0
|
||||
if (x_abs > 0x1.00000_ffff_ffffp0) // |x| > ~1.0
|
||||
return (y > 0.0) ? s * INFINITY : s * 0.0;
|
||||
/*
|
||||
* now |1-x| is tiny <= 2**-20, sufficient to compute
|
||||
|
@ -43,6 +43,8 @@ import sun.reflect.Reflection;
|
||||
import sun.security.util.SecurityConstants;
|
||||
import sun.reflect.annotation.AnnotationType;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.JavaLangAccess;;
|
||||
import jdk.internal.misc.SharedSecrets;;
|
||||
|
||||
/**
|
||||
* The <code>System</code> class contains several useful class fields
|
||||
@ -212,7 +214,7 @@ public final class System {
|
||||
public static Console console() {
|
||||
if (cons == null) {
|
||||
synchronized (System.class) {
|
||||
cons = sun.misc.SharedSecrets.getJavaIOAccess().console();
|
||||
cons = SharedSecrets.getJavaIOAccess().console();
|
||||
}
|
||||
}
|
||||
return cons;
|
||||
@ -1216,7 +1218,7 @@ public final class System {
|
||||
|
||||
private static void setJavaLangAccess() {
|
||||
// Allow privileged classes outside of java.lang
|
||||
sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
|
||||
SharedSecrets.setJavaLangAccess(new JavaLangAccess(){
|
||||
public sun.reflect.ConstantPool getConstantPool(Class<?> klass) {
|
||||
return klass.getConstantPool();
|
||||
}
|
||||
|
@ -233,7 +233,8 @@ class Thread implements Runnable {
|
||||
private volatile Interruptible blocker;
|
||||
private final Object blockerLock = new Object();
|
||||
|
||||
/* Set the blocker field; invoked via sun.misc.SharedSecrets from java.nio code
|
||||
/* Set the blocker field; invoked via jdk.internal.misc.SharedSecrets
|
||||
* from java.nio code
|
||||
*/
|
||||
void blockedOn(Interruptible b) {
|
||||
synchronized (blockerLock) {
|
||||
|
@ -27,9 +27,9 @@ package java.lang.ref;
|
||||
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.AccessController;
|
||||
import sun.misc.JavaLangAccess;
|
||||
import jdk.internal.misc.JavaLangAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.misc.SharedSecrets;
|
||||
import sun.misc.VM;
|
||||
|
||||
final class Finalizer extends FinalReference<Object> { /* Package-private; must be in
|
||||
|
@ -26,10 +26,10 @@
|
||||
package java.lang.ref;
|
||||
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.JavaLangRefAccess;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.misc.SharedSecrets;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.JavaLangRefAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* Abstract base class for reference objects. This class defines the
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
package java.lang.reflect;
|
||||
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.ConstructorAccessor;
|
||||
import sun.reflect.Reflection;
|
||||
@ -582,7 +583,7 @@ public final class Constructor<T> extends Executable {
|
||||
|
||||
// A Constructor for an inner class
|
||||
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(thisDeclClass),
|
||||
this,
|
||||
thisDeclClass,
|
||||
|
@ -28,6 +28,8 @@ package java.lang.reflect;
|
||||
import java.lang.annotation.*;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.reflect.annotation.AnnotationParser;
|
||||
import sun.reflect.annotation.AnnotationSupport;
|
||||
import sun.reflect.annotation.TypeAnnotationParser;
|
||||
@ -79,7 +81,7 @@ public abstract class Executable extends AccessibleObject
|
||||
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
|
||||
return AnnotationParser.parseParameterAnnotations(
|
||||
parameterAnnotations,
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
getDeclaringClass());
|
||||
}
|
||||
@ -601,7 +603,7 @@ public abstract class Executable extends AccessibleObject
|
||||
} else {
|
||||
declAnnos = AnnotationParser.parseAnnotations(
|
||||
getAnnotationBytes(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
getDeclaringClass()
|
||||
);
|
||||
@ -638,7 +640,7 @@ public abstract class Executable extends AccessibleObject
|
||||
*/
|
||||
AnnotatedType getAnnotatedReturnType0(Type returnType) {
|
||||
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
@ -672,7 +674,7 @@ public abstract class Executable extends AccessibleObject
|
||||
if (Modifier.isStatic(this.getModifiers()))
|
||||
return null;
|
||||
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
@ -696,7 +698,7 @@ public abstract class Executable extends AccessibleObject
|
||||
*/
|
||||
public AnnotatedType[] getAnnotatedParameterTypes() {
|
||||
return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes0(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
@ -720,7 +722,7 @@ public abstract class Executable extends AccessibleObject
|
||||
*/
|
||||
public AnnotatedType[] getAnnotatedExceptionTypes() {
|
||||
return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes0(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
package java.lang.reflect;
|
||||
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.FieldAccessor;
|
||||
import sun.reflect.Reflection;
|
||||
@ -1152,7 +1153,7 @@ class Field extends AccessibleObject implements Member {
|
||||
} else {
|
||||
declAnnos = AnnotationParser.parseAnnotations(
|
||||
annotations,
|
||||
sun.misc.SharedSecrets.getJavaLangAccess()
|
||||
SharedSecrets.getJavaLangAccess()
|
||||
.getConstantPool(getDeclaringClass()),
|
||||
getDeclaringClass());
|
||||
}
|
||||
@ -1175,7 +1176,7 @@ class Field extends AccessibleObject implements Member {
|
||||
*/
|
||||
public AnnotatedType getAnnotatedType() {
|
||||
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
|
@ -26,6 +26,7 @@
|
||||
package java.lang.reflect;
|
||||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.MethodAccessor;
|
||||
import sun.reflect.Reflection;
|
||||
@ -626,7 +627,7 @@ public final class Method extends Executable {
|
||||
getReturnType());
|
||||
Object result = AnnotationParser.parseMemberValue(
|
||||
memberType, ByteBuffer.wrap(annotationDefault),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
getDeclaringClass());
|
||||
if (result instanceof sun.reflect.annotation.ExceptionProxy)
|
||||
|
@ -35,6 +35,8 @@ import java.util.GregorianCalendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import jdk.internal.misc.JavaNetHttpCookieAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
|
||||
/**
|
||||
* An HttpCookie object represents an HTTP cookie, which carries state
|
||||
@ -971,8 +973,8 @@ public final class HttpCookie implements Cloneable {
|
||||
}
|
||||
|
||||
static {
|
||||
sun.misc.SharedSecrets.setJavaNetHttpCookieAccess(
|
||||
new sun.misc.JavaNetHttpCookieAccess() {
|
||||
SharedSecrets.setJavaNetHttpCookieAccess(
|
||||
new JavaNetHttpCookieAccess() {
|
||||
public List<HttpCookie> parse(String header) {
|
||||
return HttpCookie.parse(header, true);
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import jdk.internal.misc.JavaNetInetAddressAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.security.action.*;
|
||||
import sun.net.InetAddressCachePolicy;
|
||||
import sun.net.util.IPAddressUtil;
|
||||
@ -215,7 +217,7 @@ class InetAddress implements java.io.Serializable {
|
||||
* DNS forging.
|
||||
*
|
||||
* Oracle JSSE provider is using this original hostname, via
|
||||
* sun.misc.JavaNetAccess, for SSL/TLS endpoint identification.
|
||||
* jdk.internal.misc.JavaNetAccess, for SSL/TLS endpoint identification.
|
||||
*
|
||||
* Note: May define a new public method in the future if necessary.
|
||||
*/
|
||||
@ -297,8 +299,8 @@ class InetAddress implements java.io.Serializable {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
sun.misc.SharedSecrets.setJavaNetInetAddressAccess(
|
||||
new sun.misc.JavaNetInetAddressAccess() {
|
||||
SharedSecrets.setJavaNetInetAddressAccess(
|
||||
new JavaNetInetAddressAccess() {
|
||||
public String getOriginalHostName(InetAddress ia) {
|
||||
return ia.holder.getOriginalHostName();
|
||||
}
|
||||
|
@ -49,6 +49,9 @@ import java.util.jar.Attributes;
|
||||
import java.util.jar.Attributes.Name;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import jdk.internal.misc.JavaNetAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.misc.Resource;
|
||||
import sun.misc.URLClassPath;
|
||||
import sun.net.www.ParseUtil;
|
||||
@ -769,9 +772,9 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
}
|
||||
|
||||
static {
|
||||
sun.misc.SharedSecrets.setJavaNetAccess (
|
||||
new sun.misc.JavaNetAccess() {
|
||||
public URLClassPath getURLClassPath (URLClassLoader u) {
|
||||
SharedSecrets.setJavaNetAccess(
|
||||
new JavaNetAccess() {
|
||||
public URLClassPath getURLClassPath(URLClassLoader u) {
|
||||
return u.ucp;
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,9 @@ import java.security.AccessController;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
|
||||
import sun.misc.JavaLangRefAccess;
|
||||
import sun.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaNioAccess;
|
||||
import jdk.internal.misc.JavaLangRefAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
|
||||
@ -702,11 +703,11 @@ class Bits { // package-private
|
||||
|
||||
static {
|
||||
// setup access to this package in SharedSecrets
|
||||
sun.misc.SharedSecrets.setJavaNioAccess(
|
||||
new sun.misc.JavaNioAccess() {
|
||||
SharedSecrets.setJavaNioAccess(
|
||||
new JavaNioAccess() {
|
||||
@Override
|
||||
public sun.misc.JavaNioAccess.BufferPool getDirectBufferPool() {
|
||||
return new sun.misc.JavaNioAccess.BufferPool() {
|
||||
public JavaNioAccess.BufferPool getDirectBufferPool() {
|
||||
return new JavaNioAccess.BufferPool() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "direct";
|
||||
|
@ -34,6 +34,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.channels.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.nio.ch.Interruptible;
|
||||
|
||||
|
||||
@ -206,9 +207,8 @@ public abstract class AbstractInterruptibleChannel
|
||||
}
|
||||
|
||||
|
||||
// -- sun.misc.SharedSecrets --
|
||||
// -- jdk.internal.misc.SharedSecrets --
|
||||
static void blockedOn(Interruptible intr) { // package-private
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
|
||||
intr);
|
||||
SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), intr);
|
||||
}
|
||||
}
|
||||
|
@ -34,10 +34,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import sun.misc.JavaSecurityAccess;
|
||||
import sun.misc.JavaSecurityProtectionDomainAccess;
|
||||
import static sun.misc.JavaSecurityProtectionDomainAccess.ProtectionDomainCache;
|
||||
import sun.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaSecurityAccess;
|
||||
import jdk.internal.misc.JavaSecurityProtectionDomainAccess;
|
||||
import static jdk.internal.misc.JavaSecurityProtectionDomainAccess.ProtectionDomainCache;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.security.util.Debug;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
|
@ -1722,7 +1722,7 @@ public class SimpleDateFormat extends DateFormat {
|
||||
}
|
||||
return (start + zoneNames[nameIndex].length());
|
||||
}
|
||||
return 0;
|
||||
return -start;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@
|
||||
package java.util;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import sun.misc.SharedSecrets;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
|
||||
/**
|
||||
* A specialized {@link Map} implementation for use with enum type keys. All
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
package java.util;
|
||||
|
||||
import sun.misc.SharedSecrets;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
|
||||
/**
|
||||
* A specialized {@link Set} implementation for use with enum types. All of
|
||||
|
@ -24,8 +24,8 @@
|
||||
*/
|
||||
package java.util;
|
||||
|
||||
import sun.misc.JavaLangAccess;
|
||||
import sun.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaLangAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
|
||||
/**
|
||||
* {@code StringJoiner} is used to construct a sequence of characters separated
|
||||
|
@ -27,8 +27,8 @@ package java.util;
|
||||
|
||||
import java.security.*;
|
||||
|
||||
import sun.misc.JavaLangAccess;
|
||||
import sun.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaLangAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
|
||||
/**
|
||||
* A class that represents an immutable universally unique identifier (UUID).
|
||||
|
@ -34,7 +34,6 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
/**
|
||||
* A {@code boolean} value that may be updated atomically. See the
|
||||
@ -49,15 +48,17 @@ import sun.misc.Unsafe;
|
||||
*/
|
||||
public class AtomicBoolean implements java.io.Serializable {
|
||||
private static final long serialVersionUID = 4654671469794556979L;
|
||||
// setup to use Unsafe.compareAndSwapInt for updates
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final long valueOffset;
|
||||
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long VALUE;
|
||||
|
||||
static {
|
||||
try {
|
||||
valueOffset = unsafe.objectFieldOffset
|
||||
VALUE = U.objectFieldOffset
|
||||
(AtomicBoolean.class.getDeclaredField("value"));
|
||||
} catch (Exception ex) { throw new Error(ex); }
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private volatile int value;
|
||||
@ -96,9 +97,9 @@ public class AtomicBoolean implements java.io.Serializable {
|
||||
* the actual value was not equal to the expected value.
|
||||
*/
|
||||
public final boolean compareAndSet(boolean expect, boolean update) {
|
||||
int e = expect ? 1 : 0;
|
||||
int u = update ? 1 : 0;
|
||||
return unsafe.compareAndSwapInt(this, valueOffset, e, u);
|
||||
return U.compareAndSwapInt(this, VALUE,
|
||||
(expect ? 1 : 0),
|
||||
(update ? 1 : 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,9 +115,9 @@ public class AtomicBoolean implements java.io.Serializable {
|
||||
* @return {@code true} if successful
|
||||
*/
|
||||
public boolean weakCompareAndSet(boolean expect, boolean update) {
|
||||
int e = expect ? 1 : 0;
|
||||
int u = update ? 1 : 0;
|
||||
return unsafe.compareAndSwapInt(this, valueOffset, e, u);
|
||||
return U.compareAndSwapInt(this, VALUE,
|
||||
(expect ? 1 : 0),
|
||||
(update ? 1 : 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,8 +136,7 @@ public class AtomicBoolean implements java.io.Serializable {
|
||||
* @since 1.6
|
||||
*/
|
||||
public final void lazySet(boolean newValue) {
|
||||
int v = newValue ? 1 : 0;
|
||||
unsafe.putOrderedInt(this, valueOffset, v);
|
||||
U.putOrderedInt(this, VALUE, (newValue ? 1 : 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,9 +34,9 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
|
||||
import java.util.function.IntBinaryOperator;
|
||||
import sun.misc.Unsafe;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
|
||||
/**
|
||||
* An {@code int} value that may be updated atomically. See the
|
||||
@ -50,19 +50,20 @@ import sun.misc.Unsafe;
|
||||
*
|
||||
* @since 1.5
|
||||
* @author Doug Lea
|
||||
*/
|
||||
*/
|
||||
public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
private static final long serialVersionUID = 6214790243416807050L;
|
||||
|
||||
// setup to use Unsafe.compareAndSwapInt for updates
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final long valueOffset;
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long VALUE;
|
||||
|
||||
static {
|
||||
try {
|
||||
valueOffset = unsafe.objectFieldOffset
|
||||
VALUE = U.objectFieldOffset
|
||||
(AtomicInteger.class.getDeclaredField("value"));
|
||||
} catch (Exception ex) { throw new Error(ex); }
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private volatile int value;
|
||||
@ -107,7 +108,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
* @since 1.6
|
||||
*/
|
||||
public final void lazySet(int newValue) {
|
||||
unsafe.putOrderedInt(this, valueOffset, newValue);
|
||||
U.putOrderedInt(this, VALUE, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,7 +118,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final int getAndSet(int newValue) {
|
||||
return unsafe.getAndSetInt(this, valueOffset, newValue);
|
||||
return U.getAndSetInt(this, VALUE, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,7 +131,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
* the actual value was not equal to the expected value.
|
||||
*/
|
||||
public final boolean compareAndSet(int expect, int update) {
|
||||
return unsafe.compareAndSwapInt(this, valueOffset, expect, update);
|
||||
return U.compareAndSwapInt(this, VALUE, expect, update);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,7 +147,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
* @return {@code true} if successful
|
||||
*/
|
||||
public final boolean weakCompareAndSet(int expect, int update) {
|
||||
return unsafe.compareAndSwapInt(this, valueOffset, expect, update);
|
||||
return U.compareAndSwapInt(this, VALUE, expect, update);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,7 +156,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final int getAndIncrement() {
|
||||
return unsafe.getAndAddInt(this, valueOffset, 1);
|
||||
return U.getAndAddInt(this, VALUE, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,7 +165,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final int getAndDecrement() {
|
||||
return unsafe.getAndAddInt(this, valueOffset, -1);
|
||||
return U.getAndAddInt(this, VALUE, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,7 +175,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final int getAndAdd(int delta) {
|
||||
return unsafe.getAndAddInt(this, valueOffset, delta);
|
||||
return U.getAndAddInt(this, VALUE, delta);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,7 +184,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
* @return the updated value
|
||||
*/
|
||||
public final int incrementAndGet() {
|
||||
return unsafe.getAndAddInt(this, valueOffset, 1) + 1;
|
||||
return U.getAndAddInt(this, VALUE, 1) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,7 +193,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
* @return the updated value
|
||||
*/
|
||||
public final int decrementAndGet() {
|
||||
return unsafe.getAndAddInt(this, valueOffset, -1) - 1;
|
||||
return U.getAndAddInt(this, VALUE, -1) - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,7 +203,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
* @return the updated value
|
||||
*/
|
||||
public final int addAndGet(int delta) {
|
||||
return unsafe.getAndAddInt(this, valueOffset, delta) + delta;
|
||||
return U.getAndAddInt(this, VALUE, delta) + delta;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -301,6 +302,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
||||
|
||||
/**
|
||||
* Returns the value of this {@code AtomicInteger} as an {@code int}.
|
||||
* Equivalent to {@link #get()}.
|
||||
*/
|
||||
public int intValue() {
|
||||
return get();
|
||||
|
@ -34,9 +34,9 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
|
||||
import java.util.function.IntBinaryOperator;
|
||||
import sun.misc.Unsafe;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
|
||||
/**
|
||||
* An {@code int} array in which elements may be updated atomically.
|
||||
@ -49,16 +49,17 @@ import sun.misc.Unsafe;
|
||||
public class AtomicIntegerArray implements java.io.Serializable {
|
||||
private static final long serialVersionUID = 2862133569453604235L;
|
||||
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final int base = unsafe.arrayBaseOffset(int[].class);
|
||||
private static final int shift;
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final int ABASE;
|
||||
private static final int ASHIFT;
|
||||
private final int[] array;
|
||||
|
||||
static {
|
||||
int scale = unsafe.arrayIndexScale(int[].class);
|
||||
ABASE = U.arrayBaseOffset(int[].class);
|
||||
int scale = U.arrayIndexScale(int[].class);
|
||||
if ((scale & (scale - 1)) != 0)
|
||||
throw new Error("data type scale not a power of two");
|
||||
shift = 31 - Integer.numberOfLeadingZeros(scale);
|
||||
throw new Error("array index scale not a power of two");
|
||||
ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
||||
}
|
||||
|
||||
private long checkedByteOffset(int i) {
|
||||
@ -69,7 +70,7 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
private static long byteOffset(int i) {
|
||||
return ((long) i << shift) + base;
|
||||
return ((long) i << ASHIFT) + ABASE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,7 +115,7 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
private int getRaw(long offset) {
|
||||
return unsafe.getIntVolatile(array, offset);
|
||||
return U.getIntVolatile(array, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,7 +125,7 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
* @param newValue the new value
|
||||
*/
|
||||
public final void set(int i, int newValue) {
|
||||
unsafe.putIntVolatile(array, checkedByteOffset(i), newValue);
|
||||
U.putIntVolatile(array, checkedByteOffset(i), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,7 +136,7 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
* @since 1.6
|
||||
*/
|
||||
public final void lazySet(int i, int newValue) {
|
||||
unsafe.putOrderedInt(array, checkedByteOffset(i), newValue);
|
||||
U.putOrderedInt(array, checkedByteOffset(i), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,7 +148,7 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final int getAndSet(int i, int newValue) {
|
||||
return unsafe.getAndSetInt(array, checkedByteOffset(i), newValue);
|
||||
return U.getAndSetInt(array, checkedByteOffset(i), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,7 +166,7 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
private boolean compareAndSetRaw(long offset, int expect, int update) {
|
||||
return unsafe.compareAndSwapInt(array, offset, expect, update);
|
||||
return U.compareAndSwapInt(array, offset, expect, update);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,7 +214,7 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final int getAndAdd(int i, int delta) {
|
||||
return unsafe.getAndAddInt(array, checkedByteOffset(i), delta);
|
||||
return U.getAndAddInt(array, checkedByteOffset(i), delta);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -247,7 +248,6 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
||||
return getAndAdd(i, delta) + delta;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the previous value. The
|
||||
|
@ -34,14 +34,14 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
@ -363,11 +363,11 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard hotspot implementation using intrinsics
|
||||
* Standard hotspot implementation using intrinsics.
|
||||
*/
|
||||
private static class AtomicIntegerFieldUpdaterImpl<T>
|
||||
extends AtomicIntegerFieldUpdater<T> {
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private final long offset;
|
||||
private final Class<T> tclass;
|
||||
private final Class<?> cclass;
|
||||
@ -391,7 +391,7 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
||||
ClassLoader ccl = caller.getClassLoader();
|
||||
if ((ccl != null) && (ccl != cl) &&
|
||||
((cl == null) || !isAncestor(cl, ccl))) {
|
||||
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
|
||||
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
|
||||
}
|
||||
} catch (PrivilegedActionException pae) {
|
||||
throw new RuntimeException(pae.getException());
|
||||
@ -409,7 +409,7 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
||||
this.cclass = (Modifier.isProtected(modifiers) &&
|
||||
caller != tclass) ? caller : null;
|
||||
this.tclass = tclass;
|
||||
offset = unsafe.objectFieldOffset(field);
|
||||
offset = U.objectFieldOffset(field);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -437,32 +437,32 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
||||
|
||||
public boolean compareAndSet(T obj, int expect, int update) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
return unsafe.compareAndSwapInt(obj, offset, expect, update);
|
||||
return U.compareAndSwapInt(obj, offset, expect, update);
|
||||
}
|
||||
|
||||
public boolean weakCompareAndSet(T obj, int expect, int update) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
return unsafe.compareAndSwapInt(obj, offset, expect, update);
|
||||
return U.compareAndSwapInt(obj, offset, expect, update);
|
||||
}
|
||||
|
||||
public void set(T obj, int newValue) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
unsafe.putIntVolatile(obj, offset, newValue);
|
||||
U.putIntVolatile(obj, offset, newValue);
|
||||
}
|
||||
|
||||
public void lazySet(T obj, int newValue) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
unsafe.putOrderedInt(obj, offset, newValue);
|
||||
U.putOrderedInt(obj, offset, newValue);
|
||||
}
|
||||
|
||||
public final int get(T obj) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
return unsafe.getIntVolatile(obj, offset);
|
||||
return U.getIntVolatile(obj, offset);
|
||||
}
|
||||
|
||||
public int getAndSet(T obj, int newValue) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
return unsafe.getAndSetInt(obj, offset, newValue);
|
||||
return U.getAndSetInt(obj, offset, newValue);
|
||||
}
|
||||
|
||||
public int getAndIncrement(T obj) {
|
||||
@ -475,7 +475,7 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
||||
|
||||
public int getAndAdd(T obj, int delta) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
return unsafe.getAndAddInt(obj, offset, delta);
|
||||
return U.getAndAddInt(obj, offset, delta);
|
||||
}
|
||||
|
||||
public int incrementAndGet(T obj) {
|
||||
@ -483,7 +483,7 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
||||
}
|
||||
|
||||
public int decrementAndGet(T obj) {
|
||||
return getAndAdd(obj, -1) - 1;
|
||||
return getAndAdd(obj, -1) - 1;
|
||||
}
|
||||
|
||||
public int addAndGet(T obj, int delta) {
|
||||
|
@ -34,9 +34,9 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
|
||||
import java.util.function.LongBinaryOperator;
|
||||
import sun.misc.Unsafe;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
|
||||
/**
|
||||
* A {@code long} value that may be updated atomically. See the
|
||||
@ -54,9 +54,8 @@ import sun.misc.Unsafe;
|
||||
public class AtomicLong extends Number implements java.io.Serializable {
|
||||
private static final long serialVersionUID = 1927816293512124184L;
|
||||
|
||||
// setup to use Unsafe.compareAndSwapLong for updates
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final long valueOffset;
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long VALUE;
|
||||
|
||||
/**
|
||||
* Records whether the underlying JVM supports lockless
|
||||
@ -74,9 +73,11 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
|
||||
static {
|
||||
try {
|
||||
valueOffset = unsafe.objectFieldOffset
|
||||
VALUE = U.objectFieldOffset
|
||||
(AtomicLong.class.getDeclaredField("value"));
|
||||
} catch (Exception ex) { throw new Error(ex); }
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private volatile long value;
|
||||
@ -111,7 +112,9 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @param newValue the new value
|
||||
*/
|
||||
public final void set(long newValue) {
|
||||
value = newValue;
|
||||
// Use putLongVolatile instead of ordinary volatile store when
|
||||
// using compareAndSwapLong, for sake of some 32bit systems.
|
||||
U.putLongVolatile(this, VALUE, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,7 +124,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @since 1.6
|
||||
*/
|
||||
public final void lazySet(long newValue) {
|
||||
unsafe.putOrderedLong(this, valueOffset, newValue);
|
||||
U.putOrderedLong(this, VALUE, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,7 +134,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final long getAndSet(long newValue) {
|
||||
return unsafe.getAndSetLong(this, valueOffset, newValue);
|
||||
return U.getAndSetLong(this, VALUE, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,7 +147,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* the actual value was not equal to the expected value.
|
||||
*/
|
||||
public final boolean compareAndSet(long expect, long update) {
|
||||
return unsafe.compareAndSwapLong(this, valueOffset, expect, update);
|
||||
return U.compareAndSwapLong(this, VALUE, expect, update);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,7 +163,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @return {@code true} if successful
|
||||
*/
|
||||
public final boolean weakCompareAndSet(long expect, long update) {
|
||||
return unsafe.compareAndSwapLong(this, valueOffset, expect, update);
|
||||
return U.compareAndSwapLong(this, VALUE, expect, update);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,7 +172,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final long getAndIncrement() {
|
||||
return unsafe.getAndAddLong(this, valueOffset, 1L);
|
||||
return U.getAndAddLong(this, VALUE, 1L);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,7 +181,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final long getAndDecrement() {
|
||||
return unsafe.getAndAddLong(this, valueOffset, -1L);
|
||||
return U.getAndAddLong(this, VALUE, -1L);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,7 +191,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final long getAndAdd(long delta) {
|
||||
return unsafe.getAndAddLong(this, valueOffset, delta);
|
||||
return U.getAndAddLong(this, VALUE, delta);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,7 +200,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @return the updated value
|
||||
*/
|
||||
public final long incrementAndGet() {
|
||||
return unsafe.getAndAddLong(this, valueOffset, 1L) + 1L;
|
||||
return U.getAndAddLong(this, VALUE, 1L) + 1L;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,7 +209,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @return the updated value
|
||||
*/
|
||||
public final long decrementAndGet() {
|
||||
return unsafe.getAndAddLong(this, valueOffset, -1L) - 1L;
|
||||
return U.getAndAddLong(this, VALUE, -1L) - 1L;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,7 +219,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
* @return the updated value
|
||||
*/
|
||||
public final long addAndGet(long delta) {
|
||||
return unsafe.getAndAddLong(this, valueOffset, delta) + delta;
|
||||
return U.getAndAddLong(this, VALUE, delta) + delta;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -324,6 +327,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
||||
|
||||
/**
|
||||
* Returns the value of this {@code AtomicLong} as a {@code long}.
|
||||
* Equivalent to {@link #get()}.
|
||||
*/
|
||||
public long longValue() {
|
||||
return get();
|
||||
|
@ -34,9 +34,9 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
|
||||
import java.util.function.LongBinaryOperator;
|
||||
import sun.misc.Unsafe;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
|
||||
/**
|
||||
* A {@code long} array in which elements may be updated atomically.
|
||||
@ -48,16 +48,17 @@ import sun.misc.Unsafe;
|
||||
public class AtomicLongArray implements java.io.Serializable {
|
||||
private static final long serialVersionUID = -2308431214976778248L;
|
||||
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final int base = unsafe.arrayBaseOffset(long[].class);
|
||||
private static final int shift;
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final int ABASE;
|
||||
private static final int ASHIFT;
|
||||
private final long[] array;
|
||||
|
||||
static {
|
||||
int scale = unsafe.arrayIndexScale(long[].class);
|
||||
ABASE = U.arrayBaseOffset(long[].class);
|
||||
int scale = U.arrayIndexScale(long[].class);
|
||||
if ((scale & (scale - 1)) != 0)
|
||||
throw new Error("data type scale not a power of two");
|
||||
shift = 31 - Integer.numberOfLeadingZeros(scale);
|
||||
throw new Error("array index scale not a power of two");
|
||||
ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
||||
}
|
||||
|
||||
private long checkedByteOffset(int i) {
|
||||
@ -68,7 +69,7 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
private static long byteOffset(int i) {
|
||||
return ((long) i << shift) + base;
|
||||
return ((long) i << ASHIFT) + ABASE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,7 +114,7 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
private long getRaw(long offset) {
|
||||
return unsafe.getLongVolatile(array, offset);
|
||||
return U.getLongVolatile(array, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,7 +124,7 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
* @param newValue the new value
|
||||
*/
|
||||
public final void set(int i, long newValue) {
|
||||
unsafe.putLongVolatile(array, checkedByteOffset(i), newValue);
|
||||
U.putLongVolatile(array, checkedByteOffset(i), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,7 +135,7 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
* @since 1.6
|
||||
*/
|
||||
public final void lazySet(int i, long newValue) {
|
||||
unsafe.putOrderedLong(array, checkedByteOffset(i), newValue);
|
||||
U.putOrderedLong(array, checkedByteOffset(i), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,7 +147,7 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final long getAndSet(int i, long newValue) {
|
||||
return unsafe.getAndSetLong(array, checkedByteOffset(i), newValue);
|
||||
return U.getAndSetLong(array, checkedByteOffset(i), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,7 +165,7 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
private boolean compareAndSetRaw(long offset, long expect, long update) {
|
||||
return unsafe.compareAndSwapLong(array, offset, expect, update);
|
||||
return U.compareAndSwapLong(array, offset, expect, update);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,7 +213,7 @@ public class AtomicLongArray implements java.io.Serializable {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final long getAndAdd(int i, long delta) {
|
||||
return unsafe.getAndAddLong(array, checkedByteOffset(i), delta);
|
||||
return U.getAndAddLong(array, checkedByteOffset(i), delta);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,14 +34,14 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
import java.util.function.LongBinaryOperator;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.function.LongBinaryOperator;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
@ -366,7 +366,7 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
}
|
||||
|
||||
private static class CASUpdater<T> extends AtomicLongFieldUpdater<T> {
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private final long offset;
|
||||
private final Class<T> tclass;
|
||||
private final Class<?> cclass;
|
||||
@ -389,7 +389,7 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
ClassLoader ccl = caller.getClassLoader();
|
||||
if ((ccl != null) && (ccl != cl) &&
|
||||
((cl == null) || !isAncestor(cl, ccl))) {
|
||||
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
|
||||
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
|
||||
}
|
||||
} catch (PrivilegedActionException pae) {
|
||||
throw new RuntimeException(pae.getException());
|
||||
@ -407,7 +407,7 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
this.cclass = (Modifier.isProtected(modifiers) &&
|
||||
caller != tclass) ? caller : null;
|
||||
this.tclass = tclass;
|
||||
offset = unsafe.objectFieldOffset(field);
|
||||
offset = U.objectFieldOffset(field);
|
||||
}
|
||||
|
||||
private void fullCheck(T obj) {
|
||||
@ -419,32 +419,32 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
|
||||
public boolean compareAndSet(T obj, long expect, long update) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
return unsafe.compareAndSwapLong(obj, offset, expect, update);
|
||||
return U.compareAndSwapLong(obj, offset, expect, update);
|
||||
}
|
||||
|
||||
public boolean weakCompareAndSet(T obj, long expect, long update) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
return unsafe.compareAndSwapLong(obj, offset, expect, update);
|
||||
return U.compareAndSwapLong(obj, offset, expect, update);
|
||||
}
|
||||
|
||||
public void set(T obj, long newValue) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
unsafe.putLongVolatile(obj, offset, newValue);
|
||||
U.putLongVolatile(obj, offset, newValue);
|
||||
}
|
||||
|
||||
public void lazySet(T obj, long newValue) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
unsafe.putOrderedLong(obj, offset, newValue);
|
||||
U.putOrderedLong(obj, offset, newValue);
|
||||
}
|
||||
|
||||
public long get(T obj) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
return unsafe.getLongVolatile(obj, offset);
|
||||
return U.getLongVolatile(obj, offset);
|
||||
}
|
||||
|
||||
public long getAndSet(T obj, long newValue) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
return unsafe.getAndSetLong(obj, offset, newValue);
|
||||
return U.getAndSetLong(obj, offset, newValue);
|
||||
}
|
||||
|
||||
public long getAndIncrement(T obj) {
|
||||
@ -457,7 +457,7 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
|
||||
public long getAndAdd(T obj, long delta) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
return unsafe.getAndAddLong(obj, offset, delta);
|
||||
return U.getAndAddLong(obj, offset, delta);
|
||||
}
|
||||
|
||||
public long incrementAndGet(T obj) {
|
||||
@ -465,7 +465,7 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
}
|
||||
|
||||
public long decrementAndGet(T obj) {
|
||||
return getAndAdd(obj, -1) - 1;
|
||||
return getAndAdd(obj, -1) - 1;
|
||||
}
|
||||
|
||||
public long addAndGet(T obj, long delta) {
|
||||
@ -490,7 +490,7 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
|
||||
|
||||
private static class LockedUpdater<T> extends AtomicLongFieldUpdater<T> {
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private final long offset;
|
||||
private final Class<T> tclass;
|
||||
private final Class<?> cclass;
|
||||
@ -513,7 +513,7 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
ClassLoader ccl = caller.getClassLoader();
|
||||
if ((ccl != null) && (ccl != cl) &&
|
||||
((cl == null) || !isAncestor(cl, ccl))) {
|
||||
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
|
||||
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
|
||||
}
|
||||
} catch (PrivilegedActionException pae) {
|
||||
throw new RuntimeException(pae.getException());
|
||||
@ -531,7 +531,7 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
this.cclass = (Modifier.isProtected(modifiers) &&
|
||||
caller != tclass) ? caller : null;
|
||||
this.tclass = tclass;
|
||||
offset = unsafe.objectFieldOffset(field);
|
||||
offset = U.objectFieldOffset(field);
|
||||
}
|
||||
|
||||
private void fullCheck(T obj) {
|
||||
@ -544,10 +544,10 @@ 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) {
|
||||
long v = unsafe.getLong(obj, offset);
|
||||
long v = U.getLong(obj, offset);
|
||||
if (v != expect)
|
||||
return false;
|
||||
unsafe.putLong(obj, offset, update);
|
||||
U.putLong(obj, offset, update);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -559,7 +559,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) {
|
||||
unsafe.putLong(obj, offset, newValue);
|
||||
U.putLong(obj, offset, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -570,7 +570,7 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
public long get(T obj) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
|
||||
synchronized (this) {
|
||||
return unsafe.getLong(obj, offset);
|
||||
return U.getLong(obj, offset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -595,7 +595,7 @@ public abstract class AtomicLongFieldUpdater<T> {
|
||||
* classloader's delegation chain.
|
||||
* Equivalent to the inaccessible: first.isAncestor(second).
|
||||
*/
|
||||
private static boolean isAncestor(ClassLoader first, ClassLoader second) {
|
||||
static boolean isAncestor(ClassLoader first, ClassLoader second) {
|
||||
ClassLoader acl = first;
|
||||
do {
|
||||
acl = acl.getParent();
|
||||
|
@ -97,7 +97,7 @@ public class AtomicMarkableReference<V> {
|
||||
* Typical usage is {@code boolean[1] holder; ref = v.get(holder); }.
|
||||
*
|
||||
* @param markHolder an array of size of at least one. On return,
|
||||
* {@code markholder[0]} will hold the value of the mark.
|
||||
* {@code markHolder[0]} will hold the value of the mark.
|
||||
* @return the current value of the reference
|
||||
*/
|
||||
public V get(boolean[] markHolder) {
|
||||
@ -190,23 +190,18 @@ public class AtomicMarkableReference<V> {
|
||||
|
||||
// Unsafe mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long pairOffset =
|
||||
objectFieldOffset(UNSAFE, "pair", AtomicMarkableReference.class);
|
||||
|
||||
private boolean casPair(Pair<V> cmp, Pair<V> val) {
|
||||
return UNSAFE.compareAndSwapObject(this, pairOffset, cmp, val);
|
||||
}
|
||||
|
||||
static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
|
||||
String field, Class<?> klazz) {
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long PAIR;
|
||||
static {
|
||||
try {
|
||||
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Convert Exception to corresponding Error
|
||||
NoSuchFieldError error = new NoSuchFieldError(field);
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
PAIR = U.objectFieldOffset
|
||||
(AtomicMarkableReference.class.getDeclaredField("pair"));
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean casPair(Pair<V> cmp, Pair<V> val) {
|
||||
return U.compareAndSwapObject(this, PAIR, cmp, val);
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,9 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import java.util.function.BinaryOperator;
|
||||
import sun.misc.Unsafe;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
/**
|
||||
* An object reference that may be updated atomically. See the {@link
|
||||
@ -49,14 +49,16 @@ import sun.misc.Unsafe;
|
||||
public class AtomicReference<V> implements java.io.Serializable {
|
||||
private static final long serialVersionUID = -1848883965231344442L;
|
||||
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final long valueOffset;
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long VALUE;
|
||||
|
||||
static {
|
||||
try {
|
||||
valueOffset = unsafe.objectFieldOffset
|
||||
VALUE = U.objectFieldOffset
|
||||
(AtomicReference.class.getDeclaredField("value"));
|
||||
} catch (Exception ex) { throw new Error(ex); }
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private volatile V value;
|
||||
@ -101,7 +103,7 @@ public class AtomicReference<V> implements java.io.Serializable {
|
||||
* @since 1.6
|
||||
*/
|
||||
public final void lazySet(V newValue) {
|
||||
unsafe.putOrderedObject(this, valueOffset, newValue);
|
||||
U.putOrderedObject(this, VALUE, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,7 +115,7 @@ public class AtomicReference<V> implements java.io.Serializable {
|
||||
* the actual value was not equal to the expected value.
|
||||
*/
|
||||
public final boolean compareAndSet(V expect, V update) {
|
||||
return unsafe.compareAndSwapObject(this, valueOffset, expect, update);
|
||||
return U.compareAndSwapObject(this, VALUE, expect, update);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,7 +131,7 @@ public class AtomicReference<V> implements java.io.Serializable {
|
||||
* @return {@code true} if successful
|
||||
*/
|
||||
public final boolean weakCompareAndSet(V expect, V update) {
|
||||
return unsafe.compareAndSwapObject(this, valueOffset, expect, update);
|
||||
return U.compareAndSwapObject(this, VALUE, expect, update);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,7 +142,7 @@ public class AtomicReference<V> implements java.io.Serializable {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public final V getAndSet(V newValue) {
|
||||
return (V)unsafe.getAndSetObject(this, valueOffset, newValue);
|
||||
return (V)U.getAndSetObject(this, VALUE, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,11 +34,11 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.Arrays;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import sun.misc.Unsafe;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
/**
|
||||
* An array of object references in which elements may be updated
|
||||
@ -52,23 +52,22 @@ import sun.misc.Unsafe;
|
||||
public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
private static final long serialVersionUID = -6209656149925076980L;
|
||||
|
||||
private static final Unsafe unsafe;
|
||||
private static final int base;
|
||||
private static final int shift;
|
||||
private static final long arrayFieldOffset;
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final int ABASE;
|
||||
private static final int ASHIFT;
|
||||
private static final long ARRAY;
|
||||
private final Object[] array; // must have exact type Object[]
|
||||
|
||||
static {
|
||||
try {
|
||||
unsafe = Unsafe.getUnsafe();
|
||||
arrayFieldOffset = unsafe.objectFieldOffset
|
||||
ARRAY = U.objectFieldOffset
|
||||
(AtomicReferenceArray.class.getDeclaredField("array"));
|
||||
base = unsafe.arrayBaseOffset(Object[].class);
|
||||
int scale = unsafe.arrayIndexScale(Object[].class);
|
||||
ABASE = U.arrayBaseOffset(Object[].class);
|
||||
int scale = U.arrayIndexScale(Object[].class);
|
||||
if ((scale & (scale - 1)) != 0)
|
||||
throw new Error("data type scale not a power of two");
|
||||
shift = 31 - Integer.numberOfLeadingZeros(scale);
|
||||
} catch (Exception e) {
|
||||
throw new Error("array index scale not a power of two");
|
||||
ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
@ -81,7 +80,7 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
private static long byteOffset(int i) {
|
||||
return ((long) i << shift) + base;
|
||||
return ((long) i << ASHIFT) + ABASE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +126,7 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private E getRaw(long offset) {
|
||||
return (E) unsafe.getObjectVolatile(array, offset);
|
||||
return (E) U.getObjectVolatile(array, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,7 +136,7 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
* @param newValue the new value
|
||||
*/
|
||||
public final void set(int i, E newValue) {
|
||||
unsafe.putObjectVolatile(array, checkedByteOffset(i), newValue);
|
||||
U.putObjectVolatile(array, checkedByteOffset(i), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,7 +147,7 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
* @since 1.6
|
||||
*/
|
||||
public final void lazySet(int i, E newValue) {
|
||||
unsafe.putOrderedObject(array, checkedByteOffset(i), newValue);
|
||||
U.putOrderedObject(array, checkedByteOffset(i), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,7 +160,7 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public final E getAndSet(int i, E newValue) {
|
||||
return (E)unsafe.getAndSetObject(array, checkedByteOffset(i), newValue);
|
||||
return (E)U.getAndSetObject(array, checkedByteOffset(i), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,7 +178,7 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
private boolean compareAndSetRaw(long offset, E expect, E update) {
|
||||
return unsafe.compareAndSwapObject(array, offset, expect, update);
|
||||
return U.compareAndSwapObject(array, offset, expect, update);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -314,17 +313,20 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
||||
|
||||
/**
|
||||
* Reconstitutes the instance from a stream (that is, deserializes it).
|
||||
* @param s the stream
|
||||
* @throws ClassNotFoundException if the class of a serialized object
|
||||
* could not be found
|
||||
* @throws java.io.IOException if an I/O error occurs
|
||||
*/
|
||||
private void readObject(java.io.ObjectInputStream s)
|
||||
throws java.io.IOException, ClassNotFoundException,
|
||||
java.io.InvalidObjectException {
|
||||
throws java.io.IOException, ClassNotFoundException {
|
||||
// Note: This must be changed if any additional fields are defined
|
||||
Object a = s.readFields().get("array", null);
|
||||
if (a == null || !a.getClass().isArray())
|
||||
throw new java.io.InvalidObjectException("Not array type");
|
||||
if (a.getClass() != Object[].class)
|
||||
a = Arrays.copyOf((Object[])a, Array.getLength(a), Object[].class);
|
||||
unsafe.putObjectVolatile(this, arrayFieldOffset, a);
|
||||
U.putObjectVolatile(this, ARRAY, a);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,14 +34,14 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.function.BinaryOperator;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.UnaryOperator;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
@ -53,7 +53,7 @@ import sun.reflect.Reflection;
|
||||
* independently subject to atomic updates. For example, a tree node
|
||||
* might be declared as
|
||||
*
|
||||
* <pre> {@code
|
||||
* <pre> {@code
|
||||
* class Node {
|
||||
* private volatile Node left, right;
|
||||
*
|
||||
@ -62,7 +62,7 @@ import sun.reflect.Reflection;
|
||||
* private static AtomicReferenceFieldUpdater<Node, Node> rightUpdater =
|
||||
* AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "right");
|
||||
*
|
||||
* Node getLeft() { return left; }
|
||||
* Node getLeft() { return left; }
|
||||
* boolean compareAndSetLeft(Node expect, Node update) {
|
||||
* return leftUpdater.compareAndSet(this, expect, update);
|
||||
* }
|
||||
@ -284,7 +284,7 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
|
||||
private static final class AtomicReferenceFieldUpdaterImpl<T,V>
|
||||
extends AtomicReferenceFieldUpdater<T,V> {
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private final long offset;
|
||||
private final Class<T> tclass;
|
||||
private final Class<V> vclass;
|
||||
@ -323,7 +323,7 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
ClassLoader ccl = caller.getClassLoader();
|
||||
if ((ccl != null) && (ccl != cl) &&
|
||||
((cl == null) || !isAncestor(cl, ccl))) {
|
||||
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
|
||||
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
|
||||
}
|
||||
fieldClass = field.getType();
|
||||
} catch (PrivilegedActionException pae) {
|
||||
@ -347,7 +347,7 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
this.vclass = null;
|
||||
else
|
||||
this.vclass = vclass;
|
||||
offset = unsafe.objectFieldOffset(field);
|
||||
offset = U.objectFieldOffset(field);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -386,7 +386,7 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
(update != null && vclass != null &&
|
||||
vclass != update.getClass()))
|
||||
updateCheck(obj, update);
|
||||
return unsafe.compareAndSwapObject(obj, offset, expect, update);
|
||||
return U.compareAndSwapObject(obj, offset, expect, update);
|
||||
}
|
||||
|
||||
public boolean weakCompareAndSet(T obj, V expect, V update) {
|
||||
@ -395,7 +395,7 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
(update != null && vclass != null &&
|
||||
vclass != update.getClass()))
|
||||
updateCheck(obj, update);
|
||||
return unsafe.compareAndSwapObject(obj, offset, expect, update);
|
||||
return U.compareAndSwapObject(obj, offset, expect, update);
|
||||
}
|
||||
|
||||
public void set(T obj, V newValue) {
|
||||
@ -403,7 +403,7 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
(newValue != null && vclass != null &&
|
||||
vclass != newValue.getClass()))
|
||||
updateCheck(obj, newValue);
|
||||
unsafe.putObjectVolatile(obj, offset, newValue);
|
||||
U.putObjectVolatile(obj, offset, newValue);
|
||||
}
|
||||
|
||||
public void lazySet(T obj, V newValue) {
|
||||
@ -411,14 +411,14 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
(newValue != null && vclass != null &&
|
||||
vclass != newValue.getClass()))
|
||||
updateCheck(obj, newValue);
|
||||
unsafe.putOrderedObject(obj, offset, newValue);
|
||||
U.putOrderedObject(obj, offset, newValue);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public V get(T obj) {
|
||||
if (obj == null || obj.getClass() != tclass || cclass != null)
|
||||
targetCheck(obj);
|
||||
return (V)unsafe.getObjectVolatile(obj, offset);
|
||||
return (V)U.getObjectVolatile(obj, offset);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -427,7 +427,7 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
||||
(newValue != null && vclass != null &&
|
||||
vclass != newValue.getClass()))
|
||||
updateCheck(obj, newValue);
|
||||
return (V)unsafe.getAndSetObject(obj, offset, newValue);
|
||||
return (V)U.getAndSetObject(obj, offset, newValue);
|
||||
}
|
||||
|
||||
private void ensureProtectedAccess(T obj) {
|
||||
|
@ -97,7 +97,7 @@ public class AtomicStampedReference<V> {
|
||||
* Typical usage is {@code int[1] holder; ref = v.get(holder); }.
|
||||
*
|
||||
* @param stampHolder an array of size of at least one. On return,
|
||||
* {@code stampholder[0]} will hold the value of the stamp.
|
||||
* {@code stampHolder[0]} will hold the value of the stamp.
|
||||
* @return the current value of the reference
|
||||
*/
|
||||
public V get(int[] stampHolder) {
|
||||
@ -190,23 +190,18 @@ public class AtomicStampedReference<V> {
|
||||
|
||||
// Unsafe mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long pairOffset =
|
||||
objectFieldOffset(UNSAFE, "pair", AtomicStampedReference.class);
|
||||
|
||||
private boolean casPair(Pair<V> cmp, Pair<V> val) {
|
||||
return UNSAFE.compareAndSwapObject(this, pairOffset, cmp, val);
|
||||
}
|
||||
|
||||
static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
|
||||
String field, Class<?> klazz) {
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long PAIR;
|
||||
static {
|
||||
try {
|
||||
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Convert Exception to corresponding Error
|
||||
NoSuchFieldError error = new NoSuchFieldError(field);
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
PAIR = U.objectFieldOffset
|
||||
(AtomicStampedReference.class.getDeclaredField("pair"));
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean casPair(Pair<V> cmp, Pair<V> val) {
|
||||
return U.compareAndSwapObject(this, PAIR, cmp, val);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.function.DoubleBinaryOperator;
|
||||
|
||||
@ -126,14 +127,13 @@ public class DoubleAccumulator extends Striped64 implements Serializable {
|
||||
* @return the current value
|
||||
*/
|
||||
public double get() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
double result = Double.longBitsToDouble(base);
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null)
|
||||
for (Cell a : as)
|
||||
if (a != null)
|
||||
result = function.applyAsDouble
|
||||
(result, Double.longBitsToDouble(a.value));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -147,13 +147,12 @@ public class DoubleAccumulator extends Striped64 implements Serializable {
|
||||
* updating.
|
||||
*/
|
||||
public void reset() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
base = identity;
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null)
|
||||
a.value = identity;
|
||||
}
|
||||
for (Cell a : as)
|
||||
if (a != null)
|
||||
a.reset(identity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,14 +167,14 @@ public class DoubleAccumulator extends Striped64 implements Serializable {
|
||||
* @return the value before reset
|
||||
*/
|
||||
public double getThenReset() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
double result = Double.longBitsToDouble(base);
|
||||
base = identity;
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null) {
|
||||
for (Cell a : as) {
|
||||
if (a != null) {
|
||||
double v = Double.longBitsToDouble(a.value);
|
||||
a.value = identity;
|
||||
a.reset(identity);
|
||||
result = function.applyAsDouble(result, v);
|
||||
}
|
||||
}
|
||||
@ -237,21 +236,27 @@ public class DoubleAccumulator extends Striped64 implements Serializable {
|
||||
* @serial
|
||||
*/
|
||||
private final double value;
|
||||
|
||||
/**
|
||||
* The function used for updates.
|
||||
* @serial
|
||||
*/
|
||||
private final DoubleBinaryOperator function;
|
||||
|
||||
/**
|
||||
* The identity value
|
||||
* The identity value, represented as a long, as converted by
|
||||
* {@link Double#doubleToRawLongBits}. The original identity
|
||||
* can be recovered using {@link Double#longBitsToDouble}.
|
||||
* @serial
|
||||
*/
|
||||
private final long identity;
|
||||
|
||||
SerializationProxy(DoubleAccumulator a) {
|
||||
function = a.function;
|
||||
identity = a.identity;
|
||||
value = a.get();
|
||||
SerializationProxy(double value,
|
||||
DoubleBinaryOperator function,
|
||||
long identity) {
|
||||
this.value = value;
|
||||
this.function = function;
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -259,7 +264,7 @@ public class DoubleAccumulator extends Striped64 implements Serializable {
|
||||
* held by this proxy.
|
||||
*
|
||||
* @return a {@code DoubleAccumulator} object with initial state
|
||||
* held by this proxy.
|
||||
* held by this proxy
|
||||
*/
|
||||
private Object readResolve() {
|
||||
double d = Double.longBitsToDouble(identity);
|
||||
@ -279,7 +284,7 @@ public class DoubleAccumulator extends Striped64 implements Serializable {
|
||||
* representing the state of this instance
|
||||
*/
|
||||
private Object writeReplace() {
|
||||
return new SerializationProxy(this);
|
||||
return new SerializationProxy(get(), function, identity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -114,13 +115,12 @@ public class DoubleAdder extends Striped64 implements Serializable {
|
||||
* @return the sum
|
||||
*/
|
||||
public double sum() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
double sum = Double.longBitsToDouble(base);
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null)
|
||||
for (Cell a : as)
|
||||
if (a != null)
|
||||
sum += Double.longBitsToDouble(a.value);
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
@ -133,13 +133,12 @@ public class DoubleAdder extends Striped64 implements Serializable {
|
||||
* known that no threads are concurrently updating.
|
||||
*/
|
||||
public void reset() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
base = 0L; // relies on fact that double 0 must have same rep as long
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null)
|
||||
a.value = 0L;
|
||||
}
|
||||
for (Cell a : as)
|
||||
if (a != null)
|
||||
a.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,14 +153,14 @@ public class DoubleAdder extends Striped64 implements Serializable {
|
||||
* @return the sum
|
||||
*/
|
||||
public double sumThenReset() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
double sum = Double.longBitsToDouble(base);
|
||||
base = 0L;
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null) {
|
||||
for (Cell a : as) {
|
||||
if (a != null) {
|
||||
long v = a.value;
|
||||
a.value = 0L;
|
||||
a.reset();
|
||||
sum += Double.longBitsToDouble(v);
|
||||
}
|
||||
}
|
||||
@ -233,7 +232,7 @@ public class DoubleAdder extends Striped64 implements Serializable {
|
||||
* held by this proxy.
|
||||
*
|
||||
* @return a {@code DoubleAdder} object with initial state
|
||||
* held by this proxy.
|
||||
* held by this proxy
|
||||
*/
|
||||
private Object readResolve() {
|
||||
DoubleAdder a = new DoubleAdder();
|
||||
|
@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.function.LongBinaryOperator;
|
||||
|
||||
@ -124,13 +125,12 @@ public class LongAccumulator extends Striped64 implements Serializable {
|
||||
* @return the current value
|
||||
*/
|
||||
public long get() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
long result = base;
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null)
|
||||
for (Cell a : as)
|
||||
if (a != null)
|
||||
result = function.applyAsLong(result, a.value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -144,13 +144,12 @@ public class LongAccumulator extends Striped64 implements Serializable {
|
||||
* updating.
|
||||
*/
|
||||
public void reset() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
base = identity;
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null)
|
||||
a.value = identity;
|
||||
}
|
||||
for (Cell a : as)
|
||||
if (a != null)
|
||||
a.reset(identity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,14 +164,14 @@ public class LongAccumulator extends Striped64 implements Serializable {
|
||||
* @return the value before reset
|
||||
*/
|
||||
public long getThenReset() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
long result = base;
|
||||
base = identity;
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null) {
|
||||
for (Cell a : as) {
|
||||
if (a != null) {
|
||||
long v = a.value;
|
||||
a.value = identity;
|
||||
a.reset(identity);
|
||||
result = function.applyAsLong(result, v);
|
||||
}
|
||||
}
|
||||
@ -234,21 +233,25 @@ public class LongAccumulator extends Striped64 implements Serializable {
|
||||
* @serial
|
||||
*/
|
||||
private final long value;
|
||||
|
||||
/**
|
||||
* The function used for updates.
|
||||
* @serial
|
||||
*/
|
||||
private final LongBinaryOperator function;
|
||||
|
||||
/**
|
||||
* The identity value
|
||||
* The identity value.
|
||||
* @serial
|
||||
*/
|
||||
private final long identity;
|
||||
|
||||
SerializationProxy(LongAccumulator a) {
|
||||
function = a.function;
|
||||
identity = a.identity;
|
||||
value = a.get();
|
||||
SerializationProxy(long value,
|
||||
LongBinaryOperator function,
|
||||
long identity) {
|
||||
this.value = value;
|
||||
this.function = function;
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -256,7 +259,7 @@ public class LongAccumulator extends Striped64 implements Serializable {
|
||||
* held by this proxy.
|
||||
*
|
||||
* @return a {@code LongAccumulator} object with initial state
|
||||
* held by this proxy.
|
||||
* held by this proxy
|
||||
*/
|
||||
private Object readResolve() {
|
||||
LongAccumulator a = new LongAccumulator(function, identity);
|
||||
@ -275,7 +278,7 @@ public class LongAccumulator extends Striped64 implements Serializable {
|
||||
* representing the state of this instance
|
||||
*/
|
||||
private Object writeReplace() {
|
||||
return new SerializationProxy(this);
|
||||
return new SerializationProxy(get(), function, identity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -116,13 +117,12 @@ public class LongAdder extends Striped64 implements Serializable {
|
||||
* @return the sum
|
||||
*/
|
||||
public long sum() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
long sum = base;
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null)
|
||||
for (Cell a : as)
|
||||
if (a != null)
|
||||
sum += a.value;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
@ -135,13 +135,12 @@ public class LongAdder extends Striped64 implements Serializable {
|
||||
* known that no threads are concurrently updating.
|
||||
*/
|
||||
public void reset() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
base = 0L;
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null)
|
||||
a.value = 0L;
|
||||
}
|
||||
for (Cell a : as)
|
||||
if (a != null)
|
||||
a.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,14 +155,14 @@ public class LongAdder extends Striped64 implements Serializable {
|
||||
* @return the sum
|
||||
*/
|
||||
public long sumThenReset() {
|
||||
Cell[] as = cells; Cell a;
|
||||
Cell[] as = cells;
|
||||
long sum = base;
|
||||
base = 0L;
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null) {
|
||||
for (Cell a : as) {
|
||||
if (a != null) {
|
||||
sum += a.value;
|
||||
a.value = 0L;
|
||||
a.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -230,11 +229,11 @@ public class LongAdder extends Striped64 implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@code LongAdder} object with initial state
|
||||
* Returns a {@code LongAdder} object with initial state
|
||||
* held by this proxy.
|
||||
*
|
||||
* @return a {@code LongAdder} object with initial state
|
||||
* held by this proxy.
|
||||
* held by this proxy
|
||||
*/
|
||||
private Object readResolve() {
|
||||
LongAdder a = new LongAdder();
|
||||
|
@ -34,9 +34,11 @@
|
||||
*/
|
||||
|
||||
package java.util.concurrent.atomic;
|
||||
import java.util.function.LongBinaryOperator;
|
||||
import java.util.function.DoubleBinaryOperator;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.function.DoubleBinaryOperator;
|
||||
import java.util.function.LongBinaryOperator;
|
||||
|
||||
/**
|
||||
* A package-local class holding common representation and mechanics
|
||||
@ -121,19 +123,23 @@ abstract class Striped64 extends Number {
|
||||
volatile long value;
|
||||
Cell(long x) { value = x; }
|
||||
final boolean cas(long cmp, long val) {
|
||||
return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val);
|
||||
return U.compareAndSwapLong(this, VALUE, cmp, val);
|
||||
}
|
||||
final void reset() {
|
||||
U.putLongVolatile(this, VALUE, 0L);
|
||||
}
|
||||
final void reset(long identity) {
|
||||
U.putLongVolatile(this, VALUE, identity);
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long valueOffset;
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long VALUE;
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class<?> ak = Cell.class;
|
||||
valueOffset = UNSAFE.objectFieldOffset
|
||||
(ak.getDeclaredField("value"));
|
||||
} catch (Exception e) {
|
||||
VALUE = U.objectFieldOffset
|
||||
(Cell.class.getDeclaredField("value"));
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
@ -159,7 +165,7 @@ abstract class Striped64 extends Number {
|
||||
transient volatile int cellsBusy;
|
||||
|
||||
/**
|
||||
* Package-private default constructor
|
||||
* Package-private default constructor.
|
||||
*/
|
||||
Striped64() {
|
||||
}
|
||||
@ -168,14 +174,14 @@ abstract class Striped64 extends Number {
|
||||
* CASes the base field.
|
||||
*/
|
||||
final boolean casBase(long cmp, long val) {
|
||||
return UNSAFE.compareAndSwapLong(this, BASE, cmp, val);
|
||||
return U.compareAndSwapLong(this, BASE, cmp, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* CASes the cellsBusy field from 0 to 1 to acquire lock.
|
||||
*/
|
||||
final boolean casCellsBusy() {
|
||||
return UNSAFE.compareAndSwapInt(this, CELLSBUSY, 0, 1);
|
||||
return U.compareAndSwapInt(this, CELLSBUSY, 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,7 +189,7 @@ abstract class Striped64 extends Number {
|
||||
* Duplicated from ThreadLocalRandom because of packaging restrictions.
|
||||
*/
|
||||
static final int getProbe() {
|
||||
return UNSAFE.getInt(Thread.currentThread(), PROBE);
|
||||
return U.getInt(Thread.currentThread(), PROBE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,7 +201,7 @@ abstract class Striped64 extends Number {
|
||||
probe ^= probe << 13; // xorshift
|
||||
probe ^= probe >>> 17;
|
||||
probe ^= probe << 5;
|
||||
UNSAFE.putInt(Thread.currentThread(), PROBE, probe);
|
||||
U.putInt(Thread.currentThread(), PROBE, probe);
|
||||
return probe;
|
||||
}
|
||||
|
||||
@ -220,27 +226,24 @@ abstract class Striped64 extends Number {
|
||||
wasUncontended = true;
|
||||
}
|
||||
boolean collide = false; // True if last slot nonempty
|
||||
for (;;) {
|
||||
done: for (;;) {
|
||||
Cell[] as; Cell a; int n; long v;
|
||||
if ((as = cells) != null && (n = as.length) > 0) {
|
||||
if ((a = as[(n - 1) & h]) == null) {
|
||||
if (cellsBusy == 0) { // Try to attach new Cell
|
||||
Cell r = new Cell(x); // Optimistically create
|
||||
if (cellsBusy == 0 && casCellsBusy()) {
|
||||
boolean created = false;
|
||||
try { // Recheck under lock
|
||||
Cell[] rs; int m, j;
|
||||
if ((rs = cells) != null &&
|
||||
(m = rs.length) > 0 &&
|
||||
rs[j = (m - 1) & h] == null) {
|
||||
rs[j] = r;
|
||||
created = true;
|
||||
break done;
|
||||
}
|
||||
} finally {
|
||||
cellsBusy = 0;
|
||||
}
|
||||
if (created)
|
||||
break;
|
||||
continue; // Slot is now non-empty
|
||||
}
|
||||
}
|
||||
@ -248,8 +251,8 @@ abstract class Striped64 extends Number {
|
||||
}
|
||||
else if (!wasUncontended) // CAS already known to fail
|
||||
wasUncontended = true; // Continue after rehash
|
||||
else if (a.cas(v = a.value, ((fn == null) ? v + x :
|
||||
fn.applyAsLong(v, x))))
|
||||
else if (a.cas(v = a.value,
|
||||
(fn == null) ? v + x : fn.applyAsLong(v, x)))
|
||||
break;
|
||||
else if (n >= NCPU || cells != as)
|
||||
collide = false; // At max size or stale
|
||||
@ -257,12 +260,8 @@ abstract class Striped64 extends Number {
|
||||
collide = true;
|
||||
else if (cellsBusy == 0 && casCellsBusy()) {
|
||||
try {
|
||||
if (cells == as) { // Expand table unless stale
|
||||
Cell[] rs = new Cell[n << 1];
|
||||
for (int i = 0; i < n; ++i)
|
||||
rs[i] = as[i];
|
||||
cells = rs;
|
||||
}
|
||||
if (cells == as) // Expand table unless stale
|
||||
cells = Arrays.copyOf(as, n << 1);
|
||||
} finally {
|
||||
cellsBusy = 0;
|
||||
}
|
||||
@ -272,26 +271,30 @@ abstract class Striped64 extends Number {
|
||||
h = advanceProbe(h);
|
||||
}
|
||||
else if (cellsBusy == 0 && cells == as && casCellsBusy()) {
|
||||
boolean init = false;
|
||||
try { // Initialize table
|
||||
if (cells == as) {
|
||||
Cell[] rs = new Cell[2];
|
||||
rs[h & 1] = new Cell(x);
|
||||
cells = rs;
|
||||
init = true;
|
||||
break done;
|
||||
}
|
||||
} finally {
|
||||
cellsBusy = 0;
|
||||
}
|
||||
if (init)
|
||||
break;
|
||||
}
|
||||
else if (casBase(v = base, ((fn == null) ? v + x :
|
||||
fn.applyAsLong(v, x))))
|
||||
break; // Fall back on using base
|
||||
// Fall back on using base
|
||||
else if (casBase(v = base,
|
||||
(fn == null) ? v + x : fn.applyAsLong(v, x)))
|
||||
break done;
|
||||
}
|
||||
}
|
||||
|
||||
private static long apply(DoubleBinaryOperator fn, long v, double x) {
|
||||
double d = Double.longBitsToDouble(v);
|
||||
d = (fn == null) ? d + x : fn.applyAsDouble(d, x);
|
||||
return Double.doubleToRawLongBits(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as longAccumulate, but injecting long/double conversions
|
||||
* in too many places to sensibly merge with long version, given
|
||||
@ -307,27 +310,24 @@ abstract class Striped64 extends Number {
|
||||
wasUncontended = true;
|
||||
}
|
||||
boolean collide = false; // True if last slot nonempty
|
||||
for (;;) {
|
||||
done: for (;;) {
|
||||
Cell[] as; Cell a; int n; long v;
|
||||
if ((as = cells) != null && (n = as.length) > 0) {
|
||||
if ((a = as[(n - 1) & h]) == null) {
|
||||
if (cellsBusy == 0) { // Try to attach new Cell
|
||||
Cell r = new Cell(Double.doubleToRawLongBits(x));
|
||||
if (cellsBusy == 0 && casCellsBusy()) {
|
||||
boolean created = false;
|
||||
try { // Recheck under lock
|
||||
Cell[] rs; int m, j;
|
||||
if ((rs = cells) != null &&
|
||||
(m = rs.length) > 0 &&
|
||||
rs[j = (m - 1) & h] == null) {
|
||||
rs[j] = r;
|
||||
created = true;
|
||||
break done;
|
||||
}
|
||||
} finally {
|
||||
cellsBusy = 0;
|
||||
}
|
||||
if (created)
|
||||
break;
|
||||
continue; // Slot is now non-empty
|
||||
}
|
||||
}
|
||||
@ -335,13 +335,7 @@ abstract class Striped64 extends Number {
|
||||
}
|
||||
else if (!wasUncontended) // CAS already known to fail
|
||||
wasUncontended = true; // Continue after rehash
|
||||
else if (a.cas(v = a.value,
|
||||
((fn == null) ?
|
||||
Double.doubleToRawLongBits
|
||||
(Double.longBitsToDouble(v) + x) :
|
||||
Double.doubleToRawLongBits
|
||||
(fn.applyAsDouble
|
||||
(Double.longBitsToDouble(v), x)))))
|
||||
else if (a.cas(v = a.value, apply(fn, v, x)))
|
||||
break;
|
||||
else if (n >= NCPU || cells != as)
|
||||
collide = false; // At max size or stale
|
||||
@ -349,12 +343,8 @@ abstract class Striped64 extends Number {
|
||||
collide = true;
|
||||
else if (cellsBusy == 0 && casCellsBusy()) {
|
||||
try {
|
||||
if (cells == as) { // Expand table unless stale
|
||||
Cell[] rs = new Cell[n << 1];
|
||||
for (int i = 0; i < n; ++i)
|
||||
rs[i] = as[i];
|
||||
cells = rs;
|
||||
}
|
||||
if (cells == as) // Expand table unless stale
|
||||
cells = Arrays.copyOf(as, n << 1);
|
||||
} finally {
|
||||
cellsBusy = 0;
|
||||
}
|
||||
@ -364,48 +354,38 @@ abstract class Striped64 extends Number {
|
||||
h = advanceProbe(h);
|
||||
}
|
||||
else if (cellsBusy == 0 && cells == as && casCellsBusy()) {
|
||||
boolean init = false;
|
||||
try { // Initialize table
|
||||
if (cells == as) {
|
||||
Cell[] rs = new Cell[2];
|
||||
rs[h & 1] = new Cell(Double.doubleToRawLongBits(x));
|
||||
cells = rs;
|
||||
init = true;
|
||||
break done;
|
||||
}
|
||||
} finally {
|
||||
cellsBusy = 0;
|
||||
}
|
||||
if (init)
|
||||
break;
|
||||
}
|
||||
else if (casBase(v = base,
|
||||
((fn == null) ?
|
||||
Double.doubleToRawLongBits
|
||||
(Double.longBitsToDouble(v) + x) :
|
||||
Double.doubleToRawLongBits
|
||||
(fn.applyAsDouble
|
||||
(Double.longBitsToDouble(v), x)))))
|
||||
break; // Fall back on using base
|
||||
// Fall back on using base
|
||||
else if (casBase(v = base, apply(fn, v, x)))
|
||||
break done;
|
||||
}
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long BASE;
|
||||
private static final long CELLSBUSY;
|
||||
private static final long PROBE;
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class<?> sk = Striped64.class;
|
||||
BASE = UNSAFE.objectFieldOffset
|
||||
(sk.getDeclaredField("base"));
|
||||
CELLSBUSY = UNSAFE.objectFieldOffset
|
||||
(sk.getDeclaredField("cellsBusy"));
|
||||
Class<?> tk = Thread.class;
|
||||
PROBE = UNSAFE.objectFieldOffset
|
||||
(tk.getDeclaredField("threadLocalRandomProbe"));
|
||||
} catch (Exception e) {
|
||||
BASE = U.objectFieldOffset
|
||||
(Striped64.class.getDeclaredField("base"));
|
||||
CELLSBUSY = U.objectFieldOffset
|
||||
(Striped64.class.getDeclaredField("cellsBusy"));
|
||||
|
||||
PROBE = U.objectFieldOffset
|
||||
(Thread.class.getDeclaredField("threadLocalRandomProbe"));
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@
|
||||
* array elements to those that also provide an atomic conditional update
|
||||
* operation of the form:
|
||||
*
|
||||
* <pre> {@code boolean compareAndSet(expectedValue, updateValue);}</pre>
|
||||
* <pre> {@code boolean compareAndSet(expectedValue, updateValue);}</pre>
|
||||
*
|
||||
* <p>This method (which varies in argument types across different
|
||||
* classes) atomically sets a variable to the {@code updateValue} if it
|
||||
@ -67,7 +67,7 @@
|
||||
* {@code AtomicInteger} provide atomic increment methods. One
|
||||
* application is to generate sequence numbers, as in:
|
||||
*
|
||||
* <pre> {@code
|
||||
* <pre> {@code
|
||||
* class Sequencer {
|
||||
* private final AtomicLong sequenceNumber
|
||||
* = new AtomicLong(0);
|
||||
@ -82,7 +82,7 @@
|
||||
* <pre> {@code long transform(long input)}</pre>
|
||||
*
|
||||
* write your utility method as follows:
|
||||
* <pre> {@code
|
||||
* <pre> {@code
|
||||
* long getAndTransform(AtomicLong var) {
|
||||
* long prev, next;
|
||||
* do {
|
||||
@ -94,18 +94,19 @@
|
||||
*
|
||||
* <p>The memory effects for accesses and updates of atomics generally
|
||||
* follow the rules for volatiles, as stated in
|
||||
* <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.4">
|
||||
* The Java Language Specification (17.4 Memory Model)</a>:
|
||||
* <a href="https://docs.oracle.com/javase/specs/jls/se8/html/jls-17.html#jls-17.4">
|
||||
* Chapter 17 of
|
||||
* <cite>The Java™ Language Specification</cite></a>:
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li> {@code get} has the memory effects of reading a
|
||||
* <li>{@code get} has the memory effects of reading a
|
||||
* {@code volatile} variable.
|
||||
*
|
||||
* <li> {@code set} has the memory effects of writing (assigning) a
|
||||
* <li>{@code set} has the memory effects of writing (assigning) a
|
||||
* {@code volatile} variable.
|
||||
*
|
||||
* <li> {@code lazySet} has the memory effects of writing (assigning)
|
||||
* <li>{@code lazySet} has the memory effects of writing (assigning)
|
||||
* a {@code volatile} variable except that it permits reorderings with
|
||||
* subsequent (but not previous) memory actions that do not themselves
|
||||
* impose reordering constraints with ordinary non-{@code volatile}
|
||||
@ -119,7 +120,7 @@
|
||||
* with respect to previous or subsequent reads and writes of any
|
||||
* variables other than the target of the {@code weakCompareAndSet}.
|
||||
*
|
||||
* <li> {@code compareAndSet}
|
||||
* <li>{@code compareAndSet}
|
||||
* and all other read-and-update operations such as {@code getAndIncrement}
|
||||
* have the memory effects of both reading and
|
||||
* writing {@code volatile} variables.
|
||||
|
@ -36,10 +36,10 @@ import java.security.CodeSigner;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.AccessController;
|
||||
import java.security.CodeSource;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.misc.IOUtils;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.security.util.ManifestEntryVerifier;
|
||||
import sun.misc.SharedSecrets;
|
||||
import sun.security.util.SignatureFileVerifier;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import java.net.URL;
|
||||
import java.security.CodeSource;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import sun.misc.JavaUtilJarAccess;
|
||||
import jdk.internal.misc.JavaUtilJarAccess;
|
||||
|
||||
class JavaUtilJarAccessImpl implements JavaUtilJarAccess {
|
||||
public boolean jarFileHasClassPathAttribute(JarFile jar) throws IOException {
|
||||
|
@ -140,8 +140,10 @@ import java.util.Locale;
|
||||
* desired locale sensitive service is not available, then the runtime looks for CLDR,
|
||||
* JRE in that order.
|
||||
* <p>
|
||||
* The default order for looking up the preferred locale providers is "CLDR,JRE,SPI",
|
||||
* so specifying "CLDR,JRE,SPI" is identical to the default behavior.
|
||||
* The default order for looking up the preferred locale providers is "CLDR,JRE",
|
||||
* so specifying "CLDR,JRE" is identical to the default behavior. Applications which
|
||||
* require implementations of the locale sensitive services must explicitly specify
|
||||
* "SPI" in order for the Java runtime to load them from the classpath.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
|
@ -44,6 +44,8 @@ import java.util.Spliterators;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
import jdk.internal.misc.JavaUtilZipFileAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
|
||||
import static java.util.zip.ZipConstants64.*;
|
||||
|
||||
@ -781,12 +783,12 @@ class ZipFile implements ZipConstants, Closeable {
|
||||
}
|
||||
|
||||
static {
|
||||
sun.misc.SharedSecrets.setJavaUtilZipFileAccess(
|
||||
new sun.misc.JavaUtilZipFileAccess() {
|
||||
SharedSecrets.setJavaUtilZipFileAccess(
|
||||
new JavaUtilZipFileAccess() {
|
||||
public boolean startsWithLocHeader(ZipFile zip) {
|
||||
return zip.startsWithLocHeader();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -261,6 +261,7 @@ public final class ImageFileCreator {
|
||||
Map<String, List<Entry>> entriesForModule,
|
||||
ByteOrder byteOrder) throws IOException {
|
||||
ResourcePoolImpl resources = new ResourcePoolImpl(byteOrder);
|
||||
// Doesn't contain META-INF
|
||||
Set<String> mods = modulePackagesMap.keySet();
|
||||
for (String mn : mods) {
|
||||
for (Entry entry : entriesForModule.get(mn)) {
|
||||
@ -286,6 +287,31 @@ public final class ImageFileCreator {
|
||||
Archive archive = nameToArchive.get(mn);
|
||||
archive.close();
|
||||
}
|
||||
// Fix for 8136365. Do we have an archive with module name "META-INF"?
|
||||
// If yes, we are recreating a jimage.
|
||||
// This is a workaround for META-INF being at the top level of resource path
|
||||
String mn = "META-INF";
|
||||
Archive archive = nameToArchive.get(mn);
|
||||
if (archive != null) {
|
||||
try {
|
||||
for (Entry entry : entriesForModule.get(mn)) {
|
||||
String path = entry.name();
|
||||
try (InputStream stream = entry.stream()) {
|
||||
byte[] bytes = readAllBytes(stream);
|
||||
path = mn + "/" + path;
|
||||
try {
|
||||
resources.addResource(new ResourcePool.Resource(path,
|
||||
ByteBuffer.wrap(bytes)));
|
||||
} catch (Exception ex) {
|
||||
throw new IOException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
// Done with this archive, close it.
|
||||
archive.close();
|
||||
}
|
||||
}
|
||||
return resources;
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,6 @@ package jdk.internal.jimage;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import sun.misc.JavaNioAccess;
|
||||
import sun.misc.SharedSecrets;
|
||||
|
||||
public final class ImageNativeSubstrate implements ImageSubstrate {
|
||||
static {
|
||||
@ -42,8 +40,10 @@ public final class ImageNativeSubstrate implements ImageSubstrate {
|
||||
});
|
||||
}
|
||||
|
||||
private static final JavaNioAccess NIOACCESS =
|
||||
SharedSecrets.getJavaNioAccess();
|
||||
// TODO: Reinstate when the class below, NIOACCESS, is removed.
|
||||
//private static final JavaNioAccess NIOACCESS =
|
||||
// SharedSecrets.getJavaNioAccess();
|
||||
|
||||
|
||||
private final long id;
|
||||
private final long indexAddress;
|
||||
@ -161,4 +161,59 @@ public final class ImageNativeSubstrate implements ImageSubstrate {
|
||||
public int[] attributeOffsets() {
|
||||
return attributeOffsets(id);
|
||||
}
|
||||
|
||||
// TODO: Remove when JRT-FS no longer indirectly depends on ImageNativeSubstrate
|
||||
/**
|
||||
* Reflective wrapper around ShareSecrets JavaNioAccess.
|
||||
*
|
||||
* SharedSecrets and friend interfaces moved from 'sun.misc' to 'jdk.internal.misc'
|
||||
* in 1.9. This class provides the runtime with access to the appropriate
|
||||
* JavaNioAccess methods whether running on 1.9, or lower.
|
||||
*/
|
||||
static class NIOACCESS {
|
||||
|
||||
private static final String PKG_PREFIX = "jdk.internal.misc";
|
||||
private static final String LEGACY_PKG_PREFIX = "sun.misc";
|
||||
|
||||
private static final Object javaNioAccess;
|
||||
private static final java.lang.reflect.Method newDirectByteBufferMethod;
|
||||
|
||||
static {
|
||||
try {
|
||||
Class<?> c = getJDKClass("JavaNioAccess");
|
||||
|
||||
java.lang.reflect.Method m =
|
||||
getJDKClass("SharedSecrets").getDeclaredMethod("getJavaNioAccess");
|
||||
javaNioAccess = m.invoke(null);
|
||||
|
||||
newDirectByteBufferMethod = c.getDeclaredMethod("newDirectByteBuffer",
|
||||
long.class,
|
||||
int.class,
|
||||
Object.class);
|
||||
} catch (ReflectiveOperationException x) {
|
||||
throw new InternalError(x);
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<?> getJDKClass(String name) throws ClassNotFoundException {
|
||||
try {
|
||||
return Class.forName(PKG_PREFIX + "." + name);
|
||||
} catch (ClassNotFoundException x) {
|
||||
try {
|
||||
return Class.forName(LEGACY_PKG_PREFIX + "." + name);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
x.addSuppressed(ex);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ByteBuffer newDirectByteBuffer(long addr, int cap, Object ob) {
|
||||
try {
|
||||
return (ByteBuffer) newDirectByteBufferMethod.invoke(javaNioAccess, addr, cap, ob);
|
||||
} catch (ReflectiveOperationException x) {
|
||||
throw new InternalError(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
public interface JavaAWTAccess {
|
||||
|
@ -27,7 +27,7 @@
|
||||
* SharedSecrets interface used for the access from java.text.Bidi
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
public interface JavaAWTFontAccess {
|
||||
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
@ -23,7 +23,8 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.io.Console;
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -22,7 +22,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Executable;
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
public interface JavaLangRefAccess {
|
||||
|
@ -23,9 +23,10 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.net.URLClassLoader;
|
||||
import sun.misc.URLClassPath;
|
||||
|
||||
public interface JavaNetAccess {
|
||||
/**
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.net.HttpCookie;
|
||||
import java.util.List;
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.PrivilegedAction;
|
@ -22,7 +22,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.security.PermissionCollection;
|
||||
import java.security.ProtectionDomain;
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.util.zip.ZipFile;
|
||||
|
@ -23,14 +23,14 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.util.jar.JarFile;
|
||||
import java.io.Console;
|
||||
import java.io.FileDescriptor;
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import java.security.AccessController;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
/** A repository of "shared secrets", which are a mechanism for
|
||||
calling implementation-private methods in another package without
|
@ -66,6 +66,8 @@ import java.util.jar.Attributes.Name;
|
||||
|
||||
import jdk.internal.jimage.ImageLocation;
|
||||
import jdk.internal.jimage.ImageReader;
|
||||
import jdk.internal.misc.JavaUtilZipFileAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
|
||||
import sun.net.util.URLUtil;
|
||||
import sun.net.www.ParseUtil;
|
||||
@ -622,8 +624,8 @@ public class URLClassPath {
|
||||
private URLStreamHandler handler;
|
||||
private HashMap<String, Loader> lmap;
|
||||
private boolean closed = false;
|
||||
private static final sun.misc.JavaUtilZipFileAccess zipAccess =
|
||||
sun.misc.SharedSecrets.getJavaUtilZipFileAccess();
|
||||
private static final JavaUtilZipFileAccess zipAccess =
|
||||
SharedSecrets.getJavaUtilZipFileAccess();
|
||||
|
||||
/*
|
||||
* Creates a new JarLoader for the specified URL referring to
|
||||
|
@ -29,8 +29,8 @@ import java.io.IOException;
|
||||
import java.io.FileDescriptor;
|
||||
import java.security.AccessController;
|
||||
|
||||
import sun.misc.SharedSecrets;
|
||||
import sun.misc.JavaIOFileDescriptorAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaIOFileDescriptorAccess;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -65,6 +65,8 @@ import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import jdk.internal.misc.JavaNetHttpCookieAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.net.*;
|
||||
import sun.net.www.*;
|
||||
import sun.net.www.http.HttpClient;
|
||||
@ -2878,8 +2880,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
if (cookieHandler == null || value.length() == 0)
|
||||
return value;
|
||||
|
||||
sun.misc.JavaNetHttpCookieAccess access =
|
||||
sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
|
||||
JavaNetHttpCookieAccess access =
|
||||
SharedSecrets.getJavaNetHttpCookieAccess();
|
||||
StringJoiner retValue = new StringJoiner(","); // RFC 2965, comma separated
|
||||
List<HttpCookie> cookies = access.parse(value);
|
||||
for (HttpCookie cookie : cookies) {
|
||||
|
@ -44,9 +44,10 @@ import java.security.AccessController;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.internal.misc.JavaIOFileDescriptorAccess;
|
||||
import jdk.internal.misc.JavaNioAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.JavaIOFileDescriptorAccess;
|
||||
import sun.misc.SharedSecrets;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
public class FileChannelImpl
|
||||
@ -976,8 +977,8 @@ public class FileChannelImpl
|
||||
* Invoked by sun.management.ManagementFactoryHelper to create the management
|
||||
* interface for mapped buffers.
|
||||
*/
|
||||
public static sun.misc.JavaNioAccess.BufferPool getMappedBufferPool() {
|
||||
return new sun.misc.JavaNioAccess.BufferPool() {
|
||||
public static JavaNioAccess.BufferPool getMappedBufferPool() {
|
||||
return new JavaNioAccess.BufferPool() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "mapped";
|
||||
|
@ -35,12 +35,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import sun.misc.JavaLangAccess;
|
||||
import sun.reflect.LangReflectAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaLangAccess;
|
||||
import sun.reflect.ReflectionFactory;
|
||||
|
||||
public final class AnnotationSupport {
|
||||
private static final JavaLangAccess LANG_ACCESS = sun.misc.SharedSecrets.getJavaLangAccess();
|
||||
private static final JavaLangAccess LANG_ACCESS = SharedSecrets.getJavaLangAccess();
|
||||
|
||||
/**
|
||||
* Finds and returns all annotations in {@code annotations} matching
|
||||
|
@ -25,13 +25,13 @@
|
||||
|
||||
package sun.reflect.annotation;
|
||||
|
||||
import sun.misc.JavaLangAccess;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaLangAccess;
|
||||
|
||||
/**
|
||||
* Represents an annotation type at run time. Used to type-check annotations
|
||||
@ -79,7 +79,7 @@ public class AnnotationType {
|
||||
public static AnnotationType getInstance(
|
||||
Class<? extends Annotation> annotationClass)
|
||||
{
|
||||
JavaLangAccess jla = sun.misc.SharedSecrets.getJavaLangAccess();
|
||||
JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
|
||||
AnnotationType result = jla.getAnnotationType(annotationClass); // volatile read
|
||||
if (result == null) {
|
||||
result = new AnnotationType(annotationClass);
|
||||
@ -134,7 +134,7 @@ public class AnnotationType {
|
||||
// of the corresponding annotation types breaks infinite recursion.
|
||||
if (annotationClass != Retention.class &&
|
||||
annotationClass != Inherited.class) {
|
||||
JavaLangAccess jla = sun.misc.SharedSecrets.getJavaLangAccess();
|
||||
JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
|
||||
Map<Class<? extends Annotation>, Annotation> metaAnnotations =
|
||||
AnnotationParser.parseSelectAnnotations(
|
||||
jla.getRawClassAnnotations(annotationClass),
|
||||
|
@ -35,7 +35,8 @@ import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import sun.misc.JavaLangAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaLangAccess;
|
||||
import sun.reflect.ConstantPool;
|
||||
import static sun.reflect.annotation.TypeAnnotation.*;
|
||||
|
||||
@ -309,7 +310,7 @@ public final class TypeAnnotationParser {
|
||||
static TypeAnnotation[] parseAllTypeAnnotations(AnnotatedElement decl) {
|
||||
Class<?> container;
|
||||
byte[] rawBytes;
|
||||
JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess();
|
||||
JavaLangAccess javaLangAccess = SharedSecrets.getJavaLangAccess();
|
||||
if (decl instanceof Class) {
|
||||
container = (Class<?>)decl;
|
||||
rawBytes = javaLangAccess.getRawClassTypeAnnotations(container);
|
||||
|
@ -41,9 +41,9 @@ import java.io.FilePermission;
|
||||
import java.net.SocketPermission;
|
||||
import java.net.NetPermission;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import sun.misc.JavaSecurityProtectionDomainAccess;
|
||||
import static sun.misc.JavaSecurityProtectionDomainAccess.ProtectionDomainCache;
|
||||
import sun.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaSecurityProtectionDomainAccess;
|
||||
import static jdk.internal.misc.JavaSecurityProtectionDomainAccess.ProtectionDomainCache;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.security.util.PolicyUtil;
|
||||
import sun.security.util.PropertyExpander;
|
||||
import sun.security.util.Debug;
|
||||
|
@ -49,7 +49,7 @@ import javax.net.ssl.SSLException;
|
||||
* enum { ocsp(1), ocsp_multi(2), (255) } CertificateStatusType;
|
||||
*/
|
||||
|
||||
final class CertStatusReqItemV2 implements StatusRequest {
|
||||
final class CertStatusReqItemV2 {
|
||||
|
||||
private final StatusRequestType statReqType;
|
||||
private final StatusRequest request;
|
||||
@ -144,8 +144,7 @@ final class CertStatusReqItemV2 implements StatusRequest {
|
||||
*
|
||||
* @return the encoded length of this {@code CertStatusReqItemV2}
|
||||
*/
|
||||
@Override
|
||||
public int length() {
|
||||
int length() {
|
||||
// The length is the the status type (1 byte) + the request length
|
||||
// field (2 bytes) + the StatusRequest data length.
|
||||
return request.length() + 3;
|
||||
@ -159,8 +158,7 @@ final class CertStatusReqItemV2 implements StatusRequest {
|
||||
*
|
||||
* @throws IOException if any errors occur during the encoding process
|
||||
*/
|
||||
@Override
|
||||
public void send(HandshakeOutStream s) throws IOException {
|
||||
void send(HandshakeOutStream s) throws IOException {
|
||||
s.putInt8(statReqType.id);
|
||||
s.putInt16(request.length());
|
||||
request.send(s);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user