Merge
This commit is contained in:
commit
638a8b7435
3
.hgtags
3
.hgtags
@ -132,3 +132,6 @@ bc5710332b294676661103bb20d47d2ea3ba8def jdk8-b07
|
||||
24ee504f80412770c6874836cd9e55b536427b1d jdk8-b08
|
||||
fbf3cabc9e3bb1fcf710941d777cb0400505fbe6 jdk8-b09
|
||||
f651ce87127980c58e3599daba964eba2f3b4026 jdk8-b10
|
||||
cc1f5ce8e504d350e0b0c28c5f84333f8d540132 jdk8-b11
|
||||
86db042b3385c338e17f7664447fdc7d406dd19e jdk8-b12
|
||||
4cc0ef72c812943743ef4765f1100e2fbe2b1a08 jdk8-b13
|
||||
|
@ -132,3 +132,6 @@ b910aac18c772b823b1f7da03e2c6528725cc6de jdk8-b05
|
||||
fb1bc13260d76447e269e843859eb593fe2a8ab2 jdk8-b08
|
||||
8adb70647b5af5273dfe6a540f07be667cd50216 jdk8-b09
|
||||
a6c4c248e8fa350c35014fa94bab5ac1a1ac3299 jdk8-b10
|
||||
1defbc57940a56f0aa41e9dee87b71e8c8b71103 jdk8-b11
|
||||
8e2104d565baee473895d5eba20e39f85ab4bf9f jdk8-b12
|
||||
26fb81a1e9ceb9baffba216acd9ded62e9e9d5ab jdk8-b13
|
||||
|
@ -132,3 +132,6 @@ cc1b599b986a37cb57de4584c5e58169766ca535 jdk8-b05
|
||||
0d52b1c87aa8fdea7fdc9c4126ea58f95ca6b351 jdk8-b08
|
||||
a891732c1a83082177ff7a4cf1506068d9cc0a47 jdk8-b09
|
||||
cda87f7fefcee3b89742a57ce5ad9b03a54c210d jdk8-b10
|
||||
0199e4fef5cc2bd234c65b93220459ef7a3bb3b1 jdk8-b11
|
||||
31d70911b712c6b4e580a3110363d5f044cfed7a jdk8-b12
|
||||
5b9d9b839d3d7fe02347827221c97c6d242a6f96 jdk8-b13
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -2243,6 +2243,10 @@ public class IIOPInputStream
|
||||
}
|
||||
|
||||
try {
|
||||
Class fieldCl = fields[i].getClazz();
|
||||
if (objectValue != null && !fieldCl.isInstance(objectValue)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
bridge.putObject( o, fields[i].getFieldID(), objectValue ) ;
|
||||
// reflective code: fields[i].getField().set( o, objectValue ) ;
|
||||
} catch (IllegalArgumentException e) {
|
||||
@ -2553,6 +2557,10 @@ public class IIOPInputStream
|
||||
{
|
||||
try {
|
||||
Field fld = c.getDeclaredField( fieldName ) ;
|
||||
Class fieldCl = fld.getType();
|
||||
if(v != null && !fieldCl.isInstance(v)) {
|
||||
throw new Exception();
|
||||
}
|
||||
long key = bridge.objectFieldOffset( fld ) ;
|
||||
bridge.putObject( o, key, v ) ;
|
||||
} catch (Exception e) {
|
||||
|
@ -193,3 +193,8 @@ da883b9e6d3788057f9577e72712998ed82c9b7e hs23-b01
|
||||
e4f412d2b75d2c797acff965aa2c420e3d358f09 hs23-b02
|
||||
d815de2e85e511b7deab2a83cf80c0224d011da9 jdk8-b10
|
||||
4d3850d9d326ac3a9bee2d867727e954322d014e hs23-b03
|
||||
4538caeef7b6cbd4302bebced805d65e68ccf301 jdk8-b11
|
||||
6534482ff68ad79066dfe15dfb6d8905f09681bd hs23-b04
|
||||
1d3900713a67a0a39faf4e12c9c158d55aebef87 jdk8-b12
|
||||
3e609627e780736f372eb14d29bb9b5e53b21fbf hs23-b05
|
||||
b92ca8e229d29004f840c67e620833d23a346761 jdk8-b13
|
||||
|
@ -234,6 +234,8 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
|
||||
echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
|
||||
echo "$(call gamma-path,altsrc,share/vm) \\"; \
|
||||
echo "$(call gamma-path,commonsrc,share/vm) \\"; \
|
||||
echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
|
||||
echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
|
||||
echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
|
||||
echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
|
||||
echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
|
||||
|
@ -88,7 +88,7 @@ ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \
|
||||
ifneq ($(USE_PRECOMPILED_HEADER),0)
|
||||
USE_PRECOMPILED_HEADER=1
|
||||
PRECOMPILED_HEADER_DIR=.
|
||||
PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp
|
||||
PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
|
||||
PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
|
||||
endif
|
||||
endif
|
||||
|
@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2011
|
||||
|
||||
HS_MAJOR_VER=23
|
||||
HS_MINOR_VER=0
|
||||
HS_BUILD_NUMBER=03
|
||||
HS_BUILD_NUMBER=05
|
||||
|
||||
JDK_MAJOR_VER=1
|
||||
JDK_MINOR_VER=8
|
||||
|
@ -223,6 +223,8 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
|
||||
echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
|
||||
echo "$(call gamma-path,altsrc,share/vm) \\"; \
|
||||
echo "$(call gamma-path,commonsrc,share/vm) \\"; \
|
||||
echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
|
||||
echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
|
||||
echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
|
||||
echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
|
||||
echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
|
||||
|
@ -52,7 +52,7 @@ ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \
|
||||
ifneq ($(USE_PRECOMPILED_HEADER),0)
|
||||
USE_PRECOMPILED_HEADER=1
|
||||
PRECOMPILED_HEADER_DIR=.
|
||||
PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp
|
||||
PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
|
||||
PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
|
||||
endif
|
||||
endif
|
||||
|
@ -216,6 +216,8 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
|
||||
echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
|
||||
echo "$(call gamma-path,altsrc,share/vm) \\"; \
|
||||
echo "$(call gamma-path,commonsrc,share/vm) \\"; \
|
||||
echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
|
||||
echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
|
||||
echo "$(call gamma-path,altsrc,cpu/$(ARCH)/vm) \\"; \
|
||||
echo "$(call gamma-path,commonsrc,cpu/$(ARCH)/vm) \\"; \
|
||||
echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -51,7 +51,7 @@ ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \
|
||||
ifneq ($(USE_PRECOMPILED_HEADER),0)
|
||||
USE_PRECOMPILED_HEADER=1
|
||||
PRECOMPILED_HEADER_DIR=.
|
||||
PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp
|
||||
PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
|
||||
PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
|
||||
endif
|
||||
endif
|
||||
|
@ -134,6 +134,7 @@ CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) /I "$(ALTSRC)\cpu\$(Platform_arch)\vm"
|
||||
|
||||
CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) \
|
||||
/I "$(COMMONSRC)\share\vm" \
|
||||
/I "$(COMMONSRC)\share\vm\precompiled" \
|
||||
/I "$(COMMONSRC)\share\vm\prims" \
|
||||
/I "$(COMMONSRC)\os\windows\vm" \
|
||||
/I "$(COMMONSRC)\os_cpu\windows_$(Platform_arch)\vm" \
|
||||
|
@ -62,7 +62,7 @@ void CompactibleFreeListSpace::set_cms_values() {
|
||||
MinChunkSize = numQuanta(sizeof(FreeChunk), MinObjAlignmentInBytes) * MinObjAlignment;
|
||||
|
||||
assert(IndexSetStart == 0 && IndexSetStride == 0, "already set");
|
||||
IndexSetStart = MinObjAlignment;
|
||||
IndexSetStart = (int) MinChunkSize;
|
||||
IndexSetStride = MinObjAlignment;
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ CompactibleFreeListSpace::CompactibleFreeListSpace(BlockOffsetSharedArray* bs,
|
||||
} else {
|
||||
_fitStrategy = FreeBlockStrategyNone;
|
||||
}
|
||||
checkFreeListConsistency();
|
||||
check_free_list_consistency();
|
||||
|
||||
// Initialize locks for parallel case.
|
||||
|
||||
@ -1358,17 +1358,29 @@ FreeChunk* CompactibleFreeListSpace::getChunkFromGreater(size_t numWords) {
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
|
||||
bool CompactibleFreeListSpace::verifyChunkInIndexedFreeLists(FreeChunk* fc)
|
||||
const {
|
||||
bool CompactibleFreeListSpace::verifyChunkInIndexedFreeLists(FreeChunk* fc) const {
|
||||
assert(fc->size() < IndexSetSize, "Size of chunk is too large");
|
||||
return _indexedFreeList[fc->size()].verifyChunkInFreeLists(fc);
|
||||
}
|
||||
|
||||
bool CompactibleFreeListSpace::verify_chunk_is_linear_alloc_block(FreeChunk* fc) const {
|
||||
assert((_smallLinearAllocBlock._ptr != (HeapWord*)fc) ||
|
||||
(_smallLinearAllocBlock._word_size == fc->size()),
|
||||
"Linear allocation block shows incorrect size");
|
||||
return ((_smallLinearAllocBlock._ptr == (HeapWord*)fc) &&
|
||||
(_smallLinearAllocBlock._word_size == fc->size()));
|
||||
}
|
||||
|
||||
// Check if the purported free chunk is present either as a linear
|
||||
// allocation block, the size-indexed table of (smaller) free blocks,
|
||||
// or the larger free blocks kept in the binary tree dictionary.
|
||||
bool CompactibleFreeListSpace::verifyChunkInFreeLists(FreeChunk* fc) const {
|
||||
if (fc->size() >= IndexSetSize) {
|
||||
return dictionary()->verifyChunkInFreeLists(fc);
|
||||
} else {
|
||||
if (verify_chunk_is_linear_alloc_block(fc)) {
|
||||
return true;
|
||||
} else if (fc->size() < IndexSetSize) {
|
||||
return verifyChunkInIndexedFreeLists(fc);
|
||||
} else {
|
||||
return dictionary()->verifyChunkInFreeLists(fc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2495,7 +2507,8 @@ void CompactibleFreeListSpace::verifyIndexedFreeList(size_t size) const {
|
||||
FreeChunk* tail = _indexedFreeList[size].tail();
|
||||
size_t num = _indexedFreeList[size].count();
|
||||
size_t n = 0;
|
||||
guarantee((size % 2 == 0) || fc == NULL, "Odd slots should be empty");
|
||||
guarantee(((size >= MinChunkSize) && (size % IndexSetStride == 0)) || fc == NULL,
|
||||
"Slot should have been empty");
|
||||
for (; fc != NULL; fc = fc->next(), n++) {
|
||||
guarantee(fc->size() == size, "Size inconsistency");
|
||||
guarantee(fc->isFree(), "!free?");
|
||||
@ -2506,14 +2519,14 @@ void CompactibleFreeListSpace::verifyIndexedFreeList(size_t size) const {
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
void CompactibleFreeListSpace::checkFreeListConsistency() const {
|
||||
void CompactibleFreeListSpace::check_free_list_consistency() const {
|
||||
assert(_dictionary->minSize() <= IndexSetSize,
|
||||
"Some sizes can't be allocated without recourse to"
|
||||
" linear allocation buffers");
|
||||
assert(MIN_TREE_CHUNK_SIZE*HeapWordSize == sizeof(TreeChunk),
|
||||
"else MIN_TREE_CHUNK_SIZE is wrong");
|
||||
assert((IndexSetStride == 2 && IndexSetStart == 2) ||
|
||||
(IndexSetStride == 1 && IndexSetStart == 1), "just checking");
|
||||
assert((IndexSetStride == 2 && IndexSetStart == 4) || // 32-bit
|
||||
(IndexSetStride == 1 && IndexSetStart == 3), "just checking"); // 64-bit
|
||||
assert((IndexSetStride != 2) || (MinChunkSize % 2 == 0),
|
||||
"Some for-loops may be incorrectly initialized");
|
||||
assert((IndexSetStride != 2) || (IndexSetSize % 2 == 1),
|
||||
@ -2688,33 +2701,27 @@ void CFLS_LAB::compute_desired_plab_size() {
|
||||
}
|
||||
}
|
||||
|
||||
// If this is changed in the future to allow parallel
|
||||
// access, one would need to take the FL locks and,
|
||||
// depending on how it is used, stagger access from
|
||||
// parallel threads to reduce contention.
|
||||
void CFLS_LAB::retire(int tid) {
|
||||
// We run this single threaded with the world stopped;
|
||||
// so no need for locks and such.
|
||||
#define CFLS_LAB_PARALLEL_ACCESS 0
|
||||
NOT_PRODUCT(Thread* t = Thread::current();)
|
||||
assert(Thread::current()->is_VM_thread(), "Error");
|
||||
assert(CompactibleFreeListSpace::IndexSetStart == CompactibleFreeListSpace::IndexSetStride,
|
||||
"Will access to uninitialized slot below");
|
||||
#if CFLS_LAB_PARALLEL_ACCESS
|
||||
for (size_t i = CompactibleFreeListSpace::IndexSetSize - 1;
|
||||
i > 0;
|
||||
i -= CompactibleFreeListSpace::IndexSetStride) {
|
||||
#else // CFLS_LAB_PARALLEL_ACCESS
|
||||
for (size_t i = CompactibleFreeListSpace::IndexSetStart;
|
||||
i < CompactibleFreeListSpace::IndexSetSize;
|
||||
i += CompactibleFreeListSpace::IndexSetStride) {
|
||||
#endif // !CFLS_LAB_PARALLEL_ACCESS
|
||||
assert(_num_blocks[i] >= (size_t)_indexedFreeList[i].count(),
|
||||
"Can't retire more than what we obtained");
|
||||
if (_num_blocks[i] > 0) {
|
||||
size_t num_retire = _indexedFreeList[i].count();
|
||||
assert(_num_blocks[i] > num_retire, "Should have used at least one");
|
||||
{
|
||||
#if CFLS_LAB_PARALLEL_ACCESS
|
||||
MutexLockerEx x(_cfls->_indexedFreeListParLocks[i],
|
||||
Mutex::_no_safepoint_check_flag);
|
||||
#endif // CFLS_LAB_PARALLEL_ACCESS
|
||||
// MutexLockerEx x(_cfls->_indexedFreeListParLocks[i],
|
||||
// Mutex::_no_safepoint_check_flag);
|
||||
|
||||
// Update globals stats for num_blocks used
|
||||
_global_num_blocks[i] += (_num_blocks[i] - num_retire);
|
||||
_global_num_workers[i]++;
|
||||
|
@ -502,10 +502,14 @@ class CompactibleFreeListSpace: public CompactibleSpace {
|
||||
void verifyFreeLists() const PRODUCT_RETURN;
|
||||
void verifyIndexedFreeLists() const;
|
||||
void verifyIndexedFreeList(size_t size) const;
|
||||
// verify that the given chunk is in the free lists.
|
||||
// Verify that the given chunk is in the free lists:
|
||||
// i.e. either the binary tree dictionary, the indexed free lists
|
||||
// or the linear allocation block.
|
||||
bool verifyChunkInFreeLists(FreeChunk* fc) const;
|
||||
// Verify that the given chunk is the linear allocation block
|
||||
bool verify_chunk_is_linear_alloc_block(FreeChunk* fc) const;
|
||||
// Do some basic checks on the the free lists.
|
||||
void checkFreeListConsistency() const PRODUCT_RETURN;
|
||||
void check_free_list_consistency() const PRODUCT_RETURN;
|
||||
|
||||
// Printing support
|
||||
void dump_at_safepoint_with_locks(CMSCollector* c, outputStream* st);
|
||||
|
@ -147,12 +147,8 @@ void ConcurrentMarkThread::run() {
|
||||
}
|
||||
}
|
||||
} while (cm()->restart_for_overflow());
|
||||
|
||||
double counting_start_time = os::elapsedVTime();
|
||||
|
||||
// YSR: These look dubious (i.e. redundant) !!! FIX ME
|
||||
slt()->manipulatePLL(SurrogateLockerThread::acquirePLL);
|
||||
slt()->manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL);
|
||||
|
||||
if (!cm()->has_aborted()) {
|
||||
double count_start_sec = os::elapsedTime();
|
||||
if (PrintGC) {
|
||||
@ -175,6 +171,7 @@ void ConcurrentMarkThread::run() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double end_time = os::elapsedVTime();
|
||||
_vtime_count_accum += (end_time - counting_start_time);
|
||||
// Update the total virtual time before doing this, since it will try
|
||||
@ -335,13 +332,15 @@ void ConcurrentMarkThread::sleepBeforeNextCycle() {
|
||||
clear_started();
|
||||
}
|
||||
|
||||
// Note: this method, although exported by the ConcurrentMarkSweepThread,
|
||||
// which is a non-JavaThread, can only be called by a JavaThread.
|
||||
// Currently this is done at vm creation time (post-vm-init) by the
|
||||
// main/Primordial (Java)Thread.
|
||||
// XXX Consider changing this in the future to allow the CMS thread
|
||||
// Note: As is the case with CMS - this method, although exported
|
||||
// by the ConcurrentMarkThread, which is a non-JavaThread, can only
|
||||
// be called by a JavaThread. Currently this is done at vm creation
|
||||
// time (post-vm-init) by the main/Primordial (Java)Thread.
|
||||
// XXX Consider changing this in the future to allow the CM thread
|
||||
// itself to create this thread?
|
||||
void ConcurrentMarkThread::makeSurrogateLockerThread(TRAPS) {
|
||||
assert(UseG1GC, "SLT thread needed only for concurrent GC");
|
||||
assert(THREAD->is_Java_thread(), "must be a Java thread");
|
||||
assert(_slt == NULL, "SLT already created");
|
||||
_slt = SurrogateLockerThread::make(THREAD);
|
||||
}
|
||||
|
@ -5502,34 +5502,36 @@ void G1CollectedHeap::cleanUpCardTable() {
|
||||
CardTableModRefBS* ct_bs = (CardTableModRefBS*) (barrier_set());
|
||||
double start = os::elapsedTime();
|
||||
|
||||
// Iterate over the dirty cards region list.
|
||||
G1ParCleanupCTTask cleanup_task(ct_bs, this);
|
||||
{
|
||||
// Iterate over the dirty cards region list.
|
||||
G1ParCleanupCTTask cleanup_task(ct_bs, this);
|
||||
|
||||
if (ParallelGCThreads > 0) {
|
||||
set_par_threads(workers()->total_workers());
|
||||
workers()->run_task(&cleanup_task);
|
||||
set_par_threads(0);
|
||||
} else {
|
||||
while (_dirty_cards_region_list) {
|
||||
HeapRegion* r = _dirty_cards_region_list;
|
||||
cleanup_task.clear_cards(r);
|
||||
_dirty_cards_region_list = r->get_next_dirty_cards_region();
|
||||
if (_dirty_cards_region_list == r) {
|
||||
// The last region.
|
||||
_dirty_cards_region_list = NULL;
|
||||
if (ParallelGCThreads > 0) {
|
||||
set_par_threads(workers()->total_workers());
|
||||
workers()->run_task(&cleanup_task);
|
||||
set_par_threads(0);
|
||||
} else {
|
||||
while (_dirty_cards_region_list) {
|
||||
HeapRegion* r = _dirty_cards_region_list;
|
||||
cleanup_task.clear_cards(r);
|
||||
_dirty_cards_region_list = r->get_next_dirty_cards_region();
|
||||
if (_dirty_cards_region_list == r) {
|
||||
// The last region.
|
||||
_dirty_cards_region_list = NULL;
|
||||
}
|
||||
r->set_next_dirty_cards_region(NULL);
|
||||
}
|
||||
r->set_next_dirty_cards_region(NULL);
|
||||
}
|
||||
#ifndef PRODUCT
|
||||
if (G1VerifyCTCleanup || VerifyAfterGC) {
|
||||
G1VerifyCardTableCleanup cleanup_verifier(this, ct_bs);
|
||||
heap_region_iterate(&cleanup_verifier);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
double elapsed = os::elapsedTime() - start;
|
||||
g1_policy()->record_clear_ct_time(elapsed * 1000.0);
|
||||
#ifndef PRODUCT
|
||||
if (G1VerifyCTCleanup || VerifyAfterGC) {
|
||||
G1VerifyCardTableCleanup cleanup_verifier(this, ct_bs);
|
||||
heap_region_iterate(&cleanup_verifier);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void G1CollectedHeap::free_collection_set(HeapRegion* cs_head) {
|
||||
|
@ -320,6 +320,7 @@ G1CollectorPolicy::G1CollectorPolicy() :
|
||||
_par_last_termination_attempts = new double[_parallel_gc_threads];
|
||||
_par_last_gc_worker_end_times_ms = new double[_parallel_gc_threads];
|
||||
_par_last_gc_worker_times_ms = new double[_parallel_gc_threads];
|
||||
_par_last_gc_worker_other_times_ms = new double[_parallel_gc_threads];
|
||||
|
||||
// start conservatively
|
||||
_expensive_region_limit_ms = 0.5 * (double) MaxGCPauseMillis;
|
||||
@ -497,7 +498,6 @@ void G1CollectorPolicy::init() {
|
||||
initialize_gc_policy_counters();
|
||||
|
||||
G1YoungGenSizer sizer;
|
||||
size_t initial_region_num = sizer.initial_young_region_num();
|
||||
_min_desired_young_length = sizer.min_young_region_num();
|
||||
_max_desired_young_length = sizer.max_young_region_num();
|
||||
|
||||
@ -511,17 +511,14 @@ void G1CollectorPolicy::init() {
|
||||
}
|
||||
}
|
||||
|
||||
// GenCollectorPolicy guarantees that min <= initial <= max.
|
||||
// Asserting here just to state that we rely on this property.
|
||||
assert(_min_desired_young_length <= _max_desired_young_length, "Invalid min/max young gen size values");
|
||||
assert(initial_region_num <= _max_desired_young_length, "Initial young gen size too large");
|
||||
assert(_min_desired_young_length <= initial_region_num, "Initial young gen size too small");
|
||||
|
||||
set_adaptive_young_list_length(_min_desired_young_length < _max_desired_young_length);
|
||||
if (adaptive_young_list_length()) {
|
||||
_young_list_fixed_length = 0;
|
||||
} else {
|
||||
_young_list_fixed_length = initial_region_num;
|
||||
assert(_min_desired_young_length == _max_desired_young_length, "Min and max young size differ");
|
||||
_young_list_fixed_length = _min_desired_young_length;
|
||||
}
|
||||
_free_regions_at_end_of_collection = _g1->free_regions();
|
||||
update_young_list_target_length();
|
||||
@ -976,6 +973,7 @@ void G1CollectorPolicy::record_collection_pause_start(double start_time_sec,
|
||||
_par_last_termination_attempts[i] = -1234.0;
|
||||
_par_last_gc_worker_end_times_ms[i] = -1234.0;
|
||||
_par_last_gc_worker_times_ms[i] = -1234.0;
|
||||
_par_last_gc_worker_other_times_ms[i] = -1234.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -984,8 +982,10 @@ void G1CollectorPolicy::record_collection_pause_start(double start_time_sec,
|
||||
_cur_aux_times_set[i] = false;
|
||||
}
|
||||
|
||||
_satb_drain_time_set = false;
|
||||
_last_satb_drain_processed_buffers = -1;
|
||||
// These are initialized to zero here and they are set during
|
||||
// the evacuation pause if marking is in progress.
|
||||
_cur_satb_drain_time_ms = 0.0;
|
||||
_last_satb_drain_processed_buffers = 0;
|
||||
|
||||
_last_young_gc_full = false;
|
||||
|
||||
@ -1097,61 +1097,65 @@ void G1CollectorPolicy::print_par_sizes(int level,
|
||||
(int)total, (int)avg, (int)min, (int)max, (int)max - (int)min);
|
||||
}
|
||||
|
||||
void G1CollectorPolicy::print_stats (int level,
|
||||
const char* str,
|
||||
double value) {
|
||||
void G1CollectorPolicy::print_stats(int level,
|
||||
const char* str,
|
||||
double value) {
|
||||
LineBuffer(level).append_and_print_cr("[%s: %5.1lf ms]", str, value);
|
||||
}
|
||||
|
||||
void G1CollectorPolicy::print_stats (int level,
|
||||
const char* str,
|
||||
int value) {
|
||||
void G1CollectorPolicy::print_stats(int level,
|
||||
const char* str,
|
||||
int value) {
|
||||
LineBuffer(level).append_and_print_cr("[%s: %d]", str, value);
|
||||
}
|
||||
|
||||
double G1CollectorPolicy::avg_value (double* data) {
|
||||
double G1CollectorPolicy::avg_value(double* data) {
|
||||
if (G1CollectedHeap::use_parallel_gc_threads()) {
|
||||
double ret = 0.0;
|
||||
for (uint i = 0; i < ParallelGCThreads; ++i)
|
||||
for (uint i = 0; i < ParallelGCThreads; ++i) {
|
||||
ret += data[i];
|
||||
}
|
||||
return ret / (double) ParallelGCThreads;
|
||||
} else {
|
||||
return data[0];
|
||||
}
|
||||
}
|
||||
|
||||
double G1CollectorPolicy::max_value (double* data) {
|
||||
double G1CollectorPolicy::max_value(double* data) {
|
||||
if (G1CollectedHeap::use_parallel_gc_threads()) {
|
||||
double ret = data[0];
|
||||
for (uint i = 1; i < ParallelGCThreads; ++i)
|
||||
if (data[i] > ret)
|
||||
for (uint i = 1; i < ParallelGCThreads; ++i) {
|
||||
if (data[i] > ret) {
|
||||
ret = data[i];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
return data[0];
|
||||
}
|
||||
}
|
||||
|
||||
double G1CollectorPolicy::sum_of_values (double* data) {
|
||||
double G1CollectorPolicy::sum_of_values(double* data) {
|
||||
if (G1CollectedHeap::use_parallel_gc_threads()) {
|
||||
double sum = 0.0;
|
||||
for (uint i = 0; i < ParallelGCThreads; i++)
|
||||
for (uint i = 0; i < ParallelGCThreads; i++) {
|
||||
sum += data[i];
|
||||
}
|
||||
return sum;
|
||||
} else {
|
||||
return data[0];
|
||||
}
|
||||
}
|
||||
|
||||
double G1CollectorPolicy::max_sum (double* data1,
|
||||
double* data2) {
|
||||
double G1CollectorPolicy::max_sum(double* data1, double* data2) {
|
||||
double ret = data1[0] + data2[0];
|
||||
|
||||
if (G1CollectedHeap::use_parallel_gc_threads()) {
|
||||
for (uint i = 1; i < ParallelGCThreads; ++i) {
|
||||
double data = data1[i] + data2[i];
|
||||
if (data > ret)
|
||||
if (data > ret) {
|
||||
ret = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -1251,6 +1255,10 @@ void G1CollectorPolicy::record_collection_pause_end() {
|
||||
|
||||
_n_pauses++;
|
||||
|
||||
// These values are used to update the summary information that is
|
||||
// displayed when TraceGen0Time is enabled, and are output as part
|
||||
// of the PrintGCDetails output, in the non-parallel case.
|
||||
|
||||
double ext_root_scan_time = avg_value(_par_last_ext_root_scan_times_ms);
|
||||
double mark_stack_scan_time = avg_value(_par_last_mark_stack_scan_times_ms);
|
||||
double update_rs_time = avg_value(_par_last_update_rs_times_ms);
|
||||
@ -1260,42 +1268,68 @@ void G1CollectorPolicy::record_collection_pause_end() {
|
||||
double obj_copy_time = avg_value(_par_last_obj_copy_times_ms);
|
||||
double termination_time = avg_value(_par_last_termination_times_ms);
|
||||
|
||||
double parallel_known_time = update_rs_time +
|
||||
ext_root_scan_time +
|
||||
mark_stack_scan_time +
|
||||
scan_rs_time +
|
||||
obj_copy_time +
|
||||
termination_time;
|
||||
double known_time = ext_root_scan_time +
|
||||
mark_stack_scan_time +
|
||||
update_rs_time +
|
||||
scan_rs_time +
|
||||
obj_copy_time;
|
||||
|
||||
double parallel_other_time = _cur_collection_par_time_ms - parallel_known_time;
|
||||
double other_time_ms = elapsed_ms;
|
||||
|
||||
PauseSummary* summary = _summary;
|
||||
// Subtract the SATB drain time. It's initialized to zero at the
|
||||
// start of the pause and is updated during the pause if marking
|
||||
// is in progress.
|
||||
other_time_ms -= _cur_satb_drain_time_ms;
|
||||
|
||||
if (parallel) {
|
||||
other_time_ms -= _cur_collection_par_time_ms;
|
||||
} else {
|
||||
other_time_ms -= known_time;
|
||||
}
|
||||
|
||||
// Subtract the time taken to clean the card table from the
|
||||
// current value of "other time"
|
||||
other_time_ms -= _cur_clear_ct_time_ms;
|
||||
|
||||
// TraceGen0Time and TraceGen1Time summary info updating.
|
||||
_all_pause_times_ms->add(elapsed_ms);
|
||||
|
||||
if (update_stats) {
|
||||
_recent_rs_scan_times_ms->add(scan_rs_time);
|
||||
_recent_pause_times_ms->add(elapsed_ms);
|
||||
_recent_rs_sizes->add(rs_size);
|
||||
|
||||
MainBodySummary* body_summary = summary->main_body_summary();
|
||||
guarantee(body_summary != NULL, "should not be null!");
|
||||
_summary->record_total_time_ms(elapsed_ms);
|
||||
_summary->record_other_time_ms(other_time_ms);
|
||||
|
||||
if (_satb_drain_time_set)
|
||||
body_summary->record_satb_drain_time_ms(_cur_satb_drain_time_ms);
|
||||
else
|
||||
body_summary->record_satb_drain_time_ms(0.0);
|
||||
MainBodySummary* body_summary = _summary->main_body_summary();
|
||||
assert(body_summary != NULL, "should not be null!");
|
||||
|
||||
// This will be non-zero iff marking is currently in progress (i.e.
|
||||
// _g1->mark_in_progress() == true) and the currrent pause was not
|
||||
// an initial mark pause. Since the body_summary items are NumberSeqs,
|
||||
// however, they have to be consistent and updated in lock-step with
|
||||
// each other. Therefore we unconditionally record the SATB drain
|
||||
// time - even if it's zero.
|
||||
body_summary->record_satb_drain_time_ms(_cur_satb_drain_time_ms);
|
||||
|
||||
body_summary->record_ext_root_scan_time_ms(ext_root_scan_time);
|
||||
body_summary->record_mark_stack_scan_time_ms(mark_stack_scan_time);
|
||||
body_summary->record_update_rs_time_ms(update_rs_time);
|
||||
body_summary->record_scan_rs_time_ms(scan_rs_time);
|
||||
body_summary->record_obj_copy_time_ms(obj_copy_time);
|
||||
|
||||
if (parallel) {
|
||||
body_summary->record_parallel_time_ms(_cur_collection_par_time_ms);
|
||||
body_summary->record_clear_ct_time_ms(_cur_clear_ct_time_ms);
|
||||
body_summary->record_termination_time_ms(termination_time);
|
||||
|
||||
double parallel_known_time = known_time + termination_time;
|
||||
double parallel_other_time = _cur_collection_par_time_ms - parallel_known_time;
|
||||
body_summary->record_parallel_other_time_ms(parallel_other_time);
|
||||
}
|
||||
|
||||
body_summary->record_mark_closure_time_ms(_mark_closure_time_ms);
|
||||
body_summary->record_clear_ct_time_ms(_cur_clear_ct_time_ms);
|
||||
|
||||
// We exempt parallel collection from this check because Alloc Buffer
|
||||
// fragmentation can produce negative collections. Same with evac
|
||||
@ -1307,6 +1341,7 @@ void G1CollectorPolicy::record_collection_pause_end() {
|
||||
|| _g1->evacuation_failed()
|
||||
|| surviving_bytes <= _collection_set_bytes_used_before,
|
||||
"Or else negative collection!");
|
||||
|
||||
_recent_CS_bytes_used_before->add(_collection_set_bytes_used_before);
|
||||
_recent_CS_bytes_surviving->add(surviving_bytes);
|
||||
|
||||
@ -1357,6 +1392,13 @@ void G1CollectorPolicy::record_collection_pause_end() {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _aux_num; ++i) {
|
||||
if (_cur_aux_times_set[i]) {
|
||||
_all_aux_times_ms[i].add(_cur_aux_times_ms[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (G1PolicyVerbose > 1) {
|
||||
gclog_or_tty->print_cr(" Recording collection pause(%d)", _n_pauses);
|
||||
}
|
||||
@ -1383,61 +1425,60 @@ void G1CollectorPolicy::record_collection_pause_end() {
|
||||
recent_avg_pause_time_ratio() * 100.0);
|
||||
}
|
||||
|
||||
double other_time_ms = elapsed_ms;
|
||||
|
||||
if (_satb_drain_time_set) {
|
||||
other_time_ms -= _cur_satb_drain_time_ms;
|
||||
}
|
||||
|
||||
if (parallel) {
|
||||
other_time_ms -= _cur_collection_par_time_ms + _cur_clear_ct_time_ms;
|
||||
} else {
|
||||
other_time_ms -=
|
||||
update_rs_time +
|
||||
ext_root_scan_time + mark_stack_scan_time +
|
||||
scan_rs_time + obj_copy_time;
|
||||
}
|
||||
|
||||
// PrintGCDetails output
|
||||
if (PrintGCDetails) {
|
||||
bool print_marking_info =
|
||||
_g1->mark_in_progress() && !last_pause_included_initial_mark;
|
||||
|
||||
gclog_or_tty->print_cr("%s, %1.8lf secs]",
|
||||
(last_pause_included_initial_mark) ? " (initial-mark)" : "",
|
||||
elapsed_ms / 1000.0);
|
||||
|
||||
if (_satb_drain_time_set) {
|
||||
if (print_marking_info) {
|
||||
print_stats(1, "SATB Drain Time", _cur_satb_drain_time_ms);
|
||||
}
|
||||
if (_last_satb_drain_processed_buffers >= 0) {
|
||||
print_stats(2, "Processed Buffers", _last_satb_drain_processed_buffers);
|
||||
}
|
||||
|
||||
if (parallel) {
|
||||
print_stats(1, "Parallel Time", _cur_collection_par_time_ms);
|
||||
print_par_stats(2, "GC Worker Start Time", _par_last_gc_worker_start_times_ms);
|
||||
print_par_stats(2, "GC Worker Start", _par_last_gc_worker_start_times_ms);
|
||||
print_par_stats(2, "Ext Root Scanning", _par_last_ext_root_scan_times_ms);
|
||||
if (print_marking_info) {
|
||||
print_par_stats(2, "Mark Stack Scanning", _par_last_mark_stack_scan_times_ms);
|
||||
}
|
||||
print_par_stats(2, "Update RS", _par_last_update_rs_times_ms);
|
||||
print_par_sizes(3, "Processed Buffers", _par_last_update_rs_processed_buffers);
|
||||
print_par_stats(2, "Ext Root Scanning", _par_last_ext_root_scan_times_ms);
|
||||
print_par_stats(2, "Mark Stack Scanning", _par_last_mark_stack_scan_times_ms);
|
||||
print_par_stats(2, "Scan RS", _par_last_scan_rs_times_ms);
|
||||
print_par_stats(2, "Object Copy", _par_last_obj_copy_times_ms);
|
||||
print_par_stats(2, "Termination", _par_last_termination_times_ms);
|
||||
print_par_sizes(3, "Termination Attempts", _par_last_termination_attempts);
|
||||
print_par_stats(2, "GC Worker End Time", _par_last_gc_worker_end_times_ms);
|
||||
print_par_stats(2, "GC Worker End", _par_last_gc_worker_end_times_ms);
|
||||
|
||||
for (int i = 0; i < _parallel_gc_threads; i++) {
|
||||
_par_last_gc_worker_times_ms[i] = _par_last_gc_worker_end_times_ms[i] - _par_last_gc_worker_start_times_ms[i];
|
||||
}
|
||||
print_par_stats(2, "GC Worker Times", _par_last_gc_worker_times_ms);
|
||||
|
||||
print_stats(2, "Parallel Other", parallel_other_time);
|
||||
print_stats(1, "Clear CT", _cur_clear_ct_time_ms);
|
||||
double worker_known_time = _par_last_ext_root_scan_times_ms[i] +
|
||||
_par_last_mark_stack_scan_times_ms[i] +
|
||||
_par_last_update_rs_times_ms[i] +
|
||||
_par_last_scan_rs_times_ms[i] +
|
||||
_par_last_obj_copy_times_ms[i] +
|
||||
_par_last_termination_times_ms[i];
|
||||
|
||||
_par_last_gc_worker_other_times_ms[i] = _cur_collection_par_time_ms - worker_known_time;
|
||||
}
|
||||
print_par_stats(2, "GC Worker", _par_last_gc_worker_times_ms);
|
||||
print_par_stats(2, "GC Worker Other", _par_last_gc_worker_other_times_ms);
|
||||
} else {
|
||||
print_stats(1, "Update RS", update_rs_time);
|
||||
print_stats(2, "Processed Buffers",
|
||||
(int)update_rs_processed_buffers);
|
||||
print_stats(1, "Ext Root Scanning", ext_root_scan_time);
|
||||
print_stats(1, "Mark Stack Scanning", mark_stack_scan_time);
|
||||
if (print_marking_info) {
|
||||
print_stats(1, "Mark Stack Scanning", mark_stack_scan_time);
|
||||
}
|
||||
print_stats(1, "Update RS", update_rs_time);
|
||||
print_stats(2, "Processed Buffers", (int)update_rs_processed_buffers);
|
||||
print_stats(1, "Scan RS", scan_rs_time);
|
||||
print_stats(1, "Object Copying", obj_copy_time);
|
||||
}
|
||||
print_stats(1, "Clear CT", _cur_clear_ct_time_ms);
|
||||
#ifndef PRODUCT
|
||||
print_stats(1, "Cur Clear CC", _cur_clear_cc_time_ms);
|
||||
print_stats(1, "Cum Clear CC", _cum_clear_cc_time_ms);
|
||||
@ -1461,16 +1502,6 @@ void G1CollectorPolicy::record_collection_pause_end() {
|
||||
}
|
||||
}
|
||||
|
||||
_all_pause_times_ms->add(elapsed_ms);
|
||||
if (update_stats) {
|
||||
summary->record_total_time_ms(elapsed_ms);
|
||||
summary->record_other_time_ms(other_time_ms);
|
||||
}
|
||||
for (int i = 0; i < _aux_num; ++i)
|
||||
if (_cur_aux_times_set[i]) {
|
||||
_all_aux_times_ms[i].add(_cur_aux_times_ms[i]);
|
||||
}
|
||||
|
||||
// Update the efficiency-since-mark vars.
|
||||
double proc_ms = elapsed_ms * (double) _parallel_gc_threads;
|
||||
if (elapsed_ms < MIN_TIMER_GRANULARITY) {
|
||||
@ -2138,17 +2169,17 @@ void G1CollectorPolicy::count_CS_bytes_used() {
|
||||
_g1->collection_set_iterate(&cs_closure);
|
||||
}
|
||||
|
||||
void G1CollectorPolicy::print_summary (int level,
|
||||
const char* str,
|
||||
NumberSeq* seq) const {
|
||||
void G1CollectorPolicy::print_summary(int level,
|
||||
const char* str,
|
||||
NumberSeq* seq) const {
|
||||
double sum = seq->sum();
|
||||
LineBuffer(level + 1).append_and_print_cr("%-24s = %8.2lf s (avg = %8.2lf ms)",
|
||||
str, sum / 1000.0, seq->avg());
|
||||
}
|
||||
|
||||
void G1CollectorPolicy::print_summary_sd (int level,
|
||||
const char* str,
|
||||
NumberSeq* seq) const {
|
||||
void G1CollectorPolicy::print_summary_sd(int level,
|
||||
const char* str,
|
||||
NumberSeq* seq) const {
|
||||
print_summary(level, str, seq);
|
||||
LineBuffer(level + 6).append_and_print_cr("(num = %5d, std dev = %8.2lf ms, max = %8.2lf ms)",
|
||||
seq->num(), seq->sd(), seq->maximum());
|
||||
@ -2211,20 +2242,18 @@ void G1CollectorPolicy::print_summary(PauseSummary* summary) const {
|
||||
print_summary(1, "SATB Drain", body_summary->get_satb_drain_seq());
|
||||
if (parallel) {
|
||||
print_summary(1, "Parallel Time", body_summary->get_parallel_seq());
|
||||
print_summary(2, "Ext Root Scanning", body_summary->get_ext_root_scan_seq());
|
||||
print_summary(2, "Mark Stack Scanning", body_summary->get_mark_stack_scan_seq());
|
||||
print_summary(2, "Update RS", body_summary->get_update_rs_seq());
|
||||
print_summary(2, "Ext Root Scanning",
|
||||
body_summary->get_ext_root_scan_seq());
|
||||
print_summary(2, "Mark Stack Scanning",
|
||||
body_summary->get_mark_stack_scan_seq());
|
||||
print_summary(2, "Scan RS", body_summary->get_scan_rs_seq());
|
||||
print_summary(2, "Object Copy", body_summary->get_obj_copy_seq());
|
||||
print_summary(2, "Termination", body_summary->get_termination_seq());
|
||||
print_summary(2, "Other", body_summary->get_parallel_other_seq());
|
||||
print_summary(2, "Parallel Other", body_summary->get_parallel_other_seq());
|
||||
{
|
||||
NumberSeq* other_parts[] = {
|
||||
body_summary->get_update_rs_seq(),
|
||||
body_summary->get_ext_root_scan_seq(),
|
||||
body_summary->get_mark_stack_scan_seq(),
|
||||
body_summary->get_update_rs_seq(),
|
||||
body_summary->get_scan_rs_seq(),
|
||||
body_summary->get_obj_copy_seq(),
|
||||
body_summary->get_termination_seq()
|
||||
@ -2234,18 +2263,16 @@ void G1CollectorPolicy::print_summary(PauseSummary* summary) const {
|
||||
check_other_times(2, body_summary->get_parallel_other_seq(),
|
||||
&calc_other_times_ms);
|
||||
}
|
||||
print_summary(1, "Mark Closure", body_summary->get_mark_closure_seq());
|
||||
print_summary(1, "Clear CT", body_summary->get_clear_ct_seq());
|
||||
} else {
|
||||
print_summary(1, "Ext Root Scanning", body_summary->get_ext_root_scan_seq());
|
||||
print_summary(1, "Mark Stack Scanning", body_summary->get_mark_stack_scan_seq());
|
||||
print_summary(1, "Update RS", body_summary->get_update_rs_seq());
|
||||
print_summary(1, "Ext Root Scanning",
|
||||
body_summary->get_ext_root_scan_seq());
|
||||
print_summary(1, "Mark Stack Scanning",
|
||||
body_summary->get_mark_stack_scan_seq());
|
||||
print_summary(1, "Scan RS", body_summary->get_scan_rs_seq());
|
||||
print_summary(1, "Object Copy", body_summary->get_obj_copy_seq());
|
||||
}
|
||||
}
|
||||
print_summary(1, "Mark Closure", body_summary->get_mark_closure_seq());
|
||||
print_summary(1, "Clear CT", body_summary->get_clear_ct_seq());
|
||||
print_summary(1, "Other", summary->get_other_seq());
|
||||
{
|
||||
if (body_summary != NULL) {
|
||||
|
@ -74,7 +74,7 @@ class MainBodySummary: public CHeapObj {
|
||||
define_num_seq(termination) // parallel only
|
||||
define_num_seq(parallel_other) // parallel only
|
||||
define_num_seq(mark_closure)
|
||||
define_num_seq(clear_ct) // parallel only
|
||||
define_num_seq(clear_ct)
|
||||
};
|
||||
|
||||
class Summary: public PauseSummary,
|
||||
@ -115,7 +115,6 @@ private:
|
||||
double _cur_collection_par_time_ms;
|
||||
double _cur_satb_drain_time_ms;
|
||||
double _cur_clear_ct_time_ms;
|
||||
bool _satb_drain_time_set;
|
||||
double _cur_ref_proc_time_ms;
|
||||
double _cur_ref_enq_time_ms;
|
||||
|
||||
@ -176,6 +175,11 @@ private:
|
||||
double* _par_last_gc_worker_end_times_ms;
|
||||
double* _par_last_gc_worker_times_ms;
|
||||
|
||||
// Each workers 'other' time i.e. the elapsed time of the parallel
|
||||
// phase of the pause minus the sum of the individual sub-phase
|
||||
// times for a given worker thread.
|
||||
double* _par_last_gc_worker_other_times_ms;
|
||||
|
||||
// indicates whether we are in full young or partially young GC mode
|
||||
bool _full_young_gcs;
|
||||
|
||||
@ -892,11 +896,12 @@ public:
|
||||
}
|
||||
|
||||
void record_satb_drain_time(double ms) {
|
||||
assert(_g1->mark_in_progress(), "shouldn't be here otherwise");
|
||||
_cur_satb_drain_time_ms = ms;
|
||||
_satb_drain_time_set = true;
|
||||
}
|
||||
|
||||
void record_satb_drain_processed_buffers (int processed_buffers) {
|
||||
void record_satb_drain_processed_buffers(int processed_buffers) {
|
||||
assert(_g1->mark_in_progress(), "shouldn't be here otherwise");
|
||||
_last_satb_drain_processed_buffers = processed_buffers;
|
||||
}
|
||||
|
||||
|
@ -122,10 +122,10 @@ public:
|
||||
void set_try_claimed() { _try_claimed = true; }
|
||||
|
||||
void scanCard(size_t index, HeapRegion *r) {
|
||||
DirtyCardToOopClosure* cl =
|
||||
r->new_dcto_closure(_oc,
|
||||
CardTableModRefBS::Precise,
|
||||
HeapRegionDCTOC::IntoCSFilterKind);
|
||||
// Stack allocate the DirtyCardToOopClosure instance
|
||||
HeapRegionDCTOC cl(_g1h, r, _oc,
|
||||
CardTableModRefBS::Precise,
|
||||
HeapRegionDCTOC::IntoCSFilterKind);
|
||||
|
||||
// Set the "from" region in the closure.
|
||||
_oc->set_region(r);
|
||||
@ -140,7 +140,7 @@ public:
|
||||
// scans (the rsets of the regions in the cset can intersect).
|
||||
_ct_bs->set_card_claimed(index);
|
||||
_cards_done++;
|
||||
cl->do_MemRegion(mr);
|
||||
cl.do_MemRegion(mr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,14 +340,6 @@ void HeapRegion::reset_after_compaction() {
|
||||
init_top_at_mark_start();
|
||||
}
|
||||
|
||||
DirtyCardToOopClosure*
|
||||
HeapRegion::new_dcto_closure(OopClosure* cl,
|
||||
CardTableModRefBS::PrecisionStyle precision,
|
||||
HeapRegionDCTOC::FilterKind fk) {
|
||||
return new HeapRegionDCTOC(G1CollectedHeap::heap(),
|
||||
this, cl, precision, fk);
|
||||
}
|
||||
|
||||
void HeapRegion::hr_clear(bool par, bool clear_space) {
|
||||
assert(_humongous_type == NotHumongous,
|
||||
"we should have already filtered out humongous regions");
|
||||
|
@ -431,6 +431,14 @@ class HeapRegion: public G1OffsetTableContigSpace {
|
||||
return _humongous_start_region;
|
||||
}
|
||||
|
||||
// Same as Space::is_in_reserved, but will use the original size of the region.
|
||||
// The original size is different only for start humongous regions. They get
|
||||
// their _end set up to be the end of the last continues region of the
|
||||
// corresponding humongous object.
|
||||
bool is_in_reserved_raw(const void* p) const {
|
||||
return _bottom <= p && p < _orig_end;
|
||||
}
|
||||
|
||||
// Makes the current region be a "starts humongous" region, i.e.,
|
||||
// the first region in a series of one or more contiguous regions
|
||||
// that will contain a single "humongous" object. The two parameters
|
||||
@ -569,11 +577,6 @@ class HeapRegion: public G1OffsetTableContigSpace {
|
||||
// allocated in the current region before the last call to "save_mark".
|
||||
void oop_before_save_marks_iterate(OopClosure* cl);
|
||||
|
||||
DirtyCardToOopClosure*
|
||||
new_dcto_closure(OopClosure* cl,
|
||||
CardTableModRefBS::PrecisionStyle precision,
|
||||
HeapRegionDCTOC::FilterKind fk);
|
||||
|
||||
// Note the start or end of marking. This tells the heap region
|
||||
// that the collector is about to start or has finished (concurrently)
|
||||
// marking the heap.
|
||||
|
@ -143,7 +143,11 @@ protected:
|
||||
// If the test below fails, then this table was reused concurrently
|
||||
// with this operation. This is OK, since the old table was coarsened,
|
||||
// and adding a bit to the new table is never incorrect.
|
||||
if (loc_hr->is_in_reserved(from)) {
|
||||
// If the table used to belong to a continues humongous region and is
|
||||
// now reused for the corresponding start humongous region, we need to
|
||||
// make sure that we detect this. Thus, we call is_in_reserved_raw()
|
||||
// instead of just is_in_reserved() here.
|
||||
if (loc_hr->is_in_reserved_raw(from)) {
|
||||
size_t hw_offset = pointer_delta((HeapWord*)from, loc_hr->bottom());
|
||||
CardIdx_t from_card = (CardIdx_t)
|
||||
hw_offset >> (CardTableModRefBS::card_shift - LogHeapWordSize);
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
|
||||
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
|
||||
#include "gc_implementation/g1/g1CollectorPolicy.hpp"
|
||||
#include "gc_implementation/g1/vm_operations_g1.hpp"
|
||||
@ -165,6 +166,20 @@ void VM_G1IncCollectionPause::doit_epilogue() {
|
||||
}
|
||||
}
|
||||
|
||||
void VM_CGC_Operation::acquire_pending_list_lock() {
|
||||
// The caller may block while communicating
|
||||
// with the SLT thread in order to acquire/release the PLL.
|
||||
ConcurrentMarkThread::slt()->
|
||||
manipulatePLL(SurrogateLockerThread::acquirePLL);
|
||||
}
|
||||
|
||||
void VM_CGC_Operation::release_and_notify_pending_list_lock() {
|
||||
// The caller may block while communicating
|
||||
// with the SLT thread in order to acquire/release the PLL.
|
||||
ConcurrentMarkThread::slt()->
|
||||
manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL);
|
||||
}
|
||||
|
||||
void VM_CGC_Operation::doit() {
|
||||
gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
|
||||
TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
|
||||
@ -180,12 +195,19 @@ void VM_CGC_Operation::doit() {
|
||||
}
|
||||
|
||||
bool VM_CGC_Operation::doit_prologue() {
|
||||
// Note the relative order of the locks must match that in
|
||||
// VM_GC_Operation::doit_prologue() or deadlocks can occur
|
||||
acquire_pending_list_lock();
|
||||
|
||||
Heap_lock->lock();
|
||||
SharedHeap::heap()->_thread_holds_heap_lock_for_gc = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void VM_CGC_Operation::doit_epilogue() {
|
||||
// Note the relative order of the unlocks must match that in
|
||||
// VM_GC_Operation::doit_epilogue()
|
||||
SharedHeap::heap()->_thread_holds_heap_lock_for_gc = false;
|
||||
Heap_lock->unlock();
|
||||
release_and_notify_pending_list_lock();
|
||||
}
|
||||
|
@ -93,11 +93,17 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// Concurrent GC stop-the-world operations such as initial and final mark;
|
||||
// Concurrent GC stop-the-world operations such as remark and cleanup;
|
||||
// consider sharing these with CMS's counterparts.
|
||||
class VM_CGC_Operation: public VM_Operation {
|
||||
VoidClosure* _cl;
|
||||
const char* _printGCMessage;
|
||||
|
||||
protected:
|
||||
// java.lang.ref.Reference support
|
||||
void acquire_pending_list_lock();
|
||||
void release_and_notify_pending_list_lock();
|
||||
|
||||
public:
|
||||
VM_CGC_Operation(VoidClosure* cl, const char *printGCMsg)
|
||||
: _cl(cl), _printGCMessage(printGCMsg) { }
|
||||
|
@ -224,6 +224,8 @@ void SurrogateLockerThread::manipulatePLL(SLT_msg_type msg) {
|
||||
MutexLockerEx x(&_monitor, Mutex::_no_safepoint_check_flag);
|
||||
assert(_buffer == empty, "Should be empty");
|
||||
assert(msg != empty, "empty message");
|
||||
assert(!Heap_lock->owned_by_self(), "Heap_lock owned by requesting thread");
|
||||
|
||||
_buffer = msg;
|
||||
while (_buffer != empty) {
|
||||
_monitor.notify();
|
||||
|
@ -2580,7 +2580,7 @@ class CommandLineFlags {
|
||||
diagnostic(bool, DebugInlinedCalls, true, \
|
||||
"If false, restricts profiled locations to the root method only") \
|
||||
\
|
||||
product(bool, PrintVMOptions, trueInDebug, \
|
||||
product(bool, PrintVMOptions, NOT_EMBEDDED(trueInDebug) EMBEDDED_ONLY(false),\
|
||||
"Print flags that appeared on the command line") \
|
||||
\
|
||||
product(bool, IgnoreUnrecognizedVMOptions, false, \
|
||||
|
@ -132,3 +132,6 @@ c114306576dcc1cb871a48058b41bf7d87ce882a jdk8-b07
|
||||
de4794dd69c48b08029d158a972993ff9d5627df jdk8-b08
|
||||
93554324c014282571aeeb48552ad00d3fedb089 jdk8-b09
|
||||
d21a4d5141c04bc9e88f2c0253121d449b66d667 jdk8-b10
|
||||
d1b7a4f6dd2065fdeafbcdfd9dcc0072da8c6881 jdk8-b11
|
||||
ca977d167697a561c04894187fc1c4d927582ffa jdk8-b12
|
||||
bcc739229f6384786c7ac0b52c1822c85674dcf1 jdk8-b13
|
||||
|
@ -132,3 +132,6 @@ acffff22a9465005e8eb206224fae9f2ea4fd469 jdk8-b06
|
||||
1c9d4f59acf8f71477473c170239b43b2c9dee24 jdk8-b08
|
||||
70172e57cf29efe271b068987eefb601c2a77780 jdk8-b09
|
||||
8e7fdc8e3c758644ca6d0fd70bb255e9d2e64cda jdk8-b10
|
||||
a12ab897a249feb7859a6e6cd84b49411f4c06ac jdk8-b11
|
||||
e6eed2ff5d5f62bdc815beb5276d23347600c760 jdk8-b12
|
||||
adf2a6b5fde14090beb9ebc40c4114132ddee731 jdk8-b13
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,15 +25,15 @@
|
||||
|
||||
drops.master.copy.base=${drops.dir}
|
||||
|
||||
jaxws_src.bundle.name=jdk7-jaxws2_2_4-b03-2011_05_27.zip
|
||||
jaxws_src.bundle.md5.checksum=2f5b829ade70f67fe272d0b322e3e702
|
||||
jaxws_src.bundle.name=jdk8-jaxws2_2_4-b01-2011_07_22.zip
|
||||
jaxws_src.bundle.md5.checksum=f64bedd3c512e6b1ca265fda2feb0905
|
||||
jaxws_src.master.bundle.dir=${drops.master.copy.base}
|
||||
jaxws_src.master.bundle.url.base=http://download.java.net/glassfish/components/jax-ws/openjdk/jdk7
|
||||
jaxws_src.master.bundle.url.base=http://download.java.net/glassfish/components/jax-ws/openjdk/jdk8
|
||||
|
||||
jaf_src.bundle.name=jdk7-jaf-2010_08_19.zip
|
||||
jaf_src.bundle.name=jdk8-jaf-2011_07_22.zip
|
||||
jaf_src.bundle.md5.checksum=18d15dfd71117daadb332af003d08212
|
||||
jaf_src.master.bundle.dir=${drops.master.copy.base}
|
||||
jaf_src.master.bundle.url.base=https://java.net/downloads/jax-ws/JDK7
|
||||
jaf_src.master.bundle.url.base=http://download.java.net/glassfish/components/jax-ws/openjdk/jdk8
|
||||
|
||||
#jaxws_tests.bundle.name=jdk7-jaxws-tests-2009_08_28.zip
|
||||
#jaxws_tests.master.bundle.dir=${drops.master.copy.base}
|
||||
|
@ -133,3 +133,6 @@ bdb870cc269ef8b221d17a217be89092400b59d2 jdk8-b06
|
||||
f1ec21b8142168ff40f3278d2f6b5fe4bd5f3b26 jdk8-b09
|
||||
4788745572ef2bde34924ef34e7e4d55ba07e979 jdk8-b10
|
||||
7ab0d613cd1a271a9763ffb894dc1f0a5b95a7e4 jdk8-b11
|
||||
09fd2067f715e4505c44b01c301258a4e8f8964e jdk8-b12
|
||||
4cb2e8679b27432854690cb688ea06d3b2d8e008 jdk8-b13
|
||||
99632935785e2038b2fc836da9f2ede69dea294b jdk8-b14
|
||||
|
@ -78,7 +78,3 @@ endif # linux
|
||||
#
|
||||
include $(BUILDDIR)/common/Library.gmk
|
||||
|
||||
#
|
||||
# JVMDI implementation lives in the VM.
|
||||
#
|
||||
OTHER_LDLIBS = $(JVMLIB)
|
||||
|
@ -220,14 +220,30 @@ JDK_LOCALES = ja zh_CN
|
||||
JRE_NONEXIST_LOCALES = en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh
|
||||
|
||||
#
|
||||
# All libraries except libjava and libjvm itself link against libjvm and
|
||||
# libjava, the latter for its exported common utilities. libjava only links
|
||||
# against libjvm. Programs' makefiles take their own responsibility for
|
||||
# For now, most libraries except libjava and libjvm itself link against libjvm
|
||||
# and libjava, the latter for its exported common utilities. libjava only
|
||||
# links against libjvm. Programs' makefiles take their own responsibility for
|
||||
# adding other libs.
|
||||
#
|
||||
# The makefiles for these packages do not link against libjvm and libjava.
|
||||
# This list will eventually go away and each Programs' makefiles
|
||||
# will have to explicitly declare that they want to link to libjava/libjvm
|
||||
#
|
||||
NO_JAVALIB_PKGS = \
|
||||
sun.security.mscapi \
|
||||
sun.security.krb5 \
|
||||
sun.security.pkcs11 \
|
||||
sun.security.jgss \
|
||||
sun.security.jgss.wrapper \
|
||||
sun.security.ec \
|
||||
sun.security.smartcardio \
|
||||
com.sun.security.auth.module
|
||||
|
||||
ifdef PACKAGE
|
||||
# put JAVALIB first, but do not lose any platform specific values....
|
||||
LDLIBS_COMMON = $(JAVALIB)
|
||||
ifeq (,$(findstring $(PACKAGE),$(NO_JAVALIB_PKGS)))
|
||||
LDLIBS_COMMON = $(JAVALIB)
|
||||
endif
|
||||
endif # PACKAGE
|
||||
|
||||
#
|
||||
|
@ -158,6 +158,8 @@ ifneq ($(strip $(DEMO_ALL_NATIVE_SOURCES)),)
|
||||
# bit between them.
|
||||
LINK.demo = $(LINK.c)
|
||||
LDLIBS.demo = $(EXTRA_LIBS) $(LFLAGS_$(COMPILER_VERSION))
|
||||
DEMO_VERSION_INFO = $(OBJDIR)/$(LIBRARY).res
|
||||
LDLIBS.demo += $(DEMO_VERSION_INFO)
|
||||
else
|
||||
ifneq ($(DEMO_NEEDS_CPP),)
|
||||
LINK.demo = $(LINK.cpp)
|
||||
@ -288,6 +290,13 @@ ifndef DEMO_SKIP_SRCZIP
|
||||
$(install-file)
|
||||
endif
|
||||
|
||||
ifeq ($(PLATFORM),windows)
|
||||
# JDK name required here
|
||||
RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
|
||||
/D "JDK_INTERNAL_NAME=$(LIBRARY)" \
|
||||
/D "JDK_FTYPE=0x2L"
|
||||
endif
|
||||
|
||||
# Native library building
|
||||
ifdef DEMO_LIBRARY
|
||||
|
||||
@ -308,6 +317,9 @@ $(OBJDIR)/%.$(OBJECT_SUFFIX): $(DEMO_BUILD_SRCDIR)/%.cpp
|
||||
# Actual creation of the native shared library (C++ and C are different)
|
||||
$(DEMO_LIBRARY): $(DEMO_FULL_OBJECTS)
|
||||
@$(prep-target)
|
||||
ifeq ($(PLATFORM),windows)
|
||||
$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(DEMO_VERSION_INFO) $(VERSIONINFO_RESOURCE)
|
||||
endif
|
||||
$(LINK.demo) $(SHARED_LIBRARY_FLAG) $(CC_PROGRAM_OUTPUT_FLAG)$@ \
|
||||
$(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
|
||||
@$(call binary_file_verification,$@)
|
||||
|
@ -165,7 +165,7 @@ $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
|
||||
$(LINK) -dll -out:$(OBJDIR)/$(@F) \
|
||||
-map:$(OBJDIR)/$(LIBRARY).map \
|
||||
$(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \
|
||||
$(OTHER_LCF) $(JAVALIB) $(LDLIBS)
|
||||
$(OTHER_LCF) $(LDLIBS)
|
||||
$(CP) $(OBJDIR)/$(@F) $@
|
||||
@$(call binary_file_verification,$@)
|
||||
$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
|
||||
|
@ -90,7 +90,6 @@ SUNWprivate_1.1 {
|
||||
Java_java_io_FileSystem_getFileSystem;
|
||||
Java_java_io_ObjectInputStream_bytesToDoubles;
|
||||
Java_java_io_ObjectInputStream_bytesToFloats;
|
||||
Java_java_io_ObjectInputStream_latestUserDefinedLoader;
|
||||
Java_java_io_ObjectOutputStream_doublesToBytes;
|
||||
Java_java_io_ObjectOutputStream_floatsToBytes;
|
||||
Java_java_io_ObjectStreamClass_hasStaticInitializer;
|
||||
@ -275,6 +274,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_misc_Version_getJvmVersionInfo;
|
||||
Java_sun_misc_Version_getJvmSpecialVersion;
|
||||
Java_sun_misc_VM_getThreadStateValues;
|
||||
Java_sun_misc_VM_latestUserDefinedLoader;
|
||||
Java_sun_misc_VM_initialize;
|
||||
Java_sun_misc_VMSupport_initAgentProperties;
|
||||
|
||||
|
@ -232,6 +232,7 @@ FILES_src = \
|
||||
sun/nio/cs/UTF_16BE.java \
|
||||
sun/nio/cs/UTF_16LE.java \
|
||||
sun/nio/cs/UTF_8.java \
|
||||
sun/nio/cs/CESU_8.java \
|
||||
sun/nio/cs/Unicode.java \
|
||||
sun/nio/cs/UnicodeDecoder.java \
|
||||
sun/nio/cs/UnicodeEncoder.java \
|
||||
|
@ -21,4 +21,4 @@
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
tzdata2011j
|
||||
tzdata2011l
|
||||
|
@ -2216,7 +2216,47 @@ Zone Asia/Karachi 4:28:12 - LMT 1907
|
||||
# http://www.timeanddate.com/news/time/westbank-gaza-end-dst-2010.html
|
||||
# </a>
|
||||
|
||||
# From Steffen Thorsen (2011-08-26):
|
||||
# Gaza and the West Bank did go back to standard time in the beginning of
|
||||
# August, and will now enter daylight saving time again on 2011-08-30
|
||||
# 00:00 (so two periods of DST in 2011). The pause was because of
|
||||
# Ramadan.
|
||||
#
|
||||
# <a href="http://www.maannews.net/eng/ViewDetails.aspx?ID=416217">
|
||||
# http://www.maannews.net/eng/ViewDetails.aspx?ID=416217
|
||||
# </a>
|
||||
# Additional info:
|
||||
# <a href="http://www.timeanddate.com/news/time/palestine-dst-2011.html">
|
||||
# http://www.timeanddate.com/news/time/palestine-dst-2011.html
|
||||
# </a>
|
||||
|
||||
# From Alexander Krivenyshev (2011-08-27):
|
||||
# According to the article in The Jerusalem Post:
|
||||
# "...Earlier this month, the Palestinian government in the West Bank decided to
|
||||
# move to standard time for 30 days, during Ramadan. The Palestinians in the
|
||||
# Gaza Strip accepted the change and also moved their clocks one hour back.
|
||||
# The Hamas government said on Saturday that it won't observe summertime after
|
||||
# the Muslim feast of Id al-Fitr, which begins on Tuesday..."
|
||||
# ...
|
||||
# <a href="http://www.jpost.com/MiddleEast/Article.aspx?id=235650">
|
||||
# http://www.jpost.com/MiddleEast/Article.aspx?id=235650
|
||||
# </a>
|
||||
# or
|
||||
# <a href="http://www.worldtimezone.com/dst_news/dst_news_gazastrip05.html">
|
||||
# http://www.worldtimezone.com/dst_news/dst_news_gazastrip05.html
|
||||
# </a>
|
||||
# The rules for Egypt are stolen from the `africa' file.
|
||||
|
||||
# From Steffen Thorsen (2011-09-30):
|
||||
# West Bank did end Daylight Saving Time this morning/midnight (2011-09-30
|
||||
# 00:00).
|
||||
# So West Bank and Gaza now have the same time again.
|
||||
#
|
||||
# Many sources, including:
|
||||
# <a href="http://www.maannews.net/eng/ViewDetails.aspx?ID=424808">
|
||||
# http://www.maannews.net/eng/ViewDetails.aspx?ID=424808
|
||||
# </a>
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule EgyptAsia 1957 only - May 10 0:00 1:00 S
|
||||
Rule EgyptAsia 1957 1958 - Oct 1 0:00 0 -
|
||||
@ -2232,19 +2272,37 @@ Rule Palestine 2005 only - Oct 4 2:00 0 -
|
||||
Rule Palestine 2006 2008 - Apr 1 0:00 1:00 S
|
||||
Rule Palestine 2006 only - Sep 22 0:00 0 -
|
||||
Rule Palestine 2007 only - Sep Thu>=8 2:00 0 -
|
||||
Rule Palestine 2008 only - Aug lastFri 2:00 0 -
|
||||
Rule Palestine 2008 only - Aug lastFri 0:00 0 -
|
||||
Rule Palestine 2009 only - Mar lastFri 0:00 1:00 S
|
||||
Rule Palestine 2010 max - Mar lastSat 0:01 1:00 S
|
||||
Rule Palestine 2009 max - Sep Fri>=1 2:00 0 -
|
||||
Rule Palestine 2009 only - Sep Fri>=1 2:00 0 -
|
||||
Rule Palestine 2010 only - Mar lastSat 0:01 1:00 S
|
||||
Rule Palestine 2010 only - Aug 11 0:00 0 -
|
||||
|
||||
# From Arthur David Olson (2011-09-20):
|
||||
# 2011 transitions per http://www.timeanddate.com as of 2011-09-20.
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Asia/Gaza 2:17:52 - LMT 1900 Oct
|
||||
2:00 Zion EET 1948 May 15
|
||||
2:00 EgyptAsia EE%sT 1967 Jun 5
|
||||
2:00 Zion I%sT 1996
|
||||
2:00 Jordan EE%sT 1999
|
||||
2:00 Palestine EE%sT
|
||||
2:00 Palestine EE%sT 2011 Apr 2 12:01
|
||||
2:00 1:00 EEST 2011 Aug 1
|
||||
2:00 - EET
|
||||
|
||||
Zone Asia/Hebron 2:20:23 - LMT 1900 Oct
|
||||
2:00 Zion EET 1948 May 15
|
||||
2:00 EgyptAsia EE%sT 1967 Jun 5
|
||||
2:00 Zion I%sT 1996
|
||||
2:00 Jordan EE%sT 1999
|
||||
2:00 Palestine EE%sT 2008 Aug
|
||||
2:00 1:00 EEST 2008 Sep
|
||||
2:00 Palestine EE%sT 2011 Apr 1 12:01
|
||||
2:00 1:00 EEST 2011 Aug 1
|
||||
2:00 - EET 2011 Aug 30
|
||||
2:00 1:00 EEST 2011 Sep 30 3:00
|
||||
2:00 - EET
|
||||
|
||||
# Paracel Is
|
||||
# no information
|
||||
|
@ -318,6 +318,18 @@ Zone Indian/Cocos 6:27:40 - LMT 1900
|
||||
# http://www.worldtimezone.com/dst_news/dst_news_fiji04.html
|
||||
# </a>
|
||||
|
||||
# From Steffen Thorsen (2011-10-03):
|
||||
# Now the dates have been confirmed, and at least our start date
|
||||
# assumption was correct (end date was one week wrong).
|
||||
#
|
||||
# <a href="http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=4966:daylight-saving-starts-in-fiji&catid=71:press-releases&Itemid=155">
|
||||
# www.fiji.gov.fj/index.php?option=com_content&view=article&id=4966:daylight-saving-starts-in-fiji&catid=71:press-releases&Itemid=155
|
||||
# </a>
|
||||
# which says
|
||||
# Members of the public are reminded to change their time to one hour in
|
||||
# advance at 2am to 3am on October 23, 2011 and one hour back at 3am to
|
||||
# 2am on February 26 next year.
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 S
|
||||
Rule Fiji 1999 2000 - Feb lastSun 3:00 0 -
|
||||
@ -325,6 +337,8 @@ Rule Fiji 2009 only - Nov 29 2:00 1:00 S
|
||||
Rule Fiji 2010 only - Mar lastSun 3:00 0 -
|
||||
Rule Fiji 2010 only - Oct 24 2:00 1:00 S
|
||||
Rule Fiji 2011 only - Mar Sun>=1 3:00 0 -
|
||||
Rule Fiji 2011 only - Oct 23 2:00 1:00 S
|
||||
Rule Fiji 2012 only - Feb 26 3:00 0 -
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Pacific/Fiji 11:53:40 - LMT 1915 Oct 26 # Suva
|
||||
12:00 Fiji FJ%sT # Fiji Time
|
||||
|
@ -583,9 +583,9 @@ Rule Russia 1985 1991 - Mar lastSun 2:00s 1:00 S
|
||||
#
|
||||
Rule Russia 1992 only - Mar lastSat 23:00 1:00 S
|
||||
Rule Russia 1992 only - Sep lastSat 23:00 0 -
|
||||
Rule Russia 1993 max - Mar lastSun 2:00s 1:00 S
|
||||
Rule Russia 1993 2010 - Mar lastSun 2:00s 1:00 S
|
||||
Rule Russia 1993 1995 - Sep lastSun 2:00s 0 -
|
||||
Rule Russia 1996 max - Oct lastSun 2:00s 0 -
|
||||
Rule Russia 1996 2010 - Oct lastSun 2:00s 0 -
|
||||
|
||||
# From Alexander Krivenyshev (2011-06-14):
|
||||
# According to Kremlin press service, Russian President Dmitry Medvedev
|
||||
@ -605,7 +605,6 @@ Rule Russia 1996 max - Oct lastSun 2:00s 0 -
|
||||
# From Arthur David Olson (2011-06-15):
|
||||
# Take "abolishing daylight saving time" to mean that time is now considered
|
||||
# to be standard.
|
||||
# At least for now, keep the "old" Russia rules for the benefit of Belarus.
|
||||
|
||||
# These are for backward compatibility with older versions.
|
||||
|
||||
@ -711,6 +710,23 @@ Zone Europe/Vienna 1:05:20 - LMT 1893 Apr
|
||||
1:00 EU CE%sT
|
||||
|
||||
# Belarus
|
||||
# From Yauhen Kharuzhy (2011-09-16):
|
||||
# By latest Belarus government act Europe/Minsk timezone was changed to
|
||||
# GMT+3 without DST (was GMT+2 with DST).
|
||||
#
|
||||
# Sources (Russian language):
|
||||
# 1.
|
||||
# <a href="http://www.belta.by/ru/all_news/society/V-Belarusi-otmenjaetsja-perexod-na-sezonnoe-vremja_i_572952.html">
|
||||
# http://www.belta.by/ru/all_news/society/V-Belarusi-otmenjaetsja-perexod-na-sezonnoe-vremja_i_572952.html
|
||||
# </a>
|
||||
# 2.
|
||||
# <a href="http://naviny.by/rubrics/society/2011/09/16/ic_articles_116_175144/">
|
||||
# http://naviny.by/rubrics/society/2011/09/16/ic_articles_116_175144/
|
||||
# </a>
|
||||
# 3.
|
||||
# <a href="http://news.tut.by/society/250578.html">
|
||||
# http://news.tut.by/society/250578.html
|
||||
# </a>
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Europe/Minsk 1:50:16 - LMT 1880
|
||||
1:50 - MMT 1924 May 2 # Minsk Mean Time
|
||||
@ -722,7 +738,8 @@ Zone Europe/Minsk 1:50:16 - LMT 1880
|
||||
2:00 1:00 EEST 1991 Sep 29 2:00s
|
||||
2:00 - EET 1992 Mar 29 0:00s
|
||||
2:00 1:00 EEST 1992 Sep 27 0:00s
|
||||
2:00 Russia EE%sT
|
||||
2:00 Russia EE%sT 2011 Mar 27 2:00s
|
||||
3:00 - FET # Further-eastern European Time
|
||||
|
||||
# Belgium
|
||||
#
|
||||
@ -2056,7 +2073,7 @@ Zone Europe/Kaliningrad 1:22:00 - LMT 1893 Apr
|
||||
2:00 Poland CE%sT 1946
|
||||
3:00 Russia MSK/MSD 1991 Mar 31 2:00s
|
||||
2:00 Russia EE%sT 2011 Mar 27 2:00s
|
||||
3:00 - KALT
|
||||
3:00 - FET # Further-eastern European Time
|
||||
#
|
||||
# From Oscar van Vlijmen (2001-08-25): [This region consists of]
|
||||
# Respublika Adygeya, Arkhangel'skaya oblast',
|
||||
@ -2211,7 +2228,7 @@ Zone Asia/Irkutsk 6:57:20 - LMT 1880
|
||||
# [parts of] Respublika Sakha (Yakutiya), Chitinskaya oblast'.
|
||||
|
||||
# From Oscar van Vlijmen (2009-11-29):
|
||||
# ...some regions of RUssia were merged with others since 2005...
|
||||
# ...some regions of [Russia] were merged with others since 2005...
|
||||
# Some names were changed, no big deal, except for one instance: a new name.
|
||||
# YAK/YAKST: UTC+9 Zabajkal'skij kraj.
|
||||
|
||||
@ -2635,6 +2652,28 @@ Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents.
|
||||
# of March at 3am the time is changing to 4am and each last Sunday of
|
||||
# October the time at 4am is changing to 3am"
|
||||
|
||||
# From Alexander Krivenyshev (2011-09-20):
|
||||
# On September 20, 2011 the deputies of the Verkhovna Rada agreed to
|
||||
# abolish the transfer clock to winter time.
|
||||
#
|
||||
# Bill number 8330 of MP from the Party of Regions Oleg Nadoshi got
|
||||
# approval from 266 deputies.
|
||||
#
|
||||
# Ukraine abolishes transter back to the winter time (in Russian)
|
||||
# <a href="http://news.mail.ru/politics/6861560/">
|
||||
# http://news.mail.ru/politics/6861560/
|
||||
# </a>
|
||||
#
|
||||
# The Ukrainians will no longer change the clock (in Russian)
|
||||
# <a href="http://www.segodnya.ua/news/14290482.html">
|
||||
# http://www.segodnya.ua/news/14290482.html
|
||||
# </a>
|
||||
#
|
||||
# Deputies cancelled the winter time (in Russian)
|
||||
# <a href="http://www.pravda.com.ua/rus/news/2011/09/20/6600616/">
|
||||
# http://www.pravda.com.ua/rus/news/2011/09/20/6600616/
|
||||
# </a>
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
# Most of Ukraine since 1970 has been like Kiev.
|
||||
# "Kyiv" is the transliteration of the Ukrainian name, but
|
||||
@ -2648,7 +2687,8 @@ Zone Europe/Kiev 2:02:04 - LMT 1880
|
||||
3:00 - MSK 1990 Jul 1 2:00
|
||||
2:00 - EET 1992
|
||||
2:00 E-Eur EE%sT 1995
|
||||
2:00 EU EE%sT
|
||||
2:00 EU EE%sT 2011 Mar lastSun 1:00u
|
||||
3:00 - FET # Further-eastern European Time
|
||||
# Ruthenia used CET 1990/1991.
|
||||
# "Uzhhorod" is the transliteration of the Ukrainian name, but
|
||||
# "Uzhgorod" is more common in English.
|
||||
@ -2662,7 +2702,8 @@ Zone Europe/Uzhgorod 1:29:12 - LMT 1890 Oct
|
||||
1:00 - CET 1991 Mar 31 3:00
|
||||
2:00 - EET 1992
|
||||
2:00 E-Eur EE%sT 1995
|
||||
2:00 EU EE%sT
|
||||
2:00 EU EE%sT 2011 Mar lastSun 1:00u
|
||||
3:00 - FET # Further-eastern European Time
|
||||
# Zaporozh'ye and eastern Lugansk oblasts observed DST 1990/1991.
|
||||
# "Zaporizhia" is the transliteration of the Ukrainian name, but
|
||||
# "Zaporozh'ye" is more common in English. Use the common English
|
||||
@ -2675,7 +2716,8 @@ Zone Europe/Zaporozhye 2:20:40 - LMT 1880
|
||||
1:00 C-Eur CE%sT 1943 Oct 25
|
||||
3:00 Russia MSK/MSD 1991 Mar 31 2:00
|
||||
2:00 E-Eur EE%sT 1995
|
||||
2:00 EU EE%sT
|
||||
2:00 EU EE%sT 2011 Mar lastSun 1:00u
|
||||
3:00 - FET # Further-eastern European Time
|
||||
# Central Crimea used Moscow time 1994/1997.
|
||||
Zone Europe/Simferopol 2:16:24 - LMT 1880
|
||||
2:16 - SMT 1924 May 2 # Simferopol Mean T
|
||||
@ -2700,7 +2742,8 @@ Zone Europe/Simferopol 2:16:24 - LMT 1880
|
||||
# Assume it happened in March by not changing the clocks.
|
||||
3:00 Russia MSK/MSD 1997
|
||||
3:00 - MSK 1997 Mar lastSun 1:00u
|
||||
2:00 EU EE%sT
|
||||
2:00 EU EE%sT 2011 Mar lastSun 1:00u
|
||||
3:00 - FET # Further-eastern European Time
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -505,7 +505,7 @@ Zone America/Juneau 15:02:19 - LMT 1867 Oct 18
|
||||
-8:00 US P%sT 1983 Oct 30 2:00
|
||||
-9:00 US Y%sT 1983 Nov 30
|
||||
-9:00 US AK%sT
|
||||
Zone America/Sitka -14:58:47 - LMT 1867 Oct 18
|
||||
Zone America/Sitka 14:58:47 - LMT 1867 Oct 18
|
||||
-9:01:13 - LMT 1900 Aug 20 12:00
|
||||
-8:00 - PST 1942
|
||||
-8:00 US P%sT 1946
|
||||
@ -1190,31 +1190,21 @@ Rule StJohns 1960 1986 - Oct lastSun 2:00 0 S
|
||||
# INMS (2000-09-12) says that, since 1988 at least, Newfoundland switches
|
||||
# at 00:01 local time. For now, assume it started in 1987.
|
||||
|
||||
# From Michael Pelley (2011-08-05):
|
||||
# The Government of Newfoundland and Labrador has pending changes to
|
||||
# modify the hour for daylight savings time to come into effect in
|
||||
# November 2011. This modification would change the time from 12:01AM to
|
||||
# 2:00AM on the dates of the switches of Daylight Savings Time to/from
|
||||
# Standard Time.
|
||||
#
|
||||
# As a matter of reference, in Canada provinces have the authority of
|
||||
# setting time zone information. The legislation has passed our
|
||||
# legislative body (The House of Assembly) and is awaiting the
|
||||
# proclamation to come into effect. You may find this information at:
|
||||
# <a href="http://www.assembly.nl.ca/legislation/sr/lists/Proclamation.htm">
|
||||
# http://www.assembly.nl.ca/legislation/sr/lists/Proclamation.htm
|
||||
# </a>
|
||||
# and
|
||||
# search within that web page for Standard Time (Amendment) Act. The Act
|
||||
# may be found at:
|
||||
# <a href="http://www.assembly.nl.ca/business/bills/Bill1106.htm">
|
||||
# http://www.assembly.nl.ca/business/bills/Bill1106.htm
|
||||
# From Michael Pelley (2011-09-12):
|
||||
# We received today, Monday, September 12, 2011, notification that the
|
||||
# changes to the Newfoundland Standard Time Act have been proclaimed.
|
||||
# The change in the Act stipulates that the change from Daylight Savings
|
||||
# Time to Standard Time and from Standard Time to Daylight Savings Time
|
||||
# now occurs at 2:00AM.
|
||||
# ...
|
||||
# <a href="http://www.assembly.nl.ca/legislation/sr/annualstatutes/2011/1106.chp.htm">
|
||||
# http://www.assembly.nl.ca/legislation/sr/annualstatutes/2011/1106.chp.htm
|
||||
# </a>
|
||||
# ...
|
||||
# MICHAEL PELLEY | Manager of Enterprise Architecture - Solution Delivery
|
||||
# Office of the Chief Information Officer Executive Council Government of
|
||||
# Newfoundland & Labrador P.O. Box 8700, 40 Higgins Line, St. John's NL
|
||||
# A1B 4J6
|
||||
# MICHAEL PELLEY | Manager of Enterprise Architecture - Solution Delivery
|
||||
# Office of the Chief Information Officer
|
||||
# Executive Council
|
||||
# Government of Newfoundland & Labrador
|
||||
|
||||
Rule StJohns 1987 only - Apr Sun>=1 0:01 1:00 D
|
||||
Rule StJohns 1987 2006 - Oct lastSun 0:01 0 S
|
||||
|
@ -819,6 +819,26 @@ Zone America/La_Paz -4:32:36 - LMT 1890
|
||||
# <a href="http://www.timeanddate.com/news/time/brazil-dst-2008-2009.html">
|
||||
# http://www.timeanddate.com/news/time/brazil-dst-2008-2009.html
|
||||
# </a>
|
||||
#
|
||||
# From Alexander Krivenyshev (2011-10-04):
|
||||
# State Bahia will return to Daylight savings time this year after 8 years off.
|
||||
# The announcement was made by Governor Jaques Wagner in an interview to a
|
||||
# television station in Salvador.
|
||||
|
||||
# In Portuguese:
|
||||
# <a href="http://g1.globo.com/bahia/noticia/2011/10/governador-jaques-wagner-confirma-horario-de-verao-na-bahia.html">
|
||||
# http://g1.globo.com/bahia/noticia/2011/10/governador-jaques-wagner-confirma-horario-de-verao-na-bahia.html
|
||||
# </a> and
|
||||
# <a href="http://noticias.terra.com.br/brasil/noticias/0,,OI5390887-EI8139,00-Bahia+volta+a+ter+horario+de+verao+apos+oito+anos.html">
|
||||
# http://noticias.terra.com.br/brasil/noticias/0,,OI5390887-EI8139,00-Bahia+volta+a+ter+horario+de+verao+apos+oito+anos.html
|
||||
# </a>
|
||||
|
||||
# From Guilherme Bernardes Rodrigues (2011-10-07):
|
||||
# There is news in the media, however there is still no decree about it.
|
||||
# I just send a e-mail to Zulmira Brandão at
|
||||
# <a href="http://pcdsh01.on.br/">http://pcdsh01.on.br/</a> the
|
||||
# oficial agency about time in Brazil, and she confirmed that the old rule is
|
||||
# still in force.
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
# Decree <a href="http://pcdsh01.on.br/HV20466.htm">20,466</a> (1931-10-01)
|
||||
@ -1057,6 +1077,9 @@ Zone America/Maceio -2:22:52 - LMT 1914
|
||||
Zone America/Bahia -2:34:04 - LMT 1914
|
||||
-3:00 Brazil BR%sT 2003 Sep 24
|
||||
-3:00 - BRT
|
||||
# as noted above, not yet in operation.
|
||||
# -3:00 - BRT 2011 Oct 16
|
||||
# -3:00 Brazil BR%sT
|
||||
#
|
||||
# Goias (GO), Distrito Federal (DF), Minas Gerais (MG),
|
||||
# Espirito Santo (ES), Rio de Janeiro (RJ), Sao Paulo (SP), Parana (PR),
|
||||
|
@ -341,7 +341,8 @@ PL +5215+02100 Europe/Warsaw
|
||||
PM +4703-05620 America/Miquelon
|
||||
PN -2504-13005 Pacific/Pitcairn
|
||||
PR +182806-0660622 America/Puerto_Rico
|
||||
PS +3130+03428 Asia/Gaza
|
||||
PS +3130+03428 Asia/Gaza Gaza Strip
|
||||
PS +313200+0350542 Asia/Hebron West Bank
|
||||
PT +3843-00908 Europe/Lisbon mainland
|
||||
PT +3238-01654 Atlantic/Madeira Madeira Islands
|
||||
PT +3744-02540 Atlantic/Azores Azores
|
||||
|
@ -28,6 +28,7 @@ PACKAGE = sun.net
|
||||
PRODUCT = sun
|
||||
SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
|
||||
SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
|
||||
SUBDIRS_MAKEFLAGS += JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation,-path
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
SUBDIRS = others spi
|
||||
|
@ -30,15 +30,8 @@
|
||||
BUILDDIR = ../../..
|
||||
PACKAGE = sun.rmi
|
||||
PRODUCT = sun
|
||||
LIBRARY = rmi
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
# Add use of a mapfile
|
||||
#
|
||||
FILES_m = mapfile-vers
|
||||
include $(BUILDDIR)/common/Mapfile-vers.gmk
|
||||
|
||||
#
|
||||
# Java files to compile.
|
||||
#
|
||||
@ -51,32 +44,10 @@ AUTO_FILES_JAVA_DIRS = \
|
||||
sun/rmi/transport \
|
||||
com/sun/rmi
|
||||
|
||||
#
|
||||
# Native files to compile.
|
||||
#
|
||||
FILES_c = \
|
||||
sun/rmi/server/MarshalInputStream.c
|
||||
|
||||
#
|
||||
# Add ambient vpath to pick up files not part of sun.rmi package
|
||||
#
|
||||
vpath %.c $(SHARE_SRC)/native/sun/rmi/server
|
||||
|
||||
#
|
||||
# Exported files that require generated .h
|
||||
#
|
||||
FILES_export = \
|
||||
sun/rmi/server/MarshalInputStream.java
|
||||
|
||||
#
|
||||
# Link to JVM for JVM_LatestUserDefinedLoader
|
||||
#
|
||||
OTHER_LDLIBS = $(JVMLIB)
|
||||
|
||||
#
|
||||
# Rules
|
||||
#
|
||||
include $(BUILDDIR)/common/Library.gmk
|
||||
include $(BUILDDIR)/common/Rules.gmk
|
||||
|
||||
#
|
||||
# Full package names of implementations requiring stubs
|
||||
|
@ -1,33 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Define library interface.
|
||||
|
||||
SUNWprivate_1.1 {
|
||||
global:
|
||||
Java_sun_rmi_server_MarshalInputStream_latestUserDefinedLoader;
|
||||
local:
|
||||
*;
|
||||
};
|
@ -192,10 +192,8 @@ ifeq ($(NATIVE_ECC_AVAILABLE), true)
|
||||
#
|
||||
# Libraries to link
|
||||
#
|
||||
ifeq ($(PLATFORM), windows)
|
||||
OTHER_LDLIBS += $(JVMLIB)
|
||||
else
|
||||
OTHER_LDLIBS = -ldl $(JVMLIB) $(LIBCXX)
|
||||
ifneq ($(PLATFORM), windows)
|
||||
OTHER_LDLIBS = $(LIBCXX)
|
||||
endif
|
||||
|
||||
include $(BUILDDIR)/common/Mapfile-vers.gmk
|
||||
|
@ -72,5 +72,6 @@ include $(BUILDDIR)/common/Library.gmk
|
||||
# Libraries to link
|
||||
#
|
||||
ifneq ($(PLATFORM), windows)
|
||||
OTHER_LDLIBS = -ldl $(JVMLIB)
|
||||
OTHER_LDLIBS = -ldl
|
||||
endif
|
||||
|
||||
|
@ -69,15 +69,6 @@ else
|
||||
include $(BUILDDIR)/common/Classes.gmk
|
||||
endif # PLATFORM
|
||||
|
||||
#
|
||||
# Libraries to link
|
||||
#
|
||||
ifeq ($(PLATFORM), windows)
|
||||
OTHER_LDLIBS = $(JVMLIB)
|
||||
else
|
||||
OTHER_LDLIBS = -ldl $(JVMLIB)
|
||||
endif
|
||||
|
||||
build:
|
||||
ifeq ($(PLATFORM),windows)
|
||||
$(call make-launcher, kinit, sun.security.krb5.internal.tools.Kinit, , )
|
||||
|
@ -159,7 +159,7 @@ include $(BUILDDIR)/common/Library.gmk
|
||||
# Libraries to link
|
||||
#
|
||||
ifeq ($(PLATFORM), windows)
|
||||
OTHER_LDLIBS += $(JVMLIB) Crypt32.Lib
|
||||
OTHER_LDLIBS += Crypt32.Lib
|
||||
endif
|
||||
|
||||
#
|
||||
|
@ -38,6 +38,7 @@ AUTO_FILES_JAVA_DIRS = \
|
||||
sun/security/acl \
|
||||
sun/security/jca \
|
||||
sun/security/pkcs \
|
||||
sun/security/pkcs10 \
|
||||
sun/security/pkcs12 \
|
||||
sun/security/provider \
|
||||
sun/security/rsa \
|
||||
|
@ -159,10 +159,8 @@ include $(BUILDDIR)/common/Library.gmk
|
||||
#
|
||||
# Libraries to link
|
||||
#
|
||||
ifeq ($(PLATFORM), windows)
|
||||
OTHER_LDLIBS = $(JVMLIB)
|
||||
else
|
||||
OTHER_LDLIBS = -ldl $(JVMLIB)
|
||||
ifneq ($(PLATFORM), windows)
|
||||
OTHER_LDLIBS = -ldl
|
||||
endif
|
||||
|
||||
# Other config files
|
||||
|
@ -73,8 +73,8 @@ include $(BUILDDIR)/common/Library.gmk
|
||||
# Libraries to link
|
||||
#
|
||||
ifeq ($(PLATFORM), windows)
|
||||
OTHER_LDLIBS = $(JVMLIB) winscard.lib
|
||||
OTHER_LDLIBS = winscard.lib
|
||||
else
|
||||
OTHER_LDLIBS = -ldl $(JVMLIB)
|
||||
OTHER_LDLIBS = -ldl
|
||||
OTHER_CFLAGS = -D__sun_jdk
|
||||
endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -179,6 +179,12 @@ class HttpsURLConnection extends HttpURLConnection
|
||||
throw new IllegalArgumentException(
|
||||
"no SSLSocketFactory specified");
|
||||
}
|
||||
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkSetFactory();
|
||||
}
|
||||
|
||||
sslSocketFactory = sf;
|
||||
}
|
||||
|
||||
|
@ -250,6 +250,8 @@ public class IdResolver {
|
||||
int index=s==null ? elementIndex : names.indexOf(n.getNamespaceURI());
|
||||
index=(index<0) ? namesLength : index;
|
||||
String name=n.getLocalName();
|
||||
if (name == null)
|
||||
name = n.getName();
|
||||
if (name.length()>2)
|
||||
continue;
|
||||
String value=n.getNodeValue();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,7 @@
|
||||
package java.awt;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import sun.awt.AppContext;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -66,9 +67,6 @@ import java.lang.reflect.Field;
|
||||
public class AWTKeyStroke implements Serializable {
|
||||
static final long serialVersionUID = -6430539691155161871L;
|
||||
|
||||
private static Map cache;
|
||||
private static AWTKeyStroke cacheKey;
|
||||
private static Constructor ctor = getCtor(AWTKeyStroke.class);
|
||||
private static Map modifierKeywords;
|
||||
/**
|
||||
* Associates VK_XXX (as a String) with code (as Integer). This is
|
||||
@ -77,6 +75,25 @@ public class AWTKeyStroke implements Serializable {
|
||||
*/
|
||||
private static VKCollection vks;
|
||||
|
||||
//A key for the collection of AWTKeyStrokes within AppContext.
|
||||
private static Object APP_CONTEXT_CACHE_KEY = new Object();
|
||||
//A key withing the cache
|
||||
private static AWTKeyStroke APP_CONTEXT_KEYSTROKE_KEY = new AWTKeyStroke();
|
||||
|
||||
/*
|
||||
* Reads keystroke class from AppContext and if null, puts there the
|
||||
* AWTKeyStroke class.
|
||||
* Must be called under locked AWTKeyStro
|
||||
*/
|
||||
private static Class getAWTKeyStrokeClass() {
|
||||
Class clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
|
||||
if (clazz == null) {
|
||||
clazz = AWTKeyStroke.class;
|
||||
AppContext.getAppContext().put(AWTKeyStroke.class, AWTKeyStroke.class);
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
private char keyChar = KeyEvent.CHAR_UNDEFINED;
|
||||
private int keyCode = KeyEvent.VK_UNDEFINED;
|
||||
private int modifiers;
|
||||
@ -164,9 +181,12 @@ public class AWTKeyStroke implements Serializable {
|
||||
if (subclass == null) {
|
||||
throw new IllegalArgumentException("subclass cannot be null");
|
||||
}
|
||||
if (AWTKeyStroke.ctor.getDeclaringClass().equals(subclass)) {
|
||||
// Already registered
|
||||
return;
|
||||
synchronized (AWTKeyStroke.class) {
|
||||
Class keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
|
||||
if (keyStrokeClass != null && keyStrokeClass.equals(subclass)){
|
||||
// Already registered
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!AWTKeyStroke.class.isAssignableFrom(subclass)) {
|
||||
throw new ClassCastException("subclass is not derived from AWTKeyStroke");
|
||||
@ -197,9 +217,9 @@ public class AWTKeyStroke implements Serializable {
|
||||
}
|
||||
|
||||
synchronized (AWTKeyStroke.class) {
|
||||
AWTKeyStroke.ctor = ctor;
|
||||
cache = null;
|
||||
cacheKey = null;
|
||||
AppContext.getAppContext().put(AWTKeyStroke.class, subclass);
|
||||
AppContext.getAppContext().remove(APP_CONTEXT_CACHE_KEY);
|
||||
AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,13 +249,19 @@ public class AWTKeyStroke implements Serializable {
|
||||
private static synchronized AWTKeyStroke getCachedStroke
|
||||
(char keyChar, int keyCode, int modifiers, boolean onKeyRelease)
|
||||
{
|
||||
Map cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY);
|
||||
AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY);
|
||||
|
||||
if (cache == null) {
|
||||
cache = new HashMap();
|
||||
AppContext.getAppContext().put(APP_CONTEXT_CACHE_KEY, cache);
|
||||
}
|
||||
|
||||
if (cacheKey == null) {
|
||||
try {
|
||||
cacheKey = (AWTKeyStroke)ctor.newInstance((Object[]) null);
|
||||
Class clazz = getAWTKeyStrokeClass();
|
||||
cacheKey = (AWTKeyStroke)getCtor(clazz).newInstance((Object[]) null);
|
||||
AppContext.getAppContext().put(APP_CONTEXT_KEYSTROKE_KEY, cacheKey);
|
||||
} catch (InstantiationException e) {
|
||||
assert(false);
|
||||
} catch (IllegalAccessException e) {
|
||||
@ -253,9 +279,8 @@ public class AWTKeyStroke implements Serializable {
|
||||
if (stroke == null) {
|
||||
stroke = cacheKey;
|
||||
cache.put(stroke, stroke);
|
||||
cacheKey = null;
|
||||
AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY);
|
||||
}
|
||||
|
||||
return stroke;
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,9 @@ package java.io;
|
||||
*/
|
||||
public abstract class InputStream implements Closeable {
|
||||
|
||||
// SKIP_BUFFER_SIZE is used to determine the size of skipBuffer
|
||||
private static final int SKIP_BUFFER_SIZE = 2048;
|
||||
// skipBuffer is initialized in skip(long), if needed.
|
||||
private static byte[] skipBuffer;
|
||||
// MAX_SKIP_BUFFER_SIZE is used to determine the maximum buffer size to
|
||||
// use when skipping.
|
||||
private static final int MAX_SKIP_BUFFER_SIZE = 2048;
|
||||
|
||||
/**
|
||||
* Reads the next byte of data from the input stream. The value byte is
|
||||
@ -212,18 +211,15 @@ public abstract class InputStream implements Closeable {
|
||||
|
||||
long remaining = n;
|
||||
int nr;
|
||||
if (skipBuffer == null)
|
||||
skipBuffer = new byte[SKIP_BUFFER_SIZE];
|
||||
|
||||
byte[] localSkipBuffer = skipBuffer;
|
||||
|
||||
if (n <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int size = (int)Math.min(MAX_SKIP_BUFFER_SIZE, remaining);
|
||||
byte[] skipBuffer = new byte[size];
|
||||
while (remaining > 0) {
|
||||
nr = read(localSkipBuffer, 0,
|
||||
(int) Math.min(SKIP_BUFFER_SIZE, remaining));
|
||||
nr = read(skipBuffer, 0, (int)Math.min(size, remaining));
|
||||
if (nr < 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -2025,8 +2025,9 @@ public class ObjectInputStream
|
||||
* This method should not be removed or its signature changed without
|
||||
* corresponding modifications to the above class.
|
||||
*/
|
||||
// REMIND: change name to something more accurate?
|
||||
private static native ClassLoader latestUserDefinedLoader();
|
||||
private static ClassLoader latestUserDefinedLoader() {
|
||||
return sun.misc.VM.latestUserDefinedLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default GetField implementation.
|
||||
|
@ -27,7 +27,6 @@ package java.lang.ref;
|
||||
|
||||
import sun.misc.Cleaner;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base class for reference objects. This class defines the
|
||||
* operations common to all reference objects. Because reference objects are
|
||||
@ -69,7 +68,7 @@ public abstract class Reference<T> {
|
||||
* null.
|
||||
*
|
||||
* Pending: queue = ReferenceQueue with which instance is registered;
|
||||
* next = Following instance in queue, or this if at end of list.
|
||||
* next = this
|
||||
*
|
||||
* Enqueued: queue = ReferenceQueue.ENQUEUED; next = Following instance
|
||||
* in queue, or this if at end of list.
|
||||
@ -81,17 +80,28 @@ public abstract class Reference<T> {
|
||||
* the next field is null then the instance is active; if it is non-null,
|
||||
* then the collector should treat the instance normally.
|
||||
*
|
||||
* To ensure that concurrent collector can discover active Reference
|
||||
* To ensure that a concurrent collector can discover active Reference
|
||||
* objects without interfering with application threads that may apply
|
||||
* the enqueue() method to those objects, collectors should link
|
||||
* discovered objects through the discovered field.
|
||||
* discovered objects through the discovered field. The discovered
|
||||
* field is also used for linking Reference objects in the pending list.
|
||||
*/
|
||||
|
||||
private T referent; /* Treated specially by GC */
|
||||
|
||||
ReferenceQueue<? super T> queue;
|
||||
|
||||
/* When active: NULL
|
||||
* pending: this
|
||||
* Enqueued: next reference in queue (or this if last)
|
||||
* Inactive: this
|
||||
*/
|
||||
Reference next;
|
||||
|
||||
/* When active: next element in a discovered reference list maintained by GC (or this if last)
|
||||
* pending: next element in the pending list (or null if last)
|
||||
* otherwise: NULL
|
||||
*/
|
||||
transient private Reference<T> discovered; /* used by VM */
|
||||
|
||||
|
||||
@ -106,7 +116,8 @@ public abstract class Reference<T> {
|
||||
|
||||
/* List of References waiting to be enqueued. The collector adds
|
||||
* References to this list, while the Reference-handler thread removes
|
||||
* them. This list is protected by the above lock object.
|
||||
* them. This list is protected by the above lock object. The
|
||||
* list uses the discovered field to link its elements.
|
||||
*/
|
||||
private static Reference pending = null;
|
||||
|
||||
@ -120,14 +131,12 @@ public abstract class Reference<T> {
|
||||
|
||||
public void run() {
|
||||
for (;;) {
|
||||
|
||||
Reference r;
|
||||
synchronized (lock) {
|
||||
if (pending != null) {
|
||||
r = pending;
|
||||
Reference rn = r.next;
|
||||
pending = (rn == r) ? null : rn;
|
||||
r.next = r;
|
||||
pending = r.discovered;
|
||||
r.discovered = null;
|
||||
} else {
|
||||
try {
|
||||
lock.wait();
|
||||
@ -201,10 +210,8 @@ public abstract class Reference<T> {
|
||||
* been enqueued
|
||||
*/
|
||||
public boolean isEnqueued() {
|
||||
/* In terms of the internal states, this predicate actually tests
|
||||
whether the instance is either Pending or Enqueued */
|
||||
synchronized (this) {
|
||||
return (this.queue != ReferenceQueue.NULL) && (this.next != null);
|
||||
return (this.next != null && this.queue == ReferenceQueue.ENQUEUED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -876,10 +876,12 @@ class InetAddress implements java.io.Serializable {
|
||||
nameService = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<NameService>() {
|
||||
public NameService run() {
|
||||
Iterator itr = Service.providers(NameServiceDescriptor.class);
|
||||
// sun.misc.Service.providers returns a raw Iterator
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<NameServiceDescriptor> itr =
|
||||
Service.providers(NameServiceDescriptor.class);
|
||||
while (itr.hasNext()) {
|
||||
NameServiceDescriptor nsd
|
||||
= (NameServiceDescriptor)itr.next();
|
||||
NameServiceDescriptor nsd = itr.next();
|
||||
if (providerName.
|
||||
equalsIgnoreCase(nsd.getType()+","
|
||||
+nsd.getProviderName())) {
|
||||
|
@ -267,10 +267,9 @@ class ServerSocket implements java.io.Closeable {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Void>() {
|
||||
public Void run() throws NoSuchMethodException {
|
||||
Class[] cl = new Class[2];
|
||||
cl[0] = SocketAddress.class;
|
||||
cl[1] = Integer.TYPE;
|
||||
impl.getClass().getDeclaredMethod("connect", cl);
|
||||
impl.getClass().getDeclaredMethod("connect",
|
||||
SocketAddress.class,
|
||||
int.class);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@ -435,7 +435,7 @@ public abstract class Charset
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
try {
|
||||
Class epc
|
||||
Class<?> epc
|
||||
= Class.forName("sun.nio.cs.ext.ExtendedCharsets");
|
||||
extendedProvider = (CharsetProvider)epc.newInstance();
|
||||
} catch (ClassNotFoundException x) {
|
||||
|
@ -363,6 +363,17 @@ public final class Files {
|
||||
|
||||
// -- Directories --
|
||||
|
||||
private static class AcceptAllFilter
|
||||
implements DirectoryStream.Filter<Path>
|
||||
{
|
||||
private AcceptAllFilter() { }
|
||||
|
||||
@Override
|
||||
public boolean accept(Path entry) { return true; }
|
||||
|
||||
static final AcceptAllFilter FILTER = new AcceptAllFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a directory, returning a {@link DirectoryStream} to iterate over
|
||||
* all entries in the directory. The elements returned by the directory
|
||||
@ -397,12 +408,7 @@ public final class Files {
|
||||
public static DirectoryStream<Path> newDirectoryStream(Path dir)
|
||||
throws IOException
|
||||
{
|
||||
return provider(dir).newDirectoryStream(dir, new DirectoryStream.Filter<Path>() {
|
||||
@Override
|
||||
public boolean accept(Path entry) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return provider(dir).newDirectoryStream(dir, AcceptAllFilter.FILTER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -814,7 +814,7 @@ public final class Security {
|
||||
public Void run() {
|
||||
try {
|
||||
/* Get the class via the bootstrap class loader. */
|
||||
Class cl = Class.forName(
|
||||
Class<?> cl = Class.forName(
|
||||
"java.lang.SecurityManager", false, null);
|
||||
Field f = null;
|
||||
boolean accessible = false;
|
||||
|
@ -443,7 +443,7 @@ public abstract class BreakIterator implements Cloneable
|
||||
|
||||
/**
|
||||
* Returns a new <code>BreakIterator</code> instance
|
||||
* for <a href="#word">word breaks</a>
|
||||
* for <a href="BreakIterator.html#word">word breaks</a>
|
||||
* for the {@linkplain Locale#getDefault() default locale}.
|
||||
* @return A break iterator for word breaks
|
||||
*/
|
||||
@ -454,7 +454,7 @@ public abstract class BreakIterator implements Cloneable
|
||||
|
||||
/**
|
||||
* Returns a new <code>BreakIterator</code> instance
|
||||
* for <a href="#word">word breaks</a>
|
||||
* for <a href="BreakIterator.html#word">word breaks</a>
|
||||
* for the given locale.
|
||||
* @param locale the desired locale
|
||||
* @return A break iterator for word breaks
|
||||
@ -470,7 +470,7 @@ public abstract class BreakIterator implements Cloneable
|
||||
|
||||
/**
|
||||
* Returns a new <code>BreakIterator</code> instance
|
||||
* for <a href="#line">line breaks</a>
|
||||
* for <a href="BreakIterator.html#line">line breaks</a>
|
||||
* for the {@linkplain Locale#getDefault() default locale}.
|
||||
* @return A break iterator for line breaks
|
||||
*/
|
||||
@ -481,7 +481,7 @@ public abstract class BreakIterator implements Cloneable
|
||||
|
||||
/**
|
||||
* Returns a new <code>BreakIterator</code> instance
|
||||
* for <a href="#line">line breaks</a>
|
||||
* for <a href="BreakIterator.html#line">line breaks</a>
|
||||
* for the given locale.
|
||||
* @param locale the desired locale
|
||||
* @return A break iterator for line breaks
|
||||
@ -497,7 +497,7 @@ public abstract class BreakIterator implements Cloneable
|
||||
|
||||
/**
|
||||
* Returns a new <code>BreakIterator</code> instance
|
||||
* for <a href="#character">character breaks</a>
|
||||
* for <a href="BreakIterator.html#character">character breaks</a>
|
||||
* for the {@linkplain Locale#getDefault() default locale}.
|
||||
* @return A break iterator for character breaks
|
||||
*/
|
||||
@ -508,7 +508,7 @@ public abstract class BreakIterator implements Cloneable
|
||||
|
||||
/**
|
||||
* Returns a new <code>BreakIterator</code> instance
|
||||
* for <a href="#character">character breaks</a>
|
||||
* for <a href="BreakIterator.html#character">character breaks</a>
|
||||
* for the given locale.
|
||||
* @param locale the desired locale
|
||||
* @return A break iterator for character breaks
|
||||
@ -524,7 +524,7 @@ public abstract class BreakIterator implements Cloneable
|
||||
|
||||
/**
|
||||
* Returns a new <code>BreakIterator</code> instance
|
||||
* for <a href="#sentence">sentence breaks</a>
|
||||
* for <a href="BreakIterator.html#sentence">sentence breaks</a>
|
||||
* for the {@linkplain Locale#getDefault() default locale}.
|
||||
* @return A break iterator for sentence breaks
|
||||
*/
|
||||
@ -535,7 +535,7 @@ public abstract class BreakIterator implements Cloneable
|
||||
|
||||
/**
|
||||
* Returns a new <code>BreakIterator</code> instance
|
||||
* for <a href="#sentence">sentence breaks</a>
|
||||
* for <a href="BreakIterator.html#sentence">sentence breaks</a>
|
||||
* for the given locale.
|
||||
* @param locale the desired locale
|
||||
* @return A break iterator for sentence breaks
|
||||
|
@ -2351,6 +2351,64 @@ public class Collections {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a dynamically typesafe view of the specified queue.
|
||||
* Any attempt to insert an element of the wrong type will result in
|
||||
* an immediate {@link ClassCastException}. Assuming a queue contains
|
||||
* no incorrectly typed elements prior to the time a dynamically typesafe
|
||||
* view is generated, and that all subsequent access to the queue
|
||||
* takes place through the view, it is <i>guaranteed</i> that the
|
||||
* queue cannot contain an incorrectly typed element.
|
||||
*
|
||||
* <p>A discussion of the use of dynamically typesafe views may be
|
||||
* found in the documentation for the {@link #checkedCollection
|
||||
* checkedCollection} method.
|
||||
*
|
||||
* <p>The returned queue will be serializable if the specified queue
|
||||
* is serializable.
|
||||
*
|
||||
* <p>Since {@code null} is considered to be a value of any reference
|
||||
* type, the returned queue permits insertion of {@code null} elements
|
||||
* whenever the backing queue does.
|
||||
*
|
||||
* @param queue the queue for which a dynamically typesafe view is to be
|
||||
* returned
|
||||
* @param type the type of element that {@code queue} is permitted to hold
|
||||
* @return a dynamically typesafe view of the specified queue
|
||||
* @since 1.8
|
||||
*/
|
||||
public static <E> Queue<E> checkedQueue(Queue<E> queue, Class<E> type) {
|
||||
return new CheckedQueue<>(queue, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
static class CheckedQueue<E>
|
||||
extends CheckedCollection<E>
|
||||
implements Queue<E>, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1433151992604707767L;
|
||||
final Queue<E> queue;
|
||||
|
||||
CheckedQueue(Queue<E> queue, Class<E> elementType) {
|
||||
super(queue, elementType);
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
public E element() {return queue.element();}
|
||||
public boolean equals(Object o) {return o == this || c.equals(o);}
|
||||
public int hashCode() {return c.hashCode();}
|
||||
public E peek() {return queue.peek();}
|
||||
public E poll() {return queue.poll();}
|
||||
public E remove() {return queue.remove();}
|
||||
|
||||
public boolean offer(E e) {
|
||||
typeCheck(e);
|
||||
return add(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a dynamically typesafe view of the specified set.
|
||||
* Any attempt to insert an element of the wrong type will result in
|
||||
@ -3143,6 +3201,102 @@ public class Collections {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the empty sorted set (immutable). This set is serializable.
|
||||
*
|
||||
* <p>This example illustrates the type-safe way to obtain an empty sorted
|
||||
* set:
|
||||
* <pre>
|
||||
* SortedSet<String> s = Collections.emptySortedSet();
|
||||
* </pre>
|
||||
* Implementation note: Implementations of this method need not
|
||||
* create a separate <tt>SortedSet</tt> object for each call.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <E> SortedSet<E> emptySortedSet() {
|
||||
return (SortedSet<E>) new EmptySortedSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class EmptySortedSet<E>
|
||||
extends AbstractSet<E>
|
||||
implements SortedSet<E>, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 6316515401502265487L;
|
||||
public Iterator<E> iterator() { return emptyIterator(); }
|
||||
public int size() {return 0;}
|
||||
public boolean isEmpty() {return true;}
|
||||
public boolean contains(Object obj) {return false;}
|
||||
public boolean containsAll(Collection<?> c) { return c.isEmpty(); }
|
||||
public Object[] toArray() { return new Object[0]; }
|
||||
|
||||
public <E> E[] toArray(E[] a) {
|
||||
if (a.length > 0)
|
||||
a[0] = null;
|
||||
return a;
|
||||
}
|
||||
|
||||
// Preserves singleton property
|
||||
private Object readResolve() {
|
||||
return new EmptySortedSet<>();
|
||||
}
|
||||
|
||||
public Comparator comparator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public SortedSet<E> subSet(Object fromElement, Object toElement) {
|
||||
Objects.requireNonNull(fromElement);
|
||||
Objects.requireNonNull(toElement);
|
||||
|
||||
if (!(fromElement instanceof Comparable) ||
|
||||
!(toElement instanceof Comparable))
|
||||
{
|
||||
throw new ClassCastException();
|
||||
}
|
||||
|
||||
if ((((Comparable)fromElement).compareTo(toElement) >= 0) ||
|
||||
(((Comparable)toElement).compareTo(fromElement) < 0))
|
||||
{
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
return emptySortedSet();
|
||||
}
|
||||
|
||||
public SortedSet<E> headSet(Object toElement) {
|
||||
Objects.requireNonNull(toElement);
|
||||
|
||||
if (!(toElement instanceof Comparable)) {
|
||||
throw new ClassCastException();
|
||||
}
|
||||
|
||||
return emptySortedSet();
|
||||
}
|
||||
|
||||
public SortedSet<E> tailSet(Object fromElement) {
|
||||
Objects.requireNonNull(fromElement);
|
||||
|
||||
if (!(fromElement instanceof Comparable)) {
|
||||
throw new ClassCastException();
|
||||
}
|
||||
|
||||
return emptySortedSet();
|
||||
}
|
||||
|
||||
public E first() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
public E last() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The empty list (immutable). This list is serializable.
|
||||
*
|
||||
|
@ -71,7 +71,7 @@ all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036
|
||||
#
|
||||
# The table is based on the following web sites:
|
||||
# http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/db_en.html
|
||||
# http://www.bsi-global.com/iso4217currency
|
||||
# http://www.currency-iso.org/iso_index/iso_tables.htm
|
||||
# http://www.cia.gov/cia/publications/factbook/indexgeo.html
|
||||
|
||||
# AFGHANISTAN
|
||||
@ -105,7 +105,7 @@ AU=AUD
|
||||
# AUSTRIA
|
||||
AT=EUR
|
||||
# AZERBAIJAN
|
||||
AZ=AZM;2005-12-31-20-00-00;AZN
|
||||
AZ=AZN
|
||||
# BAHAMAS
|
||||
BS=BSD
|
||||
# BAHRAIN
|
||||
@ -378,7 +378,7 @@ MS=XCD
|
||||
# MOROCCO
|
||||
MA=MAD
|
||||
# MOZAMBIQUE
|
||||
MZ=MZM;2006-06-30-22-00-00;MZN
|
||||
MZ=MZN
|
||||
# MYANMAR
|
||||
MM=MMK
|
||||
# NAMIBIA
|
||||
@ -440,7 +440,7 @@ QA=QAR
|
||||
# REUNION
|
||||
RE=EUR
|
||||
# ROMANIA
|
||||
RO=ROL;2005-06-30-21-00-00;RON
|
||||
RO=RON
|
||||
# RUSSIAN FEDERATION
|
||||
RU=RUB
|
||||
# RWANDA
|
||||
@ -532,7 +532,7 @@ TT=TTD
|
||||
# TUNISIA
|
||||
TN=TND
|
||||
# TURKEY
|
||||
TR=TRL;2004-12-31-22-00-00;TRY
|
||||
TR=TRY
|
||||
# TURKMENISTAN
|
||||
TM=TMT
|
||||
# TURKS AND CAICOS ISLANDS
|
||||
@ -558,7 +558,7 @@ UZ=UZS
|
||||
# VANUATU
|
||||
VU=VUV
|
||||
# VENEZUELA
|
||||
VE=VEB;2008-01-01-04-00-00;VEF
|
||||
VE=VEF
|
||||
# VIET NAM
|
||||
VN=VND
|
||||
# VIRGIN ISLANDS, BRITISH
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -347,6 +347,9 @@ class HttpsURLConnection extends HttpURLConnection
|
||||
* @param sf the SSL socket factory
|
||||
* @throws IllegalArgumentException if the <code>SSLSocketFactory</code>
|
||||
* parameter is null.
|
||||
* @throws SecurityException if a security manager exists and its
|
||||
* <code>checkSetFactory</code> method does not allow
|
||||
* a socket factory to be specified.
|
||||
* @see #getSSLSocketFactory()
|
||||
*/
|
||||
public void setSSLSocketFactory(SSLSocketFactory sf) {
|
||||
@ -355,6 +358,10 @@ class HttpsURLConnection extends HttpURLConnection
|
||||
"no SSLSocketFactory specified");
|
||||
}
|
||||
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkSetFactory();
|
||||
}
|
||||
sslSocketFactory = sf;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -538,7 +538,7 @@ public abstract class SSLEngine {
|
||||
* If this <code>SSLEngine</code> has not yet started its initial
|
||||
* handshake, this method will automatically start the handshake.
|
||||
* <P>
|
||||
* This method will attempt to produce one SSL/TLS packet, and will
|
||||
* This method will attempt to produce SSL/TLS records, and will
|
||||
* consume as much source data as possible, but will never consume
|
||||
* more than the sum of the bytes remaining in each buffer. Each
|
||||
* <code>ByteBuffer</code>'s position is updated to reflect the
|
||||
|
@ -1828,6 +1828,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
|
||||
* table. While the {@code autoCreateRowSorter} property remains
|
||||
* {@code true}, every time the model is changed, a new {@code
|
||||
* TableRowSorter} is created and set as the table's row sorter.
|
||||
* The default value for the {@code autoCreateRowSorter}
|
||||
* property is {@code false}.
|
||||
*
|
||||
* @param autoCreateRowSorter whether or not a {@code RowSorter}
|
||||
* should be automatically created
|
||||
|
@ -1838,7 +1838,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
||||
* nodes, or <code>null</code> if nothing is currently selected
|
||||
*/
|
||||
public TreePath[] getSelectionPaths() {
|
||||
return getSelectionModel().getSelectionPaths();
|
||||
TreePath[] selectionPaths = getSelectionModel().getSelectionPaths();
|
||||
|
||||
return (selectionPaths != null && selectionPaths.length > 0) ? selectionPaths : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1326,7 +1326,7 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou
|
||||
if ( ! SwingUtilities2.canCurrentEventAccessSystemClipboard() ) {
|
||||
return;
|
||||
}
|
||||
if (this.dot != this.mark && component != null) {
|
||||
if (this.dot != this.mark && component != null && component.hasFocus()) {
|
||||
Clipboard clip = getSystemSelection();
|
||||
if (clip != null) {
|
||||
String selectedText;
|
||||
|
@ -1181,7 +1181,12 @@ public class HTMLDocument extends DefaultStyledDocument {
|
||||
public void insertAfterStart(Element elem, String htmlText) throws
|
||||
BadLocationException, IOException {
|
||||
verifyParser();
|
||||
if (elem != null && elem.isLeaf()) {
|
||||
|
||||
if (elem == null || htmlText == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (elem.isLeaf()) {
|
||||
throw new IllegalArgumentException
|
||||
("Can not insert HTML after start of a leaf");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -185,7 +185,7 @@ public class OffScreenImageSource implements ImageProducer {
|
||||
theConsumer.setDimensions(image.getWidth(), image.getHeight());
|
||||
theConsumer.setProperties(properties);
|
||||
sendPixels();
|
||||
theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
|
||||
theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE);
|
||||
} catch (NullPointerException e) {
|
||||
if (theConsumer != null) {
|
||||
theConsumer.imageComplete(ImageConsumer.IMAGEERROR);
|
||||
|
@ -371,6 +371,12 @@ public class VM {
|
||||
private final static int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010;
|
||||
private final static int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020;
|
||||
|
||||
/*
|
||||
* Returns the first non-null class loader up the execution stack,
|
||||
* or null if only code from the null class loader is on the stack.
|
||||
*/
|
||||
public static native ClassLoader latestUserDefinedLoader();
|
||||
|
||||
static {
|
||||
initialize();
|
||||
}
|
||||
|
@ -41,13 +41,14 @@ public class ResourceManager {
|
||||
|
||||
/* default maximum number of udp sockets per VM
|
||||
* when a security manager is enabled.
|
||||
* The default is 1024 which is high enough to be useful
|
||||
* The default is 25 which is high enough to be useful
|
||||
* but low enough to be well below the maximum number
|
||||
* of port numbers actually available on all OSes for
|
||||
* such sockets (5000 on some versions of windows)
|
||||
* of port numbers actually available on all OSes
|
||||
* when multiplied by the maximum feasible number of VM processes
|
||||
* that could practically be spawned.
|
||||
*/
|
||||
|
||||
private static final int DEFAULT_MAX_SOCKETS = 1024;
|
||||
private static final int DEFAULT_MAX_SOCKETS = 25;
|
||||
private static final int maxSockets;
|
||||
private static final AtomicInteger numSockets;
|
||||
|
||||
|
@ -363,10 +363,10 @@ class Util {
|
||||
try {
|
||||
Class<?> cl = Class.forName("java.nio.DirectByteBuffer");
|
||||
Constructor<?> ctor = cl.getDeclaredConstructor(
|
||||
new Class[] { int.class,
|
||||
long.class,
|
||||
FileDescriptor.class,
|
||||
Runnable.class });
|
||||
new Class<?>[] { int.class,
|
||||
long.class,
|
||||
FileDescriptor.class,
|
||||
Runnable.class });
|
||||
ctor.setAccessible(true);
|
||||
directByteBufferConstructor = ctor;
|
||||
} catch (ClassNotFoundException |
|
||||
@ -408,10 +408,10 @@ class Util {
|
||||
try {
|
||||
Class<?> cl = Class.forName("java.nio.DirectByteBufferR");
|
||||
Constructor<?> ctor = cl.getDeclaredConstructor(
|
||||
new Class[] { int.class,
|
||||
long.class,
|
||||
FileDescriptor.class,
|
||||
Runnable.class });
|
||||
new Class<?>[] { int.class,
|
||||
long.class,
|
||||
FileDescriptor.class,
|
||||
Runnable.class });
|
||||
ctor.setAccessible(true);
|
||||
directByteBufferRConstructor = ctor;
|
||||
} catch (ClassNotFoundException |
|
||||
|
604
jdk/src/share/classes/sun/nio/cs/CESU_8.java
Normal file
604
jdk/src/share/classes/sun/nio/cs/CESU_8.java
Normal file
@ -0,0 +1,604 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CodingErrorAction;
|
||||
|
||||
/* Legal CESU-8 Byte Sequences
|
||||
*
|
||||
* # Code Points Bits Bit/Byte pattern
|
||||
* 1 7 0xxxxxxx
|
||||
* U+0000..U+007F 00..7F
|
||||
*
|
||||
* 2 11 110xxxxx 10xxxxxx
|
||||
* U+0080..U+07FF C2..DF 80..BF
|
||||
*
|
||||
* 3 16 1110xxxx 10xxxxxx 10xxxxxx
|
||||
* U+0800..U+0FFF E0 A0..BF 80..BF
|
||||
* U+1000..U+FFFF E1..EF 80..BF 80..BF
|
||||
*
|
||||
*/
|
||||
|
||||
class CESU_8 extends Unicode
|
||||
{
|
||||
public CESU_8() {
|
||||
super("CESU-8", StandardCharsets.aliases_CESU_8);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "CESU8";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static final void updatePositions(Buffer src, int sp,
|
||||
Buffer dst, int dp) {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
|
||||
private static class Decoder extends CharsetDecoder
|
||||
implements ArrayDecoder {
|
||||
private Decoder(Charset cs) {
|
||||
super(cs, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
private static boolean isNotContinuation(int b) {
|
||||
return (b & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// [E0] [A0..BF] [80..BF]
|
||||
// [E1..EF] [80..BF] [80..BF]
|
||||
private static boolean isMalformed3(int b1, int b2, int b3) {
|
||||
return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
(b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// only used when there is only one byte left in src buffer
|
||||
private static boolean isMalformed3_2(int b1, int b2) {
|
||||
return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
(b2 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
|
||||
// [F0] [90..BF] [80..BF] [80..BF]
|
||||
// [F1..F3] [80..BF] [80..BF] [80..BF]
|
||||
// [F4] [80..8F] [80..BF] [80..BF]
|
||||
// only check 80-be range here, the [0xf0,0x80...] and [0xf4,0x90-...]
|
||||
// will be checked by Character.isSupplementaryCodePoint(uc)
|
||||
private static boolean isMalformed4(int b2, int b3, int b4) {
|
||||
return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 ||
|
||||
(b4 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// only used when there is less than 4 bytes left in src buffer
|
||||
private static boolean isMalformed4_2(int b1, int b2) {
|
||||
return (b1 == 0xf0 && b2 == 0x90) ||
|
||||
(b2 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
private static boolean isMalformed4_3(int b3) {
|
||||
return (b3 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
private static CoderResult malformedN(ByteBuffer src, int nb) {
|
||||
switch (nb) {
|
||||
case 1:
|
||||
case 2: // always 1
|
||||
return CoderResult.malformedForLength(1);
|
||||
case 3:
|
||||
int b1 = src.get();
|
||||
int b2 = src.get(); // no need to lookup b3
|
||||
return CoderResult.malformedForLength(
|
||||
((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
isNotContinuation(b2)) ? 1 : 2);
|
||||
case 4: // we don't care the speed here
|
||||
b1 = src.get() & 0xff;
|
||||
b2 = src.get() & 0xff;
|
||||
if (b1 > 0xf4 ||
|
||||
(b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) ||
|
||||
(b1 == 0xf4 && (b2 & 0xf0) != 0x80) ||
|
||||
isNotContinuation(b2))
|
||||
return CoderResult.malformedForLength(1);
|
||||
if (isNotContinuation(src.get()))
|
||||
return CoderResult.malformedForLength(2);
|
||||
return CoderResult.malformedForLength(3);
|
||||
default:
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static CoderResult malformed(ByteBuffer src, int sp,
|
||||
CharBuffer dst, int dp,
|
||||
int nb)
|
||||
{
|
||||
src.position(sp - src.arrayOffset());
|
||||
CoderResult cr = malformedN(src, nb);
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return cr;
|
||||
}
|
||||
|
||||
|
||||
private static CoderResult malformed(ByteBuffer src,
|
||||
int mark, int nb)
|
||||
{
|
||||
src.position(mark);
|
||||
CoderResult cr = malformedN(src, nb);
|
||||
src.position(mark);
|
||||
return cr;
|
||||
}
|
||||
|
||||
private static CoderResult malformedForLength(ByteBuffer src,
|
||||
int sp,
|
||||
CharBuffer dst,
|
||||
int dp,
|
||||
int malformedNB)
|
||||
{
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return CoderResult.malformedForLength(malformedNB);
|
||||
}
|
||||
|
||||
private static CoderResult malformedForLength(ByteBuffer src,
|
||||
int mark,
|
||||
int malformedNB)
|
||||
{
|
||||
src.position(mark);
|
||||
return CoderResult.malformedForLength(malformedNB);
|
||||
}
|
||||
|
||||
|
||||
private static CoderResult xflow(Buffer src, int sp, int sl,
|
||||
Buffer dst, int dp, int nb) {
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return (nb == 0 || sl - sp < nb)
|
||||
? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private static CoderResult xflow(Buffer src, int mark, int nb) {
|
||||
src.position(mark);
|
||||
return (nb == 0 || src.remaining() < nb)
|
||||
? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private CoderResult decodeArrayLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
// This method is optimized for ASCII input.
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
int dlASCII = dp + Math.min(sl - sp, dl - dp);
|
||||
|
||||
// ASCII only loop
|
||||
while (dp < dlASCII && sa[sp] >= 0)
|
||||
da[dp++] = (char) sa[sp++];
|
||||
while (sp < sl) {
|
||||
int b1 = sa[sp];
|
||||
if (b1 >= 0) {
|
||||
// 1 byte, 7 bits: 0xxxxxxx
|
||||
if (dp >= dl)
|
||||
return xflow(src, sp, sl, dst, dp, 1);
|
||||
da[dp++] = (char) b1;
|
||||
sp++;
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
if (sl - sp < 2 || dp >= dl)
|
||||
return xflow(src, sp, sl, dst, dp, 2);
|
||||
int b2 = sa[sp + 1];
|
||||
if (isNotContinuation(b2))
|
||||
return malformedForLength(src, sp, dst, dp, 1);
|
||||
da[dp++] = (char) (((b1 << 6) ^ b2)
|
||||
^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
((byte) 0x80 << 0)));
|
||||
sp += 2;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
int srcRemaining = sl - sp;
|
||||
if (srcRemaining < 3 || dp >= dl) {
|
||||
if (srcRemaining > 1 && isMalformed3_2(b1, sa[sp + 1]))
|
||||
return malformedForLength(src, sp, dst, dp, 1);
|
||||
return xflow(src, sp, sl, dst, dp, 3);
|
||||
}
|
||||
int b2 = sa[sp + 1];
|
||||
int b3 = sa[sp + 2];
|
||||
if (isMalformed3(b1, b2, b3))
|
||||
return malformed(src, sp, dst, dp, 3);
|
||||
da[dp++] = (char)
|
||||
((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
sp += 3;
|
||||
} else {
|
||||
return malformed(src, sp, dst, dp, 1);
|
||||
}
|
||||
}
|
||||
return xflow(src, sp, sl, dst, dp, 0);
|
||||
}
|
||||
|
||||
private CoderResult decodeBufferLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
int limit = src.limit();
|
||||
while (mark < limit) {
|
||||
int b1 = src.get();
|
||||
if (b1 >= 0) {
|
||||
// 1 byte, 7 bits: 0xxxxxxx
|
||||
if (dst.remaining() < 1)
|
||||
return xflow(src, mark, 1); // overflow
|
||||
dst.put((char) b1);
|
||||
mark++;
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
if (limit - mark < 2|| dst.remaining() < 1)
|
||||
return xflow(src, mark, 2);
|
||||
int b2 = src.get();
|
||||
if (isNotContinuation(b2))
|
||||
return malformedForLength(src, mark, 1);
|
||||
dst.put((char) (((b1 << 6) ^ b2)
|
||||
^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
mark += 2;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
int srcRemaining = limit - mark;
|
||||
if (srcRemaining < 3 || dst.remaining() < 1) {
|
||||
if (srcRemaining > 1 && isMalformed3_2(b1, src.get()))
|
||||
return malformedForLength(src, mark, 1);
|
||||
return xflow(src, mark, 3);
|
||||
}
|
||||
int b2 = src.get();
|
||||
int b3 = src.get();
|
||||
if (isMalformed3(b1, b2, b3))
|
||||
return malformed(src, mark, 3);
|
||||
dst.put((char)
|
||||
((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0)))));
|
||||
mark += 3;
|
||||
} else {
|
||||
return malformed(src, mark, 1);
|
||||
}
|
||||
}
|
||||
return xflow(src, mark, 0);
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return decodeArrayLoop(src, dst);
|
||||
else
|
||||
return decodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
private static ByteBuffer getByteBuffer(ByteBuffer bb, byte[] ba, int sp)
|
||||
{
|
||||
if (bb == null)
|
||||
bb = ByteBuffer.wrap(ba);
|
||||
bb.position(sp);
|
||||
return bb;
|
||||
}
|
||||
|
||||
// returns -1 if there is/are malformed byte(s) and the
|
||||
// "action" for malformed input is not REPLACE.
|
||||
public int decode(byte[] sa, int sp, int len, char[] da) {
|
||||
final int sl = sp + len;
|
||||
int dp = 0;
|
||||
int dlASCII = Math.min(len, da.length);
|
||||
ByteBuffer bb = null; // only necessary if malformed
|
||||
|
||||
// ASCII only optimized loop
|
||||
while (dp < dlASCII && sa[sp] >= 0)
|
||||
da[dp++] = (char) sa[sp++];
|
||||
|
||||
while (sp < sl) {
|
||||
int b1 = sa[sp++];
|
||||
if (b1 >= 0) {
|
||||
// 1 byte, 7 bits: 0xxxxxxx
|
||||
da[dp++] = (char) b1;
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
if (sp < sl) {
|
||||
int b2 = sa[sp++];
|
||||
if (isNotContinuation(b2)) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
sp--; // malformedN(bb, 2) always returns 1
|
||||
} else {
|
||||
da[dp++] = (char) (((b1 << 6) ^ b2)^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
((byte) 0x80 << 0)));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
return dp;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
if (sp + 1 < sl) {
|
||||
int b2 = sa[sp++];
|
||||
int b3 = sa[sp++];
|
||||
if (isMalformed3(b1, b2, b3)) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
sp -=3;
|
||||
bb = getByteBuffer(bb, sa, sp);
|
||||
sp += malformedN(bb, 3).length();
|
||||
} else {
|
||||
da[dp++] = (char)((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
if (sp < sl && isMalformed3_2(b1, sa[sp])) {
|
||||
da[dp++] = replacement().charAt(0);
|
||||
continue;
|
||||
|
||||
}
|
||||
da[dp++] = replacement().charAt(0);
|
||||
return dp;
|
||||
} else {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
}
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends CharsetEncoder
|
||||
implements ArrayEncoder {
|
||||
|
||||
private Encoder(Charset cs) {
|
||||
super(cs, 1.1f, 3.0f);
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return !Character.isSurrogate(c);
|
||||
}
|
||||
|
||||
public boolean isLegalReplacement(byte[] repl) {
|
||||
return ((repl.length == 1 && repl[0] >= 0) ||
|
||||
super.isLegalReplacement(repl));
|
||||
}
|
||||
|
||||
private static CoderResult overflow(CharBuffer src, int sp,
|
||||
ByteBuffer dst, int dp) {
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private static CoderResult overflow(CharBuffer src, int mark) {
|
||||
src.position(mark);
|
||||
return CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private static void to3Bytes(byte[] da, int dp, char c) {
|
||||
da[dp] = (byte)(0xe0 | ((c >> 12)));
|
||||
da[dp + 1] = (byte)(0x80 | ((c >> 6) & 0x3f));
|
||||
da[dp + 2] = (byte)(0x80 | (c & 0x3f));
|
||||
}
|
||||
|
||||
private static void to3Bytes(ByteBuffer dst, char c) {
|
||||
dst.put((byte)(0xe0 | ((c >> 12))));
|
||||
dst.put((byte)(0x80 | ((c >> 6) & 0x3f)));
|
||||
dst.put((byte)(0x80 | (c & 0x3f)));
|
||||
}
|
||||
|
||||
private Surrogate.Parser sgp;
|
||||
private char[] c2;
|
||||
private CoderResult encodeArrayLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
int dlASCII = dp + Math.min(sl - sp, dl - dp);
|
||||
|
||||
// ASCII only loop
|
||||
while (dp < dlASCII && sa[sp] < '\u0080')
|
||||
da[dp++] = (byte) sa[sp++];
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
if (c < 0x80) {
|
||||
// Have at most seven bits
|
||||
if (dp >= dl)
|
||||
return overflow(src, sp, dst, dp);
|
||||
da[dp++] = (byte)c;
|
||||
} else if (c < 0x800) {
|
||||
// 2 bytes, 11 bits
|
||||
if (dl - dp < 2)
|
||||
return overflow(src, sp, dst, dp);
|
||||
da[dp++] = (byte)(0xc0 | (c >> 6));
|
||||
da[dp++] = (byte)(0x80 | (c & 0x3f));
|
||||
} else if (Character.isSurrogate(c)) {
|
||||
// Have a surrogate pair
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
int uc = sgp.parse(c, sa, sp, sl);
|
||||
if (uc < 0) {
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return sgp.error();
|
||||
}
|
||||
if (dl - dp < 6)
|
||||
return overflow(src, sp, dst, dp);
|
||||
to3Bytes(da, dp, Character.highSurrogate(uc));
|
||||
dp += 3;
|
||||
to3Bytes(da, dp, Character.lowSurrogate(uc));
|
||||
dp += 3;
|
||||
sp++; // 2 chars
|
||||
} else {
|
||||
// 3 bytes, 16 bits
|
||||
if (dl - dp < 3)
|
||||
return overflow(src, sp, dst, dp);
|
||||
to3Bytes(da, dp, c);
|
||||
dp += 3;
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
private CoderResult encodeBufferLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
if (c < 0x80) {
|
||||
// Have at most seven bits
|
||||
if (!dst.hasRemaining())
|
||||
return overflow(src, mark);
|
||||
dst.put((byte)c);
|
||||
} else if (c < 0x800) {
|
||||
// 2 bytes, 11 bits
|
||||
if (dst.remaining() < 2)
|
||||
return overflow(src, mark);
|
||||
dst.put((byte)(0xc0 | (c >> 6)));
|
||||
dst.put((byte)(0x80 | (c & 0x3f)));
|
||||
} else if (Character.isSurrogate(c)) {
|
||||
// Have a surrogate pair
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
int uc = sgp.parse(c, src);
|
||||
if (uc < 0) {
|
||||
src.position(mark);
|
||||
return sgp.error();
|
||||
}
|
||||
if (dst.remaining() < 6)
|
||||
return overflow(src, mark);
|
||||
to3Bytes(dst, Character.highSurrogate(uc));
|
||||
to3Bytes(dst, Character.lowSurrogate(uc));
|
||||
mark++; // 2 chars
|
||||
} else {
|
||||
// 3 bytes, 16 bits
|
||||
if (dst.remaining() < 3)
|
||||
return overflow(src, mark);
|
||||
to3Bytes(dst, c);
|
||||
}
|
||||
mark++;
|
||||
}
|
||||
src.position(mark);
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
protected final CoderResult encodeLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
// returns -1 if there is malformed char(s) and the
|
||||
// "action" for malformed input is not REPLACE.
|
||||
public int encode(char[] sa, int sp, int len, byte[] da) {
|
||||
int sl = sp + len;
|
||||
int dp = 0;
|
||||
int dlASCII = dp + Math.min(len, da.length);
|
||||
|
||||
// ASCII only optimized loop
|
||||
while (dp < dlASCII && sa[sp] < '\u0080')
|
||||
da[dp++] = (byte) sa[sp++];
|
||||
|
||||
while (sp < sl) {
|
||||
char c = sa[sp++];
|
||||
if (c < 0x80) {
|
||||
// Have at most seven bits
|
||||
da[dp++] = (byte)c;
|
||||
} else if (c < 0x800) {
|
||||
// 2 bytes, 11 bits
|
||||
da[dp++] = (byte)(0xc0 | (c >> 6));
|
||||
da[dp++] = (byte)(0x80 | (c & 0x3f));
|
||||
} else if (Character.isSurrogate(c)) {
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
int uc = sgp.parse(c, sa, sp - 1, sl);
|
||||
if (uc < 0) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement()[0];
|
||||
} else {
|
||||
to3Bytes(da, dp, Character.highSurrogate(uc));
|
||||
dp += 3;
|
||||
to3Bytes(da, dp, Character.lowSurrogate(uc));
|
||||
dp += 3;
|
||||
sp++; // 2 chars
|
||||
}
|
||||
} else {
|
||||
// 3 bytes, 16 bits
|
||||
to3Bytes(da, dp, c);
|
||||
dp += 3;
|
||||
}
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
}
|
@ -72,8 +72,8 @@ class UTF_8 extends Unicode
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
static final void updatePositions(Buffer src, int sp,
|
||||
Buffer dst, int dp) {
|
||||
private static final void updatePositions(Buffer src, int sp,
|
||||
Buffer dst, int dp) {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
@ -88,11 +88,6 @@ class UTF_8 extends Unicode
|
||||
return (b & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// [C2..DF] [80..BF]
|
||||
private static boolean isMalformed2(int b1, int b2) {
|
||||
return (b1 & 0x1e) == 0x0 || (b2 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// [E0] [A0..BF] [80..BF]
|
||||
// [E1..EF] [80..BF] [80..BF]
|
||||
private static boolean isMalformed3(int b1, int b2, int b3) {
|
||||
@ -100,6 +95,12 @@ class UTF_8 extends Unicode
|
||||
(b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// only used when there is only one byte left in src buffer
|
||||
private static boolean isMalformed3_2(int b1, int b2) {
|
||||
return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
(b2 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// [F0] [90..BF] [80..BF] [80..BF]
|
||||
// [F1..F3] [80..BF] [80..BF] [80..BF]
|
||||
// [F4] [80..8F] [80..BF] [80..BF]
|
||||
@ -110,6 +111,16 @@ class UTF_8 extends Unicode
|
||||
(b4 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// only used when there is less than 4 bytes left in src buffer
|
||||
private static boolean isMalformed4_2(int b1, int b2) {
|
||||
return (b1 == 0xf0 && b2 == 0x90) ||
|
||||
(b2 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
private static boolean isMalformed4_3(int b3) {
|
||||
return (b3 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
private static CoderResult lookupN(ByteBuffer src, int n)
|
||||
{
|
||||
for (int i = 1; i < n; i++) {
|
||||
@ -122,28 +133,14 @@ class UTF_8 extends Unicode
|
||||
private static CoderResult malformedN(ByteBuffer src, int nb) {
|
||||
switch (nb) {
|
||||
case 1:
|
||||
int b1 = src.get();
|
||||
if ((b1 >> 2) == -2) {
|
||||
// 5 bytes 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
if (src.remaining() < 4)
|
||||
return CoderResult.UNDERFLOW;
|
||||
return lookupN(src, 5);
|
||||
}
|
||||
if ((b1 >> 1) == -2) {
|
||||
// 6 bytes 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
if (src.remaining() < 5)
|
||||
return CoderResult.UNDERFLOW;
|
||||
return lookupN(src, 6);
|
||||
}
|
||||
return CoderResult.malformedForLength(1);
|
||||
case 2: // always 1
|
||||
return CoderResult.malformedForLength(1);
|
||||
case 3:
|
||||
b1 = src.get();
|
||||
int b1 = src.get();
|
||||
int b2 = src.get(); // no need to lookup b3
|
||||
return CoderResult.malformedForLength(
|
||||
((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
isNotContinuation(b2))?1:2);
|
||||
isNotContinuation(b2)) ? 1 : 2);
|
||||
case 4: // we don't care the speed here
|
||||
b1 = src.get() & 0xff;
|
||||
b2 = src.get() & 0xff;
|
||||
@ -171,6 +168,7 @@ class UTF_8 extends Unicode
|
||||
return cr;
|
||||
}
|
||||
|
||||
|
||||
private static CoderResult malformed(ByteBuffer src,
|
||||
int mark, int nb)
|
||||
{
|
||||
@ -180,18 +178,36 @@ class UTF_8 extends Unicode
|
||||
return cr;
|
||||
}
|
||||
|
||||
private static CoderResult malformedForLength(ByteBuffer src,
|
||||
int sp,
|
||||
CharBuffer dst,
|
||||
int dp,
|
||||
int malformedNB)
|
||||
{
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return CoderResult.malformedForLength(malformedNB);
|
||||
}
|
||||
|
||||
private static CoderResult malformedForLength(ByteBuffer src,
|
||||
int mark,
|
||||
int malformedNB)
|
||||
{
|
||||
src.position(mark);
|
||||
return CoderResult.malformedForLength(malformedNB);
|
||||
}
|
||||
|
||||
|
||||
private static CoderResult xflow(Buffer src, int sp, int sl,
|
||||
Buffer dst, int dp, int nb) {
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return (nb == 0 || sl - sp < nb)
|
||||
?CoderResult.UNDERFLOW:CoderResult.OVERFLOW;
|
||||
? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private static CoderResult xflow(Buffer src, int mark, int nb) {
|
||||
CoderResult cr = (nb == 0 || src.remaining() < (nb - 1))
|
||||
?CoderResult.UNDERFLOW:CoderResult.OVERFLOW;
|
||||
src.position(mark);
|
||||
return cr;
|
||||
return (nb == 0 || src.remaining() < nb)
|
||||
? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private CoderResult decodeArrayLoop(ByteBuffer src,
|
||||
@ -210,7 +226,6 @@ class UTF_8 extends Unicode
|
||||
// ASCII only loop
|
||||
while (dp < dlASCII && sa[sp] >= 0)
|
||||
da[dp++] = (char) sa[sp++];
|
||||
|
||||
while (sp < sl) {
|
||||
int b1 = sa[sp];
|
||||
if (b1 >= 0) {
|
||||
@ -219,13 +234,20 @@ class UTF_8 extends Unicode
|
||||
return xflow(src, sp, sl, dst, dp, 1);
|
||||
da[dp++] = (char) b1;
|
||||
sp++;
|
||||
} else if ((b1 >> 5) == -2) {
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
// [C2..DF] [80..BF]
|
||||
if (sl - sp < 2 || dp >= dl)
|
||||
return xflow(src, sp, sl, dst, dp, 2);
|
||||
int b2 = sa[sp + 1];
|
||||
if (isMalformed2(b1, b2))
|
||||
return malformed(src, sp, dst, dp, 2);
|
||||
// Now we check the first byte of 2-byte sequence as
|
||||
// if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0)
|
||||
// no longer need to check b1 against c1 & c0 for
|
||||
// malformed as we did in previous version
|
||||
// (b1 & 0x1e) == 0x0 || (b2 & 0xc0) != 0x80;
|
||||
// only need to check the second byte b2.
|
||||
if (isNotContinuation(b2))
|
||||
return malformedForLength(src, sp, dst, dp, 1);
|
||||
da[dp++] = (char) (((b1 << 6) ^ b2)
|
||||
^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
@ -233,24 +255,37 @@ class UTF_8 extends Unicode
|
||||
sp += 2;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
if (sl - sp < 3 || dp >= dl)
|
||||
int srcRemaining = sl - sp;
|
||||
if (srcRemaining < 3 || dp >= dl) {
|
||||
if (srcRemaining > 1 && isMalformed3_2(b1, sa[sp + 1]))
|
||||
return malformedForLength(src, sp, dst, dp, 1);
|
||||
return xflow(src, sp, sl, dst, dp, 3);
|
||||
}
|
||||
int b2 = sa[sp + 1];
|
||||
int b3 = sa[sp + 2];
|
||||
if (isMalformed3(b1, b2, b3))
|
||||
return malformed(src, sp, dst, dp, 3);
|
||||
da[dp++] = (char)
|
||||
char c = (char)
|
||||
((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
if (Character.isSurrogate(c))
|
||||
return malformedForLength(src, sp, dst, dp, 3);
|
||||
da[dp++] = c;
|
||||
sp += 3;
|
||||
} else if ((b1 >> 3) == -2) {
|
||||
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
if (sl - sp < 4 || dl - dp < 2)
|
||||
int srcRemaining = sl - sp;
|
||||
if (srcRemaining < 4 || dl - dp < 2) {
|
||||
if (srcRemaining > 1 && isMalformed4_2(b1, sa[sp + 1]))
|
||||
return malformedForLength(src, sp, dst, dp, 1);
|
||||
if (srcRemaining > 2 && isMalformed4_3(sa[sp + 2]))
|
||||
return malformedForLength(src, sp, dst, dp, 2);
|
||||
return xflow(src, sp, sl, dst, dp, 4);
|
||||
}
|
||||
int b2 = sa[sp + 1];
|
||||
int b3 = sa[sp + 2];
|
||||
int b4 = sa[sp + 3];
|
||||
@ -289,38 +324,51 @@ class UTF_8 extends Unicode
|
||||
return xflow(src, mark, 1); // overflow
|
||||
dst.put((char) b1);
|
||||
mark++;
|
||||
} else if ((b1 >> 5) == -2) {
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
if (limit - mark < 2|| dst.remaining() < 1)
|
||||
return xflow(src, mark, 2);
|
||||
int b2 = src.get();
|
||||
if (isMalformed2(b1, b2))
|
||||
return malformed(src, mark, 2);
|
||||
dst.put((char) (((b1 << 6) ^ b2)
|
||||
if (isNotContinuation(b2))
|
||||
return malformedForLength(src, mark, 1);
|
||||
dst.put((char) (((b1 << 6) ^ b2)
|
||||
^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
mark += 2;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
if (limit - mark < 3 || dst.remaining() < 1)
|
||||
int srcRemaining = limit - mark;
|
||||
if (srcRemaining < 3 || dst.remaining() < 1) {
|
||||
if (srcRemaining > 1 && isMalformed3_2(b1, src.get()))
|
||||
return malformedForLength(src, mark, 1);
|
||||
return xflow(src, mark, 3);
|
||||
}
|
||||
int b2 = src.get();
|
||||
int b3 = src.get();
|
||||
if (isMalformed3(b1, b2, b3))
|
||||
return malformed(src, mark, 3);
|
||||
dst.put((char)
|
||||
((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0)))));
|
||||
char c = (char)
|
||||
((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
if (Character.isSurrogate(c))
|
||||
return malformedForLength(src, mark, 3);
|
||||
dst.put(c);
|
||||
mark += 3;
|
||||
} else if ((b1 >> 3) == -2) {
|
||||
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
if (limit - mark < 4 || dst.remaining() < 2)
|
||||
int srcRemaining = limit - mark;
|
||||
if (srcRemaining < 4 || dst.remaining() < 2) {
|
||||
if (srcRemaining > 1 && isMalformed4_2(b1, src.get()))
|
||||
return malformedForLength(src, mark, 1);
|
||||
if (srcRemaining > 2 && isMalformed4_3(src.get()))
|
||||
return malformedForLength(src, mark, 2);
|
||||
return xflow(src, mark, 4);
|
||||
}
|
||||
int b2 = src.get();
|
||||
int b3 = src.get();
|
||||
int b4 = src.get();
|
||||
@ -364,7 +412,7 @@ class UTF_8 extends Unicode
|
||||
return bb;
|
||||
}
|
||||
|
||||
// returns -1 if there is malformed byte(s) and the
|
||||
// returns -1 if there is/are malformed byte(s) and the
|
||||
// "action" for malformed input is not REPLACE.
|
||||
public int decode(byte[] sa, int sp, int len, char[] da) {
|
||||
final int sl = sp + len;
|
||||
@ -381,11 +429,11 @@ class UTF_8 extends Unicode
|
||||
if (b1 >= 0) {
|
||||
// 1 byte, 7 bits: 0xxxxxxx
|
||||
da[dp++] = (char) b1;
|
||||
} else if ((b1 >> 5) == -2) {
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
if (sp < sl) {
|
||||
int b2 = sa[sp++];
|
||||
if (isMalformed2(b1, b2)) {
|
||||
if (isNotContinuation(b2)) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
@ -410,21 +458,33 @@ class UTF_8 extends Unicode
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
sp -=3;
|
||||
sp -= 3;
|
||||
bb = getByteBuffer(bb, sa, sp);
|
||||
sp += malformedN(bb, 3).length();
|
||||
} else {
|
||||
da[dp++] = (char)((b1 << 12) ^
|
||||
char c = (char)((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
} else {
|
||||
da[dp++] = c;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
if (sp < sl && isMalformed3_2(b1, sa[sp])) {
|
||||
da[dp++] = replacement().charAt(0);
|
||||
continue;
|
||||
|
||||
}
|
||||
da[dp++] = replacement().charAt(0);
|
||||
return dp;
|
||||
} else if ((b1 >> 3) == -2) {
|
||||
@ -458,28 +518,29 @@ class UTF_8 extends Unicode
|
||||
}
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
|
||||
if (sp < sl && isMalformed4_2(b1, sa[sp])) {
|
||||
da[dp++] = replacement().charAt(0);
|
||||
continue;
|
||||
}
|
||||
sp++;
|
||||
if (sp < sl && isMalformed4_3(sa[sp])) {
|
||||
da[dp++] = replacement().charAt(0);
|
||||
continue;
|
||||
}
|
||||
da[dp++] = replacement().charAt(0);
|
||||
return dp;
|
||||
} else {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
sp--;
|
||||
bb = getByteBuffer(bb, sa, sp);
|
||||
CoderResult cr = malformedN(bb, 1);
|
||||
if (!cr.isError()) {
|
||||
// leading byte for 5 or 6-byte, but don't have enough
|
||||
// bytes in buffer to check. Consumed rest as malformed.
|
||||
return dp;
|
||||
}
|
||||
sp += cr.length();
|
||||
}
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends CharsetEncoder
|
||||
private static final class Encoder extends CharsetEncoder
|
||||
implements ArrayEncoder {
|
||||
|
||||
private Encoder(Charset cs) {
|
||||
|
@ -63,6 +63,10 @@ charset UTF-8 UTF_8
|
||||
alias UTF8 # JDK historical
|
||||
alias unicode-1-1-utf-8
|
||||
|
||||
charset CESU-8 CESU_8
|
||||
alias CESU8
|
||||
alias csCESU-8
|
||||
|
||||
charset UTF-16 UTF_16
|
||||
alias UTF_16 # JDK historical
|
||||
alias utf16
|
||||
|
@ -68,14 +68,18 @@ import javax.print.attribute.standard.Sides;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.CharConversionException;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
@ -673,15 +677,38 @@ public class PSPrinterJob extends RasterPrinterJob {
|
||||
private class PrinterSpooler implements java.security.PrivilegedAction {
|
||||
PrinterException pex;
|
||||
|
||||
private void handleProcessFailure(final Process failedProcess,
|
||||
final String[] execCmd, final int result) throws IOException {
|
||||
try (StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw)) {
|
||||
pw.append("error=").append(Integer.toString(result));
|
||||
pw.append(" running:");
|
||||
for (String arg: execCmd) {
|
||||
pw.append(" '").append(arg).append("'");
|
||||
}
|
||||
try (InputStream is = failedProcess.getErrorStream();
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader br = new BufferedReader(isr)) {
|
||||
while (br.ready()) {
|
||||
pw.println();
|
||||
pw.append("\t\t").append(br.readLine());
|
||||
}
|
||||
} finally {
|
||||
pw.flush();
|
||||
throw new IOException(sw.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Object run() {
|
||||
if (spoolFile == null || !spoolFile.exists()) {
|
||||
pex = new PrinterException("No spool file");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
/**
|
||||
* Spool to the printer.
|
||||
*/
|
||||
if (spoolFile == null || !spoolFile.exists()) {
|
||||
pex = new PrinterException("No spool file");
|
||||
return null;
|
||||
}
|
||||
String fileName = spoolFile.getAbsolutePath();
|
||||
String execCmd[] = printExecCmd(mDestination, mOptions,
|
||||
mNoJobSheet, getJobNameInt(),
|
||||
@ -689,12 +716,16 @@ public class PSPrinterJob extends RasterPrinterJob {
|
||||
|
||||
Process process = Runtime.getRuntime().exec(execCmd);
|
||||
process.waitFor();
|
||||
spoolFile.delete();
|
||||
|
||||
final int result = process.exitValue();
|
||||
if (0 != result) {
|
||||
handleProcessFailure(process, execCmd, result);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
pex = new PrinterIOException(ex);
|
||||
} catch (InterruptedException ie) {
|
||||
pex = new PrinterException(ie.toString());
|
||||
} finally {
|
||||
spoolFile.delete();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -38,13 +38,23 @@ import java.rmi.server.ServerNotActiveException;
|
||||
import java.rmi.registry.Registry;
|
||||
import java.rmi.server.RMIClientSocketFactory;
|
||||
import java.rmi.server.RMIServerSocketFactory;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.AccessController;
|
||||
import java.security.CodeSource;
|
||||
import java.security.Policy;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.PermissionCollection;
|
||||
import java.security.Permissions;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.text.MessageFormat;
|
||||
import sun.rmi.server.LoaderHandler;
|
||||
import sun.rmi.server.UnicastServerRef;
|
||||
import sun.rmi.server.UnicastServerRef2;
|
||||
import sun.rmi.transport.LiveRef;
|
||||
import sun.rmi.transport.ObjectTable;
|
||||
import sun.rmi.transport.Target;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
/**
|
||||
* A "registry" exists on every node that allows RMI connections to
|
||||
@ -325,6 +335,19 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
|
||||
URL[] urls = sun.misc.URLClassPath.pathToURLs(envcp);
|
||||
ClassLoader cl = new URLClassLoader(urls);
|
||||
|
||||
String codebaseProperty = null;
|
||||
String prop = java.security.AccessController.doPrivileged(
|
||||
new GetPropertyAction("java.rmi.server.codebase"));
|
||||
if (prop != null && prop.trim().length() > 0) {
|
||||
codebaseProperty = prop;
|
||||
}
|
||||
URL[] codebaseURLs = null;
|
||||
if (codebaseProperty != null) {
|
||||
codebaseURLs = sun.misc.URLClassPath.pathToURLs(codebaseProperty);
|
||||
} else {
|
||||
codebaseURLs = new URL[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* Fix bugid 4242317: Classes defined by this class loader should
|
||||
* be annotated with the value of the "java.rmi.server.codebase"
|
||||
@ -334,11 +357,19 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
|
||||
|
||||
Thread.currentThread().setContextClassLoader(cl);
|
||||
|
||||
int regPort = Registry.REGISTRY_PORT;
|
||||
if (args.length >= 1) {
|
||||
regPort = Integer.parseInt(args[0]);
|
||||
final int regPort = (args.length >= 1) ? Integer.parseInt(args[0])
|
||||
: Registry.REGISTRY_PORT;
|
||||
try {
|
||||
registry = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<RegistryImpl>() {
|
||||
public RegistryImpl run() throws RemoteException {
|
||||
return new RegistryImpl(regPort);
|
||||
}
|
||||
}, getAccessControlContext(codebaseURLs));
|
||||
} catch (PrivilegedActionException ex) {
|
||||
throw (RemoteException) ex.getException();
|
||||
}
|
||||
registry = new RegistryImpl(regPort);
|
||||
|
||||
// prevent registry from exiting
|
||||
while (true) {
|
||||
try {
|
||||
@ -358,4 +389,48 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
|
||||
}
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an AccessControlContext from several URLs.
|
||||
* The approach used here is taken from the similar method
|
||||
* getAccessControlContext() in the sun.applet.AppletPanel class.
|
||||
*/
|
||||
private static AccessControlContext getAccessControlContext(URL[] urls) {
|
||||
// begin with permissions granted to all code in current policy
|
||||
PermissionCollection perms = AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<PermissionCollection>() {
|
||||
public PermissionCollection run() {
|
||||
CodeSource codesource = new CodeSource(null,
|
||||
(java.security.cert.Certificate[]) null);
|
||||
Policy p = java.security.Policy.getPolicy();
|
||||
if (p != null) {
|
||||
return p.getPermissions(codesource);
|
||||
} else {
|
||||
return new Permissions();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Anyone can connect to the registry and the registry can connect
|
||||
* to and possibly download stubs from anywhere. Downloaded stubs and
|
||||
* related classes themselves are more tightly limited by RMI.
|
||||
*/
|
||||
perms.add(new SocketPermission("*", "connect,accept"));
|
||||
|
||||
perms.add(new RuntimePermission("accessClassInPackage.sun.*"));
|
||||
|
||||
// add permissions required to load from codebase URL path
|
||||
LoaderHandler.addPermissionsForURLs(urls, perms, false);
|
||||
|
||||
/*
|
||||
* Create an AccessControlContext that consists of a single
|
||||
* protection domain with only the permissions calculated above.
|
||||
*/
|
||||
ProtectionDomain pd = new ProtectionDomain(
|
||||
new CodeSource((urls.length > 0 ? urls[0] : null),
|
||||
(java.security.cert.Certificate[]) null),
|
||||
perms);
|
||||
return new AccessControlContext(new ProtectionDomain[] { pd });
|
||||
}
|
||||
}
|
||||
|
@ -1031,9 +1031,9 @@ public final class LoaderHandler {
|
||||
* loader. A given permission is only added to the collection if
|
||||
* it is not already implied by the collection.
|
||||
*/
|
||||
private static void addPermissionsForURLs(URL[] urls,
|
||||
PermissionCollection perms,
|
||||
boolean forLoader)
|
||||
public static void addPermissionsForURLs(URL[] urls,
|
||||
PermissionCollection perms,
|
||||
boolean forLoader)
|
||||
{
|
||||
for (int i = 0; i < urls.length; i++) {
|
||||
URL url = urls[i];
|
||||
|
@ -109,14 +109,6 @@ public class MarshalInputStream extends ObjectInputStream {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the "rmi" native library.
|
||||
*/
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.LoadLibraryAction("rmi"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MarshalInputStream object.
|
||||
*/
|
||||
@ -262,7 +254,9 @@ public class MarshalInputStream extends ObjectInputStream {
|
||||
* Returns the first non-null class loader up the execution stack, or null
|
||||
* if only code from the null class loader is on the stack.
|
||||
*/
|
||||
private static native ClassLoader latestUserDefinedLoader();
|
||||
private static ClassLoader latestUserDefinedLoader() {
|
||||
return sun.misc.VM.latestUserDefinedLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix for 4179055: Need to assist resolving sun stubs; resolve
|
||||
|
@ -390,6 +390,12 @@ public class UnicastServerRef extends UnicastRef
|
||||
ObjectInput in;
|
||||
try {
|
||||
in = call.getInputStream();
|
||||
try {
|
||||
Class<?> clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel");
|
||||
if (clazz.isAssignableFrom(skel.getClass())) {
|
||||
((MarshalInputStream)in).useCodebaseOnly();
|
||||
}
|
||||
} catch (ClassNotFoundException ignore) { }
|
||||
hash = in.readLong();
|
||||
} catch (Exception readEx) {
|
||||
throw new UnmarshalException("error unmarshalling call header",
|
||||
|
@ -27,6 +27,7 @@ package sun.security.pkcs;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URI;
|
||||
import java.util.*;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
@ -35,6 +36,7 @@ import java.security.cert.CRLException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.*;
|
||||
|
||||
import sun.security.timestamp.*;
|
||||
import sun.security.util.*;
|
||||
import sun.security.x509.AlgorithmId;
|
||||
import sun.security.x509.CertificateIssuerName;
|
||||
@ -68,6 +70,30 @@ public class PKCS7 {
|
||||
|
||||
private Principal[] certIssuerNames;
|
||||
|
||||
/*
|
||||
* Random number generator for creating nonce values
|
||||
*/
|
||||
private static final SecureRandom RANDOM;
|
||||
static {
|
||||
SecureRandom tmp = null;
|
||||
try {
|
||||
tmp = SecureRandom.getInstance("SHA1PRNG");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// should not happen
|
||||
}
|
||||
RANDOM = tmp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Object identifier for the timestamping key purpose.
|
||||
*/
|
||||
private static final String KP_TIMESTAMPING_OID = "1.3.6.1.5.5.7.3.8";
|
||||
|
||||
/*
|
||||
* Object identifier for extendedKeyUsage extension
|
||||
*/
|
||||
private static final String EXTENDED_KEY_USAGE_OID = "2.5.29.37";
|
||||
|
||||
/**
|
||||
* Unmarshals a PKCS7 block from its encoded form, parsing the
|
||||
* encoded bytes from the InputStream.
|
||||
@ -733,4 +759,164 @@ public class PKCS7 {
|
||||
public boolean isOldStyle() {
|
||||
return this.oldStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assembles a PKCS #7 signed data message that optionally includes a
|
||||
* signature timestamp.
|
||||
*
|
||||
* @param signature the signature bytes
|
||||
* @param signerChain the signer's X.509 certificate chain
|
||||
* @param content the content that is signed; specify null to not include
|
||||
* it in the PKCS7 data
|
||||
* @param signatureAlgorithm the name of the signature algorithm
|
||||
* @param tsaURI the URI of the Timestamping Authority; or null if no
|
||||
* timestamp is requested
|
||||
* @return the bytes of the encoded PKCS #7 signed data message
|
||||
* @throws NoSuchAlgorithmException The exception is thrown if the signature
|
||||
* algorithm is unrecognised.
|
||||
* @throws CertificateException The exception is thrown if an error occurs
|
||||
* while processing the signer's certificate or the TSA's
|
||||
* certificate.
|
||||
* @throws IOException The exception is thrown if an error occurs while
|
||||
* generating the signature timestamp or while generating the signed
|
||||
* data message.
|
||||
*/
|
||||
public static byte[] generateSignedData(byte[] signature,
|
||||
X509Certificate[] signerChain,
|
||||
byte[] content,
|
||||
String signatureAlgorithm,
|
||||
URI tsaURI)
|
||||
throws CertificateException, IOException, NoSuchAlgorithmException
|
||||
{
|
||||
|
||||
// Generate the timestamp token
|
||||
PKCS9Attributes unauthAttrs = null;
|
||||
if (tsaURI != null) {
|
||||
// Timestamp the signature
|
||||
HttpTimestamper tsa = new HttpTimestamper(tsaURI);
|
||||
byte[] tsToken = generateTimestampToken(tsa, signature);
|
||||
|
||||
// Insert the timestamp token into the PKCS #7 signer info element
|
||||
// (as an unsigned attribute)
|
||||
unauthAttrs =
|
||||
new PKCS9Attributes(new PKCS9Attribute[]{
|
||||
new PKCS9Attribute(
|
||||
PKCS9Attribute.SIGNATURE_TIMESTAMP_TOKEN_STR,
|
||||
tsToken)});
|
||||
}
|
||||
|
||||
// Create the SignerInfo
|
||||
X500Name issuerName =
|
||||
X500Name.asX500Name(signerChain[0].getIssuerX500Principal());
|
||||
BigInteger serialNumber = signerChain[0].getSerialNumber();
|
||||
String encAlg = AlgorithmId.getEncAlgFromSigAlg(signatureAlgorithm);
|
||||
String digAlg = AlgorithmId.getDigAlgFromSigAlg(signatureAlgorithm);
|
||||
SignerInfo signerInfo = new SignerInfo(issuerName, serialNumber,
|
||||
AlgorithmId.get(digAlg), null,
|
||||
AlgorithmId.get(encAlg),
|
||||
signature, unauthAttrs);
|
||||
|
||||
// Create the PKCS #7 signed data message
|
||||
SignerInfo[] signerInfos = {signerInfo};
|
||||
AlgorithmId[] algorithms = {signerInfo.getDigestAlgorithmId()};
|
||||
// Include or exclude content
|
||||
ContentInfo contentInfo = (content == null)
|
||||
? new ContentInfo(ContentInfo.DATA_OID, null)
|
||||
: new ContentInfo(content);
|
||||
PKCS7 pkcs7 = new PKCS7(algorithms, contentInfo,
|
||||
signerChain, signerInfos);
|
||||
ByteArrayOutputStream p7out = new ByteArrayOutputStream();
|
||||
pkcs7.encodeSignedData(p7out);
|
||||
|
||||
return p7out.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests, processes and validates a timestamp token from a TSA using
|
||||
* common defaults. Uses the following defaults in the timestamp request:
|
||||
* SHA-1 for the hash algorithm, a 64-bit nonce, and request certificate
|
||||
* set to true.
|
||||
*
|
||||
* @param tsa the timestamping authority to use
|
||||
* @param toBeTimestamped the token that is to be timestamped
|
||||
* @return the encoded timestamp token
|
||||
* @throws IOException The exception is thrown if an error occurs while
|
||||
* communicating with the TSA.
|
||||
* @throws CertificateException The exception is thrown if the TSA's
|
||||
* certificate is not permitted for timestamping.
|
||||
*/
|
||||
private static byte[] generateTimestampToken(Timestamper tsa,
|
||||
byte[] toBeTimestamped)
|
||||
throws IOException, CertificateException
|
||||
{
|
||||
// Generate a timestamp
|
||||
MessageDigest messageDigest = null;
|
||||
TSRequest tsQuery = null;
|
||||
try {
|
||||
// SHA-1 is always used.
|
||||
messageDigest = MessageDigest.getInstance("SHA-1");
|
||||
tsQuery = new TSRequest(toBeTimestamped, messageDigest);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
// Generate a nonce
|
||||
BigInteger nonce = null;
|
||||
if (RANDOM != null) {
|
||||
nonce = new BigInteger(64, RANDOM);
|
||||
tsQuery.setNonce(nonce);
|
||||
}
|
||||
tsQuery.requestCertificate(true);
|
||||
|
||||
TSResponse tsReply = tsa.generateTimestamp(tsQuery);
|
||||
int status = tsReply.getStatusCode();
|
||||
// Handle TSP error
|
||||
if (status != 0 && status != 1) {
|
||||
throw new IOException("Error generating timestamp: " +
|
||||
tsReply.getStatusCodeAsText() + " " +
|
||||
tsReply.getFailureCodeAsText());
|
||||
}
|
||||
PKCS7 tsToken = tsReply.getToken();
|
||||
|
||||
TimestampToken tst = tsReply.getTimestampToken();
|
||||
if (!tst.getHashAlgorithm().getName().equals("SHA")) {
|
||||
throw new IOException("Digest algorithm not SHA-1 in "
|
||||
+ "timestamp token");
|
||||
}
|
||||
if (!MessageDigest.isEqual(tst.getHashedMessage(),
|
||||
tsQuery.getHashedMessage())) {
|
||||
throw new IOException("Digest octets changed in timestamp token");
|
||||
}
|
||||
|
||||
BigInteger replyNonce = tst.getNonce();
|
||||
if (replyNonce == null && nonce != null) {
|
||||
throw new IOException("Nonce missing in timestamp token");
|
||||
}
|
||||
if (replyNonce != null && !replyNonce.equals(nonce)) {
|
||||
throw new IOException("Nonce changed in timestamp token");
|
||||
}
|
||||
|
||||
// Examine the TSA's certificate (if present)
|
||||
for (SignerInfo si: tsToken.getSignerInfos()) {
|
||||
X509Certificate cert = si.getCertificate(tsToken);
|
||||
if (cert == null) {
|
||||
// Error, we've already set tsRequestCertificate = true
|
||||
throw new CertificateException(
|
||||
"Certificate not included in timestamp token");
|
||||
} else {
|
||||
if (!cert.getCriticalExtensionOIDs().contains(
|
||||
EXTENDED_KEY_USAGE_OID)) {
|
||||
throw new CertificateException(
|
||||
"Certificate is not valid for timestamping");
|
||||
}
|
||||
List<String> keyPurposes = cert.getExtendedKeyUsage();
|
||||
if (keyPurposes == null ||
|
||||
!keyPurposes.contains(KP_TIMESTAMPING_OID)) {
|
||||
throw new CertificateException(
|
||||
"Certificate is not valid for timestamping");
|
||||
}
|
||||
}
|
||||
}
|
||||
return tsReply.getEncodedToken();
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,14 @@ package sun.security.pkcs;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.CertPath;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.security.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import sun.security.timestamp.TimestampToken;
|
||||
import sun.security.util.*;
|
||||
import sun.security.x509.AlgorithmId;
|
||||
import sun.security.x509.X500Name;
|
||||
@ -51,6 +55,8 @@ public class SignerInfo implements DerEncoder {
|
||||
AlgorithmId digestAlgorithmId;
|
||||
AlgorithmId digestEncryptionAlgorithmId;
|
||||
byte[] encryptedDigest;
|
||||
Timestamp timestamp;
|
||||
private boolean hasTimestamp = true;
|
||||
|
||||
PKCS9Attributes authenticatedAttributes;
|
||||
PKCS9Attributes unauthenticatedAttributes;
|
||||
@ -442,6 +448,62 @@ public class SignerInfo implements DerEncoder {
|
||||
return unauthenticatedAttributes;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extracts a timestamp from a PKCS7 SignerInfo.
|
||||
*
|
||||
* Examines the signer's unsigned attributes for a
|
||||
* <tt>signatureTimestampToken</tt> attribute. If present,
|
||||
* then it is parsed to extract the date and time at which the
|
||||
* timestamp was generated.
|
||||
*
|
||||
* @param info A signer information element of a PKCS 7 block.
|
||||
*
|
||||
* @return A timestamp token or null if none is present.
|
||||
* @throws IOException if an error is encountered while parsing the
|
||||
* PKCS7 data.
|
||||
* @throws NoSuchAlgorithmException if an error is encountered while
|
||||
* verifying the PKCS7 object.
|
||||
* @throws SignatureException if an error is encountered while
|
||||
* verifying the PKCS7 object.
|
||||
* @throws CertificateException if an error is encountered while generating
|
||||
* the TSA's certpath.
|
||||
*/
|
||||
public Timestamp getTimestamp()
|
||||
throws IOException, NoSuchAlgorithmException, SignatureException,
|
||||
CertificateException
|
||||
{
|
||||
if (timestamp != null || !hasTimestamp)
|
||||
return timestamp;
|
||||
|
||||
if (unauthenticatedAttributes == null) {
|
||||
hasTimestamp = false;
|
||||
return null;
|
||||
}
|
||||
PKCS9Attribute tsTokenAttr =
|
||||
unauthenticatedAttributes.getAttribute(
|
||||
PKCS9Attribute.SIGNATURE_TIMESTAMP_TOKEN_OID);
|
||||
if (tsTokenAttr == null) {
|
||||
hasTimestamp = false;
|
||||
return null;
|
||||
}
|
||||
|
||||
PKCS7 tsToken = new PKCS7((byte[])tsTokenAttr.getValue());
|
||||
// Extract the content (an encoded timestamp token info)
|
||||
byte[] encTsTokenInfo = tsToken.getContentInfo().getData();
|
||||
// Extract the signer (the Timestamping Authority)
|
||||
// while verifying the content
|
||||
SignerInfo[] tsa = tsToken.verify(encTsTokenInfo);
|
||||
// Expect only one signer
|
||||
ArrayList<X509Certificate> chain = tsa[0].getCertificateChain(tsToken);
|
||||
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||
CertPath tsaChain = cf.generateCertPath(chain);
|
||||
// Create a timestamp token info object
|
||||
TimestampToken tsTokenInfo = new TimestampToken(encTsTokenInfo);
|
||||
// Create a timestamp object
|
||||
timestamp = new Timestamp(tsTokenInfo.getDate(), tsaChain);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
HexDumpEncoder hexDump = new HexDumpEncoder();
|
||||
|
||||
@ -467,5 +529,4 @@ public class SignerInfo implements DerEncoder {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
|
||||
package sun.security.pkcs;
|
||||
package sun.security.pkcs10;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.IOException;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,11 +23,12 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.security.pkcs;
|
||||
package sun.security.pkcs10;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import sun.security.pkcs.PKCS9Attribute;
|
||||
import sun.security.util.*;
|
||||
|
||||
/**
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.security.pkcs;
|
||||
package sun.security.pkcs10;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
@ -192,6 +192,11 @@ final class Config {
|
||||
// works only for NSS providers created via the Secmod API
|
||||
private boolean nssUseSecmodTrust = false;
|
||||
|
||||
// Flag to indicate whether the X9.63 encoding for EC points shall be used
|
||||
// (true) or whether that encoding shall be wrapped in an ASN.1 OctetString
|
||||
// (false).
|
||||
private boolean useEcX963Encoding = false;
|
||||
|
||||
private Config(String filename, InputStream in) throws IOException {
|
||||
if (in == null) {
|
||||
if (filename.startsWith("--")) {
|
||||
@ -320,6 +325,10 @@ final class Config {
|
||||
return nssUseSecmodTrust;
|
||||
}
|
||||
|
||||
boolean getUseEcX963Encoding() {
|
||||
return useEcX963Encoding;
|
||||
}
|
||||
|
||||
private static String expand(final String s) throws IOException {
|
||||
try {
|
||||
return PropertyExpander.expand(s);
|
||||
@ -440,6 +449,8 @@ final class Config {
|
||||
parseNSSArgs(word);
|
||||
} else if (word.equals("nssUseSecmodTrust")) {
|
||||
nssUseSecmodTrust = parseBooleanEntry(word);
|
||||
} else if (word.equals("useEcX963Encoding")) {
|
||||
useEcX963Encoding = parseBooleanEntry(word);
|
||||
} else {
|
||||
throw new ConfigurationException
|
||||
("Unknown keyword '" + word + "', line " + st.lineno());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -48,7 +48,7 @@ import sun.security.util.Cache;
|
||||
*/
|
||||
final class KeyCache {
|
||||
|
||||
private final Cache strongCache;
|
||||
private final Cache<IdentityWrapper, P11Key> strongCache;
|
||||
|
||||
private WeakReference<Map<Key,P11Key>> cacheReference;
|
||||
|
||||
@ -77,7 +77,7 @@ final class KeyCache {
|
||||
}
|
||||
|
||||
synchronized P11Key get(Key key) {
|
||||
P11Key p11Key = (P11Key)strongCache.get(new IdentityWrapper(key));
|
||||
P11Key p11Key = strongCache.get(new IdentityWrapper(key));
|
||||
if (p11Key != null) {
|
||||
return p11Key;
|
||||
}
|
||||
@ -94,8 +94,8 @@ final class KeyCache {
|
||||
Map<Key,P11Key> map =
|
||||
(cacheReference == null) ? null : cacheReference.get();
|
||||
if (map == null) {
|
||||
map = new IdentityHashMap<Key,P11Key>();
|
||||
cacheReference = new WeakReference<Map<Key,P11Key>>(map);
|
||||
map = new IdentityHashMap<>();
|
||||
cacheReference = new WeakReference<>(map);
|
||||
}
|
||||
map.put(key, p11Key);
|
||||
}
|
||||
|
@ -203,14 +203,20 @@ final class P11ECKeyFactory extends P11KeyFactory {
|
||||
|
||||
private PublicKey generatePublic(ECPoint point, ECParameterSpec params) throws PKCS11Exception {
|
||||
byte[] encodedParams = ECParameters.encodeParameters(params);
|
||||
byte[] encodedPoint = null;
|
||||
DerValue pkECPoint = new DerValue(DerValue.tag_OctetString,
|
||||
ECParameters.encodePoint(point, params.getCurve()));
|
||||
byte[] encodedPoint =
|
||||
ECParameters.encodePoint(point, params.getCurve());
|
||||
|
||||
try {
|
||||
encodedPoint = pkECPoint.toByteArray();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("Could not DER encode point", e);
|
||||
// Check whether the X9.63 encoding of an EC point shall be wrapped
|
||||
// in an ASN.1 OCTET STRING
|
||||
if (!token.config.getUseEcX963Encoding()) {
|
||||
try {
|
||||
encodedPoint =
|
||||
new DerValue(DerValue.tag_OctetString, encodedPoint)
|
||||
.toByteArray();
|
||||
} catch (IOException e) {
|
||||
throw new
|
||||
IllegalArgumentException("Could not DER encode point", e);
|
||||
}
|
||||
}
|
||||
|
||||
CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
|
||||
|
@ -1028,28 +1028,21 @@ abstract class P11Key implements Key {
|
||||
try {
|
||||
params = P11ECKeyFactory.decodeParameters
|
||||
(attributes[1].getByteArray());
|
||||
|
||||
/*
|
||||
* An uncompressed EC point may be in either of two formats.
|
||||
* First try the OCTET STRING encoding:
|
||||
* 04 <length> 04 <X-coordinate> <Y-coordinate>
|
||||
*
|
||||
* Otherwise try the raw encoding:
|
||||
* 04 <X-coordinate> <Y-coordinate>
|
||||
*/
|
||||
byte[] ecKey = attributes[0].getByteArray();
|
||||
|
||||
try {
|
||||
// Check whether the X9.63 encoding of an EC point is wrapped
|
||||
// in an ASN.1 OCTET STRING
|
||||
if (!token.config.getUseEcX963Encoding()) {
|
||||
DerValue wECPoint = new DerValue(ecKey);
|
||||
if (wECPoint.getTag() != DerValue.tag_OctetString)
|
||||
throw new IOException("Unexpected tag: " +
|
||||
wECPoint.getTag());
|
||||
|
||||
if (wECPoint.getTag() != DerValue.tag_OctetString) {
|
||||
throw new IOException("Could not DER decode EC point." +
|
||||
" Unexpected tag: " + wECPoint.getTag());
|
||||
}
|
||||
w = P11ECKeyFactory.decodePoint
|
||||
(wECPoint.getDataBytes(), params.getCurve());
|
||||
|
||||
} catch (IOException e) {
|
||||
// Failover
|
||||
} else {
|
||||
w = P11ECKeyFactory.decodePoint(ecKey, params.getCurve());
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,10 @@ public class X509Factory extends CertificateFactorySpi {
|
||||
|
||||
private static final int ENC_MAX_LENGTH = 4096 * 1024; // 4 MB MAX
|
||||
|
||||
private static final Cache certCache = Cache.newSoftMemoryCache(750);
|
||||
private static final Cache crlCache = Cache.newSoftMemoryCache(750);
|
||||
private static final Cache<Object, X509CertImpl> certCache
|
||||
= Cache.newSoftMemoryCache(750);
|
||||
private static final Cache<Object, X509CRLImpl> crlCache
|
||||
= Cache.newSoftMemoryCache(750);
|
||||
|
||||
/**
|
||||
* Generates an X.509 certificate object and initializes it with
|
||||
@ -90,7 +92,7 @@ public class X509Factory extends CertificateFactorySpi {
|
||||
try {
|
||||
byte[] encoding = readOneBlock(is);
|
||||
if (encoding != null) {
|
||||
X509CertImpl cert = (X509CertImpl)getFromCache(certCache, encoding);
|
||||
X509CertImpl cert = getFromCache(certCache, encoding);
|
||||
if (cert != null) {
|
||||
return cert;
|
||||
}
|
||||
@ -151,7 +153,7 @@ public class X509Factory extends CertificateFactorySpi {
|
||||
} else {
|
||||
encoding = c.getEncoded();
|
||||
}
|
||||
X509CertImpl newC = (X509CertImpl)getFromCache(certCache, encoding);
|
||||
X509CertImpl newC = getFromCache(certCache, encoding);
|
||||
if (newC != null) {
|
||||
return newC;
|
||||
}
|
||||
@ -181,7 +183,7 @@ public class X509Factory extends CertificateFactorySpi {
|
||||
} else {
|
||||
encoding = c.getEncoded();
|
||||
}
|
||||
X509CRLImpl newC = (X509CRLImpl)getFromCache(crlCache, encoding);
|
||||
X509CRLImpl newC = getFromCache(crlCache, encoding);
|
||||
if (newC != null) {
|
||||
return newC;
|
||||
}
|
||||
@ -198,18 +200,17 @@ public class X509Factory extends CertificateFactorySpi {
|
||||
/**
|
||||
* Get the X509CertImpl or X509CRLImpl from the cache.
|
||||
*/
|
||||
private static synchronized Object getFromCache(Cache cache,
|
||||
private static synchronized <K,V> V getFromCache(Cache<K,V> cache,
|
||||
byte[] encoding) {
|
||||
Object key = new Cache.EqualByteArray(encoding);
|
||||
Object value = cache.get(key);
|
||||
return value;
|
||||
return cache.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the X509CertImpl or X509CRLImpl to the cache.
|
||||
*/
|
||||
private static synchronized void addToCache(Cache cache, byte[] encoding,
|
||||
Object value) {
|
||||
private static synchronized <V> void addToCache(Cache<Object, V> cache,
|
||||
byte[] encoding, V value) {
|
||||
if (encoding.length > ENC_MAX_LENGTH) {
|
||||
return;
|
||||
}
|
||||
@ -361,7 +362,7 @@ public class X509Factory extends CertificateFactorySpi {
|
||||
try {
|
||||
byte[] encoding = readOneBlock(is);
|
||||
if (encoding != null) {
|
||||
X509CRLImpl crl = (X509CRLImpl)getFromCache(crlCache, encoding);
|
||||
X509CRLImpl crl = getFromCache(crlCache, encoding);
|
||||
if (crl != null) {
|
||||
return crl;
|
||||
}
|
||||
@ -669,6 +670,23 @@ public class X509Factory extends CertificateFactorySpi {
|
||||
bout.write(midByte);
|
||||
bout.write(lowByte);
|
||||
length = (highByte << 16) | (midByte << 8) | lowByte;
|
||||
} else if (n == 0x84) {
|
||||
int highByte = is.read();
|
||||
int nextByte = is.read();
|
||||
int midByte = is.read();
|
||||
int lowByte = is.read();
|
||||
if (lowByte == -1) {
|
||||
throw new IOException("Incomplete BER/DER length info");
|
||||
}
|
||||
if (highByte > 127) {
|
||||
throw new IOException("Invalid BER/DER data (a little huge?)");
|
||||
}
|
||||
bout.write(highByte);
|
||||
bout.write(nextByte);
|
||||
bout.write(midByte);
|
||||
bout.write(lowByte);
|
||||
length = (highByte << 24 ) | (nextByte << 16) |
|
||||
(midByte << 8) | lowByte;
|
||||
} else { // ignore longer length forms
|
||||
throw new IOException("Invalid BER/DER data (too huge?)");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,32 +27,87 @@ package sun.security.provider.certpath;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.security.AccessController;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.cert.CertStore;
|
||||
import java.security.cert.X509CertSelector;
|
||||
import java.security.cert.X509CRLSelector;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
import java.io.IOException;
|
||||
|
||||
import sun.security.util.Cache;
|
||||
|
||||
/**
|
||||
* Helper used by URICertStore when delegating to another CertStore to
|
||||
* fetch certs and CRLs.
|
||||
* Helper used by URICertStore and others when delegating to another CertStore
|
||||
* to fetch certs and CRLs.
|
||||
*/
|
||||
|
||||
public interface CertStoreHelper {
|
||||
public abstract class CertStoreHelper {
|
||||
|
||||
private static final int NUM_TYPES = 2;
|
||||
private final static Map<String,String> classMap = new HashMap<>(NUM_TYPES);
|
||||
static {
|
||||
classMap.put(
|
||||
"LDAP",
|
||||
"sun.security.provider.certpath.ldap.LDAPCertStoreHelper");
|
||||
classMap.put(
|
||||
"SSLServer",
|
||||
"sun.security.provider.certpath.ssl.SSLServerCertStoreHelper");
|
||||
};
|
||||
private static Cache<String, CertStoreHelper> cache
|
||||
= Cache.newSoftMemoryCache(NUM_TYPES);
|
||||
|
||||
public static CertStoreHelper getInstance(final String type)
|
||||
throws NoSuchAlgorithmException
|
||||
{
|
||||
CertStoreHelper helper = cache.get(type);
|
||||
if (helper != null) {
|
||||
return helper;
|
||||
}
|
||||
final String cl = classMap.get(type);
|
||||
if (cl == null) {
|
||||
throw new NoSuchAlgorithmException(type + " not available");
|
||||
}
|
||||
try {
|
||||
helper = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<CertStoreHelper>() {
|
||||
public CertStoreHelper run() throws ClassNotFoundException {
|
||||
try {
|
||||
Class<?> c = Class.forName(cl, true, null);
|
||||
CertStoreHelper csh
|
||||
= (CertStoreHelper)c.newInstance();
|
||||
cache.put(type, csh);
|
||||
return csh;
|
||||
} catch (InstantiationException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
return helper;
|
||||
} catch (PrivilegedActionException e) {
|
||||
throw new NoSuchAlgorithmException(type + " not available",
|
||||
e.getException());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a CertStore using the given URI as parameters.
|
||||
*/
|
||||
CertStore getCertStore(URI uri)
|
||||
public abstract CertStore getCertStore(URI uri)
|
||||
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException;
|
||||
|
||||
/**
|
||||
* Wraps an existing X509CertSelector when needing to avoid DN matching
|
||||
* issues.
|
||||
*/
|
||||
X509CertSelector wrap(X509CertSelector selector,
|
||||
public abstract X509CertSelector wrap(X509CertSelector selector,
|
||||
X500Principal certSubject,
|
||||
String dn)
|
||||
throws IOException;
|
||||
@ -61,7 +116,7 @@ public interface CertStoreHelper {
|
||||
* Wraps an existing X509CRLSelector when needing to avoid DN matching
|
||||
* issues.
|
||||
*/
|
||||
X509CRLSelector wrap(X509CRLSelector selector,
|
||||
public abstract X509CRLSelector wrap(X509CRLSelector selector,
|
||||
Collection<X500Principal> certIssuers,
|
||||
String dn)
|
||||
throws IOException;
|
||||
|
@ -30,8 +30,6 @@ import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URLConnection;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.Provider;
|
||||
@ -102,8 +100,7 @@ class URICertStore extends CertStoreSpi {
|
||||
private final CertificateFactory factory;
|
||||
|
||||
// cached Collection of X509Certificates (may be empty, never null)
|
||||
private Collection<X509Certificate> certs =
|
||||
Collections.<X509Certificate>emptySet();
|
||||
private Collection<X509Certificate> certs = Collections.emptySet();
|
||||
|
||||
// cached X509CRL (may be null)
|
||||
private X509CRL crl;
|
||||
@ -120,35 +117,10 @@ class URICertStore extends CertStoreSpi {
|
||||
|
||||
// true if URI is ldap
|
||||
private boolean ldap = false;
|
||||
private CertStoreHelper ldapHelper;
|
||||
private CertStore ldapCertStore;
|
||||
private String ldapPath;
|
||||
|
||||
/**
|
||||
* Holder class to lazily load LDAPCertStoreHelper if present.
|
||||
*/
|
||||
private static class LDAP {
|
||||
private static final String CERT_STORE_HELPER =
|
||||
"sun.security.provider.certpath.ldap.LDAPCertStoreHelper";
|
||||
private static final CertStoreHelper helper =
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<CertStoreHelper>() {
|
||||
public CertStoreHelper run() {
|
||||
try {
|
||||
Class<?> c = Class.forName(CERT_STORE_HELPER, true, null);
|
||||
return (CertStoreHelper)c.newInstance();
|
||||
} catch (ClassNotFoundException cnf) {
|
||||
return null;
|
||||
} catch (InstantiationException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}});
|
||||
static CertStoreHelper helper() {
|
||||
return helper;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a URICertStore.
|
||||
*
|
||||
@ -164,10 +136,9 @@ class URICertStore extends CertStoreSpi {
|
||||
this.uri = ((URICertStoreParameters) params).uri;
|
||||
// if ldap URI, use an LDAPCertStore to fetch certs and CRLs
|
||||
if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
|
||||
if (LDAP.helper() == null)
|
||||
throw new NoSuchAlgorithmException("LDAP not present");
|
||||
ldap = true;
|
||||
ldapCertStore = LDAP.helper().getCertStore(uri);
|
||||
ldapHelper = CertStoreHelper.getInstance("LDAP");
|
||||
ldapCertStore = ldapHelper.getCertStore(uri);
|
||||
ldapPath = uri.getPath();
|
||||
// strip off leading '/'
|
||||
if (ldapPath.charAt(0) == '/') {
|
||||
@ -185,14 +156,14 @@ class URICertStore extends CertStoreSpi {
|
||||
* Returns a URI CertStore. This method consults a cache of
|
||||
* CertStores (shared per JVM) using the URI as a key.
|
||||
*/
|
||||
private static final Cache certStoreCache =
|
||||
Cache.newSoftMemoryCache(CACHE_SIZE);
|
||||
private static final Cache<URICertStoreParameters, CertStore>
|
||||
certStoreCache = Cache.newSoftMemoryCache(CACHE_SIZE);
|
||||
static synchronized CertStore getInstance(URICertStoreParameters params)
|
||||
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
|
||||
if (debug != null) {
|
||||
debug.println("CertStore URI:" + params.uri);
|
||||
}
|
||||
CertStore ucs = (CertStore) certStoreCache.get(params);
|
||||
CertStore ucs = certStoreCache.get(params);
|
||||
if (ucs == null) {
|
||||
ucs = new UCS(new URICertStore(params), null, "URI", params);
|
||||
certStoreCache.put(params, ucs);
|
||||
@ -251,7 +222,7 @@ class URICertStore extends CertStoreSpi {
|
||||
if (ldap) {
|
||||
X509CertSelector xsel = (X509CertSelector) selector;
|
||||
try {
|
||||
xsel = LDAP.helper().wrap(xsel, xsel.getSubject(), ldapPath);
|
||||
xsel = ldapHelper.wrap(xsel, xsel.getSubject(), ldapPath);
|
||||
} catch (IOException ioe) {
|
||||
throw new CertStoreException(ioe);
|
||||
}
|
||||
@ -273,62 +244,49 @@ class URICertStore extends CertStoreSpi {
|
||||
return getMatchingCerts(certs, selector);
|
||||
}
|
||||
lastChecked = time;
|
||||
InputStream in = null;
|
||||
try {
|
||||
URLConnection connection = uri.toURL().openConnection();
|
||||
if (lastModified != 0) {
|
||||
connection.setIfModifiedSince(lastModified);
|
||||
}
|
||||
in = connection.getInputStream();
|
||||
long oldLastModified = lastModified;
|
||||
lastModified = connection.getLastModified();
|
||||
if (oldLastModified != 0) {
|
||||
if (oldLastModified == lastModified) {
|
||||
if (debug != null) {
|
||||
debug.println("Not modified, using cached copy");
|
||||
}
|
||||
return getMatchingCerts(certs, selector);
|
||||
} else if (connection instanceof HttpURLConnection) {
|
||||
// some proxy servers omit last modified
|
||||
HttpURLConnection hconn = (HttpURLConnection) connection;
|
||||
if (hconn.getResponseCode()
|
||||
== HttpURLConnection.HTTP_NOT_MODIFIED) {
|
||||
try (InputStream in = connection.getInputStream()) {
|
||||
lastModified = connection.getLastModified();
|
||||
if (oldLastModified != 0) {
|
||||
if (oldLastModified == lastModified) {
|
||||
if (debug != null) {
|
||||
debug.println("Not modified, using cached copy");
|
||||
}
|
||||
return getMatchingCerts(certs, selector);
|
||||
} else if (connection instanceof HttpURLConnection) {
|
||||
// some proxy servers omit last modified
|
||||
HttpURLConnection hconn = (HttpURLConnection)connection;
|
||||
if (hconn.getResponseCode()
|
||||
== HttpURLConnection.HTTP_NOT_MODIFIED) {
|
||||
if (debug != null) {
|
||||
debug.println("Not modified, using cached copy");
|
||||
}
|
||||
return getMatchingCerts(certs, selector);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (debug != null) {
|
||||
debug.println("Downloading new certificates...");
|
||||
}
|
||||
// Safe cast since factory is an X.509 certificate factory
|
||||
certs = (Collection<X509Certificate>)
|
||||
factory.generateCertificates(in);
|
||||
return getMatchingCerts(certs, selector);
|
||||
} catch (IOException e) {
|
||||
if (debug != null) {
|
||||
debug.println("Exception fetching certificates:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (CertificateException e) {
|
||||
if (debug != null) {
|
||||
debug.println("Exception fetching certificates:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
if (debug != null) {
|
||||
debug.println("Downloading new certificates...");
|
||||
}
|
||||
// Safe cast since factory is an X.509 certificate factory
|
||||
certs = (Collection<X509Certificate>)
|
||||
factory.generateCertificates(in);
|
||||
}
|
||||
return getMatchingCerts(certs, selector);
|
||||
} catch (IOException | CertificateException e) {
|
||||
if (debug != null) {
|
||||
debug.println("Exception fetching certificates:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// exception, forget previous values
|
||||
lastModified = 0;
|
||||
certs = Collections.<X509Certificate>emptySet();
|
||||
certs = Collections.emptySet();
|
||||
return certs;
|
||||
}
|
||||
|
||||
@ -343,8 +301,7 @@ class URICertStore extends CertStoreSpi {
|
||||
if (selector == null) {
|
||||
return certs;
|
||||
}
|
||||
List<X509Certificate> matchedCerts =
|
||||
new ArrayList<X509Certificate>(certs.size());
|
||||
List<X509Certificate> matchedCerts = new ArrayList<>(certs.size());
|
||||
for (X509Certificate cert : certs) {
|
||||
if (selector.match(cert)) {
|
||||
matchedCerts.add(cert);
|
||||
@ -374,7 +331,7 @@ class URICertStore extends CertStoreSpi {
|
||||
if (ldap) {
|
||||
X509CRLSelector xsel = (X509CRLSelector) selector;
|
||||
try {
|
||||
xsel = LDAP.helper().wrap(xsel, null, ldapPath);
|
||||
xsel = ldapHelper.wrap(xsel, null, ldapPath);
|
||||
} catch (IOException ioe) {
|
||||
throw new CertStoreException(ioe);
|
||||
}
|
||||
@ -395,61 +352,48 @@ class URICertStore extends CertStoreSpi {
|
||||
return getMatchingCRLs(crl, selector);
|
||||
}
|
||||
lastChecked = time;
|
||||
InputStream in = null;
|
||||
try {
|
||||
URLConnection connection = uri.toURL().openConnection();
|
||||
if (lastModified != 0) {
|
||||
connection.setIfModifiedSince(lastModified);
|
||||
}
|
||||
in = connection.getInputStream();
|
||||
long oldLastModified = lastModified;
|
||||
lastModified = connection.getLastModified();
|
||||
if (oldLastModified != 0) {
|
||||
if (oldLastModified == lastModified) {
|
||||
if (debug != null) {
|
||||
debug.println("Not modified, using cached copy");
|
||||
}
|
||||
return getMatchingCRLs(crl, selector);
|
||||
} else if (connection instanceof HttpURLConnection) {
|
||||
// some proxy servers omit last modified
|
||||
HttpURLConnection hconn = (HttpURLConnection) connection;
|
||||
if (hconn.getResponseCode()
|
||||
== HttpURLConnection.HTTP_NOT_MODIFIED) {
|
||||
try (InputStream in = connection.getInputStream()) {
|
||||
lastModified = connection.getLastModified();
|
||||
if (oldLastModified != 0) {
|
||||
if (oldLastModified == lastModified) {
|
||||
if (debug != null) {
|
||||
debug.println("Not modified, using cached copy");
|
||||
}
|
||||
return getMatchingCRLs(crl, selector);
|
||||
} else if (connection instanceof HttpURLConnection) {
|
||||
// some proxy servers omit last modified
|
||||
HttpURLConnection hconn = (HttpURLConnection)connection;
|
||||
if (hconn.getResponseCode()
|
||||
== HttpURLConnection.HTTP_NOT_MODIFIED) {
|
||||
if (debug != null) {
|
||||
debug.println("Not modified, using cached copy");
|
||||
}
|
||||
return getMatchingCRLs(crl, selector);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (debug != null) {
|
||||
debug.println("Downloading new CRL...");
|
||||
}
|
||||
crl = (X509CRL) factory.generateCRL(in);
|
||||
return getMatchingCRLs(crl, selector);
|
||||
} catch (IOException e) {
|
||||
if (debug != null) {
|
||||
debug.println("Exception fetching CRL:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (CRLException e) {
|
||||
if (debug != null) {
|
||||
debug.println("Exception fetching CRL:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
if (debug != null) {
|
||||
debug.println("Downloading new CRL...");
|
||||
}
|
||||
crl = (X509CRL) factory.generateCRL(in);
|
||||
}
|
||||
return getMatchingCRLs(crl, selector);
|
||||
} catch (IOException | CRLException e) {
|
||||
if (debug != null) {
|
||||
debug.println("Exception fetching CRL:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// exception, forget previous values
|
||||
lastModified = 0;
|
||||
crl = null;
|
||||
return Collections.<X509CRL>emptyList();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -459,9 +403,9 @@ class URICertStore extends CertStoreSpi {
|
||||
private static Collection<X509CRL> getMatchingCRLs
|
||||
(X509CRL crl, CRLSelector selector) {
|
||||
if (selector == null || (crl != null && selector.match(crl))) {
|
||||
return Collections.<X509CRL>singletonList(crl);
|
||||
return Collections.singletonList(crl);
|
||||
} else {
|
||||
return Collections.<X509CRL>emptyList();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -79,7 +79,8 @@ public class X509CertificatePair {
|
||||
private X509Certificate reverse;
|
||||
private byte[] encoded;
|
||||
|
||||
private static final Cache cache = Cache.newSoftMemoryCache(750);
|
||||
private static final Cache<Object, X509CertificatePair> cache
|
||||
= Cache.newSoftMemoryCache(750);
|
||||
|
||||
/**
|
||||
* Creates an empty instance of X509CertificatePair.
|
||||
@ -114,7 +115,7 @@ public class X509CertificatePair {
|
||||
*
|
||||
* For internal use only, external code should use generateCertificatePair.
|
||||
*/
|
||||
private X509CertificatePair(byte[] encoded)throws CertificateException {
|
||||
private X509CertificatePair(byte[] encoded) throws CertificateException {
|
||||
try {
|
||||
parse(new DerValue(encoded));
|
||||
this.encoded = encoded;
|
||||
@ -138,7 +139,7 @@ public class X509CertificatePair {
|
||||
public static synchronized X509CertificatePair generateCertificatePair
|
||||
(byte[] encoded) throws CertificateException {
|
||||
Object key = new Cache.EqualByteArray(encoded);
|
||||
X509CertificatePair pair = (X509CertificatePair)cache.get(key);
|
||||
X509CertificatePair pair = cache.get(key);
|
||||
if (pair != null) {
|
||||
return pair;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user