This commit is contained in:
Lana Steuck 2013-08-06 17:01:05 -07:00
commit 37487a9e38
252 changed files with 15171 additions and 2192 deletions

View File

@ -222,3 +222,4 @@ ea73f01b9053e7165e7ba80f242bafecbc6af712 jdk8-b96
711eb4aa87de68de78250e0549980936bab53d54 jdk8-b98
2d3875b0d18b3ad1c2bebf385a697e309e4005a4 jdk8-b99
3d34036aae4ea90b2ca59712d5a69db3221f0875 jdk8-b100
edb01c460d4cab21ff0ff13512df7b746efaa0e7 jdk8-b101

View File

@ -222,3 +222,4 @@ a1c1e8bf71f354f3aec0214cf13d6668811e021d jdk8-b97
0d0c983a817bbe8518a5ff201306334a8de267f2 jdk8-b98
59dc9da813794c924a0383c2a6241af94defdfed jdk8-b99
d2dcb110e9dbaf9903c05b211df800e78e4b394e jdk8-b100
9f74a220677dc265a724515d8e2617548cef62f1 jdk8-b101

View File

@ -222,3 +222,4 @@ c8286839d0df04aba819ec4bef12b86babccf30e jdk8-b90
3370fb6146e47a6cc05a213fc213e12fc0a38d07 jdk8-b98
3f67804ab61303782df57e54989ef5e0e4629beb jdk8-b99
8d492f1dfd1b131a4c7886ee6b59528609f7e4fe jdk8-b100
a013024b07475782f1fa8e196e950b34b4077663 jdk8-b101

View File

@ -363,3 +363,5 @@ c9dd82da51ed34a28f7c6b3245163ee962e94572 hs25-b40
9f71e36a471ae4a668e08827d33035963ed10c08 hs25-b42
5787fac72e760c6a5fd9efa113b0c75caf554136 jdk8-b100
46487ba40ff225654d0c51787ed3839bafcbd9f3 hs25-b43
f6921c876db192bba389cec062855a66372da01c jdk8-b101
530fe88b3b2c710f42810b3580d86a0d83ad6c1c hs25-b44

View File

@ -24,16 +24,20 @@
TYPE=MINIMAL1
INCLUDE_JVMTI ?= false
INCLUDE_FPROF ?= false
INCLUDE_VM_STRUCTS ?= false
INCLUDE_JNI_CHECK ?= false
INCLUDE_SERVICES ?= false
INCLUDE_MANAGEMENT ?= false
INCLUDE_ALL_GCS ?= false
INCLUDE_NMT ?= false
INCLUDE_TRACE ?= false
INCLUDE_CDS ?= false
# Force all variables to false, overriding any other
# setting that may have occurred in the makefiles. These
# can still be overridden by passing the variable as an
# argument to 'make'
INCLUDE_JVMTI := false
INCLUDE_FPROF := false
INCLUDE_VM_STRUCTS := false
INCLUDE_JNI_CHECK := false
INCLUDE_SERVICES := false
INCLUDE_MANAGEMENT := false
INCLUDE_ALL_GCS := false
INCLUDE_NMT := false
INCLUDE_TRACE := false
INCLUDE_CDS := false
CXXFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
CFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"

View File

@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013
HS_MAJOR_VER=25
HS_MINOR_VER=0
HS_BUILD_NUMBER=43
HS_BUILD_NUMBER=44
JDK_MAJOR_VER=1
JDK_MINOR_VER=8

View File

@ -24,16 +24,20 @@
TYPE=MINIMAL1
INCLUDE_JVMTI ?= false
INCLUDE_FPROF ?= false
INCLUDE_VM_STRUCTS ?= false
INCLUDE_JNI_CHECK ?= false
INCLUDE_SERVICES ?= false
INCLUDE_MANAGEMENT ?= false
INCLUDE_ALL_GCS ?= false
INCLUDE_NMT ?= false
INCLUDE_TRACE ?= false
INCLUDE_CDS ?= false
# Force all variables to false, overriding any other
# setting that may have occurred in the makefiles. These
# can still be overridden by passing the variable as an
# argument to 'make'
INCLUDE_JVMTI := false
INCLUDE_FPROF := false
INCLUDE_VM_STRUCTS := false
INCLUDE_JNI_CHECK := false
INCLUDE_SERVICES := false
INCLUDE_MANAGEMENT := false
INCLUDE_ALL_GCS := false
INCLUDE_NMT := false
INCLUDE_TRACE := false
INCLUDE_CDS := false
CXXFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
CFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"

View File

@ -42,7 +42,7 @@ define_pd_global(bool, ProfileInterpreter, false);
#else
define_pd_global(bool, ProfileInterpreter, true);
#endif // CC_INTERP
define_pd_global(bool, TieredCompilation, false);
define_pd_global(bool, TieredCompilation, trueInTiered);
define_pd_global(intx, CompileThreshold, 10000);
define_pd_global(intx, BackEdgeThreshold, 140000);

View File

@ -44,7 +44,7 @@ define_pd_global(bool, ProfileInterpreter, false);
#else
define_pd_global(bool, ProfileInterpreter, true);
#endif // CC_INTERP
define_pd_global(bool, TieredCompilation, false);
define_pd_global(bool, TieredCompilation, trueInTiered);
define_pd_global(intx, CompileThreshold, 10000);
define_pd_global(intx, BackEdgeThreshold, 100000);

View File

@ -299,7 +299,7 @@ class CompileReplay : public StackObj {
Symbol* method_signature = parse_symbol(CHECK_NULL);
Method* m = k->find_method(method_name, method_signature);
if (m == NULL) {
report_error("can't find method");
report_error("Can't find method");
}
return m;
}
@ -398,8 +398,8 @@ class CompileReplay : public StackObj {
// compile <klass> <name> <signature> <entry_bci> <comp_level>
void process_compile(TRAPS) {
// methodHandle method;
Method* method = parse_method(CHECK);
if (had_error()) return;
int entry_bci = parse_int("entry_bci");
const char* comp_level_label = "comp_level";
int comp_level = parse_int(comp_level_label);
@ -440,6 +440,7 @@ class CompileReplay : public StackObj {
//
void process_ciMethod(TRAPS) {
Method* method = parse_method(CHECK);
if (had_error()) return;
ciMethodRecord* rec = new_ciMethod(method);
rec->invocation_counter = parse_int("invocation_counter");
rec->backedge_counter = parse_int("backedge_counter");
@ -451,6 +452,7 @@ class CompileReplay : public StackObj {
// ciMethodData <klass> <name> <signature> <state> <current mileage> orig <length> # # ... data <length> # # ... oops <length>
void process_ciMethodData(TRAPS) {
Method* method = parse_method(CHECK);
if (had_error()) return;
/* jsut copied from Method, to build interpret data*/
if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
return;

View File

@ -122,6 +122,22 @@ class MarkRefsIntoClosure: public CMSOopsInGenClosure {
}
};
class Par_MarkRefsIntoClosure: public CMSOopsInGenClosure {
private:
const MemRegion _span;
CMSBitMap* _bitMap;
protected:
DO_OOP_WORK_DEFN
public:
Par_MarkRefsIntoClosure(MemRegion span, CMSBitMap* bitMap);
virtual void do_oop(oop* p);
virtual void do_oop(narrowOop* p);
Prefetch::style prefetch_style() {
return Prefetch::do_read;
}
};
// A variant of the above used in certain kinds of CMS
// marking verification.
class MarkRefsIntoVerifyClosure: public CMSOopsInGenClosure {

View File

@ -569,6 +569,7 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen,
_restart_addr(NULL),
_overflow_list(NULL),
_stats(cmsGen),
_eden_chunk_lock(new Mutex(Mutex::leaf + 1, "CMS_eden_chunk_lock", true)),
_eden_chunk_array(NULL), // may be set in ctor body
_eden_chunk_capacity(0), // -- ditto --
_eden_chunk_index(0), // -- ditto --
@ -732,7 +733,7 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen,
assert(_eden_chunk_array != NULL || _eden_chunk_capacity == 0, "Error");
// Support for parallelizing survivor space rescan
if (CMSParallelRemarkEnabled && CMSParallelSurvivorRemarkEnabled) {
if ((CMSParallelRemarkEnabled && CMSParallelSurvivorRemarkEnabled) || CMSParallelInitialMarkEnabled) {
const size_t max_plab_samples =
((DefNewGeneration*)_young_gen)->max_survivor_size()/MinTLABSize;
@ -2137,6 +2138,39 @@ void CMSCollector::do_mark_sweep_work(bool clear_all_soft_refs,
}
void CMSCollector::print_eden_and_survivor_chunk_arrays() {
DefNewGeneration* dng = _young_gen->as_DefNewGeneration();
EdenSpace* eden_space = dng->eden();
ContiguousSpace* from_space = dng->from();
ContiguousSpace* to_space = dng->to();
// Eden
if (_eden_chunk_array != NULL) {
gclog_or_tty->print_cr("eden " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
eden_space->bottom(), eden_space->top(),
eden_space->end(), eden_space->capacity());
gclog_or_tty->print_cr("_eden_chunk_index=" SIZE_FORMAT ", "
"_eden_chunk_capacity=" SIZE_FORMAT,
_eden_chunk_index, _eden_chunk_capacity);
for (size_t i = 0; i < _eden_chunk_index; i++) {
gclog_or_tty->print_cr("_eden_chunk_array[" SIZE_FORMAT "]=" PTR_FORMAT,
i, _eden_chunk_array[i]);
}
}
// Survivor
if (_survivor_chunk_array != NULL) {
gclog_or_tty->print_cr("survivor " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
from_space->bottom(), from_space->top(),
from_space->end(), from_space->capacity());
gclog_or_tty->print_cr("_survivor_chunk_index=" SIZE_FORMAT ", "
"_survivor_chunk_capacity=" SIZE_FORMAT,
_survivor_chunk_index, _survivor_chunk_capacity);
for (size_t i = 0; i < _survivor_chunk_index; i++) {
gclog_or_tty->print_cr("_survivor_chunk_array[" SIZE_FORMAT "]=" PTR_FORMAT,
i, _survivor_chunk_array[i]);
}
}
}
void CMSCollector::getFreelistLocks() const {
// Get locks for all free lists in all generations that this
// collector is responsible for
@ -3549,6 +3583,31 @@ CMSPhaseAccounting::~CMSPhaseAccounting() {
// CMS work
// The common parts of CMSParInitialMarkTask and CMSParRemarkTask.
class CMSParMarkTask : public AbstractGangTask {
protected:
CMSCollector* _collector;
int _n_workers;
CMSParMarkTask(const char* name, CMSCollector* collector, int n_workers) :
AbstractGangTask(name),
_collector(collector),
_n_workers(n_workers) {}
// Work method in support of parallel rescan ... of young gen spaces
void do_young_space_rescan(uint worker_id, OopsInGenClosure* cl,
ContiguousSpace* space,
HeapWord** chunk_array, size_t chunk_top);
void work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl);
};
// Parallel initial mark task
class CMSParInitialMarkTask: public CMSParMarkTask {
public:
CMSParInitialMarkTask(CMSCollector* collector, int n_workers) :
CMSParMarkTask("Scan roots and young gen for initial mark in parallel",
collector, n_workers) {}
void work(uint worker_id);
};
// Checkpoint the roots into this generation from outside
// this generation. [Note this initial checkpoint need only
// be approximate -- we'll do a catch up phase subsequently.]
@ -3646,19 +3705,42 @@ void CMSCollector::checkpointRootsInitialWork(bool asynch) {
// the klasses. The claimed marks need to be cleared before marking starts.
ClassLoaderDataGraph::clear_claimed_marks();
CMKlassClosure klass_closure(&notOlder);
if (CMSPrintEdenSurvivorChunks) {
print_eden_and_survivor_chunk_arrays();
}
{
COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)
gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
gch->gen_process_strong_roots(_cmsGen->level(),
true, // younger gens are roots
true, // activate StrongRootsScope
false, // not scavenging
SharedHeap::ScanningOption(roots_scanning_options()),
&notOlder,
true, // walk all of code cache if (so & SO_CodeCache)
NULL,
&klass_closure);
if (CMSParallelInitialMarkEnabled && CollectedHeap::use_parallel_gc_threads()) {
// The parallel version.
FlexibleWorkGang* workers = gch->workers();
assert(workers != NULL, "Need parallel worker threads.");
int n_workers = workers->active_workers();
CMSParInitialMarkTask tsk(this, n_workers);
gch->set_par_threads(n_workers);
initialize_sequential_subtasks_for_young_gen_rescan(n_workers);
if (n_workers > 1) {
GenCollectedHeap::StrongRootsScope srs(gch);
workers->run_task(&tsk);
} else {
GenCollectedHeap::StrongRootsScope srs(gch);
tsk.work(0);
}
gch->set_par_threads(0);
} else {
// The serial version.
CMKlassClosure klass_closure(&notOlder);
gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
gch->gen_process_strong_roots(_cmsGen->level(),
true, // younger gens are roots
true, // activate StrongRootsScope
false, // not scavenging
SharedHeap::ScanningOption(roots_scanning_options()),
&notOlder,
true, // walk all of code cache if (so & SO_CodeCache)
NULL,
&klass_closure);
}
}
// Clear mod-union table; it will be dirtied in the prologue of
@ -4417,7 +4499,9 @@ void CMSCollector::preclean() {
verify_overflow_empty();
_abort_preclean = false;
if (CMSPrecleaningEnabled) {
_eden_chunk_index = 0;
if (!CMSEdenChunksRecordAlways) {
_eden_chunk_index = 0;
}
size_t used = get_eden_used();
size_t capacity = get_eden_capacity();
// Don't start sampling unless we will get sufficiently
@ -4526,7 +4610,9 @@ void CMSCollector::sample_eden() {
if (!_start_sampling) {
return;
}
if (_eden_chunk_array) {
// When CMSEdenChunksRecordAlways is true, the eden chunk array
// is populated by the young generation.
if (_eden_chunk_array != NULL && !CMSEdenChunksRecordAlways) {
if (_eden_chunk_index < _eden_chunk_capacity) {
_eden_chunk_array[_eden_chunk_index] = *_top_addr; // take sample
assert(_eden_chunk_array[_eden_chunk_index] <= *_end_addr,
@ -5010,6 +5096,10 @@ void CMSCollector::checkpointRootsFinalWork(bool asynch,
// Update the saved marks which may affect the root scans.
gch->save_marks();
if (CMSPrintEdenSurvivorChunks) {
print_eden_and_survivor_chunk_arrays();
}
{
COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)
@ -5116,10 +5206,53 @@ void CMSCollector::checkpointRootsFinalWork(bool asynch,
}
}
void CMSParInitialMarkTask::work(uint worker_id) {
elapsedTimer _timer;
ResourceMark rm;
HandleMark hm;
// ---------- scan from roots --------------
_timer.start();
GenCollectedHeap* gch = GenCollectedHeap::heap();
Par_MarkRefsIntoClosure par_mri_cl(_collector->_span, &(_collector->_markBitMap));
CMKlassClosure klass_closure(&par_mri_cl);
// ---------- young gen roots --------------
{
work_on_young_gen_roots(worker_id, &par_mri_cl);
_timer.stop();
if (PrintCMSStatistics != 0) {
gclog_or_tty->print_cr(
"Finished young gen initial mark scan work in %dth thread: %3.3f sec",
worker_id, _timer.seconds());
}
}
// ---------- remaining roots --------------
_timer.reset();
_timer.start();
gch->gen_process_strong_roots(_collector->_cmsGen->level(),
false, // yg was scanned above
false, // this is parallel code
false, // not scavenging
SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
&par_mri_cl,
true, // walk all of code cache if (so & SO_CodeCache)
NULL,
&klass_closure);
assert(_collector->should_unload_classes()
|| (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_CodeCache),
"if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops");
_timer.stop();
if (PrintCMSStatistics != 0) {
gclog_or_tty->print_cr(
"Finished remaining root initial mark scan work in %dth thread: %3.3f sec",
worker_id, _timer.seconds());
}
}
// Parallel remark task
class CMSParRemarkTask: public AbstractGangTask {
CMSCollector* _collector;
int _n_workers;
class CMSParRemarkTask: public CMSParMarkTask {
CompactibleFreeListSpace* _cms_space;
// The per-thread work queues, available here for stealing.
@ -5133,10 +5266,9 @@ class CMSParRemarkTask: public AbstractGangTask {
CompactibleFreeListSpace* cms_space,
int n_workers, FlexibleWorkGang* workers,
OopTaskQueueSet* task_queues):
AbstractGangTask("Rescan roots and grey objects in parallel"),
_collector(collector),
CMSParMarkTask("Rescan roots and grey objects in parallel",
collector, n_workers),
_cms_space(cms_space),
_n_workers(n_workers),
_task_queues(task_queues),
_term(n_workers, task_queues) { }
@ -5150,11 +5282,6 @@ class CMSParRemarkTask: public AbstractGangTask {
void work(uint worker_id);
private:
// Work method in support of parallel rescan ... of young gen spaces
void do_young_space_rescan(int i, Par_MarkRefsIntoAndScanClosure* cl,
ContiguousSpace* space,
HeapWord** chunk_array, size_t chunk_top);
// ... of dirty cards in old space
void do_dirty_card_rescan_tasks(CompactibleFreeListSpace* sp, int i,
Par_MarkRefsIntoAndScanClosure* cl);
@ -5186,6 +5313,25 @@ class RemarkKlassClosure : public KlassClosure {
}
};
void CMSParMarkTask::work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl) {
DefNewGeneration* dng = _collector->_young_gen->as_DefNewGeneration();
EdenSpace* eden_space = dng->eden();
ContiguousSpace* from_space = dng->from();
ContiguousSpace* to_space = dng->to();
HeapWord** eca = _collector->_eden_chunk_array;
size_t ect = _collector->_eden_chunk_index;
HeapWord** sca = _collector->_survivor_chunk_array;
size_t sct = _collector->_survivor_chunk_index;
assert(ect <= _collector->_eden_chunk_capacity, "out of bounds");
assert(sct <= _collector->_survivor_chunk_capacity, "out of bounds");
do_young_space_rescan(worker_id, cl, to_space, NULL, 0);
do_young_space_rescan(worker_id, cl, from_space, sca, sct);
do_young_space_rescan(worker_id, cl, eden_space, eca, ect);
}
// work_queue(i) is passed to the closure
// Par_MarkRefsIntoAndScanClosure. The "i" parameter
// also is passed to do_dirty_card_rescan_tasks() and to
@ -5210,23 +5356,7 @@ void CMSParRemarkTask::work(uint worker_id) {
// work first.
// ---------- young gen roots --------------
{
DefNewGeneration* dng = _collector->_young_gen->as_DefNewGeneration();
EdenSpace* eden_space = dng->eden();
ContiguousSpace* from_space = dng->from();
ContiguousSpace* to_space = dng->to();
HeapWord** eca = _collector->_eden_chunk_array;
size_t ect = _collector->_eden_chunk_index;
HeapWord** sca = _collector->_survivor_chunk_array;
size_t sct = _collector->_survivor_chunk_index;
assert(ect <= _collector->_eden_chunk_capacity, "out of bounds");
assert(sct <= _collector->_survivor_chunk_capacity, "out of bounds");
do_young_space_rescan(worker_id, &par_mrias_cl, to_space, NULL, 0);
do_young_space_rescan(worker_id, &par_mrias_cl, from_space, sca, sct);
do_young_space_rescan(worker_id, &par_mrias_cl, eden_space, eca, ect);
work_on_young_gen_roots(worker_id, &par_mrias_cl);
_timer.stop();
if (PrintCMSStatistics != 0) {
gclog_or_tty->print_cr(
@ -5334,8 +5464,8 @@ void CMSParRemarkTask::work(uint worker_id) {
// Note that parameter "i" is not used.
void
CMSParRemarkTask::do_young_space_rescan(int i,
Par_MarkRefsIntoAndScanClosure* cl, ContiguousSpace* space,
CMSParMarkTask::do_young_space_rescan(uint worker_id,
OopsInGenClosure* cl, ContiguousSpace* space,
HeapWord** chunk_array, size_t chunk_top) {
// Until all tasks completed:
// . claim an unclaimed task
@ -5530,6 +5660,32 @@ CMSParRemarkTask::do_work_steal(int i, Par_MarkRefsIntoAndScanClosure* cl,
"Else our work is not yet done");
}
// Record object boundaries in _eden_chunk_array by sampling the eden
// top in the slow-path eden object allocation code path and record
// the boundaries, if CMSEdenChunksRecordAlways is true. If
// CMSEdenChunksRecordAlways is false, we use the other asynchronous
// sampling in sample_eden() that activates during the part of the
// preclean phase.
void CMSCollector::sample_eden_chunk() {
if (CMSEdenChunksRecordAlways && _eden_chunk_array != NULL) {
if (_eden_chunk_lock->try_lock()) {
// Record a sample. This is the critical section. The contents
// of the _eden_chunk_array have to be non-decreasing in the
// address order.
_eden_chunk_array[_eden_chunk_index] = *_top_addr;
assert(_eden_chunk_array[_eden_chunk_index] <= *_end_addr,
"Unexpected state of Eden");
if (_eden_chunk_index == 0 ||
((_eden_chunk_array[_eden_chunk_index] > _eden_chunk_array[_eden_chunk_index-1]) &&
(pointer_delta(_eden_chunk_array[_eden_chunk_index],
_eden_chunk_array[_eden_chunk_index-1]) >= CMSSamplingGrain))) {
_eden_chunk_index++; // commit sample
}
_eden_chunk_lock->unlock();
}
}
}
// Return a thread-local PLAB recording array, as appropriate.
void* CMSCollector::get_data_recorder(int thr_num) {
if (_survivor_plab_array != NULL &&
@ -5553,12 +5709,13 @@ void CMSCollector::reset_survivor_plab_arrays() {
// Merge the per-thread plab arrays into the global survivor chunk
// array which will provide the partitioning of the survivor space
// for CMS rescan.
// for CMS initial scan and rescan.
void CMSCollector::merge_survivor_plab_arrays(ContiguousSpace* surv,
int no_of_gc_threads) {
assert(_survivor_plab_array != NULL, "Error");
assert(_survivor_chunk_array != NULL, "Error");
assert(_collectorState == FinalMarking, "Error");
assert(_collectorState == FinalMarking ||
(CMSParallelInitialMarkEnabled && _collectorState == InitialMarking), "Error");
for (int j = 0; j < no_of_gc_threads; j++) {
_cursor[j] = 0;
}
@ -5621,7 +5778,7 @@ void CMSCollector::merge_survivor_plab_arrays(ContiguousSpace* surv,
}
// Set up the space's par_seq_tasks structure for work claiming
// for parallel rescan of young gen.
// for parallel initial scan and rescan of young gen.
// See ParRescanTask where this is currently used.
void
CMSCollector::
@ -6748,6 +6905,28 @@ void MarkRefsIntoClosure::do_oop(oop obj) {
void MarkRefsIntoClosure::do_oop(oop* p) { MarkRefsIntoClosure::do_oop_work(p); }
void MarkRefsIntoClosure::do_oop(narrowOop* p) { MarkRefsIntoClosure::do_oop_work(p); }
Par_MarkRefsIntoClosure::Par_MarkRefsIntoClosure(
MemRegion span, CMSBitMap* bitMap):
_span(span),
_bitMap(bitMap)
{
assert(_ref_processor == NULL, "deliberately left NULL");
assert(_bitMap->covers(_span), "_bitMap/_span mismatch");
}
void Par_MarkRefsIntoClosure::do_oop(oop obj) {
// if p points into _span, then mark corresponding bit in _markBitMap
assert(obj->is_oop(), "expected an oop");
HeapWord* addr = (HeapWord*)obj;
if (_span.contains(addr)) {
// this should be made more efficient
_bitMap->par_mark(addr);
}
}
void Par_MarkRefsIntoClosure::do_oop(oop* p) { Par_MarkRefsIntoClosure::do_oop_work(p); }
void Par_MarkRefsIntoClosure::do_oop(narrowOop* p) { Par_MarkRefsIntoClosure::do_oop_work(p); }
// A variant of the above, used for CMS marking verification.
MarkRefsIntoVerifyClosure::MarkRefsIntoVerifyClosure(
MemRegion span, CMSBitMap* verification_bm, CMSBitMap* cms_bm):
@ -9305,7 +9484,6 @@ void ASConcurrentMarkSweepGeneration::shrink_by(size_t desired_bytes) {
return;
}
}
// Transfer some number of overflown objects to usual marking
// stack. Return true if some objects were transferred.
bool MarkRefsIntoAndScanClosure::take_from_overflow_list() {
@ -9377,4 +9555,3 @@ TraceCMSMemoryManagerStats::TraceCMSMemoryManagerStats(CMSCollector::CollectorSt
ShouldNotReachHere();
}
}

View File

@ -515,6 +515,8 @@ class CMSCollector: public CHeapObj<mtGC> {
friend class ConcurrentMarkSweepThread;
friend class ConcurrentMarkSweepGeneration;
friend class CompactibleFreeListSpace;
friend class CMSParMarkTask;
friend class CMSParInitialMarkTask;
friend class CMSParRemarkTask;
friend class CMSConcMarkingTask;
friend class CMSRefProcTaskProxy;
@ -749,6 +751,7 @@ class CMSCollector: public CHeapObj<mtGC> {
Generation* _young_gen; // the younger gen
HeapWord** _top_addr; // ... Top of Eden
HeapWord** _end_addr; // ... End of Eden
Mutex* _eden_chunk_lock;
HeapWord** _eden_chunk_array; // ... Eden partitioning array
size_t _eden_chunk_index; // ... top (exclusive) of array
size_t _eden_chunk_capacity; // ... max entries in array
@ -950,6 +953,7 @@ class CMSCollector: public CHeapObj<mtGC> {
// Support for parallel remark of survivor space
void* get_data_recorder(int thr_num);
void sample_eden_chunk();
CMSBitMap* markBitMap() { return &_markBitMap; }
void directAllocated(HeapWord* start, size_t size);
@ -1027,6 +1031,8 @@ class CMSCollector: public CHeapObj<mtGC> {
// Initialization errors
bool completed_initialization() { return _completed_initialization; }
void print_eden_and_survivor_chunk_arrays();
};
class CMSExpansionCause : public AllStatic {
@ -1317,6 +1323,10 @@ class ConcurrentMarkSweepGeneration: public CardGeneration {
//Delegate to collector
return collector()->get_data_recorder(thr_num);
}
void sample_eden_chunk() {
//Delegate to collector
return collector()->sample_eden_chunk();
}
// Printing
const char* name() const;

View File

@ -96,11 +96,6 @@
"the buffer will be enqueued for processing. A value of 0 " \
"specifies that mutator threads should not do such filtering.") \
\
develop(intx, G1ExtraRegionSurvRate, 33, \
"If the young survival rate is S, and there's room left in " \
"to-space, we will allow regions whose survival rate is up to " \
"S + (1 - S)*X, where X is this parameter (as a fraction.)") \
\
develop(bool, G1SATBPrintStubs, false, \
"If true, print generated stubs for the SATB barrier") \
\
@ -110,9 +105,6 @@
develop(bool, G1RSBarrierRegionFilter, true, \
"If true, generate region filtering code in RS barrier") \
\
develop(bool, G1RSBarrierNullFilter, true, \
"If true, generate null-pointer filtering code in RS barrier") \
\
develop(bool, G1DeferredRSUpdate, true, \
"If true, use deferred RS updates") \
\
@ -120,9 +112,6 @@
"If true, verify that no dirty cards remain after RS log " \
"processing.") \
\
develop(bool, G1RSCountHisto, false, \
"If true, print a histogram of RS occupancies after each pause") \
\
diagnostic(bool, G1PrintRegionLivenessInfo, false, \
"Prints the liveness information for all regions in the heap " \
"at the end of a marking cycle.") \
@ -169,9 +158,6 @@
product(uintx, G1ConcRSHotCardLimit, 4, \
"The threshold that defines (>=) a hot card.") \
\
develop(bool, G1PrintOopAppls, false, \
"When true, print applications of closures to external locs.") \
\
develop(intx, G1RSetRegionEntriesBase, 256, \
"Max number of regions in a fine-grain table per MB.") \
\

View File

@ -314,6 +314,11 @@ void HeapRegion::setup_heap_region_size(uintx min_heap_size) {
region_size = MAX_REGION_SIZE;
}
if (region_size != G1HeapRegionSize) {
// Update the flag to make sure that PrintFlagsFinal logs the correct value
FLAG_SET_ERGO(uintx, G1HeapRegionSize, region_size);
}
// And recalculate the log.
region_size_log = log2_long((jlong) region_size);

View File

@ -1033,6 +1033,9 @@ HeapWord* DefNewGeneration::allocate(size_t word_size,
// have to use it here, as well.
HeapWord* result = eden()->par_allocate(word_size);
if (result != NULL) {
if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
_next_gen->sample_eden_chunk();
}
return result;
}
do {
@ -1063,13 +1066,19 @@ HeapWord* DefNewGeneration::allocate(size_t word_size,
// circular dependency at compile time.
if (result == NULL) {
result = allocate_from_space(word_size);
} else if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
_next_gen->sample_eden_chunk();
}
return result;
}
HeapWord* DefNewGeneration::par_allocate(size_t word_size,
bool is_tlab) {
return eden()->par_allocate(word_size);
HeapWord* res = eden()->par_allocate(word_size);
if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
_next_gen->sample_eden_chunk();
}
return res;
}
void DefNewGeneration::gc_prologue(bool full) {

View File

@ -455,6 +455,7 @@ class Generation: public CHeapObj<mtGC> {
// expected to be GC worker thread-local, with the worker index
// indicated by "thr_num".
virtual void* get_data_recorder(int thr_num) { return NULL; }
virtual void sample_eden_chunk() {}
// Some generations may require some cleanup actions before allowing
// a verification.

View File

@ -2254,10 +2254,11 @@ ChunkIndex ChunkManager::list_index(size_t size) {
void SpaceManager::deallocate(MetaWord* p, size_t word_size) {
assert_lock_strong(_lock);
size_t raw_word_size = get_raw_word_size(word_size);
size_t min_size = TreeChunk<Metablock, FreeList>::min_size();
assert(word_size >= min_size,
assert(raw_word_size >= min_size,
err_msg("Should not deallocate dark matter " SIZE_FORMAT, word_size));
block_freelists()->return_block(p, word_size);
block_freelists()->return_block(p, raw_word_size);
}
// Adds a chunk to the list of chunks in use.

View File

@ -65,7 +65,8 @@ SharedHeap::SharedHeap(CollectorPolicy* policy_) :
}
_sh = this; // ch is static, should be set only once.
if ((UseParNewGC ||
(UseConcMarkSweepGC && CMSParallelRemarkEnabled) ||
(UseConcMarkSweepGC && (CMSParallelInitialMarkEnabled ||
CMSParallelRemarkEnabled)) ||
UseG1GC) &&
ParallelGCThreads > 0) {
_workers = new FlexibleWorkGang("Parallel GC Threads", ParallelGCThreads,

View File

@ -1891,6 +1891,10 @@ void Arguments::check_deprecated_gc_flags() {
warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
"and will likely be removed in future release");
}
if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) {
warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. "
"Use MaxRAMFraction instead.");
}
}
// Check stack pages settings

View File

@ -1689,6 +1689,9 @@ class CommandLineFlags {
product(bool, CMSAbortSemantics, false, \
"Whether abort-on-overflow semantics is implemented") \
\
product(bool, CMSParallelInitialMarkEnabled, true, \
"Use the parallel initial mark.") \
\
product(bool, CMSParallelRemarkEnabled, true, \
"Whether parallel remark enabled (only if ParNewGC)") \
\
@ -1700,6 +1703,14 @@ class CommandLineFlags {
"Whether to always record survivor space PLAB bdries" \
" (effective only if CMSParallelSurvivorRemarkEnabled)") \
\
product(bool, CMSEdenChunksRecordAlways, true, \
"Whether to always record eden chunks used for " \
"the parallel initial mark or remark of eden" ) \
\
product(bool, CMSPrintEdenSurvivorChunks, false, \
"Print the eden and the survivor chunks used for the parallel " \
"initial mark or remark of the eden/survivor spaces") \
\
product(bool, CMSConcurrentMTEnabled, true, \
"Whether multi-threaded concurrent work enabled (if ParNewGC)") \
\

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test TestG1HeapRegionSize
* @key gc
* @bug 8021879
* @summary Verify that the flag G1HeapRegionSize is updated properly
* @run main/othervm -Xmx64m TestG1HeapRegionSize 1048576
* @run main/othervm -XX:G1HeapRegionSize=2m -Xmx64m TestG1HeapRegionSize 2097152
* @run main/othervm -XX:G1HeapRegionSize=3m -Xmx64m TestG1HeapRegionSize 2097152
* @run main/othervm -XX:G1HeapRegionSize=64m -Xmx256m TestG1HeapRegionSize 33554432
*/
import sun.management.ManagementFactoryHelper;
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
public class TestG1HeapRegionSize {
public static void main(String[] args) {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
VMOption option = diagnostic.getVMOption("UseG1GC");
if (option.getValue().equals("false")) {
System.out.println("Skipping this test. It is only a G1 test.");
return;
}
String expectedValue = getExpectedValue(args);
option = diagnostic.getVMOption("G1HeapRegionSize");
if (!expectedValue.equals(option.getValue())) {
throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
}
}
private static String getExpectedValue(String[] args) {
if (args.length != 1) {
throw new RuntimeException("Wrong number of arguments. Expected 1 but got " + args.length);
}
return args[0];
}
}

View File

@ -27,7 +27,7 @@
* @bug 8014240
* @summary Test output of G1PrintRegionRememberedSetInfo
* @library /testlibrary
* @build TestPrintRegionRememberedSetInfo
* @run main TestPrintRegionRememberedSetInfo
* @author thomas.schatzl@oracle.com
*/

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test TestDefaultMaxRAMFraction
* @key gc
* @bug 8021967
* @summary Test that the deprecated TestDefaultMaxRAMFraction flag print a warning message
* @library /testlibrary
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
import com.oracle.java.testlibrary.ProcessTools;
public class TestDefaultMaxRAMFraction {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:DefaultMaxRAMFraction=4", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("warning: DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. Use MaxRAMFraction instead.");
output.shouldNotContain("error");
output.shouldHaveExitValue(0);
}
}

View File

@ -3,6 +3,7 @@
##
## @test Test6929067.sh
## @bug 6929067
## @bug 8021296
## @summary Stack guard pages should be removed when thread is detached
## @compile T.java
## @run shell Test6929067.sh
@ -21,6 +22,11 @@ echo "TESTSRC=${TESTSRC}"
OS=`uname -s`
case "$OS" in
Linux)
gcc_cmd=`which gcc`
if [ "x$gcc_cmd" == "x" ]; then
echo "WARNING: gcc not found. Cannot execute test." 2>&1
exit 0;
fi
NULL=/dev/null
PS=":"
FS="/"
@ -119,10 +125,10 @@ echo "VM type: ${VMTYPE}"
# Check to ensure you have a /usr/lib/libpthread.so if you don't please look
# for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation.
gcc -DLINUX ${COMP_FLAG} -o invoke \
-I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
-L${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE} \
-ljvm -lpthread invoke.c
$gcc_cmd -DLINUX ${COMP_FLAG} -o invoke \
-I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
-L${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE} \
-ljvm -lpthread invoke.c
./invoke
exit $?

View File

@ -27,6 +27,7 @@
##
## @test Test7107135.sh
## @bug 7107135
## @bug 8021296
## @summary Stack guard pages lost after loading library with executable stack.
## @run shell Test7107135.sh
##
@ -45,6 +46,11 @@ OS=`uname -s`
case "$OS" in
Linux)
echo "Testing on Linux"
gcc_cmd=`which gcc`
if [ "x$gcc_cmd" == "x" ]; then
echo "WARNING: gcc not found. Cannot execute test." 2>&1
exit 0;
fi
;;
*)
NULL=NUL
@ -62,7 +68,10 @@ THIS_DIR=.
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
${TESTJAVA}${FS}bin${FS}javac *.java
gcc -fPIC -shared -c -o test.o -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux ${TESTSRC}${FS}test.c
$gcc_cmd -fPIC -shared -c -o test.o \
-I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
${TESTSRC}${FS}test.c
ld -shared -z execstack -o libtest-rwx.so test.o
ld -shared -z noexecstack -o libtest-rw.so test.o

View File

@ -27,6 +27,7 @@
## @test Test8017498.sh
## @bug 8017498
## @bug 8020791
## @bug 8021296
## @summary sigaction(sig) results in process hang/timed-out if sig is much greater than SIGRTMAX
## @run shell/timeout=30 Test8017498.sh
##
@ -45,6 +46,11 @@ OS=`uname -s`
case "$OS" in
Linux)
echo "Testing on Linux"
gcc_cmd=`which gcc`
if [ "x$gcc_cmd" == "x" ]; then
echo "WARNING: gcc not found. Cannot execute test." 2>&1
exit 0;
fi
if [ "$VM_BITS" = "64" ]
then
MY_LD_PRELOAD=${TESTJAVA}${FS}jre${FS}lib${FS}amd64${FS}libjsig.so
@ -64,15 +70,11 @@ THIS_DIR=.
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
${TESTJAVA}${FS}bin${FS}javac *.java
gcc -DLINUX -fPIC -shared \
$gcc_cmd -DLINUX -fPIC -shared \
-o ${TESTSRC}${FS}libTestJNI.so \
-I${TESTJAVA}${FS}include \
-I${TESTJAVA}${FS}include${FS}linux \
${TESTSRC}${FS}TestJNI.c
if [ $? != 0 ]
then
echo "WARNING: the gcc command failed." 2>&1
fi
# run the java test in the background
cmd="LD_PRELOAD=$MY_LD_PRELOAD \

View File

@ -21,7 +21,6 @@
* questions.
*/
#define _GNU_SOURCE // for the definition of REG_RIP in ucontext.h
#include <stdio.h>
#include <jni.h>
#include <signal.h>
@ -32,11 +31,8 @@ extern "C" {
#endif
void sig_handler(int sig, siginfo_t *info, ucontext_t *context) {
int thrNum;
printf( " HANDLER (1) " );
// Move forward RIP to skip failing instruction
context->uc_mcontext.gregs[REG_RIP] += 6;
}
JNIEXPORT void JNICALL Java_TestJNI_doSomething(JNIEnv *env, jclass klass, jint val) {

View File

@ -222,3 +222,4 @@ b8c5f4b6f0fffb44618fc609a584953c4ed67c0b jdk8-b95
15e5bb51bc0cd89304dc2f7f29b4c8002e632353 jdk8-b98
adf49c3ef83c160d53ece623049b2cdccaf78fc7 jdk8-b99
5d1974c1d7b9a86431bc253dc5a6a52d4586622e jdk8-b100
0a7432f898e579ea35e8c51e3edab37f949168e4 jdk8-b101

View File

@ -112,7 +112,7 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
/** Initial EntityResolver */
private final EntityResolver fInitEntityResolver;
private XMLSecurityPropertyManager fSecurityPropertyMgr;
private final XMLSecurityPropertyManager fSecurityPropertyMgr;
/**
* Create a SAX parser with the associated features
@ -130,8 +130,10 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
SAXParserImpl(SAXParserFactoryImpl spf, Hashtable features, boolean secureProcessing)
throws SAXException
{
fSecurityPropertyMgr = new XMLSecurityPropertyManager();
// Instantiate a SAXParser directly and not through SAX so that we use the right ClassLoader
xmlReader = new JAXPSAXParser(this);
xmlReader = new JAXPSAXParser(this, fSecurityPropertyMgr);
// JAXP "namespaceAware" == SAX Namespaces feature
// Note: there is a compatibility problem here with default values:
@ -150,7 +152,6 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
xmlReader.setFeature0(XINCLUDE_FEATURE, true);
}
fSecurityPropertyMgr = new XMLSecurityPropertyManager();
xmlReader.setProperty0(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
// If the secure processing feature is on set a security manager.
@ -397,14 +398,30 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
private final HashMap fInitFeatures = new HashMap();
private final HashMap fInitProperties = new HashMap();
private final SAXParserImpl fSAXParser;
private XMLSecurityPropertyManager fSecurityPropertyMgr;
public JAXPSAXParser() {
this(null);
this(null, null);
}
JAXPSAXParser(SAXParserImpl saxParser) {
JAXPSAXParser(SAXParserImpl saxParser, XMLSecurityPropertyManager spm) {
super();
fSAXParser = saxParser;
fSecurityPropertyMgr = spm;
/**
* This class may be used directly. So initialize the security manager if
* it is null.
*/
if (fSecurityPropertyMgr == null) {
fSecurityPropertyMgr = new XMLSecurityPropertyManager();
try {
super.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
} catch (Exception ex) {
//shall not happen
}
}
}
/**
@ -542,9 +559,9 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
setSchemaValidatorProperty(name, value);
}
/** Check to see if the property is managed by the property manager **/
int index = fSAXParser.fSecurityPropertyMgr.getIndex(name);
int index = (fSecurityPropertyMgr != null) ? fSecurityPropertyMgr.getIndex(name) : -1;
if (index > -1) {
fSAXParser.fSecurityPropertyMgr.setValue(index,
fSecurityPropertyMgr.setValue(index,
XMLSecurityPropertyManager.State.APIPROPERTY, (String)value);
} else {
if (!fInitProperties.containsKey(name)) {
@ -564,9 +581,9 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
// JAXP 1.2 support
return fSAXParser.schemaLanguage;
}
int index = fSAXParser.fSecurityPropertyMgr.getIndex(name);
int index = (fSecurityPropertyMgr != null) ? fSecurityPropertyMgr.getIndex(name) : -1;
if (index > -1) {
return fSAXParser.fSecurityPropertyMgr.getValueByIndex(index);
return fSecurityPropertyMgr.getValueByIndex(index);
}
return super.getProperty(name);

View File

@ -222,3 +222,4 @@ dcde7f049111353ad23175f54985a4f6bfea720c jdk8-b97
b1fb4612a2caea52b5661b87509e560fa044b194 jdk8-b98
8ef83d4b23c933935e28f59b282cea920b1b1f5f jdk8-b99
4fd722afae5c02f00bbd44c3a34425ee474afb1c jdk8-b100
60b623a361642a0f5aef5f06dad9e5f279b9d9a9 jdk8-b101

View File

@ -222,3 +222,4 @@ a2a2a91075ad85becbe10a39d7fd04ef9bea8df5 jdk8-b92
c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98
6a099a36589bd933957272ba63e5263bede29971 jdk8-b99
5be9c5bfcfe9b2a40412b4fb364377d49de014eb jdk8-b100
6901612328239fbd471d20823113c1cf3fdaebee jdk8-b101

View File

@ -31,6 +31,7 @@ import java.awt.peer.MenuComponentPeer;
import javax.swing.*;
import javax.swing.plaf.MenuBarUI;
import com.apple.laf.ScreenMenuBar;
import sun.lwawt.macosx.CMenuBar;
import com.apple.laf.AquaMenuBarUI;
@ -72,12 +73,15 @@ class _AppMenuBarHandler {
// scan the current frames, and see if any are foreground
final Frame[] frames = Frame.getFrames();
for (final Frame frame : frames) {
if (frame.isVisible() && !isFrameMinimized(frame)) return;
if (frame.isVisible() && !isFrameMinimized(frame)) {
return;
}
}
// if we have no foreground frames, then we have to "kick" the menubar
final JFrame pingFrame = new JFrame();
pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
pingFrame.setUndecorated(true);
pingFrame.setVisible(true);
pingFrame.toFront();
pingFrame.setVisible(false);
@ -101,7 +105,6 @@ class _AppMenuBarHandler {
// Aqua was not installed
throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel");
}
/* TODO: disabled until ScreenMenuBar is working
final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
final ScreenMenuBar screenMenuBar = aquaUI.getScreenMenuBar();
@ -118,8 +121,7 @@ class _AppMenuBarHandler {
}
// grab the pointer to the CMenuBar, and retain it in native
nativeSetDefaultMenuBar(((CMenuBar)peer).getNativeMenuBarPeer());
*/
nativeSetDefaultMenuBar(((CMenuBar)peer).getModel());
}
void setAboutMenuItemVisible(final boolean present) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import java.util.*;
import sun.awt.SunHints;
public class CStrike extends FontStrike {
public final class CStrike extends FontStrike {
// Creates the native strike
private static native long createNativeStrikePtr(long nativeFontPtr,
@ -68,10 +68,10 @@ public class CStrike extends FontStrike {
Rectangle2D.Float result,
double x, double y);
private CFont nativeFont;
private final CFont nativeFont;
private AffineTransform invDevTx;
private GlyphInfoCache glyphInfoCache;
private GlyphAdvanceCache glyphAdvanceCache;
private final GlyphInfoCache glyphInfoCache;
private final GlyphAdvanceCache glyphAdvanceCache;
private long nativeStrikePtr;
CStrike(final CFont font, final FontStrikeDesc inDesc) {
@ -84,11 +84,11 @@ public class CStrike extends FontStrike {
// Normally the device transform should be the identity transform
// for screen operations. The device transform only becomes
// interesting when we are outputting between different dpi surfaces,
// like when we are printing to postscript.
// like when we are printing to postscript or use retina.
if (inDesc.devTx != null && !inDesc.devTx.isIdentity()) {
try {
invDevTx = inDesc.devTx.createInverse();
} catch (NoninvertibleTransformException e) {
} catch (NoninvertibleTransformException ignored) {
// ignored, since device transforms should not be that
// complicated, and if they are - there is nothing we can do,
// so we won't worry about it.
@ -134,15 +134,13 @@ public class CStrike extends FontStrike {
nativeStrikePtr = 0;
}
// the fractional metrics default on our platform is OFF
private boolean useFractionalMetrics() {
return desc.fmHint == SunHints.INTVAL_FRACTIONALMETRICS_ON;
}
@Override
public int getNumGlyphs() {
return nativeFont.getNumGlyphs();
}
@Override
StrikeMetrics getFontMetrics() {
if (strikeMetrics == null) {
StrikeMetrics metrics = getFontMetrics(getNativeStrikePtr());
@ -155,74 +153,24 @@ public class CStrike extends FontStrike {
return strikeMetrics;
}
float getGlyphAdvance(int glyphCode) {
return getScaledAdvanceForAdvance(getCachedNativeGlyphAdvance(glyphCode));
@Override
float getGlyphAdvance(final int glyphCode) {
return getCachedNativeGlyphAdvance(glyphCode);
}
float getCodePointAdvance(int cp) {
float advance = getCachedNativeGlyphAdvance(nativeFont.getMapper().charToGlyph(cp));
double glyphScaleX = desc.glyphTx.getScaleX();
double devScaleX = desc.devTx.getScaleX();
if (devScaleX == 0) {
glyphScaleX = Math.sqrt(desc.glyphTx.getDeterminant());
devScaleX = Math.sqrt(desc.devTx.getDeterminant());
}
if (devScaleX == 0) {
devScaleX = Double.NaN; // this an undefined graphics state
}
advance = (float) (advance * glyphScaleX / devScaleX);
return useFractionalMetrics() ? advance : Math.round(advance);
@Override
float getCodePointAdvance(final int cp) {
return getGlyphAdvance(nativeFont.getMapper().charToGlyph(cp));
}
// calculate an advance, and round if not using fractional metrics
private float getScaledAdvanceForAdvance(float advance) {
if (invDevTx != null) {
advance *= invDevTx.getScaleX();
}
advance *= desc.glyphTx.getScaleX();
return useFractionalMetrics() ? advance : Math.round(advance);
@Override
Point2D.Float getCharMetrics(final char ch) {
return getGlyphMetrics(nativeFont.getMapper().charToGlyph(ch));
}
Point2D.Float getCharMetrics(char ch) {
return getScaledPointForAdvance(getCachedNativeGlyphAdvance(nativeFont.getMapper().charToGlyph(ch)));
}
Point2D.Float getGlyphMetrics(int glyphCode) {
return getScaledPointForAdvance(getCachedNativeGlyphAdvance(glyphCode));
}
// calculate an advance point, and round if not using fractional metrics
private Point2D.Float getScaledPointForAdvance(float advance) {
Point2D.Float pt = new Point2D.Float(advance, 0);
if (!desc.glyphTx.isIdentity()) {
return scalePoint(pt);
}
if (!useFractionalMetrics()) {
pt.x = Math.round(pt.x);
}
return pt;
}
private Point2D.Float scalePoint(Point2D.Float pt) {
if (invDevTx != null) {
// transform the point out of the device space first
invDevTx.transform(pt, pt);
}
desc.glyphTx.transform(pt, pt);
pt.x -= desc.glyphTx.getTranslateX();
pt.y -= desc.glyphTx.getTranslateY();
if (!useFractionalMetrics()) {
pt.x = Math.round(pt.x);
pt.y = Math.round(pt.y);
}
return pt;
@Override
Point2D.Float getGlyphMetrics(final int glyphCode) {
return new Point2D.Float(getGlyphAdvance(glyphCode), 0.0f);
}
Rectangle2D.Float getGlyphOutlineBounds(int glyphCode) {
@ -414,9 +362,7 @@ public class CStrike extends FontStrike {
private SparseBitShiftingTwoLayerArray secondLayerCache;
private HashMap<Integer, Long> generalCache;
public GlyphInfoCache(final Font2D nativeFont,
final FontStrikeDesc desc)
{
GlyphInfoCache(final Font2D nativeFont, final FontStrikeDesc desc) {
super(nativeFont, desc);
firstLayerCache = new long[FIRST_LAYER_SIZE];
}
@ -527,7 +473,7 @@ public class CStrike extends FontStrike {
final int shift;
final int secondLayerLength;
public SparseBitShiftingTwoLayerArray(final int size, final int shift) {
SparseBitShiftingTwoLayerArray(final int size, final int shift) {
this.shift = shift;
this.cache = new long[1 << shift][];
this.secondLayerLength = size >> shift;
@ -559,6 +505,12 @@ public class CStrike extends FontStrike {
private SparseBitShiftingTwoLayerArray secondLayerCache;
private HashMap<Integer, Float> generalCache;
// Empty non private constructor was added because access to this
// class shouldn't be emulated by a synthetic accessor method.
GlyphAdvanceCache() {
super();
}
public synchronized float get(final int index) {
if (index < 0) {
if (-index < SECOND_LAYER_SIZE) {
@ -609,9 +561,7 @@ public class CStrike extends FontStrike {
final int shift;
final int secondLayerLength;
public SparseBitShiftingTwoLayerArray(final int size,
final int shift)
{
SparseBitShiftingTwoLayerArray(final int size, final int shift) {
this.shift = shift;
this.cache = new float[1 << shift][];
this.secondLayerLength = size >> shift;

View File

@ -182,7 +182,11 @@ public class CDataTransferer extends DataTransferer {
Long format = predefinedClipboardNameMap.get(str);
if (format == null) {
format = new Long(registerFormatWithPasteboard(str));
if (java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
// Do not try to access native system for the unknown format
return -1L;
}
format = registerFormatWithPasteboard(str);
predefinedClipboardNameMap.put(str, format);
predefinedClipboardFormatMap.put(format, str);
}

View File

@ -43,7 +43,7 @@ public abstract class CMenuComponent implements MenuComponentPeer {
return target;
}
long getModel() {
public long getModel() {
return modelPtr;
}

View File

@ -47,7 +47,7 @@ import com.apple.laf.ClientPropertyApplicator.Property;
import com.sun.awt.AWTUtilities;
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
@ -230,7 +230,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
contentView = createContentView();
contentView.initialize(peer, responder);
final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), styleBits, 0, 0, 0, 0);
final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L;
final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), ownerPtr, styleBits, 0, 0, 0, 0);
setPtr(nativeWindowPtr);
if (target instanceof javax.swing.RootPaneContainer) {

View File

@ -44,6 +44,7 @@
jint styleBits;
BOOL isEnabled;
NSWindow *nsWindow;
AWTWindow *ownerWindow;
}
// An instance of either AWTWindow_Normal or AWTWindow_Panel
@ -51,12 +52,15 @@
@property (nonatomic, retain) JNFWeakJObjectWrapper *javaPlatformWindow;
@property (nonatomic, retain) CMenuBar *javaMenuBar;
@property (nonatomic, retain) AWTWindow *ownerWindow;
@property (nonatomic) NSSize javaMinSize;
@property (nonatomic) NSSize javaMaxSize;
@property (nonatomic) jint styleBits;
@property (nonatomic) BOOL isEnabled;
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow
ownerWindow:owner
styleBits:(jint)styleBits
frameRect:(NSRect)frameRect
contentView:(NSView *)contentView;

View File

@ -30,6 +30,7 @@
#import "sun_lwawt_macosx_CPlatformWindow.h"
#import "com_apple_eawt_event_GestureHandler.h"
#import "com_apple_eawt_FullScreenHandler.h"
#import "ApplicationDelegate.h"
#import "AWTWindow.h"
#import "AWTView.h"
@ -55,7 +56,7 @@ static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow");
// doesn't provide information about "opposite" window, so we
// have to do a bit of tracking. This variable points to a window
// which had been the key window just before a new key window
// was set. It would be nil if the new key window isn't an AWT
// was set. It would be nil if the new key window isn't an AWT
// window or the app currently has no key window.
static AWTWindow* lastKeyWindow = nil;
@ -120,6 +121,7 @@ AWT_NS_WINDOW_IMPLEMENTATION
@synthesize javaMaxSize;
@synthesize styleBits;
@synthesize isEnabled;
@synthesize ownerWindow;
- (void) updateMinMaxSize:(BOOL)resizable {
if (resizable) {
@ -201,6 +203,7 @@ AWT_NS_WINDOW_IMPLEMENTATION
}
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
ownerWindow:owner
styleBits:(jint)bits
frameRect:(NSRect)rect
contentView:(NSView *)view
@ -245,6 +248,7 @@ AWT_ASSERT_APPKIT_THREAD;
self.isEnabled = YES;
self.javaPlatformWindow = platformWindow;
self.styleBits = bits;
self.ownerWindow = owner;
[self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
return self;
@ -350,7 +354,7 @@ AWT_ASSERT_APPKIT_THREAD;
[self.javaPlatformWindow setJObject:nil withEnv:env];
self.nsWindow = nil;
self.ownerWindow = nil;
[super dealloc];
}
@ -539,11 +543,27 @@ AWT_ASSERT_APPKIT_THREAD;
AWT_ASSERT_APPKIT_THREAD;
[AWTToolkit eventCountPlusPlus];
AWTWindow *opposite = [AWTWindow lastKeyWindow];
if (!IS(self.styleBits, IS_DIALOG)) {
[CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
} else if ((opposite != NULL) && IS(self.styleBits, IS_MODAL)) {
[CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES];
// Finds appropriate menubar in our hierarchy,
AWTWindow *awtWindow = self;
while (awtWindow.ownerWindow != nil) {
awtWindow = awtWindow.ownerWindow;
}
CMenuBar *menuBar = nil;
BOOL isDisabled = NO;
if ([awtWindow.nsWindow isVisible]){
menuBar = awtWindow.javaMenuBar;
isDisabled = !awtWindow.isEnabled;
}
if (menuBar == nil) {
menuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
isDisabled = NO;
}
[CMenuBar activate:menuBar modallyDisabled:isDisabled];
[AWTWindow setLastKeyWindow:nil];
[self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
@ -555,6 +575,14 @@ AWT_ASSERT_APPKIT_THREAD;
[AWTToolkit eventCountPlusPlus];
[self.javaMenuBar deactivate];
// In theory, this might cause flickering if the window gaining focus
// has its own menu. However, I couldn't reproduce it on practice, so
// perhaps this is a non issue.
CMenuBar* defaultMenu = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
if (defaultMenu != nil) {
[CMenuBar activate:defaultMenu modallyDisabled:NO];
}
// the new key window
NSWindow *keyWindow = [NSApp keyWindow];
AWTWindow *opposite = nil;
@ -741,7 +769,7 @@ AWT_ASSERT_APPKIT_THREAD;
* Signature: (JJIIII)J
*/
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCreateNSWindow
(JNIEnv *env, jobject obj, jlong contentViewPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h)
(JNIEnv *env, jobject obj, jlong contentViewPtr, jlong ownerPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h)
{
__block AWTWindow *window = nil;
@ -750,13 +778,14 @@ JNF_COCOA_ENTER(env);
JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env];
NSView *contentView = OBJC(contentViewPtr);
NSRect frameRect = NSMakeRect(x, y, w, h);
AWTWindow *owner = [OBJC(ownerPtr) delegate];
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow
styleBits:styleBits
frameRect:frameRect
contentView:contentView];
ownerWindow:owner
styleBits:styleBits
frameRect:frameRect
contentView:contentView];
// the window is released is CPlatformWindow.nativeDispose()
if (window) CFRetain(window.nsWindow);
@ -818,11 +847,19 @@ JNF_COCOA_ENTER(env);
AWTWindow *window = (AWTWindow*)[nsWindow delegate];
if ([nsWindow isKeyWindow]) [window.javaMenuBar deactivate];
if ([nsWindow isKeyWindow]) {
[window.javaMenuBar deactivate];
}
window.javaMenuBar = menuBar;
CMenuBar* actualMenuBar = menuBar;
if (actualMenuBar == nil) {
actualMenuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
}
if ([nsWindow isKeyWindow]) {
[CMenuBar activate:window.javaMenuBar modallyDisabled:NO];
[CMenuBar activate:actualMenuBar modallyDisabled:NO];
}
}];

View File

@ -63,7 +63,7 @@ static BOOL sSetupHelpMenu = NO;
if (excludingAppleMenu && ![currMenu isJavaMenu]) {
continue;
}
[currItem setSubmenu:nil];
[theMainMenu removeItemAtIndex:index];
}
@ -154,7 +154,10 @@ static BOOL sSetupHelpMenu = NO;
// Clean up extra items
NSUInteger removedIndex, removedCount = [removedMenuArray count];
for (removedIndex=removedCount; removedIndex > 0; removedIndex--) {
[theMainMenu removeItemAtIndex:[[removedMenuArray objectAtIndex:(removedIndex-1)] integerValue]];
NSUInteger index = [[removedMenuArray objectAtIndex:(removedIndex-1)] integerValue];
NSMenuItem *currItem = [theMainMenu itemAtIndex:index];
[currItem setSubmenu:nil];
[theMainMenu removeItemAtIndex:index];
}
i = cmenuIndex;

View File

@ -70,9 +70,15 @@ AWT_ASSERT_APPKIT_THREAD;
JNIEnv *env = [ThreadUtilities getJNIEnv];
JNF_COCOA_ENTER(env);
// If we are called as a result of user pressing a shorcut, do nothing,
// If we are called as a result of user pressing a shortcut, do nothing,
// because AVTView has already sent corresponding key event to the Java
// layer from performKeyEquivalent
// layer from performKeyEquivalent.
// There is an exception from the rule above, though: if a window with
// a menu gets minimized by user and there are no other windows to take
// focus, the window's menu won't be removed from the global menu bar.
// However, the Java layer won't handle invocation by a shortcut coming
// from this "frameless" menu, because there are no active windows. This
// means we have to handle it here.
NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
if ([currEvent type] == NSKeyDown) {
NSString *menuKey = [sender keyEquivalent];
@ -91,7 +97,8 @@ JNF_COCOA_ENTER(env);
eventKey = [NSString stringWithCharacters: &newChar length: 1];
}
if ([menuKey isEqualToString:eventKey]) {
NSWindow *keyWindow = [NSApp keyWindow];
if ([menuKey isEqualToString:eventKey] && keyWindow != nil) {
return;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,11 +31,12 @@
@interface AWTStrike : NSObject {
@public
AWTFont * fAWTFont;
CGFloat fSize;
CGFloat fSize;
JRSFontRenderingStyle fStyle;
jint fAAStyle;
jint fAAStyle;
CGAffineTransform fTx;
CGAffineTransform fDevTx;
CGAffineTransform fAltTx; // alternate strike tx used for Sun2D
CGAffineTransform fFontTx;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -65,6 +65,7 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
invDevTx.b *= -1;
invDevTx.c *= -1;
fFontTx = CGAffineTransformConcat(CGAffineTransformConcat(tx, invDevTx), sInverseTX);
fDevTx = CGAffineTransformInvert(invDevTx);
// the "font size" is the square root of the determinant of the matrix
fSize = sqrt(abs(fFontTx.a * fFontTx.d - fFontTx.b * fFontTx.c));
@ -148,7 +149,8 @@ Java_sun_font_CStrike_getNativeGlyphAdvance
{
CGSize advance;
JNF_COCOA_ENTER(env);
AWTFont *awtFont = ((AWTStrike *)jlong_to_ptr(awtStrikePtr))->fAWTFont;
AWTStrike *awtStrike = (AWTStrike *)jlong_to_ptr(awtStrikePtr);
AWTFont *awtFont = awtStrike->fAWTFont;
// negative glyph codes are really unicodes, which were placed there by the mapper
// to indicate we should use CoreText to substitute the character
@ -156,6 +158,10 @@ JNF_COCOA_ENTER(env);
const CTFontRef fallback = CTS_CopyCTFallbackFontAndGlyphForJavaGlyphCode(awtFont, glyphCode, &glyph);
CTFontGetAdvancesForGlyphs(fallback, kCTFontDefaultOrientation, &glyph, &advance, 1);
CFRelease(fallback);
advance = CGSizeApplyAffineTransform(advance, awtStrike->fFontTx);
if (!JRSFontStyleUsesFractionalMetrics(awtStrike->fStyle)) {
advance.width = round(advance.width);
}
JNF_COCOA_EXIT(env);
return advance.width;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -455,6 +455,7 @@ CGGI_ClearCanvas(CGGI_GlyphCanvas *canvas, GlyphInfo *info)
#define CGGI_GLYPH_BBOX_PADDING 2.0f
static inline GlyphInfo *
CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
const AWTStrike *strike,
const CGGI_RenderingMode *mode)
{
size_t pixelSize = mode->glyphDescriptor->pixelSize;
@ -477,6 +478,12 @@ CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
width = 1;
height = 1;
}
advance = CGSizeApplyAffineTransform(advance, strike->fFontTx);
if (!JRSFontStyleUsesFractionalMetrics(strike->fStyle)) {
advance.width = round(advance.width);
advance.height = round(advance.height);
}
advance = CGSizeApplyAffineTransform(advance, strike->fDevTx);
#ifdef USE_IMAGE_ALIGNED_MEMORY
// create separate memory
@ -564,10 +571,10 @@ CGGI_CreateImageForUnicode
JRSFontGetBoundingBoxesForGlyphsAndStyle(fallback, &tx, style, &glyph, 1, &bbox);
CGSize advance;
JRSFontGetAdvancesForGlyphsAndStyle(fallback, &tx, strike->fStyle, &glyph, 1, &advance);
CTFontGetAdvancesForGlyphs(fallback, kCTFontDefaultOrientation, &glyph, &advance, 1);
// create the Sun2D GlyphInfo we are going to strike into
GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, mode);
GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, mode);
// fix the context size, just in case the substituted character is unexpectedly large
CGGI_SizeCanvas(canvas, info->width, info->height, mode->cgFontMode);
@ -715,7 +722,7 @@ CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
JRSFontRenderingStyle bboxCGMode = JRSFontAlignStyleForFractionalMeasurement(strike->fStyle);
JRSFontGetBoundingBoxesForGlyphsAndStyle((CTFontRef)font->fFont, &tx, bboxCGMode, glyphs, len, bboxes);
JRSFontGetAdvancesForGlyphsAndStyle((CTFontRef)font->fFont, &tx, strike->fStyle, glyphs, len, advances);
CTFontGetAdvancesForGlyphs((CTFontRef)font->fFont, kCTFontDefaultOrientation, glyphs, advances, len);
size_t maxWidth = 1;
size_t maxHeight = 1;
@ -732,7 +739,7 @@ CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
CGSize advance = advances[i];
CGRect bbox = bboxes[i];
GlyphInfo *glyphInfo = CGGI_CreateNewGlyphInfoFrom(advance, bbox, mode);
GlyphInfo *glyphInfo = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, mode);
if (maxWidth < glyphInfo->width) maxWidth = glyphInfo->width;
if (maxHeight < glyphInfo->height) maxHeight = glyphInfo->height;

View File

@ -1,54 +1,54 @@
# Refer to the note in basic.properties for a description as to what
# the mnemonics correspond to and how to calculate them.
# GTK specific properties
# GTK color chooser properties:
GTKColorChooserPanel.textAndMnemonic=&GTK Color Chooser
# mnemonic as a VK_ constant
GTKColorChooserPanel.hue.textAndMnemonic=&Hue:
GTKColorChooserPanel.red.textAndMnemonic=R&ed:
GTKColorChooserPanel.saturation.textAndMnemonic=&Saturation:
GTKColorChooserPanel.green.textAndMnemonic=&Green:
GTKColorChooserPanel.value.textAndMnemonic=&Value:
GTKColorChooserPanel.blue.textAndMnemonic=&Blue:
GTKColorChooserPanel.color.textAndMnemonic=Color &Name:
############ FILE CHOOSER STRINGS #############
FileChooser.acceptAllFileFilter.textAndMnemonic=All Files
FileChooser.newFolderButton.textAndMnemonic=&New Folder
FileChooser.newFolderDialog.textAndMnemonic=Folder name:
FileChooser.newFolderNoDirectoryErrorTitle.textAndMnemonic=Error
FileChooser.newFolderNoDirectoryError.textAndMnemonic=Error creating directory "{0}": No such file or directory
FileChooser.deleteFileButton.textAndMnemonic=De&lete File
FileChooser.renameFileButton.textAndMnemonic=&Rename File
FileChooser.cancelButton.textAndMnemonic=&Cancel
FileChooser.saveButton.textAndMnemonic=&OK
FileChooser.openButton.textAndMnemonic=&OK
FileChooser.saveDialogTitle.textAndMnemonic=Save
FileChooser.openDialogTitle.textAndMnemonic=Open
FileChooser.pathLabel.textAndMnemonic=&Selection:
FileChooser.filterLabel.textAndMnemonic=Filter:
FileChooser.foldersLabel.textAndMnemonic=Fol&ders
FileChooser.filesLabel.textAndMnemonic=&Files
FileChooser.cancelButtonToolTip.textAndMnemonic=Abort file chooser dialog.
FileChooser.saveButtonToolTip.textAndMnemonic=Save selected file.
FileChooser.openButtonToolTip.textAndMnemonic=Open selected file.
FileChooser.renameFileDialog.textAndMnemonic=Rename file "{0}" to
FileChooser.renameFileError.titleAndMnemonic=Error
FileChooser.renameFileError.textAndMnemonic=Error renaming file "{0}" to "{1}"
# Refer to the note in basic.properties for a description as to what
# the mnemonics correspond to and how to calculate them.
# GTK specific properties
# GTK color chooser properties:
GTKColorChooserPanel.textAndMnemonic=&GTK Color Chooser
# mnemonic as a VK_ constant
GTKColorChooserPanel.hue.textAndMnemonic=&Hue:
GTKColorChooserPanel.red.textAndMnemonic=R&ed:
GTKColorChooserPanel.saturation.textAndMnemonic=&Saturation:
GTKColorChooserPanel.green.textAndMnemonic=&Green:
GTKColorChooserPanel.value.textAndMnemonic=&Value:
GTKColorChooserPanel.blue.textAndMnemonic=&Blue:
GTKColorChooserPanel.color.textAndMnemonic=Color &Name:
############ FILE CHOOSER STRINGS #############
FileChooser.acceptAllFileFilter.textAndMnemonic=All Files
FileChooser.newFolderButton.textAndMnemonic=&New Folder
FileChooser.newFolderDialog.textAndMnemonic=Folder name:
FileChooser.newFolderNoDirectoryErrorTitle.textAndMnemonic=Error
FileChooser.newFolderNoDirectoryError.textAndMnemonic=Error creating directory "{0}": No such file or directory
FileChooser.deleteFileButton.textAndMnemonic=De&lete File
FileChooser.renameFileButton.textAndMnemonic=&Rename File
FileChooser.cancelButton.textAndMnemonic=&Cancel
FileChooser.saveButton.textAndMnemonic=&OK
FileChooser.openButton.textAndMnemonic=&OK
FileChooser.saveDialogTitle.textAndMnemonic=Save
FileChooser.openDialogTitle.textAndMnemonic=Open
FileChooser.pathLabel.textAndMnemonic=&Selection:
FileChooser.filterLabel.textAndMnemonic=Filter:
FileChooser.foldersLabel.textAndMnemonic=Fol&ders
FileChooser.filesLabel.textAndMnemonic=&Files
FileChooser.cancelButtonToolTip.textAndMnemonic=Abort file chooser dialog.
FileChooser.saveButtonToolTip.textAndMnemonic=Save selected file.
FileChooser.openButtonToolTip.textAndMnemonic=Open selected file.
FileChooser.renameFileDialog.textAndMnemonic=Rename file "{0}" to
FileChooser.renameFileError.titleAndMnemonic=Error
FileChooser.renameFileError.textAndMnemonic=Error renaming file "{0}" to "{1}"

View File

@ -499,7 +499,8 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
public void setItem(Object item) {
super.setItem(item);
if (editor.hasFocus()) {
Object focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if ((focus == editor) || (focus == editor.getParent())) {
editor.selectAll();
}
}

View File

@ -1,45 +1,45 @@
# This properties file is used to create a PropertyResourceBundle
# It contains Locale specific strings used be the Synth Look and Feel.
# Currently, the following components need this for support:
#
# FileChooser
#
# When this file is read in, the strings are put into the
# defaults table. This is an implementation detail of the current
# workings of Swing. DO NOT DEPEND ON THIS.
# This may change in future versions of Swing as we improve localization
# support.
#
# Refer to the note in basic.properties for a description as to what
# the mnemonics correspond to and how to calculate them.
#
# @author Steve Wilson
############ FILE CHOOSER STRINGS #############
FileChooser.lookInLabel.textAndMnemonic=Look &In:
FileChooser.saveInLabel.textAndMnemonic=Save In:
FileChooser.fileNameLabel.textAndMnemonic=File &Name:
FileChooser.folderNameLabel.textAndMnemonic=Folder &Name:
FileChooser.filesOfTypeLabel.textAndMnemonic=Files of &Type:
FileChooser.upFolderToolTip.textAndMnemonic=Up One Level
FileChooser.upFolderAccessibleName=Up
FileChooser.homeFolderToolTip.textAndMnemonic=Home
FileChooser.homeFolderAccessibleName=Home
FileChooser.newFolderToolTip.textAndMnemonic=Create New Folder
FileChooser.newFolderAccessibleName=New Folder
FileChooser.newFolderActionLabel.textAndMnemonic=New Folder
FileChooser.listViewButtonToolTip.textAndMnemonic=List
FileChooser.listViewButtonAccessibleName=List
FileChooser.listViewActionLabel.textAndMnemonic=List
FileChooser.detailsViewButtonToolTip.textAndMnemonic=Details
FileChooser.detailsViewButtonAccessibleName=Details
FileChooser.detailsViewActionLabel.textAndMnemonic=Details
FileChooser.refreshActionLabel.textAndMnemonic=Refresh
FileChooser.viewMenuLabel.textAndMnemonic=View
FileChooser.fileNameHeader.textAndMnemonic=Name
FileChooser.fileSizeHeader.textAndMnemonic=Size
FileChooser.fileTypeHeader.textAndMnemonic=Type
FileChooser.fileDateHeader.textAndMnemonic=Modified
FileChooser.fileAttrHeader.textAndMnemonic=Attributes
# This properties file is used to create a PropertyResourceBundle
# It contains Locale specific strings used be the Synth Look and Feel.
# Currently, the following components need this for support:
#
# FileChooser
#
# When this file is read in, the strings are put into the
# defaults table. This is an implementation detail of the current
# workings of Swing. DO NOT DEPEND ON THIS.
# This may change in future versions of Swing as we improve localization
# support.
#
# Refer to the note in basic.properties for a description as to what
# the mnemonics correspond to and how to calculate them.
#
# @author Steve Wilson
############ FILE CHOOSER STRINGS #############
FileChooser.lookInLabel.textAndMnemonic=Look &In:
FileChooser.saveInLabel.textAndMnemonic=Save In:
FileChooser.fileNameLabel.textAndMnemonic=File &Name:
FileChooser.folderNameLabel.textAndMnemonic=Folder &Name:
FileChooser.filesOfTypeLabel.textAndMnemonic=Files of &Type:
FileChooser.upFolderToolTip.textAndMnemonic=Up One Level
FileChooser.upFolderAccessibleName=Up
FileChooser.homeFolderToolTip.textAndMnemonic=Home
FileChooser.homeFolderAccessibleName=Home
FileChooser.newFolderToolTip.textAndMnemonic=Create New Folder
FileChooser.newFolderAccessibleName=New Folder
FileChooser.newFolderActionLabel.textAndMnemonic=New Folder
FileChooser.listViewButtonToolTip.textAndMnemonic=List
FileChooser.listViewButtonAccessibleName=List
FileChooser.listViewActionLabel.textAndMnemonic=List
FileChooser.detailsViewButtonToolTip.textAndMnemonic=Details
FileChooser.detailsViewButtonAccessibleName=Details
FileChooser.detailsViewActionLabel.textAndMnemonic=Details
FileChooser.refreshActionLabel.textAndMnemonic=Refresh
FileChooser.viewMenuLabel.textAndMnemonic=View
FileChooser.fileNameHeader.textAndMnemonic=Name
FileChooser.fileSizeHeader.textAndMnemonic=Size
FileChooser.fileTypeHeader.textAndMnemonic=Type
FileChooser.fileDateHeader.textAndMnemonic=Modified
FileChooser.fileAttrHeader.textAndMnemonic=Attributes

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,7 @@ package java.awt;
/**
* Signals that an Absract Window Toolkit exception has occurred.
* Signals that an Abstract Window Toolkit exception has occurred.
*
* @author Arthur van Hoff
*/

View File

@ -1149,9 +1149,10 @@ public class JFileChooser extends JComponent implements Accessible {
int index = filters.indexOf(f);
if (index >= 0) {
if(getFileFilter() == f) {
if (isAcceptAllFileFilterUsed()) {
FileFilter aaff = getAcceptAllFileFilter();
if (isAcceptAllFileFilterUsed() && (aaff != f)) {
// choose default filter if it is used
setFileFilter(getAcceptAllFileFilter());
setFileFilter(aaff);
}
else if (index > 0) {
// choose the first filter, because it is not removed

View File

@ -344,7 +344,8 @@ public class SynthTreeUI extends BasicTreeUI
configureRenderer(cellContext);
while (!done && paintingEnumerator.hasMoreElements()) {
path = (TreePath)paintingEnumerator.nextElement();
if (path != null) {
bounds = getPathBounds(tree, path);
if ((path != null) && (bounds != null)) {
isLeaf = treeModel.isLeaf(path.getLastPathComponent());
if (isLeaf) {
isExpanded = hasBeenExpanded = false;
@ -353,7 +354,6 @@ public class SynthTreeUI extends BasicTreeUI
isExpanded = treeState.getExpandedState(path);
hasBeenExpanded = tree.hasBeenExpanded(path);
}
bounds = getPathBounds(tree, path);
rowBounds.y = bounds.y;
rowBounds.height = bounds.height;
paintRow(renderer, dtcr, context, cellContext, g,
@ -383,7 +383,8 @@ public class SynthTreeUI extends BasicTreeUI
paintingEnumerator = treeState.getVisiblePathsFrom(initialPath);
while (!done && paintingEnumerator.hasMoreElements()) {
path = (TreePath)paintingEnumerator.nextElement();
if (path != null) {
bounds = getPathBounds(tree, path);
if ((path != null) && (bounds != null)) {
isLeaf = treeModel.isLeaf(path.getLastPathComponent());
if (isLeaf) {
isExpanded = hasBeenExpanded = false;
@ -392,7 +393,6 @@ public class SynthTreeUI extends BasicTreeUI
isExpanded = treeState.getExpandedState(path);
hasBeenExpanded = tree.hasBeenExpanded(path);
}
bounds = getPathBounds(tree, path);
// See if the vertical line to the parent has been drawn.
parentPath = path.getParentPath();
if (parentPath != null) {

View File

@ -547,6 +547,17 @@ public class TrueTypeFont extends FileFont {
throw new FontFormatException("bad table, tag="+table.tag);
}
}
if (getDirectoryEntry(headTag) == null) {
throw new FontFormatException("missing head table");
}
if (getDirectoryEntry(maxpTag) == null) {
throw new FontFormatException("missing maxp table");
}
if (getDirectoryEntry(hmtxTag) != null
&& getDirectoryEntry(hheaTag) == null) {
throw new FontFormatException("missing hhea table");
}
initNames();
} catch (Exception e) {
if (FontUtilities.isLogging()) {

View File

@ -59,6 +59,8 @@ import javax.print.PrintService;
import javax.print.StreamPrintService;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.PrintServiceAttributeSet;
import javax.print.attribute.standard.PrinterName;
import javax.print.attribute.standard.Chromaticity;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.Destination;
@ -766,8 +768,9 @@ public class PSPrinterJob extends RasterPrinterJob {
}
}
if (mDestType == RasterPrinterJob.PRINTER) {
if (getPrintService() != null) {
mDestination = getPrintService().getName();
PrintService pServ = getPrintService();
if (pServ != null) {
mDestination = pServ.getName();
}
PrinterSpooler spooler = new PrinterSpooler();
java.security.AccessController.doPrivileged(spooler);

View File

@ -29,12 +29,18 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.ComponentListener;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.security.AccessController;
import javax.swing.JLayeredPane;
@ -80,6 +86,8 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
private boolean copyBufferEnabled;
private int[] copyBuffer;
private PropertyChangeListener layoutSizeListener;
/**
* Constructs a new, initially invisible {@code JLightweightFrame}
* instance.
@ -94,6 +102,23 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
if (getGraphicsConfiguration().isTranslucencyCapable()) {
setBackground(new Color(0, 0, 0, 0));
}
layoutSizeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
Dimension d = (Dimension)e.getNewValue();
if ("preferredSize".equals(e.getPropertyName())) {
content.preferredSizeChanged(d.width, d.height);
} else if ("maximumSize".equals(e.getPropertyName())) {
content.maximumSizeChanged(d.width, d.height);
} else if ("minimumSize".equals(e.getPropertyName())) {
content.minimumSizeChanged(d.width, d.height);
}
}
};
}
/**
@ -104,10 +129,23 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
*
* @param content the {@link LightweightContent} instance
*/
public void setContent(LightweightContent content) {
public void setContent(final LightweightContent content) {
if (content == null) {
System.err.println("JLightweightFrame.setContent: content may not be null!");
return;
}
this.content = content;
this.component = content.getComponent();
Dimension d = this.component.getPreferredSize();
content.preferredSizeChanged(d.width, d.height);
d = this.component.getMaximumSize();
content.maximumSizeChanged(d.width, d.height);
d = this.component.getMinimumSize();
content.minimumSizeChanged(d.width, d.height);
initInterior();
}
@ -202,6 +240,25 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
contentPane.setLayout(new BorderLayout());
contentPane.add(component);
setContentPane(contentPane);
contentPane.addContainerListener(new ContainerListener() {
@Override
public void componentAdded(ContainerEvent e) {
Component c = JLightweightFrame.this.component;
if (e.getChild() == c) {
c.addPropertyChangeListener("preferredSize", layoutSizeListener);
c.addPropertyChangeListener("maximumSize", layoutSizeListener);
c.addPropertyChangeListener("minimumSize", layoutSizeListener);
}
}
@Override
public void componentRemoved(ContainerEvent e) {
Component c = JLightweightFrame.this.component;
if (e.getChild() == c) {
c.removePropertyChangeListener(layoutSizeListener);
}
}
});
}
@SuppressWarnings("deprecation")

View File

@ -161,4 +161,22 @@ public interface LightweightContent {
* application that the frame has ungrabbed focus.
*/
public void focusUngrabbed();
/**
* {@code JLightweightFrame} calls this method to notify the client
* application that the content preferred size has changed.
*/
public void preferredSizeChanged(int width, int height);
/**
* {@code JLightweightFrame} calls this method to notify the client
* application that the content maximum size has changed.
*/
public void maximumSizeChanged(int width, int height);
/**
* {@code JLightweightFrame} calls this method to notify the client
* application that the content minimum size has changed.
*/
public void minimumSizeChanged(int width, int height);
}

View File

@ -106,7 +106,7 @@ extern JavaVM *jvm;
/******************** StreamBuffer definition ************************/
typedef struct streamBufferStruct {
jobject stream; // ImageInputStream or ImageOutputStream
jweak ioRef; // weak reference to a provider of I/O routines
jbyteArray hstreamBuffer; // Handle to a Java buffer for the stream
JOCTET *buf; // Pinned buffer pointer */
size_t bufferOffset; // holds offset between unpin and the next pin
@ -125,6 +125,15 @@ typedef struct streamBufferStruct {
*/
#define STREAMBUF_SIZE 4096
#define GET_IO_REF(io_name) \
do { \
if ((*env)->IsSameObject(env, sb->ioRef, NULL) || \
((io_name) = (*env)->NewLocalRef(env, sb->ioRef)) == NULL) \
{ \
cinfo->err->error_exit((j_common_ptr) cinfo); \
} \
} while (0) \
/*
* Used to signal that no data need be restored from an unpin to a pin.
* I.e. the buffer is empty.
@ -159,7 +168,7 @@ static int initStreamBuffer(JNIEnv *env, streamBufferPtr sb) {
}
sb->stream = NULL;
sb->ioRef = NULL;
sb->buf = NULL;
@ -191,9 +200,9 @@ static void unpinStreamBuffer(JNIEnv *env,
* All other state is reset.
*/
static void resetStreamBuffer(JNIEnv *env, streamBufferPtr sb) {
if (sb->stream != NULL) {
(*env)->DeleteGlobalRef(env, sb->stream);
sb->stream = NULL;
if (sb->ioRef != NULL) {
(*env)->DeleteWeakGlobalRef(env, sb->ioRef);
sb->ioRef = NULL;
}
unpinStreamBuffer(env, sb, NULL);
sb->bufferOffset = NO_DATA;
@ -571,7 +580,7 @@ sun_jpeg_output_message (j_common_ptr cinfo)
static void imageio_set_stream(JNIEnv *env,
j_common_ptr cinfo,
imageIODataPtr data,
jobject stream){
jobject io){
streamBufferPtr sb;
sun_jpeg_error_ptr jerr;
@ -579,13 +588,13 @@ static void imageio_set_stream(JNIEnv *env,
resetStreamBuffer(env, sb); // Removes any old stream
/* Now we need a new global reference for the stream */
if (stream != NULL) { // Fix for 4411955
sb->stream = (*env)->NewGlobalRef(env, stream);
if (sb->stream == NULL) {
/* Now we need a new weak global reference for the I/O provider */
if (io != NULL) { // Fix for 4411955
sb->ioRef = (*env)->NewWeakGlobalRef(env, io);
if (sb->ioRef == NULL) {
JNU_ThrowByName(env,
"java/lang/OutOfMemoryError",
"Setting Stream");
"Setting I/O provider");
return;
}
}
@ -895,6 +904,7 @@ imageio_fill_input_buffer(j_decompress_ptr cinfo)
streamBufferPtr sb = &data->streamBuf;
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
int ret;
jobject input = NULL;
/* This is where input suspends */
if (sb->suspendable) {
@ -920,9 +930,11 @@ imageio_fill_input_buffer(j_decompress_ptr cinfo)
* Now fill a complete buffer, or as much of one as the stream
* will give us if we are near the end.
*/
GET_IO_REF(input);
RELEASE_ARRAYS(env, data, src->next_input_byte);
ret = (*env)->CallIntMethod(env,
sb->stream,
input,
JPEGImageReader_readInputDataID,
sb->hstreamBuffer, 0,
sb->bufferLength);
@ -982,6 +994,7 @@ imageio_fill_suspended_buffer(j_decompress_ptr cinfo)
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jint ret;
size_t offset, buflen;
jobject input = NULL;
/*
* The original (jpegdecoder.c) had code here that called
@ -1003,6 +1016,9 @@ imageio_fill_suspended_buffer(j_decompress_ptr cinfo)
if (src->next_input_byte > sb->buf) {
memcpy(sb->buf, src->next_input_byte, offset);
}
GET_IO_REF(input);
RELEASE_ARRAYS(env, data, src->next_input_byte);
buflen = sb->bufferLength - offset;
if (buflen <= 0) {
@ -1012,7 +1028,7 @@ imageio_fill_suspended_buffer(j_decompress_ptr cinfo)
return;
}
ret = (*env)->CallIntMethod(env, sb->stream,
ret = (*env)->CallIntMethod(env, input,
JPEGImageReader_readInputDataID,
sb->hstreamBuffer,
offset, buflen);
@ -1075,6 +1091,7 @@ imageio_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jlong ret;
jobject reader;
jobject input = NULL;
if (num_bytes < 0) {
return;
@ -1104,9 +1121,11 @@ imageio_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
return;
}
GET_IO_REF(input);
RELEASE_ARRAYS(env, data, src->next_input_byte);
ret = (*env)->CallLongMethod(env,
sb->stream,
input,
JPEGImageReader_skipInputBytesID,
(jlong) num_bytes);
if ((*env)->ExceptionOccurred(env)
@ -2285,11 +2304,14 @@ imageio_empty_output_buffer (j_compress_ptr cinfo)
imageIODataPtr data = (imageIODataPtr) cinfo->client_data;
streamBufferPtr sb = &data->streamBuf;
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jobject output = NULL;
GET_IO_REF(output);
RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte));
(*env)->CallVoidMethod(env,
sb->stream,
output,
JPEGImageWriter_writeOutputDataID,
sb->hstreamBuffer,
0,
@ -2322,11 +2344,16 @@ imageio_term_destination (j_compress_ptr cinfo)
/* find out how much needs to be written */
/* this conversion from size_t to jint is safe, because the lenght of the buffer is limited by jint */
jint datacount = (jint)(sb->bufferLength - dest->free_in_buffer);
if (datacount != 0) {
jobject output = NULL;
GET_IO_REF(output);
RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte));
(*env)->CallVoidMethod(env,
sb->stream,
output,
JPEGImageWriter_writeOutputDataID,
sb->hstreamBuffer,
0,

View File

@ -2606,38 +2606,37 @@ storeDstArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
#define ERR_BAD_IMAGE_LAYOUT (-2)
#define CHECK_DST_ARRAY(start_offset, elements_per_pixel) \
do { \
int offset = (start_offset); \
int lastScanOffset; \
\
if (!SAFE_TO_MULT(rasterP->scanlineStride, \
(rasterP->height - 1))) \
{ \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset = rasterP->scanlineStride * \
(rasterP->height - 1); \
\
if (!SAFE_TO_ADD(offset, lastScanOffset)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset += offset; \
\
if (!SAFE_TO_MULT((elements_per_pixel), rasterP->width)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
offset = (elements_per_pixel) * rasterP->width; \
\
if (!SAFE_TO_ADD(offset, lastScanOffset)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset += offset; \
\
if (dataArrayLength < lastScanOffset) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
} while(0); \
#define CHECK_DST_ARRAY(start_offset, elements_per_scan, elements_per_pixel) \
do { \
int offset = (start_offset); \
int lastScanOffset; \
\
if (!SAFE_TO_MULT((elements_per_scan), \
(rasterP->height - 1))) \
{ \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset = (elements_per_scan) * (rasterP->height - 1); \
\
if (!SAFE_TO_ADD(offset, lastScanOffset)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset += offset; \
\
if (!SAFE_TO_MULT((elements_per_pixel), rasterP->width)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
offset = (elements_per_pixel) * rasterP->width; \
\
if (!SAFE_TO_ADD(offset, lastScanOffset)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset += offset; \
\
if (dataArrayLength < lastScanOffset) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
} while(0); \
static int
storeImageArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
@ -2665,39 +2664,33 @@ storeImageArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
if (hintP->packing == BYTE_INTERLEAVED) {
/* Write it back to the destination */
CHECK_DST_ARRAY(hintP->channelOffset, hintP->numChans);
if (rasterP->dataType != BYTE_DATA_TYPE) {
/* We are working with a raster which was marked
as a byte interleaved due to performance reasons.
So, we have to convert the length of the data
array to bytes as well.
*/
if (!SAFE_TO_MULT(rasterP->dataSize, dataArrayLength)) {
return ERR_BAD_IMAGE_LAYOUT;
}
dataArrayLength *= rasterP->dataSize;
}
CHECK_DST_ARRAY(hintP->dataOffset, hintP->sStride, hintP->numChans);
cmDataP = (unsigned char *) mlib_ImageGetData(mlibImP);
mStride = mlib_ImageGetStride(mlibImP);
dataP = (unsigned char *)(*env)->GetPrimitiveArrayCritical(env,
rasterP->jdata, NULL);
if (dataP == NULL) return 0;
cDataP = dataP + hintP->channelOffset;
cDataP = dataP + hintP->dataOffset;
for (y=0; y < rasterP->height;
y++, cmDataP += mStride, cDataP += rasterP->scanlineStride)
y++, cmDataP += mStride, cDataP += hintP->sStride)
{
memcpy(cDataP, cmDataP, rasterP->width*hintP->numChans);
}
(*env)->ReleasePrimitiveArrayCritical(env, rasterP->jdata, dataP,
JNI_ABORT);
}
else if (hintP->packing == SHORT_INTERLEAVED) {
/* Write it back to the destination */
unsigned short *sdataP, *sDataP;
unsigned short *smDataP = (unsigned short *)mlib_ImageGetData(mlibImP);
CHECK_DST_ARRAY(hintP->channelOffset, hintP->numChans);
mStride = mlib_ImageGetStride(mlibImP);
sdataP = (unsigned short *)(*env)->GetPrimitiveArrayCritical(env,
rasterP->jdata, NULL);
if (sdataP == NULL) return -1;
sDataP = sdataP + hintP->channelOffset;
for (y=0; y < rasterP->height;
y++, smDataP += mStride, sDataP += rasterP->scanlineStride)
{
memcpy(sDataP, smDataP, rasterP->width*hintP->numChans);
}
(*env)->ReleasePrimitiveArrayCritical(env, rasterP->jdata, sdataP,
JNI_ABORT);
}
else if (dstP->cmodel.cmType == DIRECT_CM_TYPE) {
/* Just need to move bits */
if (mlibImP->type == MLIB_BYTE) {
@ -3499,7 +3492,7 @@ static int setPackedBCR(JNIEnv *env, RasterS_t *rasterP, int component,
}
dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], rasterP->scanlineStride, 1);
outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
if (outDataP == NULL) {
@ -3575,7 +3568,7 @@ static int setPackedSCR(JNIEnv *env, RasterS_t *rasterP, int component,
}
dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], rasterP->scanlineStride, 1);
outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
if (outDataP == NULL) {
@ -3651,7 +3644,7 @@ static int setPackedICR(JNIEnv *env, RasterS_t *rasterP, int component,
}
dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], rasterP->scanlineStride, 1);
outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
if (outDataP == NULL) {
@ -3730,7 +3723,7 @@ static int setPackedBCRdefault(JNIEnv *env, RasterS_t *rasterP,
}
dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], rasterP->scanlineStride, 1);
outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
if (outDataP == NULL) {
@ -3827,7 +3820,7 @@ static int setPackedSCRdefault(JNIEnv *env, RasterS_t *rasterP,
return -1;
}
dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], rasterP->scanlineStride, 1);
outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
if (outDataP == NULL) {
@ -3925,7 +3918,7 @@ static int setPackedICRdefault(JNIEnv *env, RasterS_t *rasterP,
}
dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
CHECK_DST_ARRAY(rasterP->chanOffsets[0], rasterP->scanlineStride, 1);
outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
if (outDataP == NULL) {

View File

@ -66,6 +66,16 @@ void CanonShaping::reorderMarks(const LEUnicode *inChars, le_int32 charCount, le
le_int32 *indices = LE_NEW_ARRAY(le_int32, charCount);
le_int32 i;
if (combiningClasses == NULL || indices == NULL) {
if (combiningClasses != NULL) {
LE_DELETE_ARRAY(combiningClasses);
}
if (indices != NULL) {
LE_DELETE_ARRAY(indices);
}
return;
}
for (i = 0; i < charCount; i += 1) {
combiningClasses[i] = classTable->getGlyphClass(classTable, (LEGlyphID) inChars[i], success);
indices[i] = i;

View File

@ -1099,6 +1099,15 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
if (category == PrinterName.class) {
return (T)(new PrinterName(printer, null));
} else if (category == PrinterInfo.class) {
PrinterInfo pInfo = new PrinterInfo(printer, null);
AttributeClass ac = (getAttMap != null) ?
(AttributeClass)getAttMap.get(pInfo.getName())
: null;
if (ac != null) {
return (T)(new PrinterInfo(ac.getStringValue(), null));
}
return (T)pInfo;
} else if (category == QueuedJobCount.class) {
QueuedJobCount qjc = new QueuedJobCount(0);
AttributeClass ac = (getAttMap != null) ?
@ -1566,7 +1575,24 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
}
}
String getDest() {
return printer;
}
public String getName() {
/*
* Mac is using printer-info IPP attribute for its human-readable printer
* name and is also the identifier used in NSPrintInfo:setPrinter.
*/
if (UnixPrintServiceLookup.isMac()) {
PrintServiceAttributeSet psaSet = this.getAttributes();
if (psaSet != null) {
PrinterInfo pName = (PrinterInfo)psaSet.get(PrinterInfo.class);
if (pName != null) {
return pName.toString();
}
}
}
return printer;
}

View File

@ -65,6 +65,7 @@ import javax.print.attribute.PrintJobAttribute;
import javax.print.attribute.PrintJobAttributeSet;
import javax.print.attribute.PrintRequestAttribute;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.PrintServiceAttributeSet;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.Destination;
import javax.print.attribute.standard.DocumentName;
@ -76,6 +77,7 @@ import javax.print.attribute.standard.Media;
import javax.print.attribute.standard.MediaSize;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.OrientationRequested;
import javax.print.attribute.standard.PrinterName;
import javax.print.attribute.standard.RequestingUserName;
import javax.print.attribute.standard.NumberUp;
import javax.print.attribute.standard.Sides;
@ -120,6 +122,9 @@ public class UnixPrintJob implements CancelablePrintJob {
UnixPrintJob(PrintService service) {
this.service = service;
mDestination = service.getName();
if (UnixPrintServiceLookup.isMac()) {
mDestination = ((IPPPrintService)service).getDest();
}
mDestType = UnixPrintJob.DESTPRINTER;
}

View File

@ -926,6 +926,11 @@ void TryInitMITShm(JNIEnv *env, jint *shmExt, jint *shmPixmaps) {
*shmExt = canUseShmExt = CANT_USE_MITSHM;
*shmPixmaps = canUseShmExtPixmaps = CANT_USE_MITSHM;
if (awt_display == (Display *)NULL) {
AWT_NOFLUSH_UNLOCK();
return;
}
/**
* XShmQueryExtension returns False in remote server case.
* Unfortunately it also returns True in ssh case, so

View File

@ -112,6 +112,25 @@ static
#define PKGINFO_LINE_LEN_MAX 256
#define PKGINFO_LINE_CNT_MAX 50
/*
* X protocol uses (u_int16)length to specify the length in 4 bytes quantities
* of the whole request. Both XRenderFillRectangles() and XFillRectangles()
* have provisions to fragment into several requests if the number of rectangles
* plus the current x request does not fit into 65535*4 bytes. While
* XRenderCreateLinearGradient() and XRenderCreateRadialGradient() have
* provisions to gracefully degrade if the resulting request would exceed
* 65535*4 bytes.
*
* Below, we define a cap of 65535*4 bytes for the maximum X request payload
* allowed for Non-(XRenderFillRectangles() or XFillRectangles()) API calls,
* just to be conservative. This is offset by the size of our maximum x*Req
* type in this compilation unit, which is xRenderCreateRadiaGradientReq.
*
* Note that sizeof(xRenderCreateRadiaGradientReq) = 36
*/
#define MAX_PAYLOAD (262140u - 36u)
#define MAXUINT (0xffffffffu)
static jboolean IsXRenderAvailable(jboolean verbose) {
void *xrenderlib;
@ -267,13 +286,19 @@ Java_sun_java2d_xr_XRBackendNative_initIDs(JNIEnv *env, jclass cls) {
char *maskData;
XImage* defaultImg;
jfieldID maskImgID;
jlong fmt8 =
ptr_to_jlong(XRenderFindStandardFormat(awt_display, PictStandardA8));
jlong fmt32 =
ptr_to_jlong(XRenderFindStandardFormat(awt_display, PictStandardARGB32));
jlong fmt8;
jlong fmt32;
jfieldID a8ID = (*env)->GetStaticFieldID(env, cls, "FMTPTR_A8", "J");
jfieldID argb32ID = (*env)->GetStaticFieldID(env, cls, "FMTPTR_ARGB32", "J");
if (awt_display == (Display *)NULL) {
return;
}
fmt8 = ptr_to_jlong(XRenderFindStandardFormat(awt_display, PictStandardA8));
fmt32 = ptr_to_jlong(XRenderFindStandardFormat(awt_display, PictStandardARGB32));
(*env)->SetStaticLongField(env, cls, a8ID, fmt8);
(*env)->SetStaticLongField(env, cls, argb32ID, fmt32);
@ -404,6 +429,10 @@ Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative
if (rectCnt <= 256) {
xRects = &sRects[0];
} else {
if (MAXUINT / sizeof(XRectangle) < (unsigned)rectCnt) {
/* rectCnt too big, integer overflow */
return;
}
xRects = (XRectangle *) malloc(sizeof(XRectangle) * rectCnt);
if (xRects == NULL) {
return;
@ -460,6 +489,12 @@ Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative
XFixed *stops;
XLinearGradient grad;
if (MAX_PAYLOAD / (sizeof(XRenderColor) + sizeof(XFixed))
< (unsigned)numStops) {
/* numStops too big, payload overflow */
return -1;
}
if ((pixels = (jshort *)
(*env)->GetPrimitiveArrayCritical(env, pixelsArray, NULL)) == NULL) {
return -1;
@ -480,6 +515,18 @@ Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative
colors = (XRenderColor *) malloc(numStops * sizeof(XRenderColor));
stops = (XFixed *) malloc(numStops * sizeof(XFixed));
if (colors == NULL || stops == NULL) {
if (colors != NULL) {
free(colors);
}
if (stops != NULL) {
free(stops);
}
(*env)->ReleasePrimitiveArrayCritical(env, pixelsArray, pixels, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, fractions, JNI_ABORT);
return -1;
}
for (i=0; i < numStops; i++) {
stops[i] = XDoubleToFixed(fractions[i]);
colors[i].alpha = pixels[i*4 + 0];
@ -527,6 +574,11 @@ Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative
XFixed *stops;
XRadialGradient grad;
if (MAX_PAYLOAD / (sizeof(XRenderColor) + sizeof(XFixed))
< (unsigned)numStops) {
/* numStops too big, payload overflow */
return -1;
}
if ((pixels =
(jshort *)(*env)->GetPrimitiveArrayCritical(env, pixelsArray, NULL)) == NULL) {
@ -550,6 +602,18 @@ Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative
colors = (XRenderColor *) malloc(numStops * sizeof(XRenderColor));
stops = (XFixed *) malloc(numStops * sizeof(XFixed));
if (colors == NULL || stops == NULL) {
if (colors != NULL) {
free(colors);
}
if (stops != NULL) {
free(stops);
}
(*env)->ReleasePrimitiveArrayCritical(env, pixelsArray, pixels, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, fractions, JNI_ABORT);
return -1;
}
for (i=0; i < numStops; i++) {
stops[i] = XDoubleToFixed(fractions[i]);
colors[i].alpha = pixels[i*4 + 0];
@ -708,6 +772,12 @@ Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative
unsigned char *pixelData;
int i;
if (MAX_PAYLOAD / (sizeof(XGlyphInfo) + sizeof(Glyph))
< (unsigned)glyphCnt) {
/* glyphCnt too big, payload overflow */
return;
}
XGlyphInfo *xginfo = (XGlyphInfo *) malloc(sizeof(XGlyphInfo) * glyphCnt);
Glyph *gid = (Glyph *) malloc(sizeof(Glyph) * glyphCnt);
@ -770,6 +840,11 @@ JNIEXPORT void JNICALL
Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative
(JNIEnv *env, jclass cls, jint glyphSet, jintArray gidArray, jint glyphCnt) {
if (MAX_PAYLOAD / sizeof(Glyph) < (unsigned)glyphCnt) {
/* glyphCnt too big, payload overflow */
return;
}
/* The glyph ids are 32 bit but may be stored in a 64 bit long on
* a 64 bit architecture. So optimise the 32 bit case to avoid
* extra stack or heap allocations by directly referencing the
@ -840,6 +915,15 @@ Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative
unsigned int sids[256];
int charCnt = 0;
if ((MAX_PAYLOAD / sizeof(XGlyphElt32) < (unsigned)eltCnt)
|| (MAX_PAYLOAD / sizeof(unsigned int) < (unsigned)glyphCnt)
|| ((MAX_PAYLOAD - sizeof(XGlyphElt32)*(unsigned)eltCnt) /
sizeof(unsigned int) < (unsigned)glyphCnt))
{
/* (eltCnt, glyphCnt) too big, payload overflow */
return;
}
if (eltCnt <= 24) {
xelts = &selts[0];
}else {
@ -938,6 +1022,11 @@ Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative
if (rectCnt <= 256) {
xRects = &sRects[0];
} else {
if (MAXUINT / sizeof(XRectangle) < (unsigned)rectCnt) {
/* rectCnt too big, integer overflow */
return;
}
xRects = (XRectangle *) malloc(sizeof(XRectangle) * rectCnt);
if (xRects == NULL) {
return;

View File

@ -445,7 +445,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater,
initMedia();
if ((mediaSizeNames == null) && (mediaSizeNames.length == 0)) {
if ((mediaSizeNames == null) || (mediaSizeNames.length == 0)) {
return null;
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
* @test
* @bug 7190349
* @summary Verifies that we get correct direction, when draw rotated string.
* @author Sergey Bylokhov
* @run main/othervm DrawRotatedString
*/
public final class DrawRotatedString {
private static final int SIZE = 500;
public static void main(final String[] args) throws IOException {
BufferedImage bi = createBufferedImage(true);
verify(bi);
bi = createBufferedImage(false);
verify(bi);
System.out.println("Passed");
}
private static void verify(BufferedImage bi) throws IOException {
for (int i = 0; i < SIZE; ++i) {
for (int j = 0; j < 99; ++j) {
//Text should not appear before 100
if (bi.getRGB(i, j) != Color.RED.getRGB()) {
ImageIO.write(bi, "png", new File("image.png"));
throw new RuntimeException("Failed: wrong text location");
}
}
}
}
private static BufferedImage createBufferedImage(final boolean aa) {
final BufferedImage bi = new BufferedImage(SIZE, SIZE,
BufferedImage.TYPE_INT_RGB);
final Graphics2D bg = bi.createGraphics();
bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
aa ? RenderingHints.VALUE_ANTIALIAS_ON
: RenderingHints.VALUE_ANTIALIAS_OFF);
bg.setColor(Color.RED);
bg.fillRect(0, 0, SIZE, SIZE);
bg.translate(100, 100);
bg.rotate(Math.toRadians(90));
bg.setColor(Color.BLACK);
bg.setFont(bg.getFont().deriveFont(20.0f));
bg.drawString("MMMMMMMMMMMMMMMM", 0, 0);
bg.dispose();
return bi;
}
}

View File

@ -0,0 +1,77 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
* @test
* @bug 8013569
* @author Sergey Bylokhov
*/
public final class IncorrectTextSize {
static final int scale = 2;
static final int width = 1200;
static final int height = 100;
static BufferedImage bi = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
static final String TEXT = "The quick brown fox jumps over the lazy dog"
+ "The quick brown fox jumps over the lazy dog";
public static void main(final String[] args) throws IOException {
for (int point = 5; point < 11; ++point) {
Graphics2D g2d = bi.createGraphics();
g2d.setFont(new Font(Font.DIALOG, Font.PLAIN, point));
g2d.scale(scale, scale);
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, width, height);
g2d.setColor(Color.green);
g2d.drawString(TEXT, 0, 20);
int length = g2d.getFontMetrics().stringWidth(TEXT);
if (length < 0) {
throw new RuntimeException("Negative length");
}
for (int i = (length + 1) * scale; i < width; ++i) {
for (int j = 0; j < height; ++j) {
if (bi.getRGB(i, j) != Color.white.getRGB()) {
g2d.drawLine(length, 0, length, height);
ImageIO.write(bi, "png", new File("image.png"));
System.out.println("length = " + length);
System.err.println("Wrong color at x=" + i + ",y=" + j);
System.err.println("Color is:" + new Color(bi.getRGB(i,
j)));
throw new RuntimeException("Test failed.");
}
}
}
g2d.dispose();
}
}
}

View File

@ -0,0 +1,125 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8020983
* @summary Test verifies that jpeg writer instances are collected
* even if destroy() or reset() methods is not invoked.
*
* @run main JpegWriterLeakTest
*/
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
public class JpegWriterLeakTest {
public static void main(String[] args) {
final ReferenceQueue<ImageWriter> queue = new ReferenceQueue<>();
final ArrayList<Reference<? extends ImageWriter>> refs = new ArrayList<>();
int count = 2;
do {
ImageWriter writer =
ImageIO.getImageWritersByFormatName("jpeg").next();
final WeakReference<? extends ImageWriter> ref =
new WeakReference<>(writer, queue);
refs.add(ref);
try {
final ImageOutputStream os =
ImageIO.createImageOutputStream(new ByteArrayOutputStream());
writer.setOutput(os);
writer.write(getImage());
// NB: dispose() or reset() workarounds the problem.
} catch (IOException e) {
} finally {
writer = null;
}
count--;
} while (count > 0);
System.out.println("Wait for GC...");
final long testTimeOut = 60000L;
final long startTime = System.currentTimeMillis();
while (!refs.isEmpty()) {
// check for the test timeout
final long now = System.currentTimeMillis();
if (now - startTime > testTimeOut) {
System.out.println();
throw new RuntimeException("Test FAILED.");
}
System.gc();
try {
System.out.print(".");
Thread.sleep(1000);
} catch (InterruptedException e) {
};
Reference<? extends ImageWriter> r = queue.poll();
if (r != null) {
System.out.println("Got reference: " + r);
refs.remove(r);
}
}
System.out.println("Test PASSED.");
}
private static BufferedImage getImage() {
int width = 2500;
int height = new Random().nextInt(2500) + 1;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setColor(Color.blue);
g.fillRect(0, 0, width, height);
return image;
}
}

View File

@ -25,11 +25,12 @@
/**
* @test
* @bug 4485755 6361370 6448717 5080051 6939417
* @bug 4485755 6361370 6448717 5080051 6939417 8016343
* @summary dialog doesn't have way to specify margins
* for 6361370, verify exception for offline printer in Windows
* for 6448717, faster display of print dialog
* for 6500903, verify status of printer if accepting jobs or not
* for 8016343, verify printing to non-default printer
* @author prr
* @run main/manual DialogMargins
*/

View File

@ -0,0 +1,119 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import com.sun.java.swing.plaf.windows.WindowsComboBoxUI.WindowsComboBoxEditor;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.ComboBoxEditor;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.UIManager;
import sun.awt.SunToolkit;
import static javax.swing.SwingUtilities.invokeAndWait;
import static javax.swing.SwingUtilities.windowForComponent;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
/*
* @test
* @bug 8015300
* @summary Tests that editable combobox select all text
* @author Sergey Malenkov
*/
public class Test8015300 {
private static final SunToolkit STK = (SunToolkit) Toolkit.getDefaultToolkit();
private static final String[] ITEMS = {
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
private static JComboBox<String> combo;
public static void main(String[] args) throws Exception {
UIManager.LookAndFeelInfo[] array = UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo info : array) {
UIManager.setLookAndFeel(info.getClassName());
System.err.println("L&F: " + info.getName());
invokeAndWait(new Runnable() {
@Override
public void run() {
combo = new JComboBox<>(ITEMS);
combo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent event) {
if (ItemEvent.SELECTED == event.getStateChange() && combo.isEditable()) {
ComboBoxEditor editor = combo.getEditor();
Object component = editor.getEditorComponent();
if (component instanceof JTextField) {
JTextField text = (JTextField) component;
boolean selected = null != text.getSelectedText();
StringBuilder sb = new StringBuilder();
sb.append(" - ").append(combo.getSelectedIndex());
sb.append(": ").append(event.getItem());
if (selected) {
sb.append("; selected");
}
System.err.println(sb);
if ((editor instanceof WindowsComboBoxEditor) == (null == text.getSelectedText())) {
throw new Error("unexpected state of text selection");
}
}
}
}
});
JFrame frame = new JFrame(getClass().getSimpleName());
frame.add(combo);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
});
for (int i = 0; i < ITEMS.length; ++i) {
select(i, true);
select(1, false);
}
invokeAndWait(new Runnable() {
@Override
public void run() {
windowForComponent(combo).dispose();
}
});
}
}
private static void select(final int index, final boolean editable) throws Exception {
invokeAndWait(new Runnable() {
@Override
public void run() {
combo.setEditable(editable);
combo.setSelectedIndex(index);
}
});
STK.realSync();
Thread.sleep(50L);
}
}

View File

@ -0,0 +1,98 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8015926
* @summary Tests that there are no NPE during painting
* @author Sergey Malenkov
*/
import javax.swing.JFrame;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
public class Test8015926 implements TreeModelListener, Runnable, Thread.UncaughtExceptionHandler {
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
SwingUtilities.invokeAndWait(new Test8015926());
Thread.sleep(1000L);
}
private JTree tree;
@Override
public void treeStructureChanged(TreeModelEvent event) {
}
@Override
public void treeNodesRemoved(TreeModelEvent event) {
}
@Override
public void treeNodesInserted(TreeModelEvent event) {
this.tree.expandPath(event.getTreePath());
}
@Override
public void treeNodesChanged(TreeModelEvent event) {
}
@Override
public void run() {
Thread.currentThread().setUncaughtExceptionHandler(this);
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
DefaultMutableTreeNode child = new DefaultMutableTreeNode("Child");
DefaultTreeModel model = new DefaultTreeModel(root);
this.tree = new JTree();
this.tree.setModel(model);
JFrame frame = new JFrame(getClass().getSimpleName());
frame.add(this.tree);
model.addTreeModelListener(this); // frame is not visible yet
model.insertNodeInto(child, root, root.getChildCount());
model.removeNodeFromParent(child);
frame.setSize(640, 480);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
@Override
public void uncaughtException(Thread thread, Throwable exception) {
exception.printStackTrace();
System.exit(1);
}
}

View File

@ -0,0 +1,101 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8019201
* @summary Test verifies that medialib glue code does not throw
* an ImagingOpException for certain pairs of source and
* destination images.
*
* @run main SamePackingTypeTest
*/
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR;
import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR_PRE;
import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
import static java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE;
import java.awt.image.BufferedImageOp;
import java.awt.image.ConvolveOp;
import java.awt.image.ImagingOpException;
import java.awt.image.Kernel;
import java.util.Arrays;
public class SamePackingTypeTest {
public static void main(String[] args) {
BufferedImageOp op = createTestOp();
try {
System.out.print("Integer-based images... ");
doTest(op, TYPE_INT_ARGB, TYPE_INT_ARGB_PRE);
System.out.println("done.");
System.out.print("Byte-based images... ");
doTest(op, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE);
System.out.println("done");
} catch (ImagingOpException e) {
throw new RuntimeException("Test FAILED", e);
}
}
private static void doTest(BufferedImageOp op, int stype, int dtype) {
final int size = 100;
final BufferedImage src = new BufferedImage(size, size, stype);
Graphics2D g = src.createGraphics();
g.setColor(Color.red);
g.fillRect(0, 0, size, size);
g.dispose();
final BufferedImage dst = new BufferedImage(size, size, dtype);
g = dst.createGraphics();
g.setColor(Color.blue);
g.fillRect(0, 0, size, size);
g.dispose();
op.filter(src, dst);
final int rgb = dst.getRGB(size - 1, size - 1);
System.out.printf("dst: 0x%X ", rgb);
if (rgb != 0xFFFF0000) {
throw new RuntimeException(String.format("Wrong color in dst: 0x%X", rgb));
}
}
private static BufferedImageOp createTestOp() {
final int size = 1;
final float v = 1f / (size * size);
final float[] k_data = new float[size * size];
Arrays.fill(k_data, v);
Kernel k = new Kernel(size, size, k_data);
return new ConvolveOp(k);
}
}

View File

@ -222,3 +222,4 @@ e19283cd30a43fca94d8f7639c73ef66db493b1e jdk8-b90
ce5a90df517bdceb2739d7dd3e6764b070def802 jdk8-b98
6d85acab769eb79bc058f5640fa86a6ef096a583 jdk8-b99
82f68da70e471ee5640016e3f38c014347a5c785 jdk8-b100
0324dbf07b0f1cc51ad9fa18976489d02d23b60d jdk8-b101

View File

@ -30,7 +30,6 @@ import javax.lang.model.element.Element;
import javax.tools.JavaCompiler.CompilationTask;
import com.sun.source.doctree.DocCommentTree;
import com.sun.source.doctree.ReferenceTree;
import javax.tools.Diagnostic;
/**

View File

@ -1621,6 +1621,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
text = removeNonInlineHtmlTags(text);
}
text = Util.replaceTabs(configuration, text);
text = Util.normalizeNewlines(text);
result.addContent(new RawHtml(text));
}
}

View File

@ -71,7 +71,7 @@ public class TagletWriterImpl extends TagletWriter {
* {@inheritDoc}
*/
protected Content codeTagOutput(Tag tag) {
Content result = HtmlTree.CODE(new StringContent(tag.text()));
Content result = HtmlTree.CODE(new StringContent(Util.normalizeNewlines(tag.text())));
return result;
}
@ -135,7 +135,7 @@ public class TagletWriterImpl extends TagletWriter {
* {@inheritDoc}
*/
protected Content literalTagOutput(Tag tag) {
Content result = new StringContent(tag.text());
Content result = new StringContent(Util.normalizeNewlines(tag.text()));
return result;
}

View File

@ -631,6 +631,32 @@ public class Util {
return result.toString();
}
public static String normalizeNewlines(String text) {
StringBuilder sb = new StringBuilder();
final int textLength = text.length();
final String NL = DocletConstants.NL;
int pos = 0;
for (int i = 0; i < textLength; i++) {
char ch = text.charAt(i);
switch (ch) {
case '\n':
sb.append(text, pos, i);
sb.append(NL);
pos = i + 1;
break;
case '\r':
sb.append(text, pos, i);
sb.append(NL);
if (i + 1 < textLength && text.charAt(i + 1) == '\n')
i++;
pos = i + 1;
break;
}
}
sb.append(text, pos, textLength);
return sb.toString();
}
/**
* The documentation for values() and valueOf() in Enums are set by the
* doclet.

View File

@ -31,9 +31,11 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.Deque;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -45,6 +47,7 @@ import javax.lang.model.element.Name;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.tools.Diagnostic.Kind;
import javax.tools.JavaFileObject;
import com.sun.source.doctree.AttributeTree;
import com.sun.source.doctree.AuthorTree;
@ -88,9 +91,9 @@ import static com.sun.tools.doclint.Messages.Group.*;
public class Checker extends DocTreePathScanner<Void, Void> {
final Env env;
Set<Element> foundParams = new HashSet<Element>();
Set<TypeMirror> foundThrows = new HashSet<TypeMirror>();
Set<String> foundAnchors = new HashSet<String>();
Set<Element> foundParams = new HashSet<>();
Set<TypeMirror> foundThrows = new HashSet<>();
Map<JavaFileObject, Set<String>> foundAnchors = new HashMap<>();
boolean foundInheritDoc = false;
boolean foundReturn = false;
@ -129,7 +132,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
Checker(Env env) {
env.getClass();
this.env = env;
tagStack = new LinkedList<TagStackItem>();
tagStack = new LinkedList<>();
implicitHeaderLevel = env.implicitHeaderLevel;
}
@ -138,10 +141,27 @@ public class Checker extends DocTreePathScanner<Void, Void> {
boolean isOverridingMethod = !env.currOverriddenMethods.isEmpty();
if (tree == null) {
if (!isSynthetic() && !isOverridingMethod)
reportMissing("dc.missing.comment");
return null;
if (p.getLeaf() == p.getCompilationUnit()) {
// If p points to a compilation unit, the implied declaration is the
// package declaration (if any) for the compilation unit.
// Handle this case specially, because doc comments are only
// expected in package-info files.
JavaFileObject fo = p.getCompilationUnit().getSourceFile();
boolean isPkgInfo = fo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE);
if (tree == null) {
if (isPkgInfo)
reportMissing("dc.missing.comment");
return null;
} else {
if (!isPkgInfo)
reportReference("dc.unexpected.comment");
}
} else {
if (tree == null) {
if (!isSynthetic() && !isOverridingMethod)
reportMissing("dc.missing.comment");
return null;
}
}
tagStack.clear();
@ -184,6 +204,10 @@ public class Checker extends DocTreePathScanner<Void, Void> {
env.messages.report(MISSING, Kind.WARNING, env.currPath.getLeaf(), code, args);
}
private void reportReference(String code, Object... args) {
env.messages.report(REFERENCE, Kind.WARNING, env.currPath.getLeaf(), code, args);
}
@Override
public Void visitDocComment(DocCommentTree tree, Void ignore) {
super.visitDocComment(tree, ignore);
@ -508,7 +532,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
if (!validName.matcher(value).matches()) {
env.messages.error(HTML, tree, "dc.invalid.anchor", value);
}
if (!foundAnchors.add(value)) {
if (!checkAnchor(value)) {
env.messages.error(HTML, tree, "dc.anchor.already.defined", value);
}
}
@ -551,6 +575,14 @@ public class Checker extends DocTreePathScanner<Void, Void> {
return super.visitAttribute(tree, ignore);
}
private boolean checkAnchor(String name) {
JavaFileObject fo = env.currPath.getCompilationUnit().getSourceFile();
Set<String> set = foundAnchors.get(fo);
if (set == null)
foundAnchors.put(fo, set = new HashSet<>());
return set.add(name);
}
// http://www.w3.org/TR/html401/types.html#type-name
private static final Pattern validName = Pattern.compile("[A-Za-z][A-Za-z0-9-_:.]*");
@ -721,8 +753,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName));
if (ex == null) {
env.messages.error(REFERENCE, tree, "dc.ref.not.found");
} else if (ex.asType().getKind() == TypeKind.DECLARED
&& env.types.isAssignable(ex.asType(), env.java_lang_Throwable)) {
} else if (isThrowable(ex.asType())) {
switch (env.currElement.getKind()) {
case CONSTRUCTOR:
case METHOD:
@ -741,6 +772,15 @@ public class Checker extends DocTreePathScanner<Void, Void> {
return scan(tree.getDescription(), ignore);
}
private boolean isThrowable(TypeMirror tm) {
switch (tm.getKind()) {
case DECLARED:
case TYPEVAR:
return env.types.isAssignable(tm, env.java_lang_Throwable);
}
return false;
}
private void checkThrowsDeclared(ReferenceTree tree, TypeMirror t, List<? extends TypeMirror> list) {
boolean found = false;
for (TypeMirror tl : list) {

View File

@ -30,7 +30,6 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import javax.lang.model.element.Name;
import javax.tools.StandardLocation;
@ -166,8 +165,8 @@ public class DocLint implements Plugin {
}
void processArgs(String... args) throws BadArgs {
javacOpts = new ArrayList<String>();
javacFiles = new ArrayList<File>();
javacOpts = new ArrayList<>();
javacFiles = new ArrayList<>();
if (args.length == 0)
needHelp = true;
@ -214,7 +213,7 @@ public class DocLint implements Plugin {
}
List<File> splitPath(String path) {
List<File> files = new ArrayList<File>();
List<File> files = new ArrayList<>();
for (String f: path.split(File.pathSeparator)) {
if (f.length() > 0)
files.add(new File(f));
@ -279,7 +278,6 @@ public class DocLint implements Plugin {
TaskListener tl = new TaskListener() {
@Override
public void started(TaskEvent e) {
return;
}
@Override

View File

@ -67,6 +67,7 @@ dc.tag.self.closing = self-closing element not allowed
dc.tag.start.unmatched = end tag missing: </{0}>
dc.tag.unknown = unknown tag: {0}
dc.text.not.allowed = text not allowed in <{0}> element
dc.unexpected.comment=documentation comment not expected here
dc.main.ioerror=IO error: {0}
dc.main.no.files.given=No files given

View File

@ -69,7 +69,6 @@ import com.sun.tools.javac.code.Type.ClassType;
import com.sun.tools.javac.code.Type.ErrorType;
import com.sun.tools.javac.code.Type.UnionClassType;
import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.code.TypeTag;
import com.sun.tools.javac.code.Types.TypeRelation;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.AttrContext;
@ -358,7 +357,7 @@ public class JavacTrees extends DocTrees {
Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
new Log.DeferredDiagnosticHandler(log);
try {
final ClassSymbol tsym;
final TypeSymbol tsym;
final Name memberName;
if (ref.qualifierExpression == null) {
tsym = env.enclClass.sym;
@ -387,7 +386,7 @@ public class JavacTrees extends DocTrees {
return null;
}
} else {
tsym = (ClassSymbol) t.tsym;
tsym = t.tsym;
memberName = ref.memberName;
}
}
@ -408,15 +407,17 @@ public class JavacTrees extends DocTrees {
paramTypes = lb.toList();
}
Symbol msym = (memberName == tsym.name)
? findConstructor(tsym, paramTypes)
: findMethod(tsym, memberName, paramTypes);
ClassSymbol sym = (ClassSymbol) types.upperBound(tsym.type).tsym;
Symbol msym = (memberName == sym.name)
? findConstructor(sym, paramTypes)
: findMethod(sym, memberName, paramTypes);
if (paramTypes != null) {
// explicit (possibly empty) arg list given, so cannot be a field
return msym;
}
VarSymbol vsym = (ref.paramTypes != null) ? null : findField(tsym, memberName);
VarSymbol vsym = (ref.paramTypes != null) ? null : findField(sym, memberName);
// prefer a field over a method with no parameters
if (vsym != null &&
(msym == null ||
@ -789,6 +790,7 @@ public class JavacTrees extends DocTrees {
case METHOD:
// System.err.println("METHOD: " + ((JCMethodDecl)tree).sym.getSimpleName());
method = (JCMethodDecl)tree;
env = memberEnter.getMethodEnv(method, env);
break;
case VARIABLE:
// System.err.println("FIELD: " + ((JCVariableDecl)tree).sym.getSimpleName());
@ -800,7 +802,6 @@ public class JavacTrees extends DocTrees {
try {
Assert.check(method.body == tree);
method.body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf());
env = memberEnter.getMethodEnv(method, env);
env = attribStatToTree(method.body, env, copier.leafCopy);
} finally {
method.body = (JCBlock) tree;

View File

@ -596,7 +596,7 @@ public abstract class Symbol implements Element {
// This method is part of the javax.lang.model API, do not use this in javac code.
public <A extends java.lang.annotation.Annotation> A[] getAnnotationsByType(Class<A> annoType) {
return JavacAnnoConstructs.getAnnotations(this, annoType);
return JavacAnnoConstructs.getAnnotationsByType(this, annoType);
}
// TODO: getEnclosedElements should return a javac List, fix in FilteredMemberList

View File

@ -134,7 +134,7 @@ public class Types {
* @return the upper bound of the given type
*/
public Type upperBound(Type t) {
return upperBound.visit(t);
return upperBound.visit(t).unannotatedType();
}
// where
private final MapVisitor<Void> upperBound = new MapVisitor<Void>() {
@ -620,7 +620,9 @@ public class Types {
* (ii) perform functional interface bridge calculation.
*/
public ClassSymbol makeFunctionalInterfaceClass(Env<AttrContext> env, Name name, List<Type> targets, long cflags) {
Assert.check(targets.nonEmpty() && isFunctionalInterface(targets.head));
if (targets.isEmpty() || !isFunctionalInterface(targets.head)) {
return null;
}
Symbol descSym = findDescriptorSymbol(targets.head.tsym);
Type descType = findDescriptorType(targets.head);
ClassSymbol csym = new ClassSymbol(cflags, name, env.enclClass.sym.outermostClass());
@ -1130,9 +1132,9 @@ public class Types {
HashSet<UniqueType> set = new HashSet<UniqueType>();
for (Type x : interfaces(t))
set.add(new UniqueType(x, Types.this));
set.add(new UniqueType(x.unannotatedType(), Types.this));
for (Type x : interfaces(s)) {
if (!set.remove(new UniqueType(x, Types.this)))
if (!set.remove(new UniqueType(x.unannotatedType(), Types.this)))
return false;
}
return (set.isEmpty());

View File

@ -273,7 +273,7 @@ public class Annotate {
continue;
}
JCIdent left = (JCIdent)assign.lhs;
Symbol method = rs.resolveQualifiedMethod(left.pos(),
Symbol method = rs.resolveQualifiedMethod(assign.rhs.pos(),
env,
a.type,
left.name,

View File

@ -1948,6 +1948,8 @@ public class Attr extends JCTree.Visitor {
clazzid1 = make.at(clazz.pos).Select(make.Type(encltype),
((JCIdent) clazzid).name);
EndPosTable endPosTable = this.env.toplevel.endPositions;
endPosTable.storeEnd(clazzid1, tree.getEndPosition(endPosTable));
if (clazz.hasTag(ANNOTATED_TYPE)) {
JCAnnotatedType annoType = (JCAnnotatedType) clazz;
List<JCAnnotation> annos = annoType.annotations;
@ -2193,7 +2195,9 @@ public class Attr extends JCTree.Visitor {
syms.objectType :
clazztype;
if (!inferred.isErroneous() &&
types.isAssignable(inferred, pt().hasTag(NONE) ? polyPt : pt(), types.noWarnings)) {
(allowPoly && pt() == Infer.anyPoly ?
types.isSameType(inferred, clazztype) :
types.isAssignable(inferred, pt().hasTag(NONE) ? polyPt : pt(), types.noWarnings))) {
String key = types.isSameType(clazztype, inferred) ?
"diamond.redundant.args" :
"diamond.redundant.args.1";
@ -2968,7 +2972,9 @@ public class Attr extends JCTree.Visitor {
//check that functional interface class is well-formed
ClassSymbol csym = types.makeFunctionalInterfaceClass(env,
names.empty, List.of(fExpr.targets.head), ABSTRACT);
chk.checkImplementations(env.tree, csym, csym);
if (csym != null) {
chk.checkImplementations(env.tree, csym, csym);
}
}
}
}

View File

@ -2997,7 +2997,8 @@ public class Check {
for (Scope.Entry e = a.annotationType.type.tsym.members().elems;
e != null;
e = e.sibling)
if (e.sym.kind == MTH && e.sym.name != names.clinit)
if (e.sym.kind == MTH && e.sym.name != names.clinit &&
(e.sym.flags() & SYNTHETIC) == 0)
members.add((MethodSymbol) e.sym);
// remove the ones that are assigned values

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -124,7 +124,16 @@ public class Env<A> implements Iterable<Env<A>> {
@Override
public String toString() {
return "Env[" + info + (outer == null ? "" : ",outer=" + outer) + "]";
StringBuilder sb = new StringBuilder();
sb.append("Env[").append(info);
// if (enclMethod != null)
// sb.append(",enclMethod=").append(Pretty.toSimpleString(enclMethod));
// if (enclClass != null)
// sb.append(",enclClass=").append(Pretty.toSimpleString(enclClass));
if (outer != null)
sb.append(",outer=").append(outer);
sb.append("]");
return sb.toString();
}
public Iterator<Env<A>> iterator() {

View File

@ -1339,7 +1339,7 @@ public class Flow {
/** A mapping from addresses to variable symbols.
*/
VarSymbol[] vars;
JCVariableDecl[] vardecls;
/** The current class being defined.
*/
@ -1417,13 +1417,14 @@ public class Flow {
* to the next available sequence number and entering it under that
* index into the vars array.
*/
void newVar(VarSymbol sym) {
vars = ArrayUtils.ensureCapacity(vars, nextadr);
void newVar(JCVariableDecl varDecl) {
VarSymbol sym = varDecl.sym;
vardecls = ArrayUtils.ensureCapacity(vardecls, nextadr);
if ((sym.flags() & FINAL) == 0) {
sym.flags_field |= EFFECTIVELY_FINAL;
}
sym.adr = nextadr;
vars[nextadr] = sym;
vardecls[nextadr] = varDecl;
inits.excl(nextadr);
uninits.incl(nextadr);
nextadr++;
@ -1493,11 +1494,13 @@ public class Flow {
/** Check that trackable variable is initialized.
*/
void checkInit(DiagnosticPosition pos, VarSymbol sym) {
checkInit(pos, sym, "var.might.not.have.been.initialized");
}
void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) {
if ((sym.adr >= firstadr || sym.owner.kind != TYP) &&
trackable(sym) &&
!inits.isMember(sym.adr)) {
log.error(pos, "var.might.not.have.been.initialized",
sym);
log.error(pos, errkey, sym);
inits.incl(sym.adr);
}
}
@ -1599,7 +1602,7 @@ public class Flow {
if ((def.mods.flags & STATIC) != 0) {
VarSymbol sym = def.sym;
if (trackable(sym))
newVar(sym);
newVar(def);
}
}
}
@ -1619,7 +1622,7 @@ public class Flow {
if ((def.mods.flags & STATIC) == 0) {
VarSymbol sym = def.sym;
if (trackable(sym))
newVar(sym);
newVar(def);
}
}
}
@ -1678,9 +1681,22 @@ public class Flow {
scan(tree.body);
if (isInitialConstructor) {
for (int i = firstadr; i < nextadr; i++)
if (vars[i].owner == classDef.sym)
checkInit(TreeInfo.diagEndPos(tree.body), vars[i]);
boolean isSynthesized = (tree.sym.flags() &
GENERATEDCONSTR) != 0;
for (int i = firstadr; i < nextadr; i++) {
JCVariableDecl vardecl = vardecls[i];
VarSymbol var = vardecl.sym;
if (var.owner == classDef.sym) {
// choose the diagnostic position based on whether
// the ctor is default(synthesized) or not
if (isSynthesized) {
checkInit(TreeInfo.diagnosticPositionFor(var, vardecl),
var, "var.not.initialized.in.default.constructor");
} else {
checkInit(TreeInfo.diagEndPos(tree.body), var);
}
}
}
}
List<AssignPendingExit> exits = pendingExits.toList();
pendingExits = new ListBuffer<AssignPendingExit>();
@ -1691,7 +1707,7 @@ public class Flow {
if (isInitialConstructor) {
inits.assign(exit.exit_inits);
for (int i = firstadr; i < nextadr; i++)
checkInit(exit.tree.pos(), vars[i]);
checkInit(exit.tree.pos(), vardecls[i].sym);
}
}
} finally {
@ -1706,7 +1722,7 @@ public class Flow {
public void visitVarDef(JCVariableDecl tree) {
boolean track = trackable(tree.sym);
if (track && tree.sym.owner.kind == MTH) newVar(tree.sym);
if (track && tree.sym.owner.kind == MTH) newVar(tree);
if (tree.init != null) {
Lint lintPrev = lint;
lint = lint.augment(tree.sym);
@ -2239,11 +2255,11 @@ public class Flow {
Flow.this.make = make;
startPos = tree.pos().getStartPosition();
if (vars == null)
vars = new VarSymbol[32];
if (vardecls == null)
vardecls = new JCVariableDecl[32];
else
for (int i=0; i<vars.length; i++)
vars[i] = null;
for (int i=0; i<vardecls.length; i++)
vardecls[i] = null;
firstadr = 0;
nextadr = 0;
pendingExits = new ListBuffer<AssignPendingExit>();
@ -2255,8 +2271,8 @@ public class Flow {
startPos = -1;
resetBits(inits, uninits, uninitsTry, initsWhenTrue,
initsWhenFalse, uninitsWhenTrue, uninitsWhenFalse);
if (vars != null) for (int i=0; i<vars.length; i++)
vars[i] = null;
if (vardecls != null) for (int i=0; i<vardecls.length; i++)
vardecls[i] = null;
firstadr = 0;
nextadr = 0;
pendingExits = null;

View File

@ -1240,7 +1240,8 @@ public class Infer {
CAPTURED(InferenceBound.UPPER) {
@Override
public boolean accepts(UndetVar t, InferenceContext inferenceContext) {
return !inferenceContext.free(t.getBounds(InferenceBound.UPPER, InferenceBound.LOWER));
return t.isCaptured() &&
!inferenceContext.free(t.getBounds(InferenceBound.UPPER, InferenceBound.LOWER));
}
@Override

View File

@ -2649,6 +2649,13 @@ public class Resolve {
InferenceContext inferenceContext) {
MethodResolutionPhase maxPhase = boxingAllowed ? VARARITY : BASIC;
if (site.hasTag(TYPEVAR)) {
return resolveMemberReference(pos, env, referenceTree, site.getUpperBound(),
name, argtypes, typeargtypes, boxingAllowed, methodCheck, inferenceContext);
}
site = types.capture(site);
ReferenceLookupHelper boundLookupHelper;
if (!name.equals(names.init)) {
//method reference
@ -2675,24 +2682,52 @@ public class Resolve {
//merge results
Pair<Symbol, ReferenceLookupHelper> res;
if (!lookupSuccess(unboundSym)) {
res = new Pair<Symbol, ReferenceLookupHelper>(boundSym, boundLookupHelper);
env.info.pendingResolutionPhase = boundEnv.info.pendingResolutionPhase;
} else if (lookupSuccess(boundSym)) {
res = new Pair<Symbol, ReferenceLookupHelper>(ambiguityError(boundSym, unboundSym), boundLookupHelper);
env.info.pendingResolutionPhase = boundEnv.info.pendingResolutionPhase;
} else {
res = new Pair<Symbol, ReferenceLookupHelper>(unboundSym, unboundLookupHelper);
env.info.pendingResolutionPhase = unboundEnv.info.pendingResolutionPhase;
}
Symbol bestSym = choose(boundSym, unboundSym);
res = new Pair<Symbol, ReferenceLookupHelper>(bestSym,
bestSym == unboundSym ? unboundLookupHelper : boundLookupHelper);
env.info.pendingResolutionPhase = bestSym == unboundSym ?
unboundEnv.info.pendingResolutionPhase :
boundEnv.info.pendingResolutionPhase;
return res;
}
//private
boolean lookupSuccess(Symbol s) {
//where
private Symbol choose(Symbol s1, Symbol s2) {
if (lookupSuccess(s1) && lookupSuccess(s2)) {
return ambiguityError(s1, s2);
} else if (lookupSuccess(s1) ||
(canIgnore(s2) && !canIgnore(s1))) {
return s1;
} else if (lookupSuccess(s2) ||
(canIgnore(s1) && !canIgnore(s2))) {
return s2;
} else {
return s1;
}
}
private boolean lookupSuccess(Symbol s) {
return s.kind == MTH || s.kind == AMBIGUOUS;
}
private boolean canIgnore(Symbol s) {
switch (s.kind) {
case ABSENT_MTH:
return true;
case WRONG_MTH:
InapplicableSymbolError errSym =
(InapplicableSymbolError)s;
return new Template(MethodCheckDiag.ARITY_MISMATCH.regex())
.matches(errSym.errCandidate().snd);
case WRONG_MTHS:
InapplicableSymbolsError errSyms =
(InapplicableSymbolsError)s;
return errSyms.filterCandidates(errSyms.mapCandidates()).isEmpty();
default:
return false;
}
}
/**
* Helper for defining custom method-like lookup logic; a lookup helper
* provides hooks for (i) the actual lookup logic and (ii) accessing the
@ -3504,7 +3539,9 @@ public class Resolve {
List<Type> argtypes,
List<Type> typeargtypes) {
Map<Symbol, JCDiagnostic> candidatesMap = mapCandidates();
Map<Symbol, JCDiagnostic> filteredCandidates = filterCandidates(candidatesMap);
Map<Symbol, JCDiagnostic> filteredCandidates = compactMethodDiags ?
filterCandidates(candidatesMap) :
mapCandidates();
if (filteredCandidates.isEmpty()) {
filteredCandidates = candidatesMap;
}
@ -3556,8 +3593,7 @@ public class Resolve {
Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
for (Map.Entry<Symbol, JCDiagnostic> _entry : candidatesMap.entrySet()) {
JCDiagnostic d = _entry.getValue();
if (!compactMethodDiags ||
!new Template(MethodCheckDiag.ARITY_MISMATCH.regex()).matches(d)) {
if (!new Template(MethodCheckDiag.ARITY_MISMATCH.regex()).matches(d)) {
candidates.put(_entry.getKey(), d);
}
}

View File

@ -674,7 +674,11 @@ public class TransTypes extends TreeTranslator {
if (tree.varargsElement != null)
tree.varargsElement = types.erasure(tree.varargsElement);
else
Assert.check(tree.args.length() == argtypes.length());
if (tree.args.length() != argtypes.length()) {
log.error(tree.pos(),
"method.invoked.with.incorrect.number.arguments",
tree.args.length(), argtypes.length());
}
tree.args = translateArgs(tree.args, argtypes, tree.varargsElement);
tree.type = types.erasure(tree.type);

View File

@ -1820,7 +1820,6 @@ public class Gen extends JCTree.Visitor {
msym.externalType(types).getParameterTypes());
if (!msym.isDynamic()) {
code.statBegin(tree.pos);
code.markStatBegin();
}
result = m.invoke();
}

View File

@ -108,20 +108,38 @@ public class JavacAnnoConstructs {
}
// Helper to getAnnotation[s]
private static <A extends Annotation> Attribute.Compound getAttributeOnClass(ClassSymbol annotated,
Class<A> annoType) {
private static <A extends Annotation> Attribute.Compound getAttributeOnClass(
ClassSymbol annotated,
final Class<A> annoType)
{
boolean inherited = annoType.isAnnotationPresent(Inherited.class);
Attribute.Compound result = null;
while (annotated.name != annotated.name.table.names.java_lang_Object) {
result = getAttribute(annotated, annoType);
if (result != null || !inherited)
return result;
while ((annotated = nextSupertypeToSearch(annotated)) != null) {
result = getAttribute(annotated, annoType);
if (result != null || !inherited)
break;
Type sup = annotated.getSuperclass();
if (!sup.hasTag(CLASS) || sup.isErroneous())
break;
annotated = (ClassSymbol) sup.tsym;
if (result != null)
return result;
}
return result;
return null; // no more supertypes to search
}
/**
* Returns the next type to search for inherited annotations or {@code null}
* if the next type can't be found.
*/
private static ClassSymbol nextSupertypeToSearch(ClassSymbol annotated) {
if (annotated.name == annotated.name.table.names.java_lang_Object)
return null;
Type sup = annotated.getSuperclass();
if (!sup.hasTag(CLASS) || sup.isErroneous())
return null;
return (ClassSymbol) sup.tsym;
}
/**
@ -129,8 +147,9 @@ public class JavacAnnoConstructs {
* annotations. This is the implementation of
* Element.getAnnotations(Class).
*/
public static <A extends Annotation> A[] getAnnotations(Symbol annotated,
Class<A> annoType) {
public static <A extends Annotation> A[] getAnnotationsByType(Symbol annotated,
Class<A> annoType)
{
if (!annoType.isAnnotation())
throw new IllegalArgumentException("Not an annotation type: "
+ annoType);
@ -153,62 +172,48 @@ public class JavacAnnoConstructs {
}
// So we have a containing type
String name = annoType.getName();
String annoTypeName = annoType.getSimpleName();
String containerTypeName = containerType.getSimpleName();
int directIndex = -1, containerIndex = -1;
Attribute.Compound direct = null, container = null;
Attribute.Compound[] rawAttributes = annotated.getRawAttributes().toArray(new Attribute.Compound[0]);
// Find directly present annotations
for (int i = 0; i < rawAttributes.length; i++) {
if (annoTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) {
directIndex = i;
direct = rawAttributes[i];
// Find directly (explicit or implicit) present annotations
int index = -1;
for (List<Attribute.Compound> list = annotated.getAnnotationMirrors();
!list.isEmpty();
list = list.tail) {
Attribute.Compound attribute = list.head;
index++;
if (attribute.type.tsym.flatName().contentEquals(annoTypeName)) {
directIndex = index;
direct = attribute;
} else if(containerTypeName != null &&
containerTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) {
containerIndex = i;
container = rawAttributes[i];
attribute.type.tsym.flatName().contentEquals(containerTypeName)) {
containerIndex = index;
container = attribute;
}
}
// Deal with inherited annotations
if (annotated.kind == Kinds.TYP &&
(annotated instanceof ClassSymbol)) {
ClassSymbol s = (ClassSymbol)annotated;
if (direct == null && container == null) {
direct = getAttributeOnClass(s, annoType);
container = getAttributeOnClass(s, containerType);
// both are inherited and found, put container last
if (direct != null && container != null) {
directIndex = 0;
containerIndex = 1;
} else if (direct != null) {
directIndex = 0;
} else {
containerIndex = 0;
}
} else if (direct == null) {
direct = getAttributeOnClass(s, annoType);
if (direct != null)
directIndex = containerIndex + 1;
} else if (container == null) {
container = getAttributeOnClass(s, containerType);
if (container != null)
containerIndex = directIndex + 1;
if (direct == null && container == null) {
if (annotated.kind == Kinds.TYP &&
(annotated instanceof ClassSymbol)) {
ClassSymbol s = nextSupertypeToSearch((ClassSymbol)annotated);
if (s != null)
return getAnnotationsByType(s, annoType);
}
}
// Pack them in an array
Attribute[] contained0 = new Attribute[0];
Attribute[] contained0 = null;
if (container != null)
contained0 = unpackAttributes(container);
ListBuffer<Attribute.Compound> compounds = ListBuffer.lb();
for (Attribute a : contained0)
if (a instanceof Attribute.Compound)
compounds = compounds.append((Attribute.Compound)a);
Attribute.Compound[] contained = compounds.toArray(new Attribute.Compound[0]);
if (contained0 != null) {
for (Attribute a : contained0)
if (a instanceof Attribute.Compound)
compounds = compounds.append((Attribute.Compound)a);
}
Attribute.Compound[] contained = compounds.toArray(new Attribute.Compound[compounds.size()]);
int size = (direct == null ? 0 : 1) + contained.length;
@SuppressWarnings("unchecked") // annoType is the Class for A
@ -298,35 +303,38 @@ public class JavacAnnoConstructs {
}
// So we have a containing type
String name = annoType.getName();
String annoTypeName = annoType.getSimpleName();
String containerTypeName = containerType.getSimpleName();
int directIndex = -1, containerIndex = -1;
Attribute.Compound direct = null, container = null;
Attribute.Compound[] rawAttributes = annotated.getAnnotationMirrors().toArray(new Attribute.Compound[0]);
// Find directly present annotations
for (int i = 0; i < rawAttributes.length; i++) {
if (annoTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) {
directIndex = i;
direct = rawAttributes[i];
// Find directly (explicit or implicit) present annotations
int index = -1;
for (List<? extends Attribute.Compound> list = annotated.getAnnotationMirrors();
!list.isEmpty();
list = list.tail) {
Attribute.Compound attribute = list.head;
index++;
if (attribute.type.tsym.flatName().contentEquals(annoTypeName)) {
directIndex = index;
direct = attribute;
} else if(containerTypeName != null &&
containerTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) {
containerIndex = i;
container = rawAttributes[i];
attribute.type.tsym.flatName().contentEquals(containerTypeName)) {
containerIndex = index;
container = attribute;
}
}
// Pack them in an array
Attribute[] contained0 = new Attribute[0];
Attribute[] contained0 = null;
if (container != null)
contained0 = unpackAttributes(container);
ListBuffer<Attribute.Compound> compounds = ListBuffer.lb();
for (Attribute a : contained0) {
if (a instanceof Attribute.Compound)
compounds = compounds.append((Attribute.Compound)a);
if (contained0 != null) {
for (Attribute a : contained0)
if (a instanceof Attribute.Compound)
compounds = compounds.append((Attribute.Compound)a);
}
Attribute.Compound[] contained = compounds.toArray(new Attribute.Compound[0]);
Attribute.Compound[] contained = compounds.toArray(new Attribute.Compound[compounds.size()]);
int size = (direct == null ? 0 : 1) + contained.length;
@SuppressWarnings("unchecked") // annoType is the Class for A

View File

@ -4053,7 +4053,7 @@ public class JavacParser implements Parser {
endPosMap = new HashMap<JCTree, Integer>();
}
protected void storeEnd(JCTree tree, int endpos) {
public void storeEnd(JCTree tree, int endpos) {
endPosMap.put(tree, errorEndPos > endpos ? errorEndPos : endpos);
}
@ -4091,7 +4091,7 @@ public class JavacParser implements Parser {
super(parser);
}
protected void storeEnd(JCTree tree, int endpos) { /* empty */ }
public void storeEnd(JCTree tree, int endpos) { /* empty */ }
protected <T extends JCTree> T to(T t) {
return t;
@ -4126,14 +4126,6 @@ public class JavacParser implements Parser {
this.parser = parser;
}
/**
* Store ending position for a tree, the value of which is the greater
* of last error position and the given ending position.
* @param tree The tree.
* @param endpos The ending position to associate with the tree.
*/
protected abstract void storeEnd(JCTree tree, int endpos);
/**
* Store current token's ending position for a tree, the value of which
* will be the greater of last error position and the ending position of

View File

@ -905,6 +905,10 @@ compiler.err.repeated.modifier=\
compiler.err.report.access=\
{0} has {1} access in {2}
# 0: symbol, 1: set of modifier, 2: symbol
compiler.misc.report.access=\
{0} has {1} access in {2}
compiler.err.ret.outside.meth=\
return outside method
@ -914,6 +918,10 @@ compiler.err.signature.doesnt.match.supertype=\
compiler.err.signature.doesnt.match.intf=\
signature does not match {0}; incompatible interfaces
# 0: number, 1: number
compiler.err.method.invoked.with.incorrect.number.arguments=\
method invoked with incorrect number of arguments; expected {0}, found {1}
# 0: symbol, 1: symbol, 2: symbol
compiler.err.does.not.override.abstract=\
{0} is not abstract and does not override abstract method {1} in {2}
@ -1068,6 +1076,10 @@ compiler.err.var.might.already.be.assigned=\
compiler.err.var.might.not.have.been.initialized=\
variable {0} might not have been initialized
# 0: symbol
compiler.err.var.not.initialized.in.default.constructor=\
variable {0} not initialized in the default constructor
# 0: symbol
compiler.err.var.might.be.assigned.in.loop=\
variable {0} might be assigned in loop

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -42,11 +42,18 @@ public interface EndPosTable {
*/
public int getEndPos(JCTree tree);
/**
* Store ending position for a tree, the value of which is the greater of
* last error position and the given ending position.
* @param tree The tree.
* @param endpos The ending position to associate with the tree.
*/
public abstract void storeEnd(JCTree tree, int endpos);
/**
* Give an old tree and a new tree, the old tree will be replaced with
* the new tree, the position of the new tree will be that of the old
* tree.
* not exist.
* @param oldtree a JCTree to be replaced
* @param newtree a JCTree to be replaced with
* @return position of the old tree or Positions.NOPOS for non-existent mapping

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -38,7 +38,7 @@ import java.util.*;
public class TestCRLineSeparator extends JavadocTester {
//Test information.
private static final String BUG_ID = "4979486";
private static final String BUG_ID = "4979486-8014636";
//Javadoc arguments.
private static final String[] ARGS = new String[] {
@ -47,7 +47,7 @@ public class TestCRLineSeparator extends JavadocTester {
//Input for string search tests.
private static final String[][] TEST = {
{BUG_ID + FS + "pkg" + FS + "MyClass.html", "Line 1\n Line 2"}
{BUG_ID + FS + "pkg" + FS + "MyClass.html", "Line 1" + NL + " Line 2"}
};
private static final String[][] NEGATED_TEST = NO_TEST;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,11 +23,11 @@
/*
* @test
* @bug 4232882
* @bug 4232882 8014636
* @summary Javadoc strips all of the leading spaces when the comment
* does not begin with a star. This RFE allows users to
* begin their comment without a leading star without leading
* spaces striped
* spaces stripped
* @author jamieh
* @library ../lib/
* @build JavadocTester
@ -37,15 +37,15 @@
public class LeadingSpaces extends JavadocTester {
private static final String BUG_ID = "4232882";
private static final String BUG_ID = "4232882-8014636";
private static final String[][] TEST = {
{BUG_ID + FS + "LeadingSpaces.html",
" 1\n" +
" 2\n" +
" 3\n" +
" 4\n" +
" 5\n" +
" 6\n" +
" 1" + NL +
" 2" + NL +
" 3" + NL +
" 4" + NL +
" 5" + NL +
" 6" + NL +
" 7"}
};
private static final String[][] NEGATED_TEST = NO_TEST;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/*
* @test
* @bug 4732864 6280605 7064544
* @bug 4732864 6280605 7064544 8014636
* @summary Make sure that you can link from one member to another using
* non-qualified name, furthermore, ensure the right one is linked.
* @author jamieh
@ -36,7 +36,7 @@
public class TestLinkTaglet extends JavadocTester {
//Test information.
private static final String BUG_ID = "4732864-6280605-7064544";
private static final String BUG_ID = "4732864-6280605-7064544-8014636";
//Javadoc arguments.
private static final String[] ARGS = new String[] {
@ -46,16 +46,16 @@ public class TestLinkTaglet extends JavadocTester {
//Input for string search tests.
private static final String[][] TEST = {
{BUG_ID + FS + "pkg" + FS + "C.html",
"Qualified Link: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>\n" +
" Unqualified Link1: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>\n" +
" Unqualified Link2: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>\n" +
" Qualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(pkg.C.InnerC, pkg.C.InnerC2)</code></a>.<br/>\n" +
" Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(C.InnerC, C.InnerC2)</code></a>.<br/>\n" +
"Qualified Link: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>" + NL +
" Unqualified Link1: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>" + NL +
" Unqualified Link2: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>" + NL +
" Qualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(pkg.C.InnerC, pkg.C.InnerC2)</code></a>.<br/>" + NL +
" Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(C.InnerC, C.InnerC2)</code></a>.<br/>" + NL +
" Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(InnerC, InnerC2)</code></a>.<br/>"
},
{BUG_ID + FS + "pkg" + FS + "C.InnerC.html",
"Link to member in outer class: <a href=\"../pkg/C.html#MEMBER\"><code>C.MEMBER</code></a> <br/>\n" +
" Link to member in inner class: <a href=\"../pkg/C.InnerC2.html#MEMBER2\"><code>C.InnerC2.MEMBER2</code></a> <br/>\n" +
"Link to member in outer class: <a href=\"../pkg/C.html#MEMBER\"><code>C.MEMBER</code></a> <br/>" + NL +
" Link to member in inner class: <a href=\"../pkg/C.InnerC2.html#MEMBER2\"><code>C.InnerC2.MEMBER2</code></a> <br/>" + NL +
" Link to another inner class: <a href=\"../pkg/C.InnerC2.html\" title=\"class in pkg\"><code>C.InnerC2</code></a>"
},
{BUG_ID + FS + "pkg" + FS + "C.InnerC2.html",

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 8002387
* @bug 8002387 8014636
* @summary Improve rendered HTML formatting for {@code}
* @library ../lib/
* @build JavadocTester TestLiteralCodeInPre
@ -33,7 +33,7 @@
public class TestLiteralCodeInPre extends JavadocTester {
//Test information.
private static final String BUG_ID = "8002387";
private static final String BUG_ID = "8002387-8014636";
private static final String OUTPUT_DIR = BUG_ID;
//Javadoc arguments.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,11 +23,9 @@
/*
* @test
* @bug 4460354
* @bug 4460354 8014636
* @summary Test to make sure that relative paths are redirected in the
* output so that they are not broken.
* NOTE: these tests have \\n instead of NL because they are user
* generated new lines, not Java generated.
* @author jamieh
* @library ../lib/
* @build JavadocTester
@ -38,7 +36,7 @@
public class TestRelativeLinks extends JavadocTester {
//Test information.
private static final String BUG_ID = "4460354";
private static final String BUG_ID = "4460354-8014636";
//Javadoc arguments.
private static final String[] ARGS = new String[] {
@ -58,7 +56,7 @@ public class TestRelativeLinks extends JavadocTester {
{BUG_ID + FS + "pkg" + FS + "package-summary.html",
"<a href=\"relative-package-link.html\">relative package link</a>"},
{BUG_ID + FS + "pkg" + FS + "C.html",
" <a\n" +
" <a" + NL +
" href=\"relative-multi-line-link.html\">relative-multi-line-link</a>."},
//These relative paths should be redirected because they are in different
@ -74,7 +72,7 @@ public class TestRelativeLinks extends JavadocTester {
{BUG_ID + FS + "index-all.html",
"<a href=\"./pkg/relative-package-link.html\">relative package link</a>"},
{BUG_ID + FS + "index-all.html",
" <a\n" +
" <a" + NL +
" href=\"./pkg/relative-multi-line-link.html\">relative-multi-line-link</a>."},
@ -92,7 +90,7 @@ public class TestRelativeLinks extends JavadocTester {
{BUG_ID + FS + "pkg" + FS + "class-use" + FS + "C.html",
"<a href=\"../../pkg/relative-package-link.html\">relative package link</a>"},
{BUG_ID + FS + "pkg" + FS + "class-use" + FS + "C.html",
" <a\n" +
" <a" + NL +
" href=\"../../pkg/relative-multi-line-link.html\">relative-multi-line-link</a>."},
//PACKAGE OVERVIEW

View File

@ -0,0 +1,20 @@
/*
* @test /nodynamiccopyright/
* @bug 8020313
* @summary doclint doesn't reset HTML anchors correctly
* @build DocLintTester
* @run main DocLintTester -ref AnchorTest2.out AnchorTest2.java AnchorTest2a.java
* @run main DocLintTester -ref AnchorTest2.out AnchorTest2a.java AnchorTest2.java
*/
/** */
public class AnchorTest2 {
/** <a name="AnchorTest2"> </a> */
public void a_name_AnchorTest2() { }
/** <a name="AnchorTest2"> </a> */
public void a_name_AnchorTest2_already_defined() { }
/** <a name="AnchorTest2a"> </a> */
public void a_name_AnchorTest2a_defined_in_other_file() { }
}

View File

@ -0,0 +1,4 @@
AnchorTest2.java:15: error: anchor already defined: AnchorTest2
/** <a name="AnchorTest2"> </a> */
^
1 error

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